Skip to content

Instantly share code, notes, and snippets.

Derek Gathright derek

View GitHub Profile
@derek
derek / gist:3599f91c5ea96a3f3045
Created Aug 5, 2014
Function.prototype.bind CoffeeScript polyfill
View gist:3599f91c5ea96a3f3045
# https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind#Compatibility
Function::bind ?= (oThis, args...) ->
fNOP = ->
fNOP:: ?= @::
fBound = =>
context = if this instanceof fNOP and oThis then this else oThis
@apply context, args.concat arguments
fBound:: = new fNOP()
View gist:8073844
function makeChange (total, coins) {
var tail = coins.slice(0), // clone coins, because we're about to modify it
head = tail.shift(); // grab the first coin out of the purse
// If total is less than zero, or there are no coins left, this isn't a match
if (total < 0 || !head) {
return 0;
}
// If the total reached 0, this is a match
else if (total === 0 ) {
@derek
derek / gist:8035740
Last active Apr 30, 2018
Boyer–Moore–Horspool in JavaScript
View gist:8035740
function boyer_moore_horspool(haystack, needle) {
var badMatchTable = {};
var maxOffset = haystack.length - needle.length;
var offset = 0;
var last = needle.length - 1;
var scan;
// Generate the bad match table, which is the location of offsets
// to jump forward when a comparison fails
Array.prototype.forEach.call(needle, function (char, i) {
View gist:7159637
var suite = new PerfSuite('pathogen prefix tree compression', {
assets: ['assets/gallery-pathogen-encoder-min.js'],
yui: {
use: ['gallery-pathogen-encoder'],
config: {
modules: {
'gallery-pathogen-encoder': 'assets/gallery-pathogen-encoder-min.js'
}
}
},
View up-down.txt
┌─ attribute-base
├─ attribute-complex
├─ attribute-core
├─ attribute-extras
├─ attribute-observable
├─ base-base
├─ base-core
├─ base-observable
├─ base-pluginhost
View 1-raw.json
[
{
"unit": "Hz",
"name": "Y.Model: Instantiate a bare model",
"value": 5818.296044147161,
"stats": {
"moe": 0.0000014629321229748081,
"rme": 0.8511772183960135,
"sem": 7.463939402932695e-7,
"deviation": 0.0000061549221083002235,
View gist:6302063
yogi [info] using yogi@0.1.11 on node@0.10.15
yogi [info] using module: anim
yogi [info] running lint on source files
/Users/derek/src/yui/yui3/src/anim/js/anim-color.js
/Users/derek/src/yui/yui3/src/anim/js/anim-curve.js
/Users/derek/src/yui/yui3/src/anim/js/anim-easing.js
/Users/derek/src/yui/yui3/src/anim/js/anim-node-plugin.js
/Users/derek/src/yui/yui3/src/anim/js/anim-scroll.js
/Users/derek/src/yui/yui3/src/anim/js/anim-shape.js
/Users/derek/src/yui/yui3/src/anim/js/anim-xy.js
View README.md

Walkdown

Walks a directory looking for Markdown files and converts them to HTML.

Installing

$ git clone https://gist.github.com/6002636.git
$ cd 6002636
$ sudo npm install -g
View gist:5912304
// Obfuscated
function (t) {
var r1365158103887,
s1365158103887,
m1365158103887 = this,
f1365158103887 = m1365158103887.fn,
i1365158103887 = m1365158103887.count,
n1365158103887 = t1365158103887.ns; // no operation performed
s1365158103887 = n1365158103887.now();
while (i1365158103887--) {
@derek
derek / gist:5886972
Created Jun 28, 2013
YUI Open RoundTable Meeting Notes June 27, 2013
View gist:5886972

YUI Open RoundTable Meeting Notes June 27, 2013

  • Participants:
    • Rashad
    • Tilo
    • Patrick
    • Eugene
    • Clarance
    • Derek
  • Topics Discussed
You can’t perform that action at this time.