Skip to content

Instantly share code, notes, and snippets.

View zeroeth's full-sized avatar
🤖
🐱 🤖 🐱 🤖

[0] zeroeth

🤖
🐱 🤖 🐱 🤖
View GitHub Profile
@zeroeth
zeroeth / crimea.csv
Created August 2, 2012 21:44 — forked from mbostock/.block
Stacked Bar Chart
date wounds other disease
5/1854 0 95 105
6/1854 0 40 95
7/1854 0 140 520
8/1854 20 150 800
9/1854 220 230 740
10/1854 305 310 600
11/1854 480 290 820
12/1854 295 310 1100
1/1855 230 460 1440
@zeroeth
zeroeth / attr_accessor_with_eval.rb
Created July 31, 2012 15:52
playing with the devil
class Class
def attr_accessor_with_history(attr_name)
attr_name = attr_name.to_s # make sure it's a string
attr_reader attr_name # create the attribute's getter
attr_reader attr_name+"_history" # create bar_history getter
class_eval %Q{
define_method "#{attr_name}=" do |value|
@#{attr_name} = value
@#{attr_name}_history ||= [nil]
@#{attr_name}_history << value
@zeroeth
zeroeth / attr_accessor_history.rb
Created July 31, 2012 15:41
class eval is the devil
class Class
def attr_accessor_with_history attribute_name
attr_reader "#{attribute_name}"
attr_reader "#{attribute_name}_history"
define_method "#{attribute_name}=" do |new_value|
history = instance_variable_get("@#{attribute_name}_history") || [nil]
instance_variable_set "@#{attribute_name}_history", history
history << new_value
@zeroeth
zeroeth / test_driven.rb
Created July 25, 2012 15:16
no irb test driven example
require "test/unit"
class String
def palindrome?
stripped = self.gsub(/\W/,'')
stripped == stripped.reverse
end
end
class TestPalindromeChecker < Test::Unit::TestCase
@zeroeth
zeroeth / no_irb.rb
Created July 25, 2012 15:14
no irb
class String
def palindrome?
stripped = self.gsub(/\W/,'')
stripped == stripped.reverse
end
end
puts "race_car".palindrome?
@zeroeth
zeroeth / no_irb.rb
Created July 25, 2012 15:14
no irb
class String
def palindrome?
stripped = self.gsub(/\W/,'')
stripped == stripped.reverse
end
end
puts "race_car".palindrome?
@zeroeth
zeroeth / README.mkd
Created July 9, 2012 19:18 — forked from christophermanning/README.md
Voronoi Diagram with Force Directed Nodes and Delaunay Links

Created by Christopher Manning

Summary

Nodes are linked to nodes in neighboring cells. The cell's color is a function of its area.

Controls

  • Drag the nodes to interact with the diagram.
  • Use the mousewheel to add/remove nodes.
@zeroeth
zeroeth / derp.txt
Created June 28, 2012 23:29
rails review notes
rails new 'appname'
rails scaffold birds name:string description:text ....
(generates views, routes, database models)
rake db:create (once when creating app)
rake db:migrate (every time database changes.. from scaffold/migrations)
rails s (starts server)
rails c (starts interactive prompt)
@zeroeth
zeroeth / blah.rb
Created June 27, 2012 15:23
player quest json pseudo classes
class Player
QuestContainer quests;
end
class QuestContainer
Quest[] completed;
Quest[] locked;
Quest[] unlocked;
end
#!/usr/bin/ruby
# inkscape -b '#ffffff' -e circles.png -w 3000 circles.svg
# gem install color-tools
require 'color'
# http://code.google.com/p/chipmunk-physics/
# svn checkout http://chipmunk-physics.googlecode.com/svn/trunk/ chipmunk-physics-read-only
# cmake -D BUILD_RUBY_EXT=ON .
# make && sudo make install