Skip to content

Instantly share code, notes, and snippets.

View peterdavidhamilton's full-sized avatar
🥁

Peter Hamilton peterdavidhamilton

🥁
View GitHub Profile
#!/usr/bin/env ruby
# Execute the git, gem, or rake command, depending on the second argument
case ARGV.first
when /^(add|bisect|branch|checkout|clone|commit|diff|fetch|grep|init|log|merge|mv|pull|push|rebase|reset|rm|show|status|tag)$/
system "git #{ARGV.join(' ')}"
when /^(build|cert|check|cleanup|contents|dependency|environment|fetch|generate_index|help|install|list|lock|mirror|outdated|pristine|query|rdoc|search|server|sources|specification|stale|uninstall|unpack|update|which)$/
system "gem #{ARGV.join(' ')}"
else
@peterdavidhamilton
peterdavidhamilton / production.pill
Created November 17, 2010 16:23 — forked from arya/production.pill
bluepill config example
env_vars = "RAILS_ENV=production PATH=/sb/thehierarchy/ruby/bin:/sb/thehierarchye/nginx/sbin:$PATH RUBY_HEAP_MIN_SLOTS=500000 RUBY_HEAP_SLOTS_INCREMENT=250000 RUBY_HEAP_SLOTS_GROWTH_FACTOR=1 RUBY_GC_MALLOC_LIMIT=50000000"
RAILS_ROOT = "/var/www/apps/thehierarchy/current/"
Bluepill.application("thehierarchy") do |app|
app.process("scheduled_notifications") do |process|
process.group = "thehierarchy"
process.pid_file = File.join(RAILS_ROOT, "tmp", "pids", "scheduled_notifications")
process.daemonize = true
process.start_command = "/usr/bin/env #{env_vars} rake --rakefile=#{RAILS_ROOT}/Rakefile app_name:scheduled_notifications"
require 'growl'
module Jekyll
class GrowlGenerator < Generator
safe false
def generate(site)
Growl.notify 'Building...', :title => 'Jekyll'
end
end
@peterdavidhamilton
peterdavidhamilton / ip-down
Created November 21, 2011 15:23 — forked from copiousfreetime/ip-down
PPP ip-up/ip-down for vpn with optional dns resolving
#!/bin/sh
# install into /etc/ppp/ip-down
# chmod a+x /etc/ppp/ip-down
source /etc/ppp/ip.config
case "${IPREMOTE}" in
${MY_IPREMOTE})
/sbin/route delete ${MY_ROUTE} -interface ${IFNAME}

pool management

  • create a new pool by first creating an empty partition space using diskutil or Disk Utility

adding a mirror to an existing pool

check current status

zpool status -v

Setup Mac OS X Mountain Lion

I just replaced the hard drive of my mbp and decided to do a clean install of Mountain Lion (10.8.5) since I was still using Snow Leopard (10.6.8).

I kinda regret for not using Boxen to automate the process, but TBH I have this laptop for almost 3yrs and this is the first time I needed to reinstall everything, maybe the next time...

#!/usr/bin/env python
#
# Copyright 2011, Jason Graham
#
# Uses python-markdown to convert a markdown document to the body
# of an HTML document to display with cgit (http://hjemli.net/git/cgit/).
#
# Install:
#
# 1- Install python-markdown ( sudo apt-get install python-markdown )
gem 'kaminari' # Pagination
@peterdavidhamilton
peterdavidhamilton / 01-activerecord.rb
Created July 28, 2016 13:53 — forked from janko/01-activerecord.rb
PostgreSQL JSON querying in Sequel (my presentation from our local Ruby meetup)
require "active_record"
ActiveRecord::Base.establish_connection('postgres:///testing')
ActiveRecord::Migration.verbose = false
ActiveRecord::Migration.class_eval do
create_table :played_quizzes, force: true do |t|
t.integer :player_ids, array: true
t.json :quiz_snapshot
end
@peterdavidhamilton
peterdavidhamilton / gist:6ff6dde3f6f899e0cc35accff5336459
Created March 29, 2022 23:48 — forked from mattconnolly/gist:4158961
RSpec basic authentication helper module for request and controller specs
module AuthHelper
def http_login
user = 'username'
pw = 'password'
request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(user,pw)
end
end
module AuthRequestHelper
#