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
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
// 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
<?php | |
trait Tree | |
{ | |
protected $nameChildAttribute = 'children'; | |
public function getTree(\Illuminate\Support\Collection &$tree, $nameMethod) : array | |
{ | |
foreach ($tree as &$parent) | |
{ |
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
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
"sort" | |
"strconv" | |
"strings" | |
"math" |
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
package main | |
import ( | |
"log" | |
"fmt" | |
"os" | |
"path/filepath" | |
"strings" | |
) |
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
/** | |
* Generates unique id (mix datetime and random). | |
* @param {number=} len Required length of id (16 by default). | |
* @returns {string} Generated id. | |
*/ | |
function genUID(len){ | |
function base36(val){ | |
return Math.round(val).toString(36); | |
} |
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
// для escape значений | |
function escapeHtml (string) { | |
return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) { | |
return entityMap[s]; | |
}); | |
} | |
var entityMap = { | |
'&': '&', | |
'<': '<', | |
'>': '>', |
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 | |
abstract class DomainObjectAbstract | |
{ | |
protected $_id = null; | |
/** | |
* Get the ID of this object (unique to the | |
* object type) | |
* | |
* @return 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
let name = 'Maria'; | |
let name2 = 'Vasilij'; | |
let age = 18; | |
let result = tag`My name ${name} sd sdc sdc and ${name2} and ${age}`; | |
function tag(srting,...values) { | |
return srting.reduce((prev,current,id) => { | |
if (id > 0) { | |
if (typeof values[id - 1] == 'string') { |