Skip to content

Instantly share code, notes, and snippets.

@jimweirich
jimweirich / fic
Created December 10, 2008 01:48
Find In Code
#!/usr/bin/env ruby
# -*- ruby -*-
begin
require 'rubygems'
rescue LoadError
end
exts = ['.rb', '.rhtml', '.erb', '.builder']
if ARGV[0] =~ /^\.[a-zA-Z0-9]+$/
;;; Load twittering mode.
(require 'twittering-mode)
(let ((fn (expand-file-name "~/.pw/twittering-pw.el")))
(when (file-readable-p fn)
(load fn) ))
# 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..
# Example of how to create a back-reved rake command.
require 'rubygems'
gem 'rake', '= 0.7.3'
require 'rake'
Rake.application.run
$ ruby shared.rb
dog
dog
$
$ ruby distinct.rb
animal
dog
$
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
#!/bin/sh
export GEM_HOME=/Users/jim/local/ruby19.gems
RUBYDIR=/Users/jim/local/ruby19
RUBYOPT=''
PATH=$RUBYDIR/bin:$PATH
exec "$@"
#!/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
# 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.)
# 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.)