Skip to content

Instantly share code, notes, and snippets.

View agoalofalife's full-sized avatar
😉
Do what you can, with what you have, where you are

Ilya Chubarov agoalofalife

😉
Do what you can, with what you have, where you are
View GitHub Profile
// 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]
@agoalofalife
agoalofalife / GO_MYSQL_EXAMPLE.go
Last active July 6, 2017 07:15
Classic exanpl mysql Golang (SELECT)
import (
"database/sql"
_ "github.com/go-sql-driver/mysql"
"log"
"os"
"fmt"
)
type User struct {
id int
@agoalofalife
agoalofalife / function_overloading.js
Last active July 6, 2017 07:15
function overloading depend count arguments js
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)
@agoalofalife
agoalofalife / carry.js
Last active July 6, 2017 07:15
Способ применения каррирования в js
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)
@agoalofalife
agoalofalife / pipleine-laravel.php
Last active July 6, 2017 08:55
An example of processing depending on values
<?php
interface Handler
{
public function handle($value, Closure $next);
}
// handler if the value
class NumberHandler implements Handler
{
<?php
use League\Pipeline\Pipeline;
class NumberHandler
{
public function __invoke($value)
{
if (gettype($value) == 'float')
{
<?php
use League\Pipeline\Pipeline;
interface Registrator{}
interface Notificator{}
class Order implements Registrator,Notificator
{
protected $order;
version: '2'
services:
nginx:
image: nginx:latest
ports:
- "8010:80"
- "442:443"
volumes:
- ./hosts:/etc/nginx/conf.d
- ./www:/var/www
@agoalofalife
agoalofalife / .conf
Last active July 26, 2017 13:01
flarum ngnix setting
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; }
@agoalofalife
agoalofalife / live_template_bash_command.sh
Last active October 27, 2017 19:48
List commands bash, which help me in work and studies
// 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