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 fancyDate(then, now, suffix) { | |
| if(now === undefined) | |
| now = new Date(); | |
| if(suffix === undefined) | |
| suffix = 'ago'; | |
| var thenMs = null; | |
| typeof then === 'number' ? thenMs = then : thenMs = then.getTime(); | |
| var nowMs = null; |
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 | |
| function request($url) { | |
| $c = curl_init(); | |
| curl_setopt($c, CURLOPT_URL, $url); | |
| curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 3); | |
| curl_setopt($c, CURLOPT_TIMEOUT, 5); | |
| curl_setopt($c, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); | |
| $response = curl_exec($c); |
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 | |
| function request($url) { | |
| $c = curl_init(); | |
| curl_setopt($c, CURLOPT_URL, $url); | |
| curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 3); | |
| curl_setopt($c, CURLOPT_TIMEOUT, 5); | |
| curl_setopt($c, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); | |
| $response = curl_exec($c); |
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
| var _rmod = _rmod || {}; //require module namespace | |
| _rmod.LOADED = false; | |
| _rmod.on_ready_fn_stack = []; | |
| _rmod.libpath = ''; | |
| _rmod.imported = {}; | |
| _rmod.loading = { | |
| scripts: {}, | |
| length: 0 | |
| }; |
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 threading | |
| def set_interval(func, sec): | |
| def func_wrapper(): | |
| set_interval(func, sec) | |
| func() | |
| t = threading.Timer(sec, func_wrapper) | |
| t.start() | |
| return t |
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
| var namespace = function(str, root) { | |
| var chunks = str.split('.'); | |
| if(!root) | |
| root = window; | |
| var current = root; | |
| for(var i = 0; i < chunks.length; i++) { | |
| if (!current.hasOwnProperty(chunks[i])) | |
| current[chunks[i]] = {}; | |
| current = current[chunks[i]]; | |
| } |
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
| var def = function(functions, parent) { | |
| return function() { | |
| var types = []; | |
| var args = []; | |
| eachArg(arguments, function(i, elem) { | |
| args.push(elem); | |
| types.push(whatis(elem)); | |
| }); | |
| if(functions.hasOwnProperty(types.join())) { | |
| return functions[types.join()].apply(parent, 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
| //Thanks to perfectionkills.com <http://perfectionkills.com/instanceof-considered-harmful-or-how-to-write-a-robust-isarray/> | |
| __getClass = function(val) { | |
| return Object.prototype.toString.call(val) | |
| .match(/^\[object\s(.*)\]$/)[1]; | |
| }; | |
| var whatis = function(val) { | |
| if(val === undefined) | |
| return 'undefined'; |
NewerOlder