Skip to content

Instantly share code, notes, and snippets.

jimweirich / eternal_flame.sng
Created Aug 8, 2013
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,
jimweirich / attrs.rb
Created Aug 7, 2013
Trivial non-factory for valid attributes.
View attrs.rb
require 'date'
# Trivial collection of valid attributes for Active Record objects.
# Usage:
# emp =
module Attrs
Attributes = { }
jimweirich / assertions.rb
Last active Dec 20, 2015
Proof of concept for Pre/Post condition assertions based on RSpec/Given
View assertions.rb
require 'given/natural_assertion'
require 'given/line_extractor'
class Object
def self._Gvn_location_of(block)
eval "[__FILE__, __LINE__]", block.binding
module Given
View arg_matching_spec.rb
require 'rspec/given'
class Array
def ===(other)
size == other.size &&
zip(other).all? { |a, b| a === b }
describe "Arg Matching" do
jimweirich /
Created Jul 10, 2013
Can't push minitest-given
$ gem push minitest-given-3.0.0.beta.3.gem
Pushing gem to
You do not have permission to push to this gem.
jimweirich / cpu.rb
Last active Dec 18, 2015
Can people run this script and see if it gives accurate count of CPUs on their system. Report results in the comments please. Thanks! Oh! And don't forget to report what kind of system you are running this on (linux, windows, mac, etc.). UPDATE: Revised version that uses the Java runtime if running under JRuby.
View cpu.rb
require 'rbconfig'
# Based on a script at:
class CpuCounter
def self.count
def count
View equator_weight.rb
printf "Latitude? "
latitude_degrees = gets.to_f
latitude = latitude_degrees * Math::PI / 180.0
angular_velocity = 2 * Math::PI / (24 * 60 * 60) # Radians per second
radius_at_equator = 6_371_000 # meters
radius_at_latitude = radius_at_equator * Math.cos(latitude)
jimweirich /
Last active Jul 22, 2017
Controlling multiple drones with a single Ruby program.
# This script should be run on the drone.
# Change the IP address to be difference
# for each drone on the same ad-hoc network
killall udhcpd
ifconfig ath0 down
iwconfig ath0 mode ad-hoc essid ardrone2_070401 channel auto commit
ifconfig ath0 netmask up
View event_bus_spec.rb
describe 'EventBus methods cascade' do
Invariant { result.should == EventBus }
context 'clear' do
When(:result) { EventBus.clear }
Then { }
context 'publish' do
When(:result) { EventBus.publish('aa123bb', {}) }
jimweirich / Gemfile
Created May 21, 2013
Template for creating autonomous drone programs.
View Gemfile
source ''
gem 'celluloid'
gem 'celluloid-io'
You can’t perform that action at this time.