Skip to content

Instantly share code, notes, and snippets.

jimweirich / froth.rb
Created February 22, 2012 23:24
Stupid Simple Forth System in Ruby
View froth.rb
# Example Usage: ruby froth.rb ": sq dup * ; 2 sq ."
class Froth
attr_reader :storage
attr_accessor :trace
WordDefinition =, :xt, :immediate)
class WordDefinition
def immediate?
jimweirich / eternal_flame.sng
Created August 8, 2013 05:59
Words/Chords to the Eternal Flame
View eternal_flame.sng
The Eternal Flame (God Wrote in Lisp)
Bob Kanefsky / Julia Ecklar
I was taught assembler in my second year of school.
It's kinda like construction work, with a toothpick for a tool.
F G C Em Am
So when I made my senior year, I threw my code away,
View source_for.rb
# My take on Mike's source_for method.
# (see
# (1) I named it 'src' rather than source_for (ok, I'm a lazy typer).
# (2) The edit function was broken out as a separate function.
# (3) The edit function is for emacs
# (4) If the method is not defined on the object, and the object
# is a class, then see if it is an instance method on the class.
# The fourth point allows my to say:
View Has Anybody Seen My Code
In celebration of Whyday: Rubyists always want to show others the beautiful code
they have created, hence the question: Has Anybody Seen My Code?
Has Anybody Seen My Code
(sung to the tune of Has Anybody Seen My Gal)
Clean and small, works for all,
Ruby is my all in all.
Has anybody seen my code?
jimweirich / Rakefile
Last active January 10, 2019 05:12
Bottles of Beer, for Sandi Metz
View Rakefile
#!/usr/bin/env ruby
require 'rake/clean'
require 'rake/testtask'
task :default => [:spec, :test]
task :spec do
sh "rspec ."
jimweirich / Gemfile
Created May 21, 2013 19:08
Template for creating autonomous drone programs.
View Gemfile
source ''
gem 'celluloid'
gem 'celluloid-io'
jimweirich / x.rb
Created February 7, 2012 11:54
Vital Ruby my_each
View x.rb
class Array
def my_each
i = 0
while i < self.length
yield self[i]
i += 1
jimweirich /
Created April 17, 2012 23:53
Berlin Clock Kata

Berlin Clock

Original Reference

Create a representation of the Berlin Clock for a given time (hh::mm:ss).

The Berlin Uhr (Clock) is a rather strange way to show the time. On the top of the clock there is a yellow lamp that blinks on/off every two seconds. The time is calculated by adding rectangular lamps.

jimweirich / attr_flag.rb
Created February 8, 2012 12:04
Vital Ruby Lab 6
View attr_flag.rb
class Module
def attr_flag(*names)
names.each do |name|
module_eval "def #{name}?(); @#{name}; end"
jimweirich / analysis.rb
Created July 20, 2011 16:37
Results from Roman Numeral Calculator Kata at @cincinnatirb
View analysis.rb
# When I posted the results of the Roman Numeral Calculator kata
# earlier this week, I said that I felt that the evolution of the code
# through TDD was much more interesting than the final result. Let me
# explain.
# First, some background. The goal of this Kata is to produce a
# RomanNumeralCalculator object that converts from arabic numbers to
# Roman numerals, and from Roman numerals back to arabic.
Then { calculate("1").should == "I" }