Skip to content

Instantly share code, notes, and snippets.

Nathan Youngman nathany

Block or report user

Report or block nathany

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
nathany / scope.go
Created Jul 27, 2012
Fiddling with scoping in Go
View scope.go
package main
import (
// Many functions in Go return an error as the last argument, nil for no error
func f() (int, error) {
return 42, nil
nathany / LICENSE
Created Jan 21, 2012
Pruning remote branches that are already in master
Copyright (C) 2012 Nathan Youngman
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
nathany / git.rake
Created Mar 30, 2011
Generate a "Compare View" in markdown, complete with Gravatars and links to GitHub commits
View git.rake
require 'digest/md5'
namespace :git do
GITHUB_COMMIT_URL = "" # <= set me
# Before doing a deploy, I like to check GitHub's branch list
# but I wanted to be able to save it in a Lighthouse message
'production' => 'origin/production..origin/release',
nathany / Vagrantfile
Created Mar 7, 2011
Vagrant Fabric experiment
View Vagrantfile do |config|
# Every Vagrant virtual environment requires a box to build off of. = "debian_squeeze_32"
# The url from where the '' box will be fetched if it
# doesn't already exist on the user's system.
config.vm.box_url = ""
# Assign this VM to a host only network IP, allowing you to access it via the IP. ""
nathany / deploy.rb
Created Mar 7, 2011
Vagrant deploy.rb for Sprinkle using Capistrano delivery method
View deploy.rb
set :user, 'vagrant'
set :run_method, :sudo
role :app, ''
ssh_options[:keys] = `vagrant ssh_config | grep IdentityFile`.split.last
nathany / styleterm.scpt
Created Dec 15, 2010
Style your OS X terminal
View styleterm.scpt
-- osascript ~/styleterm.scpt 'Red Sands'
on run argv
tell application "Terminal" to set current settings of selected tab of front window to first settings set whose name is (item 1 of argv)
end run
nathany / assigned_to_sites.rb
Created Dec 3, 2010
Sometimes my Ruby code has enough parens, it might as well be Lisp
View assigned_to_sites.rb
# find admin users assigned to a given set of sites
named_scope :assigned_to_sites, lambda { |site_ids|
:joins => :admin_user_site_assignments,
:conditions => {
:admin_user_site_assignments => {:site_id => site_ids}
nathany / change_log.sql
Created Oct 27, 2010
Trigger to maintain a basic audit trail of changes to our Users table using PIVOTs instead of yucky, slow dynamic SQL.
View change_log.sql
-- Trigger to maintain a log of changes to the Users table (T-SQL, SQL Server 2005)
-- Presently only tracking UPDATEs
-- Inspiration from:
IF OBJECT_ID('tr_ChangeLogOnUsers', 'TR') IS NOT NULL
DROP TRIGGER tr_ChangeLogOnUsers;
-- only when LastModifiedBy is changed (someone made a change vs. something)
nathany / ranked.rb
Created Oct 17, 2010
I'm sure glad I'm using an ORM!
View ranked.rb
scope :ranked, select(', rubygem_id,
COUNT(distinct machine_id) as machine_count,
COUNT(distinct platform_id) as platform_count,
GROUP_CONCAT(version_list) as version_list').
order('machine_count DESC, platform_count DESC,')
View passenger
PassengerMaxPoolSize to 30 in httpd.conf (recommended for 2 GB of RAM)
You can’t perform that action at this time.