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
# I was thinking about it, and thought if you were going to do "mixins" in Haml | |
# then they ought to work in a predictable way. In ERB you can simply define a | |
# method and place more ERB inside of it. This does not work in Haml, but maybe | |
# it should. | |
require 'sinatra' | |
require 'haml' | |
get '/erb' do | |
erb :test_erb |
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
heycarsten:lcbo carsten$ gem list nokogiri | |
*** LOCAL GEMS *** | |
nokogiri (1.4.3) | |
heycarsten:lcbo carsten$ irb | |
ruby-1.9.2-preview3 > require 'nokogiri' | |
LoadError: no such file to load -- nokogiri/version_warning | |
from /Users/carsten/.rvm/gems/ruby-1.9.2-preview3/gems/nokogiri-1.4.3/lib/nokogiri.rb:34:in `require' | |
from /Users/carsten/.rvm/gems/ruby-1.9.2-preview3/gems/nokogiri-1.4.3/lib/nokogiri.rb:34:in `<top (required)>' |
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
# I wanted a simple object factory for use with Ohm, I'm used to factory_girl | |
# and fabrication. After a few minutes of messing around and trying to get them | |
# to work with Ohm, I decided to try giving it a whirl myself... | |
class Factory | |
def self.factories | |
@factories ||= {} | |
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
# I had no idea that you could do this: | |
def attribute(name, type = Ohm::Types::String, klass = Ohm::Types[type]) | |
# If no 3rd argument is provided then it uses the second argument to key | |
# the default value. Not super obvious, but now that I know about it, I | |
# think it's kinda cool :-) |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Using LCBO API via jQuery</title> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script> | |
<script src="http://ajax.cdnjs.com/ajax/libs/underscore.js/1.1.4/underscore-min.js"></script> | |
<script type="text/javascript"> | |
// Let's make an object in the global namespace that will serve as an API | |
// wrapper for LCBO API. | |
var LCBO = new function() { |
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
ENV['DATABASE_URL'] ||= lambda { | |
def config | |
ActiveRecord::Base.configurations[Rails.env.to_s] | |
end | |
def credentials | |
if (creds = [config['user'], config['password']]).any? | |
creds.join(':') | |
else | |
nil |
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 'benchmark' | |
Benchmark.bmbm do |x| | |
x.report('printf') do | |
for i in 1..1_000_000 | |
3.times.map { '%06x' % rand(0x100000) }.join | |
end | |
end | |
x.report('to_s') 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
require 'benchmark' | |
require 'time' | |
SECS_IN_HOUR = 3600 | |
def while_loop | |
now = Time.now | |
ago = now - (SECS_IN_HOUR * 23) | |
max, count, times = now.to_i, ago.to_i, [] | |
begin |
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
heycarsten:~ carsten$ gem install rakins | |
Successfully installed rakins-0.0.1 | |
1 gem installed | |
heycarsten:~ carsten$ rakins install rakins | |
,,,, | |
.' `/\_/\ | |
' <@V@> /=========================== | |
<(((((((((( ) ( \./ <== INSTALLIN' rakins, YO. = | |
\(''''''\(\( \=========================== | |
`-"`-" " " |
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 major: A | |
A minor: a | |
A-flat major: A♭ | |
A-flat minor: a♭ | |
A-sharp minor: a♯ | |
B major: B | |
B minor: b | |
B-flat major: B♭ | |
B-flat minor: b♭ | |
C major: C |