This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'bundler' | |
Bundler.setup(:default) | |
require 'yajl' | |
require 'beanstalk-client' | |
jobs = 100_000 | |
prod = Thread.new do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'nokogiri' | |
require 'minitest/spec' | |
describe 'nokogiri css selectors' do | |
before do | |
@doc = Nokogiri::HTML %Q{ | |
<html> | |
<body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bharanee@tardis $ ./simple.rb -s swift -s dm -r 1000 | |
-- driver: sqlite3 rows: 1000 runs: 5 -- | |
benchmark sys user total real rss | |
swift #create 0.060000 0.370000 0.430000 0.431087 18.81m | |
swift #select 0.000000 0.020000 0.020000 0.027583 3.56m | |
swift #update 0.070000 1.760000 1.830000 1.836255 77.74m | |
dm #create 0.120000 1.640000 1.760000 1.799292 119.61m | |
dm #select 0.050000 0.760000 0.810000 0.812489 49.06m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Key | Action | |
------------------------------+-------------------------------------------- | |
c | Compose | |
/ | Search | |
k | Move to newer conversation | |
j | Move to older conversation | |
n | Next message | |
p | Previous message | |
o or <Enter> | Open | |
u | Return to conversation list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./overload | |
>> Person | |
>> operator new | |
>> Person | |
>> ~Person | |
>> operator delete | |
>> ~Person |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby1.9.1 | |
require 'em-http' | |
EM.run do | |
url = "http://www.scribd.com:80/doc/45016088/He-Spake-and-It-Was-Done" | |
http = EM::HttpRequest.new(url).get timeout: 10 | |
http.callback { puts "done"; EM.stop }; | |
http.errback {|res| puts "error\n"; p res.response_header; EM.stop } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for ip in `sudo cat /var/log/auth.log | grep "invalid user .* from" | sed 's/^.*invalid user \([0-9a-zA-Z_\-]\+\) from \([0-9.]\+\).*$/\1\t\2/' | cut -f2 | sort -u`; do echo iptables -A INPUT -s $ip/32 -p tcp -j REJECT; done | xargs sudo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add pessmistic locking support. Make sure you're inside a transaction. | |
# resource = MyResource.get(24) | |
# resource.lock! # write lock (FOR UPDATE) | |
# | |
# TODO: | |
# resource = MyResource.get_with_lock!(:write, 24) | |
# resource = MyResource.get_with_lock!(:read, 24) | |
# MyResource.all(:lock => :write) | |
module DataMapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ruby.h> | |
VALUE blocking_function(void *data) { | |
throw "die die die"; | |
} | |
VALUE run(VALUE self) { | |
try { | |
rb_thread_blocking_region(blocking_function, 0, 0, 0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ruby/ruby.h> | |
#include <time.h> | |
#include <unistd.h> | |
#define CONST_GET(scope, constant) rb_const_get(scope, rb_intern(constant)) | |
VALUE day_secs; | |
VALUE cDateTime; | |
VALUE fNewBang; |