Skip to content

Instantly share code, notes, and snippets.

View wakatara's full-sized avatar

Daryl Manning wakatara

View GitHub Profile
@pamelafox
pamelafox / gist:1006753
Created June 3, 2011 17:35
Sendgrid Python Web API example
import urllib2, urllib
import logging
def send_mail_sendgrid(from, to, subject, body):
base_url = 'https://sendgrid.com/api/mail.send.json'
params = {
'api_user': 'you@you.com',
'api_key': 'yourpassword',
'from': from,
'to': to,
@pamelafox
pamelafox / newtalk.html
Created May 23, 2011 18:31
Calculating timezone from city/country
<!DOCTYPE html>
<html">
<head>
<script src="/static/js/jquery.min.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
</head>
<body>
<h2 class="headline">New Talk</h2>
@tjmcewan
tjmcewan / .bash_profile
Created May 20, 2011 02:52
Rails version-agnostic server & console
# Rails 2 and Rails 3 console
function rc {
if [ -e "./script/console" ]; then
./script/console $@
else
rails console $@
fi
}
# Rails 2 and Rails 3 server
@alexyoung
alexyoung / deploy.sh
Created May 17, 2011 10:47
Deployment script
#!/usr/bin/env bash
# Configuration
SERVER='myserver'
DEPLOY_TO='/path/to/app'
EXCLUDE='*.swp .git/ db/sphinx/ tmp/ log/'
DRY_RUN=false
DEPLOY_GEM_PATH='/opt/ec/ruby/1.8.7/lib/ruby/gems/1.8'
@slayer
slayer / gist:935641
Created April 21, 2011 22:46
SQL JOIN via AREL in Rails 3
# Simple JOIN
User.joins(:account) # User -> Account
# Will produce
# SELECT `users`.* FROM `users` INNER JOIN `accounts` ON `accounts`.`user_id` = `users`.`id`
# Complicated JOIN
Trait.joins(:user => :account) # Trait -> User -> Account
# Will produce
# SELECT `traits`.* FROM `traits` INNER JOIN `users` ON `users`.`id` = `traits`.`user_id` INNER JOIN `accounts` ON `accounts`.`user_id` = `users`.`id`
TypeError (can't convert String into Integer):
app/models/user.rb:12:in `[]'
app/models/user.rb:12:in `find_for_google_apps_oauth'
app/controllers/users/omniauth_callbacks_controller.rb:17:in `google_apps'
@dnagir
dnagir / rspec-syntax-cheat-sheet.rb
Created November 5, 2010 09:29
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
heroku_client = Heroku::Client.new(ENV['HEROKU_EMAIL'], ENV['HEROKU_PASSWORD'])
heroku_client.add_domain(ENV['HEROKU_APP'], new_domain_name)
@bryanthompson
bryanthompson / cache_helper.rb
Created January 14, 2010 22:08
Simple fragment caching in sinatra
require 'sinatra/base'
class CacheHelper
module Sinatra
module Helpers
def cache(name, options = {}, &block)
if cache = read_fragment(name, options)
@_out_buf << cache
else
pos = @_out_buf.length
@assaf
assaf / gist:205689
Created October 9, 2009 03:55
MySQL/EBS volume hourly snapshot
We couldn’t find that file to show.