Skip to content

Instantly share code, notes, and snippets.

View richhollis's full-sized avatar

Richard Hollis richhollis

View GitHub Profile
@cowboy
cowboy / jquery_plugin_org_1.js
Created January 8, 2010 20:52
View revisions from oldest -> newest
// Creating a plugin with $.myNS.public_method1() and $.myNS.public_method2() methods, a few different ways.
(function($){
var private_var,
myNS = $.myNS = {},
public_method2;
myNS.public_method1 = function(){
private_method();
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@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')
@jpmckinney
jpmckinney / tz_identifiers_to_rails_identifiers.rb
Created January 5, 2011 21:44
Maps tz database time zone identifiers to Rails time zone identifiers
# blog post: http://blog.slashpoundbang.com/post/2613268281/changing-from-tz-database-identifiers-to-rails-friendly
{
"Australia/Adelaide" => "Adelaide",
"Australia/Broken_Hill" => "Adelaide",
"America/Anchorage" => "Alaska",
"America/Juneau" => "Alaska",
"America/Nome" => "Alaska",
"America/Yakutat" => "Alaska",
"Pacific/Gambier" => "Alaska",
"Asia/Almaty" => "Almaty",
@seamusabshere
seamusabshere / delayed_job_singleton.rb
Created February 18, 2011 15:38
how we hacked DelayedJob 2.0.3 logs in Rails 3
#!/usr/bin/env ruby
PRESUMPTIVE_RAILS_ROOT = "/data/[APP_NAME]/current"
LOG_PATH = "/data/[APP_NAME]/shared/log/delayed_job_singleton.log"
Dir.chdir PRESUMPTIVE_RAILS_ROOT
require 'home_run'
require "rubygems"
require "bundler/setup"
@tcocca
tcocca / delayed_job.monitrc
Created March 17, 2011 13:30
Monit script for multiple delayed_job workers
check process sequoia_dj2_delayed_job_0
with pidfile /home/deploy/rails/sequoia/shared/pids/delayed_job.0.pid
start program = "/home/deploy/rails/sequoia/shared/delayed_job_runner.sh start production 0"
as uid deploy and gid deploy
stop program = "/home/deploy/rails/sequoia/shared/delayed_job_runner.sh stop production 0"
as uid deploy and gid deploy
check process sequoia_dj2_delayed_job_1
with pidfile /home/deploy/rails/sequoia/shared/pids/delayed_job.1.pid
start program = "/home/deploy/rails/sequoia/shared/delayed_job_runner.sh start production 1"
@a-chernykh
a-chernykh / application_controller.rb
Created June 22, 2011 19:43
devise force https for sign in and sign up routes
class ApplicationController < ActionController::Base
before_filter :ensure_proper_protocol
protected
def ssl_allowed_action?
(params[:controller] == 'users/sessions' && ['new', 'create'].include?(params[:action])) ||
(params[:controller] == 'users/registrations' && ['new', 'create', 'edit', 'update'].include?(params[:action])) ||
(params[:controller] == 'users/omniauth_callbacks')
end
@kylebarrow
kylebarrow / example.html
Created June 23, 2011 06:30
Prevent links in standalone web apps opening Mobile Safari
<!DOCTYPE html>
<head>
<title>Stay Standalone</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<script src="stay_standalone.js" type="text/javascript"></script>
</head>
<body>
<ul>
<li><a href="http://google.com/">Remote Link (Google)</a></li>
@nruth
nruth / image_helpers.rb
Created July 6, 2011 20:13
share test helper libs between rspec and cucumber in a pluggable fashion
# an example, showing how to load for rspec and conditionally load for cucumber
# lives in whichever dir you set the other file to load
module ImageStepHelpers
def page_should_contain_image_link_for(image)
page.should have_xpath(%Q(//img[@src="#{image.url}"]))
end
def image_data_from_file(image)
image_file_path = Rails.root.join image.image.path
@chrisjacob
chrisjacob / README.md
Created July 16, 2011 11:23
How to: GitHub Pages "gh-pages" branch for User & Organization Pages

GitHub Pages "Normal" Setup for User & Organization Pages

Let’s say your GitHub username is “alice”. If you create a GitHub repository named alice.github.com, commit a file named index.html into the master branch, and push it to GitHub, then this file will be automatically published to http://alice.github.com/... The same works for organizations.

Read more here: http://pages.github.com/

However... the downside of this is that anyone that forks this repo won't get it as a GitHub Pages repo when they are working on it... because they have a different GitHub "username" (or "organisation name").

So the trick is to not use a master branch as the documentation tells you... rather, use a gh-pages branch, as you would for your other "Project Pages".