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
// link playground https://play.golang.org/p/VGPJNwdvjH | |
func insertion_sort(arr []int) []int { | |
var ( | |
twoPosition int | |
onePosition int | |
comparisonItem int | |
) | |
for onePosition = 1; onePosition < len(arr); onePosition++ { | |
comparisonItem = arr[onePosition] |
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
import ( | |
"database/sql" | |
_ "github.com/go-sql-driver/mysql" | |
"log" | |
"os" | |
"fmt" | |
) | |
type User struct { | |
id int |
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
function addMethod(object, name, fn) { | |
var old = object[name] | |
object[name] = function(){ | |
console.log(fn, 'fn') | |
if (fn.length == arguments.length) { | |
return fn.apply(this, arguments) | |
} else if (typeof old == 'function') { | |
return old.apply(this, arguments) |
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
Function.prototype.partial = function(){ | |
var fn = this, args = Array.prototype.slice.call(arguments) | |
return function(){ | |
var arg = 0 | |
for (var i = 0; i < args.length && arg < arguments.length; i++) { | |
if(args[i] === undefined) { | |
args[i] = arguments[arg++] | |
return fn.apply(this, 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 | |
interface Handler | |
{ | |
public function handle($value, Closure $next); | |
} | |
// handler if the value | |
class NumberHandler implements Handler | |
{ |
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 | |
use League\Pipeline\Pipeline; | |
class NumberHandler | |
{ | |
public function __invoke($value) | |
{ | |
if (gettype($value) == 'float') | |
{ |
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 | |
use League\Pipeline\Pipeline; | |
interface Registrator{} | |
interface Notificator{} | |
class Order implements Registrator,Notificator | |
{ | |
protected $order; |
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
version: '2' | |
services: | |
nginx: | |
image: nginx:latest | |
ports: | |
- "8010:80" | |
- "442:443" | |
volumes: | |
- ./hosts:/etc/nginx/conf.d | |
- ./www:/var/www |
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
server { | |
index index.php; | |
server_name flarum.dev; | |
error_log /var/log/nginx/error.log; | |
access_log /var/log/nginx/access.log; | |
root /var/www/flarum.dev; | |
location / { try_files $uri $uri/ /index.php?$query_string; } | |
location /api { try_files $uri $uri/ /api.php?$query_string; } | |
location /admin { try_files $uri $uri/ /admin.php?$query_string; } |
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
// dump mysql with date and gzip master! | |
mysqldump -u root -p databasename | gzip > `date '+%m-%y-%d %H:%M:%S'`.databasename.sql.gz | |
// dump mysql with date and gzip master from remote server | |
ssh [email protected] "mysqldump -u username -p basename | gzip > ./`date '+%m-%y-%d-%H:%M:%S'`.basename.sql.gz" | |
// with ignore table | |
ssh [email protected] "mysqldump -u username -p basename --ignore-table=database.table1" | gzip > ./`date '+%m-%y-%d-%H:%M:%S'`.basename.sql.gz |