Skip to content

Instantly share code, notes, and snippets.

View rondale-sc's full-sized avatar

Jonathan rondale-sc

  • Providence, Rhode Island
View GitHub Profile
#!/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
#!/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 August 24, 2011 04:12
Ninety Nine Bottles of Beer
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 September 6, 2011 16:15
insert_grid Sass function
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 September 21, 2011 23:05
The hough transform in ruby. Only looks for straight black lines.
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 October 5, 2011 14:09
rvm benchmark trace
➜ ~ 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 October 5, 2011 14:18
rvm info ruby-1.9.3-rc1
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 October 5, 2011 14:20
rvm info ruby-1.9.2-p290
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 October 7, 2011 22:24
rvm benchmark trace 2
➜ ~ 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 October 18, 2011 22:38
pconsole bash/zsh alias
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: