Skip to content

Instantly share code, notes, and snippets.

@reinh
reinh / .rspec
Last active December 15, 2015 00:19 — forked from coreyhaines/.rspec
--colour
-I app
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
def map
out = ''
overlay = {}
overlay.merge! player_overlay
height.times do |x|
width.times do |y|
char = overlay.fetch [x,y], '.'
out << char
end
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
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'
module StatsdLoginNotifier
def authenticate(name, password)
result = super
Statsd.new.count result ? 'login.success' : 'login.failure'
return result
end
end
class Session
prepend StatsdLoginNotifier
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
@reinh
reinh / gist:4330992
Created December 18, 2012 19:14
Code Smell of the Day: "Threadsafe" Singleton

Example

class PonyService
  def self.instance
    Thread.current['pony_service_instance'] ||= new
  end
end

PonyService.instance.find params[:pony_id]
# 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
@reinh
reinh / fizzbuzz.coffee
Created November 16, 2012 16:53
FizzBuzz++
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