Skip to content

Instantly share code, notes, and snippets.

@joshmcarthur
joshmcarthur / date_time_extension_spec.rb
Last active December 11, 2015 12:28
A code snippet to add #beginning_of_financial_year and #end_of_financial_year methods to Rails' DateTime class.
# spec/extensions/date_time_spec.rb
# PS: I know this spec code isn't particularly DRY or nice.
require 'spec_helper'
describe DateTime do
describe "#beginning_of_financial_year" do
subject do
DateTime.now.beginning_of_financial_year
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private
@mystix
mystix / passenger-nginx-setup.sh
Created March 21, 2011 14:00
Rackspace Ubuntu -- RVM + PostgreSQL + Passenger + NGiNX setup script
# install rvm
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
# install ruby 1.9.2 + some global gems
rvm install 1.9.2
rvm use 1.9.2@global
gem install awesome_print map_by_method wirble bundler builder pg cheat
gem install -v2.1.2 builder
@ches
ches / gist:243611
Created November 26, 2009 19:09 — forked from lukesutton/gist:107966
basic example of Warden authentication with Sinatra
Warden::Manager.serialize_into_session{|user| user.id }
Warden::Manager.serialize_from_session{|id| User.get(id) }
Warden::Manager.before_failure do |env,opts|
# Sinatra is very sensitive to the request method
# since authentication could fail on any type of method, we need
# to set it for the failure app so it is routed to the correct block
env['REQUEST_METHOD'] = "POST"
end