Skip to content

Instantly share code, notes, and snippets.


Jamie Lawrence ideasasylum

View GitHub Profile
peterc / methods_returning.rb
Last active Jun 19, 2021
Object#methods_returning - to work out which method on an object returns what we want
View methods_returning.rb
require 'stringio'
require 'timeout'
class Object
def methods_returning(expected, *args, &blk)
old_stdout = $>
$> = do |meth|
Timeout::timeout(1) { dup.public_send(meth, *args, &blk) == expected rescue false } rescue false
manuelmeurer / controller.rb
Last active Nov 15, 2016
Render dynamic CSS
View controller.rb
class Display::WidgetsController < ApplicationController
def show
scss = render_to_string('show', locals: { foo: bar }, formats: :scss)
@css =, Compass.sass_engine_options.merge(syntax: :scss)).render