This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- ruby -*- | |
begin | |
require 'rubygems' | |
rescue LoadError | |
end | |
exts = ['.rb', '.rhtml', '.erb', '.builder'] | |
if ARGV[0] =~ /^\.[a-zA-Z0-9]+$/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; Load twittering mode. | |
(require 'twittering-mode) | |
(let ((fn (expand-file-name "~/.pw/twittering-pw.el"))) | |
(when (file-readable-p fn) | |
(load fn) )) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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.. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example of how to create a back-reved rake command. | |
require 'rubygems' | |
gem 'rake', '= 0.7.3' | |
require 'rake' | |
Rake.application.run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ruby shared.rb | |
dog | |
dog | |
$ | |
$ ruby distinct.rb | |
animal | |
dog | |
$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
export GEM_HOME=/Users/jim/local/ruby19.gems | |
RUBYDIR=/Users/jim/local/ruby19 | |
RUBYOPT='' | |
PATH=$RUBYDIR/bin:$PATH | |
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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.) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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.) |
OlderNewer