This file contains 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 a = [1,2,3,4,5,6,7,8]; | |
Array.prototype.map = function(callback) { | |
var mapped = []; | |
for (var i = 0; i < this.length; i++) { | |
mapped[i] = callback.call(null, this[i]); | |
} | |
return mapped; | |
}; | |
This file contains 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
$.fn.getAttributes = function() { | |
var attributes = {}; | |
if(this.length === 0) { | |
return attributes; | |
} | |
$.each(this[0].attributesttributes, function(index, attr) { | |
attributes[attr.name] = attr.value; | |
}); |
This file contains 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 unique = function(origArr) { | |
var newArr = [], | |
origLen = origArr.length, | |
found, | |
x, y; | |
for ( x = 0; x < origLen; x++ ) { | |
found = undefined; | |
for ( y = 0; y < newArr.length; y++ ) { | |
if ( origArr[x] === newArr[y] ) { |
This file contains 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 unique = function(origArr) { | |
var newArr = [], | |
origLen = origArr.length, | |
found, | |
x, y; | |
for ( x = 0; x < origLen; x++ ) { | |
found = undefined; | |
for ( y = 0; y < newArr.length; y++ ) { | |
if ( origArr[x] === newArr[y] ) { |
This file contains 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 | |
class UniqId { | |
public static function get() { | |
static $db = null; | |
if ( $db == null ) { | |
$db = new UniqId(); | |
} | |
return $db; |
This file contains 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
protected function doRequest($url) { | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_HEADER, false); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_USERAGENT, 'spider'); | |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); | |
$html = curl_exec($ch); | |
$header = curl_getinfo($ch); |
This file contains 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 | |
class Vkapi { | |
protected $_access_token = '%access_token%'; | |
protected $_client_id = 0; | |
public static function factory () | |
{ | |
$class = get_class(); |
This file contains 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 slugify($text) { | |
return strtolower(strtr(trim($text), array(' '=>'_') )); | |
} | |
function translit($str){ | |
static $tbl= array( | |
'а'=>'a', 'б'=>'b', 'в'=>'v', 'г'=>'g', 'д'=>'d', 'е'=>'e', 'ж'=>'g', 'з'=>'z', | |
'и'=>'i', 'й'=>'y', 'к'=>'k', 'л'=>'l', 'м'=>'m', 'н'=>'n', 'о'=>'o', 'п'=>'p', |
This file contains 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
moduleKeywords = ['included', 'extended'] | |
class Module | |
@extend: (object) -> | |
for key, value of object when key not in moduleKeywords | |
@[key] = value | |
object.included?.apply(@) | |
this |
This file contains 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
clone = (object) -> | |
if not object? or typeof object isnt 'object' | |
return object | |
instance = object.constructor() | |
for key of object | |
instance[key] = clone object[key] | |
return instance |
OlderNewer