Skip to content

Instantly share code, notes, and snippets.

Avatar

Stephen Celis stephencelis

View GitHub Profile
View ruby_thread_hooks.diff
=== ruby.h
==================================================================
--- ruby.h (/trunk) (revision 16)
+++ ruby.h (/branches/thread-hooks) (revision 16)
@@ -724,6 +724,19 @@
void ruby_native_thread_kill _((int));
#endif
+
+typedef unsigned int rb_threadswitch_event_t;
View build-emacs-osx.rb
#!/bin/env ruby
require 'fileutils'
# Most Macs these days are dual-core machines. This should, maybe, default to 2.
print "How many cores does your system have? [1] "
cores = gets.chomp.to_i
cores = 1 if cores < 1
config_opts = ["--with-jpeg=no", "--with-gif=no", "--with-tiff=no", "--with-ns"]
View gist:60823
function_with_string_arg_and_hash_arg(<<-STRING, :key => value)
The string
can go
here
STRING
View production.rb
# config/environments/production.rb
config.action_controller.asset_host = Proc.new { |path|
'assets.example.com' if Time.at(path[/\d+$/].to_i) < 1.hour.ago
end
View gist:72782
# ~/.bash_profile
export GEMDIR=`gem env gemdir`
gemdoc() {
local gems=($GEMDIR/doc/$1*/rdoc/index.html)
open ${gems[@]: -1}
}
complete -W '$(`which ls` $GEMDIR/doc)' gemdoc
View gist:72783
# ~/.bash_profile
sg() {
local migration=`script/generate $@ | awk ' /db\/migrate\//{print $NF}'`
if [ $migration ]; then $EDITOR $migration && rake db:migrate; fi
}
alias sgmo="sg model $@"
alias sgmi="sg migration $@"
View articles_controller.rb
class ArticlesController < ActionController::Base
helper_method :articles, :article
# render index, show, new, edit
def create
article.save!
redirect_to articles_path
end
View gist:72787
# ~/.zsh/aliases
alias ez="mvim -f ~/.zshrc +1 \"+set syntax=sh\" \"+Sex ~/.zsh\" \
&& echo Sourcing... \
&& source ~/.zshrc"
View gist:72788
# ~/.zsh/config
export GEMPATH=`gem env gemdir` # we should cache this call
# ~/.zsh/functions/gemdoc
open $(echo $GEMPATH/doc/$1*(om[1]))/rdoc/index.html
# ~/.zsh/functions/_gemdoc
#compdef gemdoc
_files -W $GEMPATH/doc
View gist:72789
curl -O http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p160.tar.gz
tar xzf ruby-1.8.7-p160.tar.gz
cd ruby-1.8.7-p160
curl http://gist.github.com/98109.txt | patch -p0
./configure --enable-shared --enable-pthread --enable-install-doc \
CFLAGS=-D_XOPEN_SOURCE=1
make
sudo make install