Skip to content

Instantly share code, notes, and snippets.

View delano's full-sized avatar
👋
Let's talk about building teams

Delano delano

👋
Let's talk about building teams
View GitHub Profile
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
# - a browser with WebSocket support
#
# Usage:
# ruby redis_pubsub_demo.rb
#
# Power law (log tail) distribution
# Copyright(C) 2010 Salvatore Sanfilippo
# this code is under the public domain
# min and max are both inclusive
# n is the distribution power: the higher, the more biased
def powerlaw(min,max,n)
max += 1
pl = ((max**(n+1) - min**(n+1))*rand() + min**(n+1))**(1.0/(n+1))
max-1-pl.to_i

A (Nicer) Redis Client for EventMachine

Redis is my favourite key/value store; it’s flexible, easy to set up and insanely fast. [EventMachine][] is a popular Ruby library for doing asynchronous I/O using an event loop. Bindings already [exist][em-redis] for accessing a Redis server using EM’s async-I/O (courtesy of Jonathan Broad), but unfortunately the resulting code has to use [Continuation-Passing Style][cps] via Ruby blocks. A very basic example of what that looks like follows:

require 'digest/sha1'
class String
def hash
Digest::SHA1.hexdigest self
end
def bit
unpack('B*').first
end
@delano
delano / .bashrc
Created July 8, 2009 21:37 — forked from defunkt/.bashrc
# $ tweet "your message"
#
# See: http://solutious.com/blog/2009/07/13/bash-twitter/
#
# Contributors
# * @defunkt for the initial version
# * @anildigital and @grundprinzip for curl-fu
# * @solutious for the SSL sexytime
# See: http://curl.netmirror.org/docs/caextract.html

Amazon EC2 EBS Performance Test

This gist describes a working Rudy configuration for running the Bonnie64 benchmark on EC2.

Installation (2 steps)

  1. Install Rudy
    • Follow the Getting Started guide up to and including "Create Accounts Configuration".
  2. Download this gist
  • git clone git://gist.github.com/123400.git bonnie64-aws-test
In response to all the responses to:
http://twitter.com/rtomayko/status/1155906157
You should never do this in a source file included with your library,
app, or tests:
require 'rubygems'
The system I use to manage my $LOAD_PATH is not your library/app/tests
s1 = {:host=>'foo', :user => 'foobar'}
s2 = {:host=>'bar', :user => 'foobar'}
s3 = {:host=>'baz', :user => 'foobar'}
s4 = {:host=>'moo', :user => 'foobar', :options => {:password => 'barfoo'}}
def gate(s, s2, opts={})
gw = Net::SSH::Gateway.new(s[:host], s[:user], {:port => 22}.merge(opts))
gw_port = gw.open(s2[:host], s2[:port])
yield(gw_port)
ensure

(This is the text of the keynote I gave at Startup Riot 2009. Will update when video becomes available.)

Hi everyone, I’m Chris Wanstrath, and I’m one of the co-founders of GitHub.

GitHub, if you haven’t heard of it, has been described as “Facebook for developers.” Which is great when talking about GitHub as a website, but not so great when describing GitHub as a business. In fact, I think we’re the polar opposite of Facebook as a business: we’re small, never took investment, and actually make money. Some have even called us successful.

Which I’ve always wondered about. Success is very vague, right? Probably even relative. How do you define it?

After thinking for a while I came up with two criteria. The first is profitability. We employ four people full time, one person part time, have thousands of paying customers, and are still growing. In fact, our rate of growth is increasing – which means January was our best month so far, and February is looking pretty damn good.

require 'uri'
require 'benchmark'
require 'net/http'
require 'rubygems'
require 'eventmachine'
require 'dnsruby'
# github.com/careo/em-http-request/