Skip to content

Instantly share code, notes, and snippets.

View igrigorik's full-sized avatar
:octocat:

Ilya Grigorik igrigorik

:octocat:
View GitHub Profile
@baroquebobcat
baroquebobcat / mirah_repl.rb
Created May 1, 2012 03:53
Mirah REPL -- hacked together
#
# Mirah REPL -- hacked to bits
#
# assuming your ruby is jruby,
# $ gem install mirah
# $ ruby -rubygems repl.rb
# m> class Foo
# m> def bar
# m> 12
# m> end
@moderation
moderation / gist:2467004
Created April 22, 2012 21:22
SPDY proxy
var fs = require('fs'),
spdy = require('spdy'),
httpProxy = require('http-proxy');
var options = {
key: fs.readFileSync(__dirname + '/moderation-key.pem'),
cert: fs.readFileSync(__dirname + '/moderation-cert.pem'),
ca: fs.readFileSync(__dirname + '/moderation-csr.pem')
};
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@toolmantim
toolmantim / simpler_goliath_test_helpers.rb
Created March 25, 2012 18:57
Simpler test helpers for Goliath
# Additional methods for Goliath::TestHelper to make simple Goliath testing
# simple. You might need the other syntax for testing gnarly stuff, but I've
# yet to need it. To use, just include this in your spec_helper.rb.
#
# Your spec must respond to #api and return the Goliath API class to test.
#
# @example
# describe MyAPI do
# let(:api) { MyAPI }
# describe "GET /" do
@paulmillr
paulmillr / mapreduce.scala
Created March 10, 2012 16:03
Why functional programming matters (aka MapReduce for humans)
import com.cloudera.crunch._
import com.cloudera.scrunch._
class ScrunchWordCount {
def wordCount(inputFile: String, outputFile: String) = {
val pipeline = new Pipeline[ScrunchWordCount]
pipeline.read(from.textFile(inputFile))
.flatMap(_.toLowerCase.split("\\W+"))
.filter(!_.isEmpty())
.count
@amacdougall
amacdougall / focus.vim
Created March 6, 2012 23:38
Simple vim script for a single centered text column.
" Name: focus.vim
" Author: Alan MacDougall <smoke@alanmacdougall.com>
" License: Public Domain
"
" Focus on a single column of text, showing it in a distraction-free format.
" Save this as ~/.vim/scripts/focus.vim (or whatever you please), and invoke
" it with :source <filename>. Of course, you could certainly hook that up to a
" :command, or a macro, or a Vimscript function...
" collapse current splits and divide screen in three
@tarcieri
tarcieri / example_task.mirah
Created December 21, 2011 20:39
Kilim "Hello World" with Mirah
# Adapted from https://github.com/kilim/kilim/blob/master/examples/kilim/examples/SimpleTask.java
import "kilim.Mailbox"
import "kilim.Pausable"
import "kilim.Task"
class ExampleTask < Task
def initialize
@mailbox = Mailbox.new
end
@headius
headius / gist:1408381
Created November 30, 2011 07:54
JRuby Fiber perf compared to 1.9.3
# Ruby 1.9.3
ruby-1.9.3-p0 ~/projects/jruby $ ruby -v bench/bench_fiber_ring.rb 5 100 1000
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0]
bench/bench_fiber_ring.rb:23: warning: mismatched indentations at 'end' with 'def' at 21
100 fibers / 1000 passes: 0.150000 0.000000 0.150000 ( 0.155022)
100 fibers / 1000 passes: 0.150000 0.000000 0.150000 ( 0.153985)
100 fibers / 1000 passes: 0.150000 0.000000 0.150000 ( 0.153822)
100 fibers / 1000 passes: 0.150000 0.000000 0.150000 ( 0.152370)
100 fibers / 1000 passes: 0.160000 0.000000 0.160000 ( 0.155857)
require 'jruby'
module Serialize
def self.serialize(obj)
baos = java.io.ByteArrayOutputStream.new
oos = java.io.ObjectOutputStream.new(baos)
oos.write_object(JRuby.reference(obj))
oos.close
@fennb
fennb / gist:1283573
Created October 13, 2011 06:35
nginx microcaching config example
# Set cache dir
proxy_cache_path /var/cache/nginx levels=1:2
keys_zone=microcache:5m max_size=1000m;
# Virtualhost/server configuration
server {
listen 80;
server_name yourhost.domain.com;
# Define cached location (may not be whole site)