Skip to content

Instantly share code, notes, and snippets.

@lucaspiller
lucaspiller / gist:177135
Created August 28, 2009 18:23
My first gist!
puts "Hello World!"
@lucaspiller
lucaspiller / gist:360176
Created April 8, 2010 15:19
Patron benchmark
require 'rubygems'
require 'patron'
50.times do
Thread.new do
print "+ Start\n"
session = Patron::Session.new
session.timeout = 30000
session.connect_timeout = 30000
@lucaspiller
lucaspiller / play_spec.rb
Created April 29, 2010 15:49
Play Spec - Making your specs fun!
We couldn’t find that file to show.
@lucaspiller
lucaspiller / tag_fixer.rb
Created October 24, 2010 08:53
Set ID3 tags from filename
require 'rubygems'
require 'id3lib'
file=ARGV.join
filename=File.basename(file, '.mp3')
parts = filename.split('-')
artist = parts[1].strip
title = parts[2].strip
@lucaspiller
lucaspiller / gist:847749
Created February 28, 2011 18:17
Riak basic benchmark script
#!/usr/bin/env ruby
require 'bundler'
Bundler.setup( :utilities )
Bundler.require( :utilities )
class Value
include Ripple::Document
property :name, String
@lucaspiller
lucaspiller / gist:847756
Created February 28, 2011 18:26
Riak config
$ cat /etc/riak/app.config
%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ts=4 sw=4 et
[
%% Riak Core config
{riak_core, [
%% Default location of ringstate
{ring_state_dir, "/var/lib/riak/ring"},
%% http is a list of IP addresses and TCP ports that the Riak
gem list | grep '(' | awk ' { print $1, $2 } ' | sed 's/[\(\),]//g' | awk -F " " ' { print "gem \""$1"\",","\""$2"\"" } ' >> Gemfile
@lucaspiller
lucaspiller / isthereanewgit.rb
Created June 14, 2011 16:23
Checks whether the version of Git you have installed is the latest.
require 'open-uri'
require 'rubygems'
require 'nokogiri'
doc = Nokogiri::HTML(open('http://git-scm.com/'))
latest = if doc.css('#ver').first.content =~ /v([0-9.]+)/
$1
else
abort "Borked"
end
@lucaspiller
lucaspiller / gist:1101508
Created July 23, 2011 14:49
CoffeeScript Bug
class Model
CONST_A: 1
CONST_B: 2
CONSTS: [@CONST_A, @CONST_B]
m = new Model
# => Model
m.CONST_A
# => 1
@lucaspiller
lucaspiller / gist:1213285
Created September 13, 2011 06:55
t.co is slow... (from a London data centre)
$ ping -c 10 t.co
PING t.co (199.59.148.12) 56(84) bytes of data.
64 bytes from r-199-59-148-12.twttr.com (199.59.148.12): icmp_seq=1 ttl=47 time=152 ms
64 bytes from r-199-59-148-12.twttr.com (199.59.148.12): icmp_seq=2 ttl=47 time=151 ms
64 bytes from r-199-59-148-12.twttr.com (199.59.148.12): icmp_seq=3 ttl=47 time=152 ms
64 bytes from r-199-59-148-12.twttr.com (199.59.148.12): icmp_seq=4 ttl=47 time=151 ms
64 bytes from r-199-59-148-12.twttr.com (199.59.148.12): icmp_seq=5 ttl=47 time=152 ms
64 bytes from r-199-59-148-12.twttr.com (199.59.148.12): icmp_seq=6 ttl=47 time=152 ms
64 bytes from r-199-59-148-12.twttr.com (199.59.148.12): icmp_seq=7 ttl=47 time=152 ms
64 bytes from r-199-59-148-12.twttr.com (199.59.148.12): icmp_seq=8 ttl=47 time=152 ms