Skip to content

Instantly share code, notes, and snippets.

View chrismcg's full-sized avatar

Chris McGrath chrismcg

View GitHub Profile
#!/usr/bin/env ruby -w
#---
# Excerpted from "TextMate"
# We make no guarantees that this code is fit for any purpose.
# Visit http://www.pragmaticprogrammer.com/titles/textmate for more book information.
#---
$LOAD_PATH << "#{ENV["TM_SUPPORT_PATH"]}/lib"
require "exit_codes"
require "web_preview"
export LSCOLORS=gxfxcxdxbxegedabagacad
if [[ $OS == 'Linux' ]]; then
alias ls='ls --color=auto'
else
alias ls='ls -G'
fi
alias ll='ls -l'
alias lls='ll -S'
alias lt='ll -t'
alias ltr='ls -ltr'
# in ~/.irbrc
if ENV['RAILS_ENV']
load '~/.railsrc'
end
# in ~/.railsrc
def sql(query)
ActiveRecord::Base.connection.select_all(query)
end
#!/usr/bin/ruby
require 'osx/cocoa'
include OSX
class Foo < NSObject
def applicationDidFinishLaunching(sender)
puts "yo"
end
end
/* Ruby Thread support:
Ruby implements threads by using setjmp/longjmp to switch between separate
C stacks within one native thread.
This confuses Objective C because NSThread stores a per-native-thread stack
of autorelease pools and exception handlers. When the C stack changes, an
error message like this is likely to appear:
Exception handlers were not properly removed. Some code has jumped or