Skip to content

Instantly share code, notes, and snippets.

View nickhammond's full-sized avatar

Nick Hammond nickhammond

View GitHub Profile
@nickhammond
nickhammond / application.js
Created June 30, 2017 21:26
Intuit payments
function intuitRespondHandler(response) {
console.log("handling")
console.log(response)
var $form = $('#payment-form');
var $payment_errors = $form.find('.payment-errors')
if (response.value) {
$payment_errors.hide().text('');
@nickhammond
nickhammond / application.rb
Created June 22, 2012 22:48 — forked from steve9001/application.rb
Rails middleware to provide information about errors during :js => true requests in test.log and to STDERR
module MyApp
class Application < Rails::Application
if Rails.env == 'test'
require 'diagnostic'
config.middleware.use(MyApp::DiagnosticMiddleware)
end
end
end
echo "Show all extensions"
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
echo "Require password immediately after sleep or screen saver begins"
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0
echo "Disable the Ping sidebar in iTunes"
defaults write com.apple.iTunes disablePingSidebar -bool true
@nickhammond
nickhammond / gist:1378244
Created November 19, 2011 01:00
Order users by company name or last name
# This assumes you have the fields first_name, last_name and company_name on your model User.
#
# If there's a simpler way to do this please let me know. The issue was mostly with how MySQL
# sorts null values. If you have your order clause as "order by company_name, last_name" then
# columns with company_name that have null would be first which you don't want, you want it
# to use the value for last_name instead. You could also do this all in memory in Ruby but
# when you are also paginating it's easy enough to get your hands dirty with some SQL.
# app/models/user.rb
named_scope :sorted, :order => "sort_name, first_name ASC",
@nickhammond
nickhammond / gist:1308382
Created October 24, 2011 04:39
Clone a git repository, cd into and run bundle install
function clinstall(){
echo "Cloning repository, cd'ing into it and running bundle install..."
filename=$(basename $1)
filename=${filename%.*}
git clone $1 && cd "$filename" && bundle install
}
# if you look in clearance/lib/clearance/user.rb you can see the encryption method
#
# def encrypt(string)
# generate_hash("--#{salt}--#{string}--")
# end
#
# lib/clearance_crypto.rb
class ClearanceCrypto
def self.encrypt(*tokens)
Digest::SHA1.hexdigest("--#{tokens[1]}--#{tokens[0]}--")
@nickhammond
nickhammond / Basic html structure
Created June 4, 2010 05:58
basic html for css styling
<h1>The largest header is an h1</h1>
<p>
Ut lacus lacus, hendrerit id tincidunt vel, posuere ac lorem. Donec posuere sem sed est vestibulum commodo ut vel nunc. Nunc placerat, lorem a pharetra aliquet, nunc lacus facilisis nibh, in ultricies metus sapien eu augue. Nullam quis neque magna. Ut at metus tellus. Nullam vehicula hendrerit ligula vitae iaculis. </p>
<h2>Next we have an h2</h2>
<p>
Here's a paragraph with a <a>link to nowhere</a>. Lorem a pharetra aliquet, nunc lacus facilisis nibh, in ultricies metus sapien eu augue. Nullam quis neque magna. Ut at metus tellus. Nullam vehicula hendrerit ligula vitae iaculis. Also, something <strong>that is bolded</strong> and also an <em>emphasized phrase</em>.</p>