Skip to content

Instantly share code, notes, and snippets.

@ream88
ream88 / before_each.rb
Created August 21, 2011 12:56
Before each method hook
require 'active_support/all'
module BeforeEach
extend ActiveSupport::Concern
module InstanceMethods
def before_each
raise NotImplementedError('Please define before_each method')
end
end
@ream88
ream88 / gist:1183322
Created August 31, 2011 11:20
Uninstall all gems
gem list --no-versions | grep \w* | xargs gem uninstall
@ream88
ream88 / gist:1212213
Created September 12, 2011 19:54
@ThomasFuchs: lazy tweet: on Lion, how can I pipe from the command line into a new email in Mail.app?
osascript -e 'tell application "Mail" to make new outgoing message with properties { Content: do shell script "ls", visible: true }' -e 'tell application "Mail" to activate'
@ream88
ream88 / chat.rb
Created January 22, 2012 19:54
How to separate cc and bcc in messages?
class Chat < ActiveRecord::Base
has_many :user_chats, conditions: { bbc: false }
has_many :bbc_user_chats, class_name: 'UserChat', conditions: { bbc: true }
has_many :users, through: :user_chats
has_many :bbc_users, through: :bbc_user_chats, source: :user
end
@ream88
ream88 / excel_template_handler.rb
Created January 24, 2012 15:30 — forked from stephencelis/redcarpet.rb
Markdown, Excel template handler for Rails 3.2.
class ActionView::Template
module Handlers
class Excel
def call(template)
%{
Tempfile.open('writeexcel').tap do |tmp|
WriteExcel.new(tmp.path).tap do |workbook|
#{template.source}
end.close
end.tap(&:rewind).read
@ream88
ream88 / dabblet.css
Created January 31, 2012 18:50 — forked from chriscoyier/dabblet.css
Click open/close Dropdown in pure CSS
/* Click open/close Dropdown in pure CSS */
/* Disclaimer: Not the most semantic
thing in the universe. */
/* Forked from original idea
http://jsfiddle.net/paullferguson/Sv54G/3/ */
.tabs {
position: relative;
@ream88
ream88 / collegia-webfont.eot
Created February 9, 2012 15:20 — forked from tpryan/ribbon.html
Github Ribbon in CSS.
@ream88
ream88 / mock_verify_method.rb
Created February 27, 2012 21:16
Mock :verify: method with MiniTest::Mock
class MiniTest::Mock
alias_method :__verify, :verify
undef :verify
end
mock = MiniTest::Mock.new
# call :verify on mock object
# ...
@ream88
ream88 / 0-README.md
Created March 1, 2012 11:47
Ruby-1.9.x debugger install script

Ruby-1.9.3 debugger install script

This script will install ruby-debug19 under your current Ruby 1.9.3 environment.

Requirements

  • rbenv

Installation

@ream88
ream88 / Cakefile
Created March 29, 2012 21:04
Simple Cakefile which helps you to compile coffee-script files in the order you like.
exec = require('child_process').exec
fs = require('fs')
Array::remove = (e) -> @[t..t] = [] if (t = @indexOf(e)) > -1
Array::include = (e) -> @indexOf(e) > -1
config =
# All files are compiled in the order you like into following ".js" file.
output: 'public/javascripts/app.js'