Skip to content

Instantly share code, notes, and snippets.

@jimfisher
jimfisher / rw.zsh
Created July 24, 2011 03:30
zsh rails workspace launcher for OSX terminal.app
rails_workspace(){
osascript -e 'tell application "Terminal"' \
-e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down' \
-e "do script with command \"cd `pwd`;clear;\" in selected tab of the front window" \
-e "do script with command \"rails server\" in selected tab of the front window" \
-e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down' \
-e "do script with command \"cd `pwd`;clear;\" in selected tab of the front window" \
-e "do script with command \"rails console\" in selected tab of the front window" \
-e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down' \
-e "do script with command \"cd `pwd`;clear;\" in selected tab of the front window" \
@jimfisher
jimfisher / difference_in_analog_clock_hands.rb
Created March 7, 2011 21:36
A simple program to calculate the difference in degrees between two hands on analog clock. This was a puzzle presented to me, so I thought I'd give it a shot in code.
#
# Author: Jim Fisher @jimfish
# Date: March 7th, 2011
# Description: A simple program to calculate the difference in degrees between two hands on analog clock. This was a puzzle presented to me, so I thought I'd give it a shot in code.
#
def difference_between_hands_on_an_analog_clock_in_degrees(time)
hours = time.strftime("%l").to_f
minutes = time.min.to_f
hratio = 1/12.0
mratio = 1/60.0
@jimfisher
jimfisher / words_to_numeric.rb
Created February 14, 2011 00:12
Coded by Jim Fisher github: @jimfisher twitter: @jimfish #A simple app for converting words into NUMERIC representations and then making that into a % # Based on a silly email I received found below ###### EMAIL ######
begin
# lets define numbers for every letter as A = 1, B = 2, C=3, etc.
alphabet_numbers = {}
('a'..'z').each_with_index{|x,y| alphabet_numbers[x] = y+1}
# lets get a word
loop do
puts "Please enter a word to convert to a percent (ctrl C to exit):"
input = gets.chomp.downcase
# lets process the word
sum = input.split("").map{|l|alphabet_numbers[l].to_i}.reduce(&:+)