Skip to content

Instantly share code, notes, and snippets.

View robotlolita's full-sized avatar
🐴
everything happens so much oh no

Quil robotlolita

🐴
everything happens so much oh no
View GitHub Profile
/**
* Object.keys(object) -> Array of String
*
* List the keys that belongs only to the given object.
**/
(function() {
function list_keys(object) {
var prop
, keys = [];
/**
* 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
// 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) {
// --[ 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 */
// ----------------------------------------------------------------------------
(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;
(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
html = "some\
multiline\
string"; // "some multiline string"
html = "some "
+ "multiline "
+ "string"; // "some multiline string"
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);
class Foo(object):
@classmethod
def bar(cls, text):
print text
>>> Foo.bar("stuff")
stuff
>>> local_bar = Foo.bar
>>> local_bar("stuff")
stuff
/**************************************************************************
* 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))