Skip to content

Instantly share code, notes, and snippets.

View derek's full-sized avatar

Derek Gathright derek

View GitHub Profile
CREATE TABLE lighthouse
(
`fetchTime` Nullable(DateTime),
`s3Path` String,
`suite` String,
`device` String,
`env` String,
`lighthouseVersion` String,
`requestedUrl` String,
`finalUrl` String,
@derek
derek / gist:3599f91c5ea96a3f3045
Created August 5, 2014 18:51
Function.prototype.bind CoffeeScript polyfill
# 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()
@derek
derek / gist:8073844
Last active February 10, 2019 14:31
Change making algorithm in JavaScript - http://en.wikipedia.org/wiki/Change-making_problem
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 April 30, 2018 04:01
Boyer–Moore–Horspool in JavaScript
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) {
@derek
derek / gist:7159637
Last active December 26, 2015 13:39
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'
}
}
},
@derek
derek / up-down.txt
Last active December 26, 2015 06:19
┌─ attribute-base
├─ attribute-complex
├─ attribute-core
├─ attribute-extras
├─ attribute-observable
├─ base-base
├─ base-core
├─ base-observable
├─ base-pluginhost
@derek
derek / 1-raw.json
Last active December 22, 2015 20:59
[
{
"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,
yogi [info] using [email protected] on [email protected]
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
@derek
derek / README.md
Last active December 19, 2015 18:58

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
// 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--) {