Skip to content

Instantly share code, notes, and snippets.

View cmer's full-sized avatar

Carl Mercier cmer

  • Toronto, ON, Canada
View GitHub Profile
# COWBOY CODING FTW! TESTING IS FOR WUSSIES. ;-)
require File.dirname(__FILE__) + '/test_helper'
class CowboyTest < Test::Unit::TestCase
def test_my_awesomeness
(0..12612).each {
assert :this_code_does_not_contain_bugs
}
end
#!/bin/bash
#================================================================================
# /engineyard/bin/monit_merb_mpc
#================================================================================
# This script controls the multi-process Merb 1.0 service
#
# Do not forget to ensure this script is executable:
# $ chmod a+x /engineyard/bin/monit_merb_mpc
#================================================================================
#!/bin/bash
#================================================================================
# /engineyard/bin/monit_merb_mpc
#================================================================================
# This script controls the multi-process Merb 1.0 service
#
# Do not forget to ensure this script is executable:
# $ chmod a+x /engineyard/bin/monit_merb_mpc
#================================================================================
# taken from http://eigenclass.org/hiki.rb?ruby+live+process+introspection
###################
# #### RUBY STUFF
define eval
call(rb_p(rb_eval_string_protect($arg0,(int*)0)))
end
define redirect_stdout
Routing tables
Internet:
Destination Gateway Flags Refs Use Netif Expire
0/1 10.8.0.5 UGSc 3 0 tun0
default 192.168.1.1 UGSc 10 0 en1
10.8.0.1/32 10.8.0.5 UGSc 0 0 tun0
10.8.0.5 10.8.0.6 UH 9 0 tun0
10.37.129/24 link#8 UC 3 0 vnic1
10.37.129.2 0:1c:42:0:0:9 UHLWI 2 7 lo0
( [4689]11 | *xxS0 | <:1>[2-9]xx[2-9]xxxxxxS0 | 1[2-9]xx[2-9]xxxxxxS0 | 011xxxxxxx. | [#*x][#*x][#*x][#*x]. )
@cmer
cmer / yaml_benchmark.rb
Created November 19, 2010 23:05
YAML, ZAML, Marshal & JSON quick'n'dirty benchmark.rb
require 'rubygems'
require 'benchmark'
require 'yaml'
require 'zaml'
require 'json'
yaml_str = <<-eos
yaml goes here
eos
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
--------------------------------------------------------------------
YAML.load: 0.7924
Marshal.load: 0.0742
to_yaml: 5.1661
ZAML.dump: 1.4574
to_json: 0.1152
Marshal.dump: 0.0845
ruby 1.8.7 (2010-04-19 patchlevel 253) [i686-darwin10.4.0], MBARI 0x6770, Ruby Enterprise Edition 2010.02
@cmer
cmer / git-completion.sh
Created January 2, 2011 17:24
GIT Bash Prompt Awesomeness -- Shortened directory name, uncommitted changes indicator, commits not pushed indicator
#
# bash completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
# *) local and remote branch names
# Fixes broken UTF8 strings as instructed at http://ruby.runpaint.org/encoding
def self.sanitize_string(str, request_charset=nil)
return str unless str.is_a?(String)
ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')
dest = ic.iconv(str + ' ')[0..-2]
dest = encode_from_request_charset(str, request_charset) unless dest.valid_encoding?
dest
end