Skip to content

Instantly share code, notes, and snippets.

Avatar

Jonathan rondale-sc

View GitHub Profile
View tm_comment_blocks.rb
#!/usr/bin/env ruby
str = STDIN.read
out = ''
str.each_line do |line|
if line[0] == 35
out << line
elsif line[0] != 35
out << "#" + "\t" + line
end
end
View tm_comment_blocks.rb
#!/usr/bin/env ruby
str = STDIN.read
start_marker, end_marker = "=begin\n", "\n=end"
out = ''
str.each_line do |line|
if str.split.shift == "=begin"
@uncomment = true
end
@rondale-sc
rondale-sc / 99bottles.rb
Created Aug 24, 2011
Ninety Nine Bottles of Beer
View 99bottles.rb
require 'pp'
@unique_number_words = {
1 => "one", 2 => "two", 3 => "three",
4 => "four", 5 => "five", 6 => "six",
7 => "seven", 8 => "eight", 9 => "nine",
10 => "ten", 11 => "eleven", 12 => "twelve", 13 => "thirteen"
}
@compound_number_words = {
@rondale-sc
rondale-sc / insert_grid.rb
Created Sep 6, 2011
insert_grid Sass function
View insert_grid.rb
module Sass::Script::Functions
def insert_grid(columns, width_string)
assert_type columns, :Number
assert_type width_string, :String
width = width_string.match(/\A(\d+)(\w+)\z/)[1]
type = width_string.match(/\A(\d+)(\w+)\z/)[2]
raise StandardError, "You must set width_string with unit ie '960px'. " unless ["px","em", "pt", "%"].include?(type)
grid, grid_segment_width = "", 0
@rondale-sc
rondale-sc / ruby-hough.rb
Created Sep 21, 2011
The hough transform in ruby. Only looks for straight black lines.
View ruby-hough.rb
begin
['oily_png', 'pp'].each do |g|
require g
end
rescue LoadError => e
puts "Could not load '#{e}'"; exit
end
class Hough
Convert = "/usr/local/bin/convert"
@rondale-sc
rondale-sc / gist:1264514
Created Oct 5, 2011
rvm benchmark trace
View gist:1264514
~ rvm --trace 1.9.2,1.9.3 benchmark test.rb
+__rvm_parse_args:727> [[ -n 4.3.11 ]]
+__rvm_parse_args:750> [[ -z '' && -n '' ]]
+__rvm_parse_args:752> [[ 0 -eq 1 || -n '' ]]
+__rvm_parse_args:20> [[ -n 1.9.2,1.9.3 ]]
+__rvm_parse_args:22> rvm_token=1.9.2,1.9.3
+__rvm_parse_args:24> (( 2 > 0 ))
+__rvm_parse_args:26> next_token=benchmark
+__rvm_parse_args:27> shift
+__rvm_parse_args:32> case 1.9.2,1.9.3 ([[:alnum:]]*|@*)
@rondale-sc
rondale-sc / gist:1264538
Created Oct 5, 2011
rvm info ruby-1.9.3-rc1
View gist:1264538
ruby-1.9.3-rc1:
system:
uname: "Darwin gitorious.promedicalinc.com 11.0.0 Darwin Kernel Version 11.0.0: Sat Jun 18 12:56:35 PDT 2011; root:xnu-1699.22.73~1/RELEASE_X86_64 x86_64"
bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11)"
zsh: "/bin/zsh => zsh 4.3.11 (i386-apple-darwin11.0)"
rvm:
version: "rvm 1.8.5 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]"
@rondale-sc
rondale-sc / gist:1264541
Created Oct 5, 2011
rvm info ruby-1.9.2-p290
View gist:1264541
ruby-1.9.2-p290:
system:
uname: "Darwin gitorious.promedicalinc.com 11.0.0 Darwin Kernel Version 11.0.0: Sat Jun 18 12:56:35 PDT 2011; root:xnu-1699.22.73~1/RELEASE_X86_64 x86_64"
bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11)"
zsh: "/bin/zsh => zsh 4.3.11 (i386-apple-darwin11.0)"
rvm:
version: "rvm 1.8.5 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]"
@rondale-sc
rondale-sc / gist:1271481
Created Oct 7, 2011
rvm benchmark trace 2
View gist:1271481
➜ ~ rvm --trace 1.9.2,1.9.3 benchmark test.rb
+__rvm_parse_args:730> [[ -n 4.3.11 ]]
+__rvm_parse_args:753> [[ -z '' && -n '' ]]
+__rvm_parse_args:755> [[ 0 -eq 1 || -n '' ]]
+__rvm_parse_args:20> [[ -n 1.9.2,1.9.3 ]]
+__rvm_parse_args:22> rvm_token=1.9.2,1.9.3
+__rvm_parse_args:24> (( 2 > 0 ))
+__rvm_parse_args:26> next_token=benchmark
+__rvm_parse_args:27> shift
+__rvm_parse_args:32> case 1.9.2,1.9.3 ([[:alnum:]]*|@*)
@rondale-sc
rondale-sc / pconsole.sh
Created Oct 18, 2011
pconsole bash/zsh alias
View pconsole.sh
pconsole () {
if [[ -n $1 ]];
then RAILS_ENV=$1 pry -r ./config/environment.rb -r rails/console/app -r rails/console/helpers;
elif [[ -r ./config/environment.rb ]];
then RAILS_ENV=development pry -r ./config/environment.rb -r rails/console/app -r rails/console/helpers;
elif [[ -z $1 ]];
then pry;
fi }
# Place in ~/.zshrc || ~/.bashrc to open pry with rails environment like this: