Discover gists
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 python | |
# encoding: utf-8 | |
# | |
# Rudementary Python Brainfuck Interpreter | |
# jeremy@jeremybanks.ca | |
# | |
# Usage: brainfuck.py program.bf | |
# | |
# Input is from stdin, output to stdout, obviously. | |
# The grid is infinite in both directions. |
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
<html> | |
<head> | |
<title>test</title> | |
</head> | |
<body> | |
this is a foo | |
</body> | |
</html> |
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
class AddPriceToProduct < ActiveRecord::Migration | |
def self.up | |
options = {:precision => 8, :scale => 2, :default => 0} | |
add_column :products, :decimal, options | |
add_column :price, :decimal, options | |
end | |
def self.down | |
remove_column :products, :price |
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
class AddPriceToProduct < ActiveRecord::Migration | |
def self.up | |
add_column :products, :price, :decimal, | |
:precision => 8, :scale => 2, :default => 0 | |
end | |
def self.down | |
remove_column :products, :price | |
end | |
end |
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
class Manager < ActiveRecord::Base | |
belongs_to :demo | |
serialize :state | |
serialize :cache | |
def after_initialize | |
@observers = [] | |
end | |
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
class Note | |
include ::DataMapper::Resource | |
property :id, Integer, :serial => true | |
property :content, String, :length => 2048 | |
property :type, Discriminator | |
validates_length :content, :minimum => 4, :maximum => 2048 | |
before :save do |
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
curl http://api.feedburner.com/awareness/1.0/GetFeedData?uri=peelmeagrape | sed -n -e 's/.*circulation="\([0-9]*\)".*/\1/p' |
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
require 'open-uri' | |
response = URI.parse("http://api.feedburner.com/awareness/1.0/GetFeedData?uri=peelmeagrape").read | |
puts response.match(/circulation="([0-9]*)"/)[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
Loading development environment (Rails 2.1.0) | |
>> m = Manager.new | |
=> #<Manager id: nil, state: nil, cache: nil, kind: nil, demo_id: nil, created_at: nil, updated_at: nil> | |
>> m.cache | |
Restoring state:--- | |
cache: | |
state: | |
=> {} | |
>> m.cache[:name] = "Mike" |
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
<!-- A stab at how the first pie chart on http://teethgrinder.co.uk/open-flash-chart/gallery-pie.php could be created from a table --> | |
<table summary="Microsoft's Internet Explorer appears to be dying, with the Wii taking 20% of market"> | |
<caption>Pie Chart</caption> | |
<tr> | |
<td>Wii</td> | |
<td>15%</td> | |
</tr> | |
<tr> | |
<td>Opera</td> | |
<td>12%</td> |