Skip to content

Instantly share code, notes, and snippets.

View jbr's full-sized avatar
:octocat:
Focusing on OSS for April

Jacob Rothstein jbr

:octocat:
Focusing on OSS for April
View GitHub Profile
@eyliu
eyliu / homework.cls
Created December 3, 2009 08:29
LaTeX document class for typesetting homework
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesClass{homework}[2009/05/15 v0.0.1 Document class for typesetting homework]
\LoadClass[12pt,letterpaper,answers]{exam}
\RequirePackage{xspace}
\newcommand{\course}[1]{\def\@course{#1\xspace}}
\newcommand{\problemlist}[1]{\begin{center}\large #1 \end{center}}
\makeatletter
#!/bin/sh
set -u
set -e
# Example init script, this can be used with nginx, too,
# since nginx and unicorn accept the same signals
# Feel free to change any of the following variables for your app:
APP_ROOT=/home/deploy/public_html/rm/current
PID=$APP_ROOT/tmp/pids/unicorn.pid
ENV=production
(defun open (project) (interactive (list (read-directory-name "Peepopen for project: " "~/code/")))
(flet ((textmate-project-root () (file-truename project)))
(peepopen-goto-file-gui)))
(global-set-key [(meta ?o)] 'open)
@jbr
jbr / bay-area-food
Last active September 5, 2015 14:14
Things worth eating in the bay area
This is an unordered list
I am a vegetarian
East Bay:
Cheese puffs from gregoire
var util = require("./_util")
, events = require("events")
EventEmitter = exports.EventEmitter = function(){
events.EventEmitter.call(this);
};
util.inherits(EventEmitter, events.EventEmitter);
EventEmitter.prototype.emit = function(type) {
require 'v8'
class HandlebarsTemplateHandler
def self.js
Thread.current[:v8_context] ||= begin
V8::Context.new do |js|
js.load(File.join(Rails.root, 'vendor', 'javascripts', 'handlebars.js'))
js.eval("Templates = {}")
end
@avdi
avdi / deep_fetch.rb
Created June 28, 2011 19:28
Deep Fetch
module DeepFetch
def deep_fetch(*keys, &fetch_default)
throw_fetch_default = fetch_default && lambda {|key, coll|
args = [key, coll]
# only provide extra block args if requested
args = args.slice(0, fetch_default.arity) if fetch_default.arity >= 0
# If we need the default, we need to stop processing the loop immediately
throw :df_value, fetch_default.call(*args)
}
catch(:df_value){
@avibryant
avibryant / loess.js
Created August 17, 2011 15:45
Loess smoothing
//adapted from the LoessInterpolator in org.apache.commons.math
function loess_pairs(pairs, bandwidth)
{
var xval = pairs.map(function(pair){return pair[0]});
var yval = pairs.map(function(pair){return pair[1]});
console.log(xval);
console.log(yval);
var res = loess(xval, yval, bandwidth);
console.log(res);
return xval.map(function(x,i){return [x, res[i]]});
@hallettj
hallettj / for.sibilant
Created July 29, 2013 01:22
Demonstration of a monad comprehension macro in Sibilant, a Lisp dialect that compiles to JavaScript. See http://sibilantjs.info/ for information on Sibilant.
; A monad comprehension is a syntactic construct that translates
; synchronous-looking code into a callback-based implementation. Monads
; are a very general abstraction - which means that monad comprehensions
; have more expressive power than other sync-to-async code
; transformations.
; Here is an example that uses jQuery's $.get method to fetch resources:
(def post-with-author (id)
(for
@josevalim
josevalim / watcher.sh
Last active May 22, 2024 10:06
A 1LOC bash script for re-running tests whenever a lib/ or test/ file changes keeping the same VM instance
# You will need fswatch installed (available in homebrew and friends)
# The command below will run tests and wait until fswatch writes something.
# The --stale flag will only run stale entries, it requires Elixir v1.3.
fswatch lib/ test/ | mix test --stale --listen-on-stdin