Skip to content

Instantly share code, notes, and snippets.

View dalmaer's full-sized avatar

Dion Almaer dalmaer

View GitHub Profile
@dalmaer
dalmaer / x
Created March 25, 2009 00:22
Super-primitive Bespin integration
CmdUtils.CreateCommand({
name: "bespin",
icon: "https://bespin.mozilla.com/favicon.ico",
homepage: "http://bespin.mozilla.com/",
author: {name: "Atul Varma", email: "avarma@mozilla.com",
homepage: "http://www.toolness.com"},
license: "MIT",
description: "Super-primitive Bespin integration.",
help: "You can run any Bespin command-line command via Ubiquity; just make sure you're on a tab with the Bespin editor when you use the command.",
takes: {"command": /.*/},
try {
Gilt.Hummingbird.track( {"pageName":"login","server":"www.gilt.com","channel":"login","pageType":null,"prop1":null,"eVar1":null,"prop2":null,"eVar2":null,"prop3":null,"eVar3":null,"prop4":"login page","eVar4":null,"prop5":null,"eVar5":null,"prop6":null,"eVar6":null,"prop7":null,"eVar7":null,"prop8":null,"eVar8":null,"prop9":null,"eVar9":null,"prop10":null,"eVar10":null,"prop11":null,"eVar11":null,"prop12":null,"eVar12":null,"prop13":null,"eVar13":null,"prop14":null,"eVar14":null,"prop15":null,"eVar15":null,"prop16":null,"eVar16":null,"prop17":null,"eVar17":null,"prop18":null,"eVar18":null,"prop19":null,"eVar19":null,"prop20":null,"eVar20":null,"campaign":null,"state":null,"zip":null,"events":"","products":"","purchaseID":null,"trackingServer":"stat.gilt.com","trackingServerSecure":"sstat.gilt.com"} );
} catch(e) {}
});
HummingbirdTracker = {};
HummingbirdTracker.track = function(env) {
delete env.trackingServer;
delete env.trackingServerSecure;
env.u = document.location.href;
env.bw = window.innerWidth;
env.bh = window.innerHeight;
env.guid = document.cookie.match(/guid=([^\_]*)_([^;]*)/)[2];
env.gen = document.cookie.match(/gender=([^;]*);/)[1];
env.uid = document.cookie.match(/user_id=([^\_]*)_([^;]*)/)[2];
var db = indexedDB.open('books', 'Book store', false);
if (db.version !== '1.0') {
var olddb = indexedDB.open('books', 'Book store');
olddb.createObjectStore('books', 'isbn');
olddb.createIndex('BookAuthor', 'books', 'author', false);
olddb.setVersion("1.0");
}
// db.version === "1.0";
var index = db.openIndex('BookAuthor');
var matching = index.get('fred');
var store = db.openObjectStore('Contact');
var lincoln = {name: 'Lincoln', number: '7012'};
var contact = store.put(lincoln);
// contact.id === 1
var contact = store.get(1);
// contact.name === 'Lincoln'
@dalmaer
dalmaer / coffee2js
Created April 6, 2011 23:38
Someone wanted a script that converts javascript to coffeescript. easy! ;)
#!/usr/bin/env perl
print "`";
while (<>) {
print;
}
print "`";
// draw a URL that the reader can pick up and launch a browser say
// basic library
draw_qrcode("http://functionsource.com/");
// jQuery plugin
jquery('#insertit').qrcode("http://functionsource.com/");
var zombie = require("zombie");
var assert = require("assert");
// Load the page from localhost
zombie.visit("http://localhost:3000/", function (err, browser, status) {
// Fill email, password and submit form
browser.
fill("email", "zombie@underworld.dead").
fill("password", "eat-the-living").
// the code of the "foo" function
// never changes, but the "this" value
// differs in every activation
function foo() {
alert(this);
}
// caller activates "foo" (callee) and
// provides "this" for the callee
@dalmaer
dalmaer / phantom.example.pizza.js
Created April 11, 2011 01:07
A phantom.js example
if (phantom.state.length === 0) {
phantom.state = 'pizza';
phantom.open('http://www.google.com/m/local?site=local&q=pizza+nyc');
} else {
var list = document.querySelectorAll('div.bf');
for (var i in list) {
console.log(list[i].innerText);
}
phantom.exit();
}