Skip to content

Instantly share code, notes, and snippets.

View bravoecho's full-sized avatar

Luca bravoecho

  • UK
  • 07:28 (UTC +01:00)
View GitHub Profile
@bravoecho
bravoecho / dependency_injection_example.rb
Created November 20, 2011 15:57 — forked from mperham/gist:1379464
Flexibility with and without Dependency Injection
require 'minitest/autorun'
class TaxCodeBase
class AbstractMethod < StandardError
end
attr_accessor :user_id
def initialize(user_id=nil)
self.user_id = user_id
@bravoecho
bravoecho / active_model_lint.rb
Created March 6, 2012 11:17 — forked from mikegehard/active_model_lint.rb
RSpec shared examples for ActiveModel::Lint
# adapted from rspec-rails http://github.com/rspec/rspec-rails/blob/master/spec/rspec/rails/mocks/mock_model_spec.rb
# put this in a file in your spec/support directory, or add the code to the spec_helper.rb
# USAGE:
#
# context "ActiveModel Lint" do
# it_behaves_like "an ActiveModel", YourModel.new
# end
shared_examples "an ActiveModel" do |model|
require 'test/unit/assertions'
@bravoecho
bravoecho / chef_solo_bootstrap.sh
Created April 14, 2012 09:59 — forked from ryanb/chef_solo_bootstrap.sh
Bootstrap Chef Solo
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
rm ruby-1.9.3-p125.tar.gz
rm -r ruby-1.9.3-p125
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
tar -xvzf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125/
./configure --prefix=/usr/local
@bravoecho
bravoecho / selectable_queue.rb
Created June 23, 2012 14:51 — forked from garybernhardt/selectable_queue.rb
A queue that you can pass to IO.select. This is for use in a GUI application. I'm not turning into a Node programmer.
# A queue that you can pass to IO.select.
#
# NOT THREAD SAFE: Only one thread should write; only one thread should read.
#
# Purpose:
# Allow easy integration of data-producing threads into event loops. The
# queue will be readable from select's perspective as long as there are
# objects in the queue.
#
# Implementation:

This document is intended to be a simplified version of the OAuth v2-28 specification. In particular it has been written with implementors in mind, and as such attempts to trim the spec down to just what you need to implement an OAuth provider or client. It is necessarily not complete, but attempts to introduce spec requirements in the same order in which the protocol proceeds in practise, with everything you need to know about each protocol endpoint brought together in one place rather than scattered across a large document.

@bravoecho
bravoecho / gist:3423782
Created August 22, 2012 08:36 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
module Suggestions
def self.included( base )
base.extend ClassMethods
end
module ClassMethods
# USAGE:
#
# class Doctor
# # this model should have the typical Sunspot.setup clause somewhere else

Motivation

We recently were working on a project where the version of Firefox on the development machines was causing acceptance tests running on Capybara and Selenium to fail and/or hang erroneously. The solution was to point Selenium at a custom version of Firefox. We also added the Firefox binaries to the application git repo so that all devs could run against a known good version of Firefox.

Solution

  1. Download the desired version of Firefox from ftp://ftp.mozilla.org/pub/firefox/releases/

  2. Put Firefox.app in your rails app somewhere like ./bin/spec/macosx/

#!/bin/sh
# For simplicity's sake I dump this file in the project folder and execute
# it from the VM straight out of /vagrant -> could run as part of box/basebox buildout.
alias apt-get="sudo apt-get"
alias mount="sudo mount"
alias umount="sudo umount"
# Oh. Start by making .vbox_version contain the desired version string.
VBOX_VERSION=$(cat /home/vagrant/.vbox_version)
#!/bin/sh
#
# Shell script that configures gnome-terminal to use solarized theme
# colors. Written for Ubuntu 11.10, untested on anything else.
#
# Solarized theme: http://ethanschoonover.com/solarized
#
# Adapted from these sources:
# https://gist.github.com/1280177
# http://xorcode.com/guides/solarized-vim-eclipse-ubuntu/