Skip to content

Instantly share code, notes, and snippets.

View jschomay's full-sized avatar

Jeff Schomay jschomay

View GitHub Profile
@jschomay
jschomay / NestedList.elm
Created March 21, 2017 03:38
Nested List example in Elm
import Html exposing (text)
import List
{- Challenge: flatten an array of arbitrarily nested arrays of integers into a flat array of integers. e.g. [[1,2,[3]],4] -> [1,2,3,4].
(This is a little tricky in Elm because the type system does not allow for lists with different element types. So we have to make a whole new data structure...)
-}
@jschomay
jschomay / fizzbuzz
Last active August 29, 2015 14:16
Functional FizzBuzz
# My functional implementation of the common "fizzbuzz" interview coding test
FIZZBUZZMAP = [null, "fizz", "buzz", "fizzbuzz"]
isDivisibleBy = (d) ->
(n) -> !(n%d)
isFizz = isDivisibleBy 3
isBuzz = isDivisibleBy 5
@jschomay
jschomay / next-step.sh
Created December 3, 2014 07:14
Walk forward in git history for live coding presentations (displays diff and copies file to clipboard to paste into jsbin for example)
#!/bin/sh
clear
git checkout $(git rev-list HEAD..master | tail -n 1)
pbcopy < game.js
git show --format="%C(yellow)%s%Creset%n%n%b"
@jschomay
jschomay / nodemon watch and build
Created December 18, 2013 03:38
use nodemon to monitor file changes and run a build script
nodemon -w . -e ".coffee" -x "bash" build
@jschomay
jschomay / makeTimedFunction
Last active December 30, 2015 05:29
functional util to make a function time itself
// functional util to make a function time itself
function makeTimedFunction(fn, lable) {
return function(){
console.time(lable || 'time to complete '+fn.name);
var results = fn.apply(fn,Array.prototype.slice.call(arguments));
console.timeEnd(lable || 'time to complete '+fn.name);
return results;
};
}
@jschomay
jschomay / gist:5958608
Created July 9, 2013 16:02
sublime plugins
"AdvancedNewFile",
"Clipboard History",
"CoffeeScript",
"Jade",
"JavaScript Refactor",
"JsFormat",
"Package Control",
"Pretty JSON",
"SASS Build",
"Stylus",
@jschomay
jschomay / gist:5958594
Created July 9, 2013 16:01
sublime key bindings
[
{ "keys": ["tab"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
[
{ "key": "following_text", "operator": "regex_contains", "operand": "^[)\"'\\]]", "match_all": true },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false }
]
},
{ "keys": ["alt+up"], "command": "move_caret_top" },
{ "keys": ["alt+command+up"], "command": "move_caret_back", "args": { "nlines": 10} },
{ "keys": ["alt+command+down"], "command": "move_caret_forward", "args": { "nlines": 10} },
@jschomay
jschomay / gist:5958585
Created July 9, 2013 16:00
sublime user preferences
{
"font_size": 14.0,
"ignored_packages":
[
"Vintage"
],
"tab_size": 2,
"translate_tabs_to_spaces": true,
"word_wrap": true
}
@jschomay
jschomay / page exploder
Created May 19, 2013 17:41
little loop to "explode/scatter" any page's - each element moves in a random direction/speed along its x axis For demo, copy code, go to random website, paste in console
var elems=document.querySelectorAll("body *");
var l=elems.length;
var i, c, move, x = 1;
var A = function (){
for(i=0; i-l; i++){
c=elems[i].style;
move = elems[i].move
if (!move){
move=(Math.random()*8*(Math.round(Math.random())?1:-1));
}