Skip to content

Instantly share code, notes, and snippets.

@jimweirich
jimweirich / fic
Created Dec 10, 2008
Find In Code
View fic
#!/usr/bin/env ruby
# -*- ruby -*-
begin
require 'rubygems'
rescue LoadError
end
exts = ['.rb', '.rhtml', '.erb', '.builder']
if ARGV[0] =~ /^\.[a-zA-Z0-9]+$/
View gist:41973
;;; Load twittering mode.
(require 'twittering-mode)
(let ((fn (expand-file-name "~/.pw/twittering-pw.el")))
(when (file-readable-p fn)
(load fn) ))
View evil.sud
# http://www.websudoku.com/?level=4&set_id=470872047
..53.694.
.3.1....6
.......3.
7..9.....
.1..3..2.
.....2..7
.6.......
8....7.5.
.436.81..
View gist:45839
# Example of how to create a back-reved rake command.
require 'rubygems'
gem 'rake', '= 0.7.3'
require 'rake'
Rake.application.run
View Example Output
$ ruby shared.rb
dog
dog
$
$ ruby distinct.rb
animal
dog
$
View gist:88188
fortune = 0
max = 1000000
for i in 1..max do
n = rand(100) + 1
if (n <= 50) then fortune = fortune - 1
elsif (n >= 51 && n <= 65) then fortune = fortune + 0
elsif (n >= 66 && n <= 75) then fortune = fortune + 0.5
elsif (n >= 76 && n <= 99) then fortune = fortune + 1
View gist:99498
#!/bin/sh
export GEM_HOME=/Users/jim/local/ruby19.gems
RUBYDIR=/Users/jim/local/ruby19
RUBYOPT=''
PATH=$RUBYDIR/bin:$PATH
exec "$@"
View gist:107832
#!/usr/bin/env ruby
# Execute the git, gem, or rake command, depending on the second argument
case ARGV.first
when /^(add|bisect|branch|checkout|clone|commit|diff|fetch|grep|init|log|merge|mv|pull|push|rebase|reset|rm|show|status|tag)$/
system "git #{ARGV.join(' ')}"
when /^(build|cert|check|cleanup|contents|dependency|environment|fetch|generate_index|help|install|list|lock|mirror|outdated|pristine|query|rdoc|search|server|sources|specification|stale|uninstall|unpack|update|which)$/
system "gem #{ARGV.join(' ')}"
else
View quiz.rb
# COMMUNITY CHALLENGE
#
# How would you test this Quiz#problem method? Only two rules:
#
# 1. The tests should fail if any part of the application breaks.
# For example: If "gets" is moved before "puts" then the tests should
# fail since that breaks the application.
#
# 2. You cannot change the Quiz class. But you can use whatever framework
# and tools you want for the tests. (RSpec, Cucumber, etc.)
View quiz.rb
# COMMUNITY CHALLENGE
#
# How would you test this Quiz#problem method? Only two rules:
#
# 1. The tests should fail if any part of the application breaks.
# For example: If "gets" is moved before "puts" then the tests should
# fail since that breaks the application.
#
# 2. You cannot change the Quiz class. But you can use whatever framework
# and tools you want for the tests. (RSpec, Cucumber, etc.)
You can’t perform that action at this time.