Skip to content

Instantly share code, notes, and snippets.

View raroni's full-sized avatar

Rasmus Rønn Nielsen raroni

View GitHub Profile
@raroni
raroni / txt
Created February 24, 2016 08:47
Sublime talk notes
Sublime tricks
You probably know some of these tricks, but hopefully you don't know them all.
File navigation
* Quick open (cmd + t)
* Quick open with symbols
* Quick open peek
def b(n, &block)
puts "start: #{n}"
if block_given?
puts yield
end
puts "stop"
end
def a(&block)
b(1, &block)
@raroni
raroni / gist:99ddb8eebf639096c899
Created August 6, 2014 11:30
Validation spike 2
class RidesIndexParamValidation
MAX_LIMIT = 200
attr_reader :result, :failure_details
def initialize(params)
@params = params
@result = :unspecified
end
class Result
attr_reader :failure_details
def initialize(successful, failure_details = nil)
@failure_details = failure_details
end
def failure?
@failure_details != nil
end
@raroni
raroni / classico.coffee
Created April 21, 2012 16:51
Classico - mini lib for creating classes in JS/Coffeescript
"use strict"
# Classico lib - go down for examples
Classico = {}
Classico.prototype =
super: (propertyName) ->
Object.getPrototypeOf(Object.getPrototypeOf(@))[propertyName].call @
Classico.include = (hash) ->
@raroni
raroni / wingman_intelligent_property_changes.coffee
Created February 14, 2012 08:58
Wingman intelligent property changes
# Wingman is a yet to be released coffeescript MVC framework. Throughout Wingman, WingmanObject is
# used for monitoring changes to a object in real time in various handy ways.
# The simplest use of #observe is like this:
o = new WingmanObject
o.set name: 'Ras'
o.observe 'name', -> alert 'cb fired!'
o.set name: 'Yogi'
@raroni
raroni / async_io_looking_sync.rb
Created April 16, 2010 08:51
Asynchronous IO behaving synchronously using Ruby 1.9's fibers
# this code snippet was inspired by
# http://www.igvita.com/2010/04/15/non-blocking-activerecord-rails/
require 'fiber' # needed to use Fiber.current
require 'rubygems'
require 'mysqlplus'
require 'eventmachine'
require 'em-mysqlplus'
def query(sql)