Skip to content

Instantly share code, notes, and snippets.

View woods's full-sized avatar

Scott Woods woods

View GitHub Profile
@woods
woods / order.html
Created October 25, 2018 20:44
Code snippet for purple lizard order checkout page (just the total amount)
<tr>
<td colspan="4" class="align_right"><strong>{{ 'customer.order.total' | t }}</strong></td>
<td class="text-right"><strong>{{ order.total_price | money }} {{ order.currency }}</strong></td>
</tr>
@woods
woods / command.bash
Created October 6, 2018 13:40
Selectively remove old kernels and source
for n in 57 61 68 77 79 83 85 86 87 88 91 92 93 95 96 98 100 101 103 105 106 107 108 109 110 111 112 113 115 116
do
apt-get purge -y \
linux-headers-3.13.0-$n \
linux-headers-3.13.0-${n}-generic \
linux-image-3.13.0-${n}-generic \
linux-image-extra-3.13.0-${n}-generic
done
@woods
woods / specs.md
Last active November 7, 2017 16:29
West Arete's spec layout

Over time, West Arete has developed a convention for how we organize our spec directories. This arrangement has been very successful for us over many years and many projects. We'd love to extract it into some kind of framework/gem, but have never managed/invested to do so. So at the very least we can share this writeup of what we've found to be useful, in the hope that it's useful to others.

The top level of our spec directory looks like this:

spec/
  spec_helper.rb
### Keybase proof
I hereby claim:
* I am woods on github.
* I am woods (https://keybase.io/woods) on keybase.
* I have a public key ASBRwmuep3o_XIJa0bbb-0xxkdgyxWqCt-SEvK1MHlkjoQo
To claim this, I am signing this object:
@woods
woods / example.rb
Created May 8, 2012 03:05
How to dynamically query enum values from Postgresql in Rails
sql = %{
select enumlabel
from pg_enum
where enumtypid = 'company_status'::regtype
order by oid
}
result = ActiveRecord::Base.connection.execute(sql)
result.each do |row|
@woods
woods / git-bump-version
Last active September 27, 2016 10:08
A script to bump a project's version number in git.
#!/usr/bin/env ruby
# Bump the version of the current git project
#
# Installation instructions: copy to /usr/local/bin/git-bump-version and set
# permissions to 0755.
#
# Author: Scott Woods <scott@westarete.com>
# Ref: https://gist.github.com/woods/7424599
require 'rubygems'
@woods
woods / friendly_urls.markdown
Last active August 17, 2016 00:28 — forked from cdmwebs/friendly_urls.markdown
Friendly URLs in Rails

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.

<!DOCTYPE html>
<HTML>
<head>
<title id="PageTitle">Allegheny County Assessment</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR" />
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE" />
<meta content="JavaScript" name="vs_defaultClientScript" />
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
@woods
woods / gist:8138988
Created December 26, 2013 21:35
Run the night's google analytics code
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-42147894-1', 'runthenightltd.com');
ga('send', 'pageview');
</script>
@woods
woods / aliases.sh
Created October 30, 2013 17:39
Helpful aliases for git and github.
# Use the "hub" wrapper for git (https://github.com/defunkt/hub)
eval "$(hub alias -s)"
# Enable autocomplete for built in git functions
source ~/.git-completion.sh
# git aliases. Add new ones to the bottom of ~/.git-completion.bash to enable
# autocomplete.
alias ga='git add'
alias gap='git add -p'