This file contains hidden or 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
int gold_coin; | |
int* dollar_bill; | |
gold_coin = 100; | |
dollar_bill = &gold_coin; | |
if (dollar_bill == gold_coin ) | |
printf("Dollar bill has same intrinsic value as gold coin\n"); | |
else | |
printf("Dollar bill does not have same intrinsic value as gold coin\n"); |
This file contains hidden or 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
FUNGIBLE = [:coin, :coin, :coin, :coin] | |
INFUNGIBLE = [:coin, :cow, :wine, :kebab] | |
# Is each unit in the list of assets interchangeable? | |
def fungible?(assets) | |
if assets.all?{ |unit| assets.all? {|other_unit| unit==other_unit }} | |
puts "#{assets.inspect} is fungible" | |
else | |
puts "#{assets.inspect} is not fungible" | |
end | |
end |
This file contains hidden or 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 | |
import hashlib, urllib, time | |
def digest( content ): | |
return hashlib.sha1( content ).hexdigest() | |
def timecert( content): | |
url = "http://timecert.org/%s.time"%digest(content) | |
timestamp = urllib.urlopen( url ).read() | |
return time.strptime(timestamp,"%a %b %d %H:%M:%S %Z %Y") |
This file contains hidden or 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 'digest/sha1' | |
require 'open-uri' | |
# Calculate the digest of content | |
def digest(content) | |
Digest::SHA1.hexdigest(content) | |
end | |
# Gets the timecert timestamp for a given piece of content | |
def timecert(content) |
This file contains hidden or 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 'digest/sha1' | |
class Article < ActiveRecord::Base | |
before_save :update_digest | |
def full_text | |
"#{title}\n\n#{body}" | |
end | |
protected |
This file contains hidden or 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
NoMethodError: You have a nil object when you didn't expect it! | |
You might have expected an instance of Array. | |
The error occurred while evaluating nil.- | |
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:159:in `decrement_open_transactions' | |
/Library/Ruby/Gems/1.8/gems/aslakhellesoy-cucumber-0.1.99.23/bin/../lib/cucumber/rails/world.rb:61:in `__instance_exec0' | |
/Library/Ruby/Gems/1.8/gems/rspec-1.2.0/lib/spec/matchers/extensions/instance_exec.rb:19:in `send' |
NewerOlder