Skip to content

Instantly share code, notes, and snippets.

@igrigorik
igrigorik / webapp.rb
Created November 13, 2010 21:28
Inspired by @JEG2's talk at Rubyconf... Any ruby object, as a webapp! 'Cause we can. :-)
require 'rubygems'
require 'rack'
class Object
def webapp
class << self
define_method :call do |env|
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
@evnm
evnm / brew-install-missing-unix-tools
Created October 24, 2011 05:27
A brew command to install useful tools missing from Mac OS X
# Legitimately-useful utilities missing from OS X.
brew install wget watch gnu-sed coreutils
# Up-to-date versions of included tools.
brew install git emacs
# Just for fun.
brew install fortune cowsay
cscotta@ordasity:~/Desktop$ scala -cp mongo-2.7.0.jar Repro.scala
Inserting canary...
Inserting test data...
Paging through records...
Spotted the canary!
Updating canary object...
Spotted the canary!
Whoops, shipped the same order multiple times!
cscotta@ordasity:~/Desktop$
@mrflip
mrflip / maximum_battery_life.md
Created March 19, 2012 08:32
maximum battery life checklist -- use before a long plane flight

Max Battery Life Checklist

Here is a checklist to follow if you want maximum battery life -- for instance if you're about to get on a long plane flight.

10 hour battery life on a non-SSD Macbook Pro 17"

Low power use checklist

With power connected:

public final static RuntimeException ᚇ = new RuntimeException("┻━┻");
public void ノಠ益ಠノ彡(RuntimeException t) { throw t; }
public void ノಠ益ಠノ彡(Throwable t) { throw new RuntimeException(t); }
public int hashCode() {
ノಠ益ಠノ彡(ᚇ);
return 0;
}
@lukego
lukego / gist:4706097
Last active December 12, 2015 03:19
Table data structure that "garbage collects" not-recently-used items in O(1) time

I use this data structure all the time. Can someone leave a comment and tell me what it's called?

  1. insert(k,v): add a new value
  2. lookup(k): lookup an existing value
  3. age(): delete old entries (that have not been used since previous call to age())
# Initialize 'old' and 'new' to empty tables
local old, new = {}, {}
aphyr@waterhouse:~/timelike master$ lein test timelike.node-test
lein test timelike.node-test
Even connections LB
Total reqs: 10000
Latency distribution:
Min: 0.017489419380090965
Median: 141.4027252436847
95th %: 612.7774737814785
99th %: 937.1806417316121

On the relative value of startup stock

How do you compare the potential value of different stage companies? And as a company progresses what is the appropriate amount of stock to give new employees?

Using data from Crunchbase and Yahoo Finance we can calculate the average value created per company broken down by how much money they have raised. From this we can then compute relative returns at the different stages, e.g. $1M raised, $10M, $100M, etc.

tl;dr

For this exercise we'll calibrate relative to expected return from a company that's raised $1M.

@cmeiklejohn
cmeiklejohn / gist:8346377
Last active January 2, 2016 18:49
Think Distributed Systems Summer School; Providence, RI
Think Distributed Systems Summer School
Providence, RI
Curriculum
Friday (night session, open discussion)
* Background, introductions
* What are you working on in distributed systems?
* Lightning talks on research or open problems
@Wilto
Wilto / thanks.md
Last active August 29, 2015 14:02

Let’s leave aside, for now, the fact that you’ve changed web standards. You’ve been a participant in the first time—in the history of the web, far as I know—that the web development community has taken a feature from an initial proposal to the funding of an honest-to-God native implementation.

Instead, I want you to focus on this: say only ten developers use a native responsive images solution to reduce the weight of just one page apeice by only 500kb, and each of those pages has a barely-significant 5,000 hits per month: those users have been saved almost 24GB of data. A thousand pages saving 500kb apeice, and we’ve saved users an entire terabyte in a month. Now expand that to the entire industry: every web developer; every hit on every page that would otherwise carry with it a huge, wasteful image request, saving megabytes at a time. To those users, the only change is that the web is faster, less expensive, more accessible. For those users, the web is just better.

In helping make the picture element