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
(function domReady (callback) { | |
!/in/.test(document.readyState) | |
? setTimeout(function () { domReady(callback) }, 1000) | |
: callback(); | |
})(function () { | |
console && console.log('dom is ready'); | |
}); |
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
(function () { | |
'use strict'; | |
var get_synchronizer = function (delay, callback) { | |
var pretime = new Date().getTime(); | |
return function () { | |
var curtime = new Date().getTime(); | |
console.log(curtime - pretime); | |
if (curtime - pretime >= delay) { | |
callback(); |
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
#!/bin/bash | |
function usage { | |
echo "Usage: $0 [file] [start|stop|status|connect]" | |
} | |
if [ -z $1 ]; then | |
usage | |
exit 0 | |
fi |
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 | |
spl_autoload_register(function($classname) { | |
if (strpos($classname, '\\with') === false) | |
return false; | |
list($namespace, $class) = str_split($classname, strrpos($classname, '\\')); | |
$class = substr($class, 1); | |
$parts = explode('\\with', $classname); |
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 | |
namespace CommandLine; | |
class Colors { | |
public static $_backgroundColors = array( | |
'black' => '40', | |
'red' => '41', | |
'green' => '42', |
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 | |
// how to reverse the singleton pattern | |
class Service { | |
public static $data; | |
public static function inc () { | |
static::$data++; | |
} | |
} |
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 | |
// quick'n dirty | |
class Fibonacci implements Iterator { | |
public function __construct () { | |
$this->rewind(); | |
} |
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 stumble2url ($url) { | |
$doc = new DOMDocument; | |
if (!@$doc->loadHTMLFile($url)) | |
return null; | |
return ($iframe = $doc->getElementById('tb-stumble-frame')) | |
? $iframe->getAttribute('src') |
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
#!/bin/bash | |
mkdir /tmp/adodefont | |
cd /tmp/adodefont | |
wget https://github.com/adobe-fonts/source-code-pro/archive/2.010R-ro/1.030R-it.zip | |
unzip 1.030R-it.zip | |
mkdir -p ~/.fonts | |
cp source-code-pro-2.010R-ro-1.030R-it/OTF/*.otf ~/.fonts/ | |
fc-cache -f -v |
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
(function(w) { | |
var konami = [38,38,40,40,37,39,37,39,66,65], n = -1; | |
w.addEventListener('keyup', function(event){ | |
(n = event.keyCode == konami[n+1] ? n+1 : -1) == konami.length-1 && w.dispatchEvent(new Event('konami')); | |
}); | |
w.konami = function(callback) { | |
w.addEventListener('konami', callback); | |
} |