Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require 'csv'
require 'socket'
class AverageSessionsPerServer
Server = Struct.new(:name, :current_sessions, :status) do
META_SERVER_NAMES = ['FRONTEND', 'BACKEND'].freeze
def up?
# Act like Vim
setw -g mode-keys vi
# Use the mouse
set -g mode-mouse on
# Look good
set -g default-terminal "screen-256color"
set -g status-right "#[fg=black]#(rbenv version | awk '{ print $1 }' 2> /dev/null)"
set -g status-bg "blue"
@nwjsmith
nwjsmith / gist:3657103
Created September 6, 2012 15:02 — forked from amateurhuman/gist:2005745
Installing Rubinius 2.0.0-dev with rbenv

Installing rbx-2.0.0-dev with Ruby 1.9 support using rbenv can be a tad tricky. This is what I did to get up and running, you'll need another version of ruby already installed as well as rake.

The basic outline:

  1. Clone Rubinius HEAD from github
  2. Configure installation for rbenv and 1.9 support
  3. Install Rubinius
  4. Configure your $PATH to use Rubinius gems
  5. Start using Rubinius
@nwjsmith
nwjsmith / latency.txt
Created June 5, 2012 14:44 — forked from jhclark/latency.txt
Latency numbers every programmer should know
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 1 MB sequentially from memory 250,000 ns 0.25 ms
Round trip within same datacenter 500,000 ns 0.5 ms
Read 1 MB sequentially from SSD 1,000,000 ns 1 ms 4X memory
@nwjsmith
nwjsmith / results.txt
Created March 29, 2012 20:10
Compare the 'schema' of two hashes
Hash#structurally_equal?
when compared with a single-level hash
with the same keys
should be true
with different keys
should be false
with more keys
should be false
with less keys
vagrant@master:~$ python --version
Python 2.6.5
vagrant@master:~$ wget https://raw.github.com/gist/2126960/9babcd4b49b8ae4841b92a5b5124eb6fc84027d7/destdir.py
--2012-03-20 06:18:51-- https://raw.github.com/gist/2126960/9babcd4b49b8ae4841b92a5b5124eb6fc84027d7/destdir.py
Resolving raw.github.com... 207.97.227.243
Connecting to raw.github.com|207.97.227.243|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 996 [text/plain]
Saving to: `destdir.py'
defaults: &defaults # The '&' creates a reference called 'defaults' for later
grizzlies: 'hardcore'
pandas: 'stupid'
mammals:
pandas: 'furry' # Overrides key/value in 'defaults'
<<: *defaults # Concatenates defaults
bears:
grizzlies: 'smelly' # Overrides key/value in 'defaults'
# You write a class called Wrapper, that has a single static function named
# wrap that takes two arguments, a string, and a column number. The function
# returns the string, but with line breaks inserted at just the right places
# to make sure that no line is longer than the column number. You try to break
# lines at word boundaries.
#
# Like a word processor, break the line by replacing the last space in a line
# with a newline.
class Wrapper
#!/bin/sh
set -e
# Add host-only network
cat <<-EOF > /etc/network/interfaces
# Loopback
auto lo
iface lo inet loopback
#!/bin/sh
set -e
# Add host-only network
cat <<-EOF > /etc/network/interfaces
# Loopback
auto lo
iface lo inet loopback