Skip to content

Instantly share code, notes, and snippets.

View sstarr's full-sized avatar
🏠
Working from home

Simon Starr sstarr

🏠
Working from home
View GitHub Profile
@sstarr
sstarr / staging_deploy.sh
Created June 18, 2012 14:43
A sample Bash deployment script. This is for a Rails app hosted on an OS X server.
#!/usr/bin/env bash
# Configuration
SERVER='10.20.30.40'
DEPLOY_TO='/Users/simon/apps/some_app/staging/'
EXCLUDE='*.sqlite3 *.swp .DS_Store .git/ tmp/ log/ public/uploads/ uploads/'
DRY_RUN=false
DEPLOY_GEM_PATH='/Users/simon/.rvm/gems/ruby-1.9.2-p180'
MYSQL2_BUNDLE='/Users/simon/apps/some_app/staging/vendor/bundle/ruby/1.9.1/gems/mysql2-0.2.13/lib/mysql2/mysql2.bundle'
571-187-661
141-852-370
954-700-406
997-847-345
745-141-212
286-180-138
812-747-746
964-270-942
262-372-429
482-337-966
mic-wet-pan
sin-bag-roy
biz-dom-mel
mat-yet-con
lap-pal-las
pay-bob-dem
faq-ted-gap
wan-had-bug
fox-gen-bad
say-bin-vid
@sstarr
sstarr / gb.sh
Created July 17, 2019 15:11
Returns a list of local branches, sorted by latest commit date, with the latest SHA, commit message, author, and age
git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'
@sstarr
sstarr / cpr.rb
Created January 9, 2013 20:11
Randomly generate a valid Danish CPR number (personnummer) for someone born between 20 and 50 years ago.
# Based on the format described in this Wikipedia article: http://en.wikipedia.org/wiki/Personal_identification_number_(Denmark)
"#{(20.years.ago - (0..11000).to_a.sample.days).strftime('%d%m%y')}-1#{'%03d' % (0..999).to_a.sample}"
# Regular expression to validate a CPR number
/\b(0[1-9]|[12]\d|3[01])(0[1-9]|1[0-2])\d{2}-\d{4}\b/
@sstarr
sstarr / wercker.yml
Created December 19, 2013 14:37
A Wercker config for Ruby on Rails, Elasticsearch, Postgres and Qt (for capybara-webkit).
box: wercker/ruby
services:
- wunki/elasticsearch@0.0.1
- wercker/postgresql
build:
steps:
# Taken from https://gist.github.com/pjvds/6008266
- script:
@sstarr
sstarr / Google Apps .zone File
Created February 1, 2017 14:46 — forked from clakeb/Google Apps .zone File
Quick .zone file to import when you are setting up Google Apps. I use it with CloudFlare. Enjoy.
; CNAME
calendar 1 IN CNAME ghs.googlehosted.com
drive 1 IN CNAME ghs.googlehosted.com
mail 1 IN CNAME ghs.googlehosted.com
sites 1 IN CNAME ghs.googlehosted.com
video 1 IN CNAME ghs.googlehosted.com
; MX
@ 1 IN MX 10 aspmx3.googlemail.com
@ 1 IN MX 1 aspmx.l.google.com
def possessive_name
# Profile name is a proper noun, so we add an apostrophe with or without 's' as appropriate
# e.g. Bob Smith's project or Bob Edwards' project
# See rule 1c. here: http://www.grammarbook.com/punctuation/apostro.asp
name[-1] == "s" ? "#{name}'" : "#{name}'s"
end
# - A `Thing` can be 1% - 100% green
# - This is represented on the front end with a doughnut chart
# - The doughnut chart can't be generated since it's in an email
# - To get around this, we have 25 static doughnut images in increments of 4%
# This code takes the percentage and returns the relevant image.
# I'm sure there must be a more sensible way of doing this than using the
# world's longest switch statement. Any ideas?
@sstarr
sstarr / gist:6995732
Created October 15, 2013 17:54
Generate a random hex colour value in Ruby. WARNING: May produce colours offensive to people with eyes.
colour = "##{((0..6).map{rand(256).chr}*'').unpack('H*')[0][0,6]}"
# => "#9ee5a3"