Results: 1580
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
JavaScript concat()
const firstName = 'Giorgi';
const job = 'Doctor';
const birthdayYear = 1991;
const currentDate = new Date();
const currentYear = currentDate.getFullYear()

//same results but different syntax

const giorgisInfo = "I'm " + firstName + ', a ' + (currentYear - birthdayYear) + ' year old ' + job + '!';
console.log(giorgisInfo)
//----------------
const giorgisInfoNew = `I'm ${firstName}, a ${currentYear - birthdayYear} year old ${job}!`
console.log(giorgisInfoNew)
by გიორგი ბაკაშვილი
4 years ago
1
JavaScript
concat
0
Rest Pattern and Parameters
//SPREAD, because on RIGHT side of =
const arr = [1, 2, ...[3, 4]]

//REST because on LEFT side of =
const [a, b, ...others] = [1, 2, 3, 4, 5];

console.log(a, b, others);   //result: 1 2 (3)[3, 4, 5]
by გიორგი ბაკაშვილი
4 years ago
0
JavaScript
Arrays
0
Short Circuiting(&& and ||)
Use ANY data type, return ANY data type, short-circuiting
console.log('---- OR ----');
console. log(3 || 'Jonas');     //result:3
console.log('' || 'Jonas');     //result:Jonas
console.log(true || 0);         //result:true
console.log(undefined || null); //result:null

console.log(undefined || 0 || '' || 'Hello' || 23 || null); //result:Hello
console.log('---- AND ----');
console. log(0 && 'Jonas');     //result:0
console. log(7 && 'Jonas');     //result:Jonas

console.log('Hello' && 23 && null && 'Jonas'); //result:null
by გიორგი ბაკაშვილი
4 years ago
0
JavaScript
0
database size in MYSQL
The following query can show the size (GB) of all the database in a table view :
SELECT table_schema "database", sum(data_length + index_length)/1024/1024/1024 "size in GB"
FROM information_schema.TABLES GROUP BY table_schema;
The following query can show the size (MB) of all the database in a table view :
SELECT table_schema 'database', ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"
FROM information_schema.tables
GROUP BY table_schema;
The following query can show only the size of a specific database:
SELECT table_schema,
ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"
FROM information_schema.tables WHERE table_schema='DB_NAME'
GROUP BY table_schema ;
The following query can show total tables, the total table row, DB size of a specific database:
SELECT TABLE_SCHEMA AS DB_Name, count(TABLE_SCHEMA) AS Total_Tables, 
SUM(TABLE_ROWS) AS Total_Tables_Row, 
ROUND(sum(data_length + index_length)/1024/1024) AS "DB Size (MB)", ROUND(sum( data_free )/ 1024 / 1024) AS "Free Space (MB)"
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = 'DB_NAME'
GROUP BY TABLE_SCHEMA ;
by გიორგი ბაკაშვილი
4 years ago
0
MySQL
0
MySQL row count of a single table:
SELECT 
    COUNT(*)
FROM
    customers;
MySQL row count of two or more tables:
SELECT 
    'customers' tablename, 
     COUNT(*) rows
FROM
    customers 
UNION 
SELECT 
    'orders' tablename, 
     COUNT(*) rows
FROM
    orders;
by Luka Tatarishvili
4 years ago
0
MySQL
Select
0
for example we want to sort this
$users
array according to
"score"
value
$users = array(
    [
        'id' => 1, 
        'name' => 'vighac tipovichi', 
        'score' => 90
    ],
    [
        'id' => 2, 
        'name' => 'sxva tipson', 
        'score' => 100
    ],

);
__________________________________________ 1st method is using this custom function:
array_sort($users, 'score', SORT_DESC)
function array_sort($array, $on, $order=SORT_ASC){
    $new_array = array();
    $sortable_array = array();

    if (count($array) > 0) {
        foreach ($array as $k => $v) {
            if (is_array($v)) {
                foreach ($v as $k2 => $v2) {
                    if ($k2 == $on) {
                        $sortable_array[$k] = $v2;
                    }
                }
            } else {
                $sortable_array[$k] = $v;
            }
        }


        switch ($order) {
            case SORT_ASC:
                asort($sortable_array);
            break;
            case SORT_DESC:
                arsort($sortable_array);
            break;
        }

        foreach ($sortable_array as $k => $v) {
            $new_array[$k] = $array[$k];
        }
    }
  return $new_array;
}
__________________________________________ 2nd method is by using
usort
built-in function which allows us to use "user defined" callback/function to sort array: 1.either by declaring another function dedicated to sort array as you wish
function custom_sort_users($a, $b) {
        if ($a['score'] == $b['score']) {
                return 0;
        }
        return ($a['score'] > $b['score']) ? -1 : 1;
}
usort($users, "custom_sort_users");
2.or using callback:
usort($users, function($a, $b){
    if ($a['score'] == $b['score']) {
            return 0;
    }
    return ($a['score'] > $b['score']) ? -1 : 1;
});
by გიორგი უზნაძე
4 years ago
0
PHP
Arrays
0
zip / unzip file or folder
Zips .sql file
db_backup.sql
and locates it to
public_html/
directory
zip -r db_backup.sql public_html/
Unzips the file
zipped.zip
and puts it to the current directory
unzip zipped.zip
by Valeri Tandilashvili
4 years ago
0
Linux
0
move file to another server using scp
Moves
sql.zip
file to the location
/var/www/
of
use.ge
server using
root
user
scp sql.zip root@use.ge:/var/www/
We can use full path for the file that we want to move
scp /var/www/sql.zip root@use.ge:/var/www/
We can also use an IP address (instead of domain name) to specify the server that we want the file to move to
scp /var/www/sql.zip root@167.172.187.21:/var/www/
After the command execution the user is required to enter password of
root
user
by Valeri Tandilashvili
4 years ago
0
Linux
0
create directory
Creates
testdirectory
directory to the location that the console is pointing at
sudo mkdir testdirectory
by Valeri Tandilashvili
4 years ago
0
Linux
0
move file to another directory
Moves
file.zip
file into
some_folder
folder
sudo mv file.zip some_folder/
In this example
file.zip
file and
some_folder
folder are at the same folder level (they have the same parent folder)
by Valeri Tandilashvili
4 years ago
0
Linux
0
Results: 1580