Skip to content

Instantly share code, notes, and snippets.

View vangberg's full-sized avatar

Harry Vangberg vangberg

View GitHub Profile
@vangberg
vangberg / gist:1104053
Created July 25, 2011 12:51
pseudo ci, lol.
#!/usr/bin/env bash
set -m
[ -f post-receive.pid ] && kill `cat post-receive.pid` &>/dev/null
echo $$ > post-receive.pid
trap 'kill %%; exit 1' EXIT
APIKEY=somekey
while true
do
$pid = fork
if $pid == nil
exec "./srvd/redis-server ./srvd/redis.conf"
end
sleep 5
Process.kill(:$pid)
[harry@icecreamtruck (ruby19) maildir]$ bundle exec rake
(in /Users/harry/code/maildir)
/Users/harry/.rvm/rubies/rbx-1.2.3-20110315/bin/rbx -I"lib:test" "/Users/harry/.rvm/gems/rbx-1.2.3-20110315/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/test_helper.rb" "test/test_keywords.rb" "test/test_maildir.rb" "test/test_message.rb" "test/test_serializers.rb" "test/test_subdirs.rb" "test/test_unique_name.rb"
ERROR: the VM is exiting improperly
intended operation: :exception
associated value: nil
=====================================
Exception occurred during top-level exception output! (THIS IS BAD)
@vangberg
vangberg / gist:899175
Created April 2, 2011 02:18
post-receive.sh
#!/usr/bin/env bash
set -m
[ -f post-receive.pid ] && kill `cat post-receive.pid` &>/dev/null
echo $$ > post-receive.pid
trap 'kill %%; exit 1' EXIT
while true
do
echo "Waiting for request."
echo -ne "HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nOK" \
def path matcher
lambda {|req|
return unless match = req.env["PATH_INFO"].match(/^\/(#{matcher})(\/|$)/)
path = match.captures[0]
req.env["SCRIPT_NAME"] += "/#{path}"
req.env["PATH_INFO"] = "/#{match.post_match}"
}
end
require "ircator"
irc = Ircator::Connection.new(
:nick => "ircator",
:host => "irc.ircator.com",
:port => 6667,
:password => "secret"
)
irc.transmit "JOIN #channel"
require "sinatra"
use Rack::Session::Cookie
get "/" do
session["counter"] ||= 0
session["counter"] += 1
"count: #{session["counter"]}"
end
@vangberg
vangberg / curb.rb
Created December 14, 2010 20:10
persistent http w/ ruby
require "curb"
# Persistent.
c = Curl::Easy.new
c.url = "http://127.0.0.1"
2.times { c.perform }
# Not persistent.
2.times {
c = Curl::Easy.new
diff --git a/lib/mock_server.rb b/lib/mock_server.rb
index d09a2b4..99c4089 100644
--- a/lib/mock_server.rb
+++ b/lib/mock_server.rb
@@ -6,11 +6,9 @@ class MockServer
use Rack::ShowExceptions
end
- def initialize(port = 4000, &block)
+ def initialize(app, port = 4000, &block)
$ ruby thread-rmagick.rb ruby-1.9.2-p0
thread-rmagick.rb:4: [BUG] Segmentation fault
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]
-- control frame ----------
c:0004 p:---- s:0011 b:0011 l:000010 d:000010 CFUNC :read
c:0003 p:0019 s:0007 b:0007 l:001598 d:000006 BLOCK thread-rmagick.rb:4
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:---- s:0002 b:0002 l:000001 d:000001 TOP
---------------------------