class PonyService
def self.instance
Thread.current['pony_service_instance'] ||= new
end
end
PonyService.instance.find params[:pony_id]
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
--colour | |
-I app |
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
Merchant Date Ends Deal Price Value | |
Burger King 10/2/2011 10/4/2011 Your way 25 50 | |
McDonalds 10/5/2011 Not really food 22 44 | |
Arbys 10/8/2011 10/10/2011 More burgers 7 14 |
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
def map | |
out = '' | |
overlay = {} | |
overlay.merge! player_overlay | |
height.times do |x| | |
width.times do |y| | |
char = overlay.fetch [x,y], '.' | |
out << char | |
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
module Roguish | |
module UI | |
class CursesUI | |
class Window < Curses::Window | |
def paint(contents) | |
clear | |
contents = contents.split("\n") if contents.respond_to?(:split) | |
contents.each_with_index do |line, i| | |
setpos(i, 0) | |
self << line.to_s |
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
brew install wine --use-gcc ⮂ ⮂ system ⮂ 2013-01-29 | |
Warning: Your Xcode (4.5.2) is outdated | |
Please install Xcode 4.6. | |
==> Downloading http://downloads.sourceforge.net/project/wine/Source/wine-1.4.1.tar.bz2 | |
Already downloaded: /Library/Caches/Homebrew/wine-1.4.1.tar.bz2 | |
Error: undefined method `/' for nil:NilClass | |
Please report this bug: | |
https://github.com/mxcl/homebrew/wiki/troubleshooting | |
/usr/local/Library/Homebrew/macos/xquartz.rb:80:in `include' | |
/usr/local/Library/Formula/wine.rb:82:in `install' |
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
module StatsdLoginNotifier | |
def authenticate(name, password) | |
result = super | |
Statsd.new.count result ? 'login.success' : 'login.failure' | |
return result | |
end | |
end | |
class Session | |
prepend StatsdLoginNotifier |
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 StatsdLoginNotifier | |
def initialize(session) | |
@session=session | |
@statsd = Statsd.new | |
end | |
def authenticate(name, password) | |
result = @session.authenticate(name, password) | |
@statsd.count result ? 'login.success' : 'login.failure' | |
return result |
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
# Context: a campfire client using ranger (https://github.com/mrduncan/ranger) | |
# takes a callback function which it passes the messages returned from | |
# Campfire. | |
room.recentMessages (messages) -> console.log messages | |
# takes a user id and a callback function which it passes the user returned | |
# from Campfire. | |
client.user userId, (user) -> console.log user |
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
for i in [1..120] | |
ret = "" | |
ret = ret + string for [j, string] in [[3, 'Fizz'], [5, 'Buzz'], [7, 'Baz']] when i%j is 0 | |
console.log ret or i |