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
/** | |
* Object.keys(object) -> Array of String | |
* | |
* List the keys that belongs only to the given object. | |
**/ | |
(function() { | |
function list_keys(object) { | |
var prop | |
, keys = []; |
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
/** | |
* preload(urls[, wait=10][, callback]) | |
* - urls (Array): a list of all image urls to preload | |
* - delay (Number): how much time to wait for an image before | |
* flagging it as unreachable, in seconds. | |
* - callback (Function): optional function to call after all images | |
* are preloaded. | |
**/ | |
function preload(urls, wait, callback) { | |
var timer_id; // id of the last timer event |
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
// The outrageous totally awesomely unoptimized and hard way of doing | |
// the stuff :D | |
(function() { | |
var c, list | |
, letters = {} | |
, str = "ah, yes, for all the letters, you'll need" | |
+ "a loop... i read it wrong." | |
; | |
str.replace(/\s|\S/g, function(match) { |
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
// --[ main.js ]--------------------------------------------------------------- | |
require('A.js', function cba() { /* A.js was loaded */ }); | |
// --[ A.js ]------------------------------------------------------------------ | |
require('B.js', function cbb() { /* B.js was loaded */ }); | |
// --[ B.js ]------------------------------------------------------------------ | |
/* dummy file */ | |
// ---------------------------------------------------------------------------- |
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() { /* creates a new scope */ | |
var created = {}; // all objects that have been created. | |
function create(name, value) { | |
/* this is within the main function's scope, so we have access to all | |
variables defined in it from here */ | |
var obj = {}; | |
if (!created[name]) { | |
obj.data = value; | |
created[name] = obj; |
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() { | |
var stuff = "str"; | |
// creates a really long string | |
var str = ""; | |
for (var i = 0; i < 10000; ++i) { | |
str += 'stuff + '; | |
} | |
eval("stuff = 'str'; var d = +new Date; x = " + str |
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
html = "some\ | |
multiline\ | |
string"; // "some multiline string" | |
html = "some " | |
+ "multiline " | |
+ "string"; // "some multiline string" |
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 arr = []; var x = []; | |
for (var i = 0; i < 100; ++i) { x [i] = i }; | |
var d = +new Date; | |
for (var i = 0; i < 1000; ++i) { | |
arr = arr.concat(x); | |
} | |
console.log(+new Date - d); |
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
class Foo(object): | |
@classmethod | |
def bar(cls, text): | |
print text | |
>>> Foo.bar("stuff") | |
stuff | |
>>> local_bar = Foo.bar | |
>>> local_bar("stuff") | |
stuff |
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
/************************************************************************** | |
* Returns a JSON object for the given request * | |
**************************************************************************/ | |
def request(req: string, parms: array of string | |
,retry: bool = true): Json.Object? \ | |
raises Error, BitlyError | |
result: string // string to get the JSON text | |
/* loads the API url */ | |
var f = File.new_for_uri(_apiurl + req + "/?" + get_query(parms)) |
OlderNewer