Skip to content

Instantly share code, notes, and snippets.

View rinaldifonseca's full-sized avatar

Rinaldi Fonseca rinaldifonseca

View GitHub Profile

Install Postgresql on Mountain Lion

Based on: http://coderwall.com/p/1mni7w

brew install postgresql
initdb /usr/local/var/postgres -E utf8
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/postgresql/9.1.4/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
convert -list font
describe("SinonFakeServerWithJasmine", function() {
var server;
beforeEach(function() {
server = sinon.fakeServer.create();
});
afterEach(function () {
server.restore();
});
require "delegate"
class PostsController < ApplicationController
respond_to :html, :json
module PubSub
def add_observer(observer)
(@observers ||= []) << observer
end
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'machinist/active_record'
require 'machinist/caching/active_record'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
spec_support = Rails.root.join("spec/support/**/*.rb")
source :rubygems
gem 'sinatra'
@rinaldifonseca
rinaldifonseca / gist:4163420
Created November 28, 2012 19:18
Resque and Sidekiq Adapter
class ResqueAdapter
def self.push(MyJob, params)
Resque.enqueue(MyJob, params)
end
end
class SideKiqAdapter
def self.push(MyJob, params)
Sidekiq::Client.enqueue(MyJob, params)
end
@rinaldifonseca
rinaldifonseca / Gemfile
Created November 21, 2012 22:19
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin
class CardData
def initialize(node)
@card_data = node
end
def name
@card_data.search("name").text
end
def image
c = XmlImport.new("path", CockatriceXmlParser).process!
c.each { |card_attributes| Card.create!(card_attributes, :without_protection => true) }