This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Export | |
mysqldump -u root -p your_db | gzip -c > your_db_2018-05-12.sql.gz | |
# Export with datetime in filename | |
mysqldump -u root -p your_db | gzip -c > your_db_$(date +%Y-%m-%d-%H.%M.%S).sql.gz | |
# Import | |
zcat your_db_2018-05-12.sql.gz | mysql -u root -p your_db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const countDecimals = function (value) { | |
if(Math.floor(value) === value) return 0; | |
return value.toString().split(".")[1].length || 0; | |
} | |
const operators = { | |
'+': (a, b) => { | |
let decimalLength = Math.pow(10, Math.max(countDecimals(a), countDecimals(b))) | |
return ((a*decimalLength) + (b*decimalLength))/decimalLength | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// USE BABEL WITH PRESET ES2017 | |
// FUCKING AWESOME PROMISE EXAMPLE | |
// FIRST PROMISE | |
function a() { | |
return Promise.resolve([1, 2, 3, 4, 5, 6]) | |
// return Promise.reject(new Error("xxxx")) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
basedir=`dirname "$0"` | |
# This is like symlink for bash cmd such as mintty, GIT bash, Cygwin | |
# I pass parameters to it too. | |
"$basedir/pstorm.cmd" "$@" | |
# Note - I tried create symlink but it not work at bash environment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Create blank array by number | |
* | |
* @param int Number of members in each dimension | |
* @return array | |
*/ | |
function createBlankArray() | |
{ | |
$dimensions = func_get_args(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function sortByArray($array, $sortOrder, $options = SORT_REGULAR, $descending = false) | |
{ | |
// Before first! LOL | |
// I just extend sortBy in Laravel collection to can use with normal array | |
// and it will sort data from another array. | |
// Perfect!! | |
// Before first. We will add diff array index to last item of sortOrder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Models\Traits; | |
use Exception; | |
/** | |
* This is trait for use with eloquent model only. | |
* Develop by Nimit Suwannagate <[email protected]> | |
* I don't allow to modify anythings in this code. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Composer install this package. | |
// https://github.com/reactphp/socket | |
// Command support: broadcast, who | |
require 'vendor/autoload.php'; | |
$loop = React\EventLoop\Factory::create(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var net = require('net'); | |
// Config | |
var config = { | |
server: { | |
port: 7890 | |
} | |
}; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create array for hold all dogs data | |
// just loop by get data from getNames() | |
// getNames() is generator so it's simple loop | |
// and we just need 5 dogs only | |
// each dog will name as value | |
// echo all dogs as json |