Skip to content

Instantly share code, notes, and snippets.

View wjlroe's full-sized avatar
📷

William Roe wjlroe

📷
View GitHub Profile
Get Turbogears minor mode - like Rinari mode
#!/usr/bin/env ruby
project_root = "/Users/will/projects/random"
server_script = File.join(project_root, 'script', 'server')
pid1 = Process.fork {
exec "#{server_script} start"
}
Process.detach(pid1)
This example shows how to setup an environment running Rails 3 beta under 1.9.1 with a 'rails3' gem set.
∴ rvm update --head
# ((Open a new shell)) or do 'rvm reload'
# If you do not already have the ruby interpreter installed, install it:
∴ rvm install 1.9.1
# Switch to 1.9.1 and gemset rails3, create if it doesn't exist.
∴ rvm --create use 1.9.1@rails3
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'open-uri'
messages = {}
first_run = true
loop do
#!/bin/env ruby
require 'rubygems'
require 'eventmachine'
def start_nodes(num_nodes, num_messages)
EM.run {
nodes = []
num_nodes.times do
nodes << EM.spawn{|message|
(defmodule hello
(export (start 0) (len 1)))
(defun start ()
(: io format '"Hello World!~n"))
(defun len (l)
(if (== l ()) 0
(+ 1 (len (cdr l)))))
X = fun() ->
lists:foldl(fun(Pid, Acc) ->
case erlang:process_info(Pid,message_queue_len) of
undefined ->
Acc;
{_, Len} ->
if
Len > 3 ->
[{Len, process_info(Pid)} | Acc];
true ->
@wjlroe
wjlroe / ssh_auth
Created January 20, 2011 10:43
Function to help set the ssh auth sock (helps with screen/tmux usage)
function set_current_ssh_auth_sock {
current_ssh_auth_sock=${1:-~/.ssh/current_ssh_auth_sock}
if [ ! -e "$current_ssh_auth_sock" -o -h "$current_ssh_auth_sock" ]
then
if file -L "$current_ssh_auth_sock" >/dev/null
then
SSH_AUTH_SOCK="$current_ssh_auth_sock"
else
rm -f "$current_ssh_auth_sock"
@wjlroe
wjlroe / room.rb
Created May 21, 2011 15:47
to_xml - is there a better way?
class Room < ActiveRecord::Base
def full
false
end
def to_xml(options = {})
options[:methods] = [:full]
super(options)
end
end
@wjlroe
wjlroe / gist:984988
Created May 21, 2011 23:13 — forked from agl/gist:876829
Proxy server for testing revocation
package main
import (
"encoding/line"
"fmt"
"io"
"net"
"strings"
)