Skip to content

Instantly share code, notes, and snippets.

@henrik
henrik / hash_deep_diff.rb
Created July 14, 2009 08:38
Recursively diff two Ruby hashes.
# Recursively diff two hashes, showing only the differing values.
# By Henrik Nyh <http://henrik.nyh.se> 2009-07-14 under the MIT license.
#
# Example:
#
# a = {
# "same" => "same",
# "diff" => "a",
# "only a" => "a",
# "nest" => {
@georgebrock
georgebrock / Rakefile
Created February 18, 2010 23:32
Rake tasks to manage Heroku deploys
namespace :deploy do
PRODUCTION_APP = 'myapp'
STAGING_APP = 'myapp-staging'
def run(*cmd)
system(*cmd)
raise "Command #{cmd.inspect} failed!" unless $?.success?
end
def confirm(message)
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@shripadk
shripadk / gist:552554
Created August 27, 2010 00:59
Setting up Heroku Hostname SSL with GoDaddy SSL Cert
How to setup Heroku Hostname SSL with GoDaddy SSL Certificate and Zerigo DNS
Heroku recently added an exciting new 'Hostname SSL' option. This option offers the broad compatibility of IP-based SSL, but at 1/5 the price ($20 / month at the time of this writing).
The following tutorial explains how to use Heroku's new 'Hostname SSL' option on your Heroku project. Before we begin, let's list what we're using here:
* Heroku Hostname SSL
* GoDaddy Standard SSL Certificate
* Zerigo DNS
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>SoundCloud OAuth 2 User Agent Authentication Flow Demo</title>
<script type="text/javascript" charset="utf-8" src="javascript/jquery-1.4.2.js"></script>
<script type="text/javascript" charset="utf-8">
$(function () {
var extractToken = function(hash) {
@JangoSteve
JangoSteve / thread_safe_block_depth.rb
Created October 25, 2010 21:29
A way to track the current block level for instance block-methods, which is completely thread-safe
class MyObject
def block_depth=(value)
Thread.current[:block_depth] = value
end
def block_depth
Thread.current[:block_depth] || 0
end
@martinhawkins
martinhawkins / date_convert.rb
Created December 9, 2010 12:57
Contains the date_of_next method
#date_convert.rb
require 'date'
require 'active_support/core_ext'
Date::DATE_FORMATS.merge!({british: "%d/%m/%Y"})
class DateConvert
# usage:
# date_of_next( day_name, date) where day_name is a string or symbol representation of a full weekday name, e.g. :saturday
# and date is either a valid Date object or a string representation of a date
@gonzalo123
gonzalo123 / gist:868939
Created March 14, 2011 09:31
push existing repository to github
cd existing_git_repo
git remote add origin git@github.com:[user]/[reponame].git
git push -u origin master
@rdegges
rdegges / proxy_nginx.sh
Created April 11, 2011 05:30
Create a HTTP proxy for jenkins using NGINX.
sudo aptitude -y install nginx
cd /etc/nginx/sites-available
sudo rm default
sudo cat > jenkins
upstream app_server {
server 127.0.0.1:8080 fail_timeout=0;
}
server {
listen 80;
@rmoriz
rmoriz / Gemfile
Last active February 7, 2020 12:30
UUID primary keys in Rails 3
# Gemfile
gem 'uuidtools'