Skip to content

Instantly share code, notes, and snippets.

View tubbo's full-sized avatar
:shipit:
i don't make rails apps you use, i make the rails apps you use faster..

Tom Scott tubbo

:shipit:
i don't make rails apps you use, i make the rails apps you use faster..
View GitHub Profile
@tubbo
tubbo / install_postgis_osx.sh
Created October 30, 2012 14:02 — forked from oliverbarnes/install_postgis_osx.sh
Installing PostGIS 1.5.3 (old formula) for Postgres 9.1.3 (Mac)
#1. Install postgis 1.5.3. Latest is 2.0.0, so using url old formula on github
brew install https://raw.github.com/mxcl/homebrew/8a04a43763906e6a9bef68881acf997f3a6f6687/Library/Formula/postgis.rb
#2. Create a template to be used on creating GIS-enabled databases
createdb template_postgis
#3. Import Postgis Data
psql -d template_postgis -f /usr/local/Cellar/postgis/1.5.3/share/postgis/postgis.sql
psql -d template_postgis -f /usr/local/Cellar/postgis/1.5.3/share/postgis/spatial_ref_sys.sql
<div id="header_block">
<div id="header_block_title"><%= title %></div>
<div id="header_block_content"><%= content %></div>
</div>
<!--
call it with:
<%= render 'header_block', title: "Something", content: "A bit more" %>
options = ActiveSupport::HashWithIndifferentAccess.new(YAML.load_file("#{Rails.root}/config/mailer.yml")[Rails.env])
ActionMailer::Base.smtp_settings = options[:smtp]
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.default_url_options[:host] = options[:host]
ActionMailer::Base.raise_delivery_errors = true if Rails.env.development?
class ContractorsController < ApplicationController
def search; end
def import; end
end
@tubbo
tubbo / editor.rb
Created December 10, 2012 19:26 — forked from anonymous/gist:4252505
Good idea?
class Editor < ActiveRecord::Base
belongs_to :user
def do_editor_stuff;end
end
@tubbo
tubbo / reverser.rb
Created December 11, 2012 20:52
play that record backwards
def reverser(&block)
words = yield
words.reverse
end
describe "reverser" do
it "reverses the string returned by the default block" do
reverser { "hello" }.should == "olleh"
end
end
class Appointment < ActiveRecord::Base
attr_accessible :booking_resource_id, :boooking_id, :customer_id
belongs_to :customer
belongs_to :booking
end
@tubbo
tubbo / test.rb
Last active December 11, 2015 19:08 — forked from jonleighton/test.rb
require "active_record"
require "logger"
puts ActiveRecord::VERSION::STRING
# ActiveRecord::Base.logger = Logger.new(STDERR)
ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
ActiveRecord::Schema.define do
create_table :people
@tubbo
tubbo / gist:4708514
Last active December 12, 2015 03:38 — forked from anonymous/gist:4708502
<table>
<% current_user.hospital_bookings.each do |hospital_booking| %>
<tr>
<td>
<%= hospital_booking.hospital.try :name if hospital_booking == current_user.id %>
</td>
</tr>
<% end %>
<% if current_user.hospital_bookings.empty? %>
<tr><td>No bookings found.</td></tr>
module Admin::PermissionsHelper
def permissions
['view', 'create tickets', 'edit tickets', 'delete tickets', 'change states']
end
end