Skip to content

Instantly share code, notes, and snippets.

View jfairbairn's full-sized avatar

James Fairbairn jfairbairn

View GitHub Profile
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/user.h>
#include <string.h>
#include <errno.h>
@jfairbairn
jfairbairn / gist:1648593
Created January 20, 2012 17:35
An eventmachine-based test server forking child processes to do the work, connecting to a UNIX domain socket on which the parent process is listening.
require 'eventmachine'
CRLF = "\r\n"
module Child
attr_writer :child_number
include EM::P::LineText2
def post_init
set_line_mode
end
heffalump:~ james$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.1]
heffalump:~ james$ php -v
PHP 5.3.4 (cli) (built: Jan 17 2011 21:54:20)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
heffalump:~ james$ cat foo.rb
msg = "Hello world"
#!/usr/bin/env ruby1.9.1
#
#
# Testing streaming a single object into s3
# In this case the kernel sources as they are a decent size for sending up
require 'fog'
key = 'AAAAA'
secret = 'BBBB'
@jfairbairn
jfairbairn / benchmark.rb
Created March 22, 2011 23:37
Using haml-js in Ruby. See comments for what/why. You'll need to get haml.js and copy it to your clone directory to make this work.
#!/usr/bin/env ruby
require 'benchmark'
require 'rubygems'
gem 'therubyracer'
gem 'haml'
gem 'tilt'
require 'v8'
require 'haml'