Skip to content

Instantly share code, notes, and snippets.

James Abney jabney

Block or report user

Report or block jabney

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jabney
jabney / keyframeInterpolateBinary.js
Created May 6, 2017
keyframeInterplation function using binary search
View keyframeInterpolateBinary.js
function keyframeInterpolate(keyframes, time, timing, lib) {
const first = 0
const last = keyframes.length - 1
// Clamp time to [0, 1]
time = Math.max(Math.min(time, 1), 0)
if (!Array.isArray(keyframes) || !keyframes.length) {
return lib.zero()
}
@jabney
jabney / binary-search.js
Last active May 6, 2017
Binary search with comparator
View binary-search.js
// The default comparator is for any values that can be
// compared with '==', '<', '<=', '>', '>='.
function defaultComparator(candidate, target) {
if (target < candidate) {
return -1
} else if (target > candidate) {
return 1
} else {
return 0
}
View case_loader.py
import os
import re
import gzip
import base64
import json
from glob import glob
from argparse import ArgumentParser
from KnoDB.crawler.scc import case_parser
from KnoDB.crawler import bcca
@jabney
jabney / post-transform-coords.js
Last active Aug 29, 2015
Javascript function to return post-transform coordinates of an element.
View post-transform-coords.js
// Return the post-transform coords of an element,
// assuming that proper pre-transform coords are supplied.
function getElementCoords(element, coords) {
var ctm = element.getCTM(),
xn = ctm.e + coords.x*ctm.a,
yn = ctm.f + coords.y*ctm.d;
return { x: xn, y: yn };
};
var circle = document.getElementById('svgCircle'),
@jabney
jabney / factory-inheritance.js
Last active Aug 29, 2015
JavaScript Factory Inheritance
View factory-inheritance.js
(function() {
'use strict';
// Create a factory function (a function that returns an object).
function aFactory() {
// Create a data store.
var _data = [];
// Add supplied arguments to the data store.
if (arguments.length)
@jabney
jabney / gen_fontawesome.py
Last active Aug 29, 2015
Python utility for converting Font Awesome cheatsheet to a JSON file
View gen_fontawesome.py
"""
Generate fontawesome icon set in JSON format from website cheatsheet.
http://fortawesome.github.io/Font-Awesome/cheatsheet/
Usage: python gen_fontawesome.py
Output: font-awesome.json
{icon_name: entity_reference, ...}
Author: James Abney
Date: 2015-05-21
@jabney
jabney / font-awesome.json
Created May 22, 2015
Font Awesome JSON Entity Reference
View font-awesome.json
{"cc": "&#xf20a;", "bookmark": "&#xf02e;", "venus-mars": "&#xf228;", "arrow-circle-o-down": "&#xf01a;", "comment-o": "&#xf0e5;", "long-arrow-left": "&#xf177;", "arrow-right": "&#xf061;", "delicious": "&#xf1a5;", "chevron-circle-left": "&#xf137;", "bullhorn": "&#xf0a1;", "outdent": "&#xf03b;", "jpy": "&#xf157;", "drupal": "&#xf1a9;", "hdd-o": "&#xf0a0;", "hand-o-left": "&#xf0a5;", "pinterest": "&#xf0d2;", "plane": "&#xf072;", "question": "&#xf128;", "child": "&#xf1ae;", "circle-o": "&#xf10c;", "italic": "&#xf033;", "meanpath": "&#xf20c;", "subway": "&#xf239;", "google-plus": "&#xf0d5;", "angle-up": "&#xf106;", "star": "&#xf005;", "star-half-empty": "&#xf123;", "facebook-official": "&#xf230;", "youtube-square": "&#xf166;", "rss": "&#xf09e;", "toggle-off": "&#xf204;", "list-ol": "&#xf0cb;", "dot-circle-o": "&#xf192;", "copyright": "&#xf1f9;", "user": "&#xf007;", "key": "&#xf084;", "minus-square-o": "&#xf147;", "mobile": "&#xf10b;", "table": "&#xf0ce;", "columns": "&#xf0db;", "bolt": "&#xf0e7;", "fighter-jet": "&
@jabney
jabney / augment.js
Last active Aug 29, 2015
Javascript augmentation pattern for a factory method
View augment.js
// This augmentation style is appropriate for a factory-style function,
// which might be something that was imported as part of a library.
var factory = function factory() {
var data = [];
// Return an object with one or more methods.
return {
init: function() {
data.push.apply(data, arguments);
@jabney
jabney / containers.js
Last active Aug 29, 2015
Containers deque, bag, stack, queue, priority queue, and set
View containers.js
/*
containers.js
MIT License © 2015 James Abney
http://github.com/jabney
Containers: bag, stack, queue, double-ended queue (deque),
priorityQueue, and set.
See documentation at http://github.com/jabney/containers.js
*/
@jabney
jabney / graph.js
Last active Aug 29, 2015
Graph abstract data type and some associated algorithms
View graph.js
// graph.js © 2015 James Abney http://github.com/jabney
(function(ex, undefined) {
'use strict';
var gr = ex.graph || (ex.graph = Object.create(null));
// ---------------------------------------------------------------
// The graph abstract data type.
// ---------------------------------------------------------------
gr.graph = function graph(numVerts) {
You can’t perform that action at this time.