Skip to content

Instantly share code, notes, and snippets.

View iamjwc's full-sized avatar

Justin Camerer iamjwc

  • LimeWire, LLC
  • New York City
View GitHub Profile
import Debug.Trace
-- Problem 0
helloWorld :: [Char]
helloWorld = "Hello World"
-- Problem 1
myLast :: [a] -> a
myLast = head . reverse
@iamjwc
iamjwc / flarp.rb
Last active May 20, 2016 16:07
Flattens hashes/arrays into a single level hash with the full json key path as a top level key. Useful for finding differences between two large manifests.
# Usage:
# (irb)> { "some" => [{"keys" => "with", "some" => ["values"]}]}.flarp
# => {"some.0.keys"=>"with", "some.0.some.0"=>"values"}
class Hash
def flarp(h = {}, prefix = nil)
each do |k, v|
new_k = [prefix, k].compact.join(".")
if v.is_a?(Array) || v.is_a?(Hash)
class Hash
def flarp(h = {}, prefix = nil)
each do |k, v|
new_k = [prefix, k].compact.join(".")
if v.is_a?(Array) || v.is_a?(Hash)
v.flarp(h, new_k)
else
h[new_k] = v
end
@iamjwc
iamjwc / maze.go
Last active October 16, 2015 17:58
// go-race
// width: `tput cols`
// height: `tput lines`
// Our generated maze needs to be just less than 1/2 the size of our
// terminal size, so we can have room to print walls.
//
// Each cell is an integer. Each wall on the cell (N, E, S, W) are
// represented by a bit. If a wall exists only on the north side,
@iamjwc
iamjwc / migrant_work_enqueuer.rb
Created August 21, 2015 20:21
File takes a CSV of "okey,root_okey,source_okey" and enqueues work for the "SetRootAndSourceProjectIdsProcessor".
def enqueue_for_migrant_work(okey, root, source)
queue_name = "migrant_worker_$$$ENVIRONMENTNAME$$$"
payload = {
'processor' => 'SetRootAndSourceProjectIdsProcessor',
'okey' => okey,
'root' => root,
'source' => source,
}
filetype off
"call pathogen#helptags()
call pathogen#runtime_append_all_bundles()
" first clear any existing autocommands:
autocmd!
set nocompatible
" http://items.sjbach.com/319/configuring-vim-right
var gia = (function (obj){
var stateEV=[["Alabama","AL",9,"SR"],["Alaska","AK",3,"SR"],["Arizona","AZ",11,"SR"],["Arkansas","AR",6,"SR"],["California","CA",55,"SO"],["Colorado","CO",9,"T"],["Connecticut","CT",7,"LO"],["Delaware","DE",3,"SO"],["Dist. of Columbia","DC",3,"SO"],["Florida","FL",29,"T"],["Georgia","GA",16,"SR"],["Hawaii","HI",4,"SO"],["Idaho","ID",4,"SR"],["Illinois","IL",20,"SO"],["Indiana","IN",11,"SR"],["Iowa","IA",6,"T"],["Kansas","KS",6,"SR"],["Kentucky","KY",8,"SR"],["Louisiana","LA",8,"SR"],["Maine","ME",4,"SO"],["Maryland","MD",10,"SO"],["Massachusetts","MA",11,"SO"],["Michigan","MI",16,"LO"],["Minnesota","MN",10,"SO"],["Mississippi","MS",6,"SR"],["Missouri","MO",10,"LR"],["Montana","MT",3,"SR"],["Nebraska","NE",5,"SR"],["Nevada","NV",6,"T"],["New Hampshire","NH",4,"T"],["New Jersey","NJ",14,"SO"],["New Mexico","NM",5,"SO"],["New York","NY",29,"SO"],["North Carolina","NC",15,"T"],["North Dakota","ND",3,"SR"],["Ohio","OH",18,"T"],["Oklahoma","OK",7,"SR"],["Oregon","OR",7,"SO"],["Pennsylvan
var margin = {top: 1, right: 1, bottom: 6, left: 1},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var formatNumber = d3.format(",.0f"),
format = function(d) { return formatNumber(d) + " TWh"; },
color = d3.scale.category20();
<script type="text/javascript">
// Make the back button work on the search page.
$(function() {
var addPushState = function() {
// When a link in the pager is clicked, add the new url
// to the pushState to make the back button work.
$('.pager li a').click(function() {
history.pushState({}, '', $(this).attr('href'));
return true;
});
@iamjwc
iamjwc / mysql.rb
Last active January 2, 2016 10:19
require 'formula'
class Mysql < Formula
homepage 'http://dev.mysql.com/doc/refman/5.6/en/'
url 'http://downloads.mysql.com/archives/mysql-5.6/mysql-5.6.10.tar.gz'
version '5.6.10'
sha1 'f37979eafc241a0ebeac9548cb3f4113074271b7'
bottle do
sha1 'e07b9a207364b6e020fc96f49116b58d33d0eb78' => :mountain_lion