Skip to content

Instantly share code, notes, and snippets.

@keesey
keesey / save-bootstrap-customize.js
Last active December 11, 2015 16:38
This script will save and reinstate form values for Twitter Bootstrap's customization page.
var STORAGE_KEY = 'http://twitter.github.com/bootstrap/customize.html::settings';
function findLabel(name) {
$.each($('label'), function (index, label) {
if(getName(label) === name) {
return name;
}
});
}
function isInput(element) {
return $(element).prop('nodeName') === 'INPUT';
@keesey
keesey / Placentalia_DNA+morph_parsimony_TNT.newick.txt
Last active December 12, 2015 12:39
Newick string for analysis (DNA + morphology: Parsimony: TNT) from O'Leary et al. (2013). The placental mammal ancestor and the post–K-Pg radiation of placentals. Science 339(6120):662–667. doi:10.1126/science.1229237
((Morganucodon oehleri,Morganucodon watsoni)Morganucodon,(Haldanodon exspectatus,(((Eomaia scansoria,(((((((Amblysomus hottentotus,Echinops telfairi)Afrosoricida,(Leptictis dakotensis,Rhynchocyon cirnei))Afroinsectivora,(Orycteropus afer,(Procavia capensis,(Thomashuxleya externa,(Carodnia vieirai,(Loxodonta africana,(Moeritherium lyonsi,Trichechus manatus)Pan-Sirenia)Tethytheria))Pan-Tethytheria)Paenungulata)Colbertia)Afrotheria,(((((Protungulatum donnae,(((Apheliscus insidiosus,Hyopsodus paulus),(Phenacodus intermedius,(Didolodus multicuspis,Protolipterna ellipsodontoides))),(Mesonyx obtusidens,(Rodhocetus balochistanensis,((Lama glama,(Sus scrofa,(Bos taurus,(Archaeotherium mortoni,(Hippopotamus amphibius,(Artiocetus clavis,(Basilosaurus cetoides,(Caperea marginata,Tursiops truncatus)Cetacea))Cetaceamorpha)Cetancodonta)Cetancodontamorpha)))Artiodactyla,(Equus caballus,Mesohippus bairdi)Perissodactyla)Euungulata))))Pan-Euungulata,(Pteropus giganteus,((Icaronycteris index,Onychonycteris finneyi),(Rhinopoma ha
@keesey
keesey / gist:5173882
Created March 15, 2013 23:07 — forked from diverted247/gist:5173656
Slightly more robust.
walkManagerChain( manager:any , event:any ):void{
while( manager ){
if( manager.hasOwnProperty( '_' + event.type ) ){
manager[ '_' + event.type ]( event );
}
if( manager.hasOwnProperty( 'manager' ) ){
manager = manager.manager;
}else{
return;
}
@keesey
keesey / combineUIDs.js
Last active December 18, 2015 15:59
combine UIDs
function combineUIDs(o)
{
function cu(a, b)
{
function cc(a, b)
{
if (a === '-') return '-';
return Number(parseInt(a, 16) ^ parseInt(b, 16)).toString(16);
}
var i = 0,
@keesey
keesey / aop.ts
Last active December 20, 2015 09:09
module aop
{
export function after<R>(
f: (...args: any[]) => R,
advice: (result: R, ...args: any[]) => any
): (...args: any[]) => R
{
return function()
{
var result = f.apply(this, arguments),
interface Oboe
{
(url: string): Oboe.Call;
doDelete(url: string): Oboe.Call;
doDelete(request: Oboe.Request): Oboe.Call;
doGet(url: string): Oboe.Call;
doGet(request: Oboe.Request): Oboe.Call;
doPatch(url: string, body: any): Oboe.Call;
doPatch(request: Oboe.BodyRequest): Oboe.Call;
doPost(url: string, body: any): Oboe.Call;
var CHANCE_OF_LIGHTNING = 1 / 100; // Tweak this.
var TOTAL_FRAMES = 4; // Include 'still' frame and lightning frames.
this.stop();
this.addEventListener('tick', function()
{
if (Math.random() < CHANCE_OF_LIGHTNING)
{
this.gotoAndStop(Math.floor(Math.random() * (TOTAL_FRAMES - 1)) + 1);
}
module Newtonsoft.Json
{
export function deserialize(o: any): any
{
const dict: { [$id: string]: Object } = {};
function _deserialize(o: any): any
{
if (typeof o === "object" && o !== null)
{
let $id: string;
declare module node_neo4j {
export interface PropertyContainer
{
// The URL of this property container.
self: string;
// Whether this property container exists in (has been persisted to) the Neo4j database.
exists: boolean;
@keesey
keesey / levenshtein.ts
Last active February 14, 2024 10:59
Levenshtein distance implemented in TypeScript
export function levenshtein(a: string, b: string): number
{
const an = a ? a.length : 0;
const bn = b ? b.length : 0;
if (an === 0)
{
return bn;
}
if (bn === 0)
{