Skip to content

Instantly share code, notes, and snippets.

View richpeck's full-sized avatar

Richard Peck richpeck

View GitHub Profile
@jwage
jwage / SplClassLoader.php
Last active April 9, 2024 21:04
Add MIT license.
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
@unixmonkey
unixmonkey / load_sass_variables.rb
Created March 5, 2010 21:45
initializer to load a yaml file into sass variables
# Throw this in config/initializers and add
# @import variables.sass to the top of application.sass
# to have all variables in app_config.yml
# available as variables in your sass stylesheets
sass_variables = []
app_variables = YAML.load_file("#{Rails.root}/config/app_config.yml")
app_variables.each do |key, value|
sass_vars << "!#{key} = #{value}"
@karmi
karmi / post-receive-deploy.rb
Created June 17, 2010 13:21
Example script to deploy a Rails application via Git post-receive hook
#!/usr/bin/env ruby
# Example script to deploy a Rails application via Git post-receive hook
#
# INSTALL
#
# $ curl http://gist.github.com/442106.txt -o post-receive
# $ mv post-receive path/to/to/your/repo.git/hooks/post-receive
# $ chmod +x post-receive
@pedrodelgallego
pedrodelgallego / pony-example.rb
Created October 27, 2010 07:30
A working example of pony and sinatra.
# You need to install these gems.
# - smtp_tls
# - pony
post "/contact-us" do
Pony.mail :to => 'pedro.delgallego@gmail.com',
:from => "#{params[:email]}",
:subject => "Contact SFT : #{params[:name]}",
:body=> "#{params[:body]}, --- Contact Address #{params[:email]}",
:via => :smtp,
@carlosantoniodasilva
carlosantoniodasilva / post-receive
Created February 9, 2011 01:28
Basic git post-receive hook file to deploy a Rails app.
#!/bin/bash
APP_NAME="your-app-name-goes-here"
APP_PATH=/home/deploy/${APP_NAME}
# Production environment
export RAILS_ENV="production"
# This loads RVM into a shell session. Uncomment if you're using RVM system wide.
# [[ -s "/usr/local/lib/rvm" ]] && . "/usr/local/lib/rvm"
@napcs
napcs / README.md
Created May 6, 2011 04:10
Deploying Rails to Linode

Deploying Rails to Linode

Installing Ruby Enterprise Edition, Apache, MySQL, and Passenger for deploying Rails 3.0 applications.

Get a Linode, and set it up with Ubuntu 10.04 LTS so that you have till April 2013 to get updates. Once the Linode is formatted, boot it and continue on.

Set up an 'A' record in your DNS, pointing to the IP of your Linode. I'm using demo.napcs.com here.

Initial setup

@yortz
yortz / post-receive
Created June 26, 2011 00:28 — forked from carlosantoniodasilva/post-receive
Basic git post-receive hook file to deploy a Rails app.
#!/bin/bash
APP_NAME="your-app-name-goes-here"
APP_PATH=/home/deploy/${APP_NAME}
# Production environment
export RAILS_ENV="production"
# This loads RVM into a shell session. Uncomment if you're using RVM system wide.
# [[ -s "/usr/local/lib/rvm" ]] && . "/usr/local/lib/rvm"
@bigfive
bigfive / gist:1399762
Created November 28, 2011 09:33
Ruby on Rails. Module to handle 'quantity' attributes by overriding the << and delete methods of the has_many association
class Package < ActiveRecord::Base
has_many :products, :through => :packagings, extend => QuantityAssociation
# ... do stuff
end
module QuantityAssociation
def include_duplicates
@mathias
mathias / buttons.coffee
Created January 30, 2012 15:31
Haml + Coffeescript Tweet button and Like button
((d, s, id) ->
js = undefined
fjs = d.getElementsByTagName(s)[0]
return if d.getElementById(id)
js = d.createElement(s)
js.id = id
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"
fjs.parentNode.insertBefore js, fjs
) document, "script", "facebook-jssdk"
@kevinSuttle
kevinSuttle / meta-tags.md
Last active March 31, 2024 14:26 — forked from lancejpollard/meta-tags.md
List of Usable HTML Meta and Link Tags