Skip to content

Instantly share code, notes, and snippets.

View dherman's full-sized avatar

Dave Herman dherman

View GitHub Profile
@dherman
dherman / functions.js
Created July 29, 2012 01:44
Function utilities
(function(Fp, Ap) {
var applyMethod = Fp.apply,
bindMethod = Fp.bind,
callMethod = Fp.call;
var sliceMethod = Ap.slice,
concatMethod = Ap.concat;
var apply = callMethod.bind(applyMethod),
bind = callMethod.bind(bindMethod),
@dherman
dherman / emacs-cheat-sheet.md
Created August 2, 2012 16:22
My emacs cheat sheet

In penance for cracking stupid jokes on Twitter, here's my Emacs cheat sheet. Emacs has a steep learning curve, so I've tried to order them by importance so you could learn them in stages.

One overall rule of thumb: pay attention to the minibuffer (the line at the bottom of the editor). It will often guide you through a process, and also gives you hints about what state you're in, such as the middle of a multi-chord sequence.

The other rule of thumb: when in doubt, C-g it out.

Basics (mandatory)

You simply can't get by without having these at your fingertips.

@dherman
dherman / paproxy.js
Created August 22, 2012 17:23 — forked from syg/gist:3427627
demonstrate PA behavior as a proxy
function isIndex(n) {
// This isn't right, but pretend that this checks if n is an index in the
// way that SpiderMonkey checks in js_IdIsIndex.
return Number(n) % 1 == 0;
}
function indices(obj) {
var result = [];
for (var i = 0; i < obj.length; i++)
result.push(i);
@dherman
dherman / wc.sh
Created September 13, 2012 23:26
count LOC in mozilla-central
#!/bin/sh
find . -name '*.tbl' -or -name '*.c' -or -name '*.cpp' -or -name '*.h' | xargs wc -l | fgrep total | awk '{total = total + $1}END{print total}'
@dherman
dherman / TDZ.js
Created September 29, 2012 18:36
temporary dead zone
// ---------------------------------------------------------------------
// 1. UNCONTROVERSIAL AMONGST TC39
// ---------------------------------------------------------------------
// read before write throws
{
console.log(x); // throws
let x = 12;
console.log(x);
}
@dherman
dherman / accepted.js
Created October 1, 2012 16:25
TypeScript type system examples
// This type-checks and compiles.
function Thing(arg : string) { }
var obj = new Thing("");
if (true) {
obj.x = 3;
}
@dherman
dherman / fml.txt
Created October 9, 2012 18:44
fml fml fml
Installing rb-fsevent (0.4.3.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/dherman/.rbenv/versions/1.9.3-p194/bin/ruby extconf.rb
creating Makefile
extconf.rb:21:in `<main>': Only Darwin systems greater than 8 (Mac OS X 10.5+) are supported (RuntimeError)
Gem files will remain installed in /Users/dherman/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rb-fsevent-0.4.3.1 for inspection.
Results logged to /Users/dherman/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rb-fsevent-0.4.3.1/ext/gem_make.out
@dherman
dherman / extconf.rb
Created October 9, 2012 18:52
hello world
# Workaround to make Rubygems believe it builds a native gem
require 'mkmf'
create_makefile('none')
# TODO: determine whether we really need to be working around instead of with mkmf
if `uname -s`.chomp != 'Darwin'
puts "Warning! Only Darwin (Mac OS X) systems are supported, nothing will be compiled"
else
begin
@dherman
dherman / Act-I-FML.txt
Created October 9, 2012 18:55
FML, a play in one act
Davids-MacBook-Air-2:calculist dherman$ rbenv version
1.9.3-p194 (set by /Users/dherman/Sources/calculist/.rbenv-version)
Davids-MacBook-Air-2:calculist dherman$ which ruby
/Users/dherman/.rbenv/shims/ruby
Davids-MacBook-Air-2:calculist dherman$ ruby --version
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.2.0]
Davids-MacBook-Air-2:calculist dherman$ which gem
/Users/dherman/.rbenv/shims/gem
Davids-MacBook-Air-2:calculist dherman$ gem install bundler
Fetching: bundler-1.2.1.gem (100%)b
@dherman
dherman / Gemfile
Created October 9, 2012 18:56
Gemfile
source "http://rubygems.org"
group :development do
gem 'rake'
gem 'rack'
gem 'jekyll'
gem 'rdiscount'
gem 'pygments.rb'
gem 'RedCloth'
gem 'haml', '>= 3.1'