Skip to content

Instantly share code, notes, and snippets.

View Mab879's full-sized avatar

Matthew Burket Mab879

View GitHub Profile
@terryjray
terryjray / gist:3296171
Created August 8, 2012 15:55
Enabling hstore for new postgresql 9.1 and rails 3 install on ubuntu 12.04
RAILS_ENV=production rake db:setup
# produces the error below.....hmmm.....it's a no-worky
psql:/yourprojectpath/yourproject/db/structure.sql:29: ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/hstore.control": No such file or directory
# hstore postgresql extension needs to be installed, so....
sudo apt-get install postgresql-contrib
# now your extension should be available to enable so log in with psql
psql -d yourproject_production -U yourdbuser -W
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private
@ryangray
ryangray / buttondown.css
Created February 22, 2012 06:45
A clean, minimal CSS stylesheet for Markdown, Pandoc and MultiMarkdown HTML output.
/*
Buttondown
A Markdown/MultiMarkdown/Pandoc HTML output CSS stylesheet
Author: Ryan Gray
Date: 15 Feb 2011
Revised: 21 Feb 2012
General style is clean, with minimal re-definition of the defaults or
overrides of user font settings. The body text and header styles are
left alone except title, author and date classes are centered. A Pandoc TOC
@citrus
citrus / date_time_helper.rb
Created July 26, 2011 20:28
Round time to next quarter hour with ruby (00,15,30,45)
module DateTimeHelper
def time_to_next_quarter_hour(time)
array = time.to_a
quarter = ((array[1] % 60) / 15.0).ceil
array[1] = (quarter * 15) % 60
Time.local(*array) + (quarter == 4 ? 3600 : 0)
end
end
@nesquena
nesquena / index_users_emails.rb
Created July 14, 2011 00:11
Add concurrent index in Postgres Rails migration
class IndexUsersEmails < ActiveRecord::Migration
def self.up
execute "END"
add_pg_index :users, :email, :lock => false
execute "BEGIN"
end
end
@jesseproudman
jesseproudman / Auto Scale API Mashup.rb
Created March 16, 2011 18:51
Logic for simple Auto Scale setup
require 'rubygems'; require 'active_resource'; require 'new_relic_api'
servers = File.open("server_count.txt", "r").first.to_i
instances_per_server = 6
cpu_burn_for_system = 1000.0 * 0.20
NewRelicApi.api_key = "<Your API Key>"
account = NewRelicApi::Account.find(:first);
application = account.applications[3];