Skip to content

Instantly share code, notes, and snippets.

Avatar
🐴
everything happens so much oh no

Quil robotlolita

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