Skip to content

Instantly share code, notes, and snippets.

permanent omnishambles

Robin Howard damncabbage

permanent omnishambles
View GitHub Profile
passy /
Created Mar 16, 2012
Chromium Daily Installer for Linux
#!/usr/bin/env python
# coding: utf-8
import errno
import os
import platform
import shutil
import stat
import subprocess
import sys

I <3 the Asset Pipeline

People talk shit on Sprockets and the Asset Pipeline all the time. I get it. It's pretty confusing and when it breaks it can break in really undesirable ways. I was originally very sceptical, and I strongly considered upgrading to Rails 3.2 with sprockets disabled.

I didn't, and I'm glad I've stuck with the pipeline. Here's why:

  1. If you're using digested assets (by default you are), asset expiry just works. No cache clearing during dev, no "wait a few minutes for the CSS to expire", no expiring every asset on every deploy, no deployment issues where people get new HTML and old CSS or JS. Sprocket's digest strategy has so far been excellent and I'm glad it's there.

  2. SASS and CoffeeScript just work. No running guard or compass to watch and auto-compile your shit, relatively seamless integration into Rails, and effective separation of vendored code from application code.

jfirebaugh /
Created Apr 25, 2012
Auto-restoring sinon fakes with Konacha
# require spec_helper
Test =
fn: -> 'result'
it 'auto-resets sinon fakes', ->
@stub(Test, 'fn')
fryguy1013 / realtime.html
Created Apr 30, 2012
Realtime simplegraph
View realtime.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
cjheath / datol.cxx
Created Jul 19, 2012
Conversion of year/month/day to day since epoch, and back (with weekday)
View datol.cxx
#define OFFS -306 /* Offset to epoch-day (Day 1 is 1/1/0001) */
#define WD 0L /* Day of week offset */
* datol: takes a YMD date, and returns the number of days since some base
* date (in the very distant past).
* Handy for getting date of x number of days before/after a given date.
* A date is valid if ltodate() yields the same YMD you started with.
pda / query_spy.rb
Created Sep 3, 2012
QuerySpy for counting ActiveRecord queries, asserting against n+1 regressions.
View query_spy.rb
# An SQL query spy derived from the perhaps deprecated SQLCounter
# in ActiveRecord::TestCase and/or activerecord/test/cases/helper.rb
class QuerySpy
# Returns the number of queries executed by yielding the given block.
# Examples:
# QuerySpy.count { get "/things" }.should == 1
# create_a_thing
View Rakefile
require 'rake_timer'
View credit_card.rb
class CreditCard
include ActiveAttr::Model
attribute :number
attribute :expiry
attribute :cvn
attribute :name
validate :must_be_valid
validates :number, :expiry, :cvn, :name, presence: true
travisbrown / needle-in-haystack.scala
Created Nov 13, 2012
Digging through arbitrarily nested case classes, tuples, and lists
View needle-in-haystack.scala
* Digging through arbitrarily nested case classes, tuples, and lists
* by Travis Brown
* In response to this question by Channing Walton on the Shapeless dev list:
* Tested with Scala 2.9.2 and Shapeless 1.2.3. Should work on 1.2.2 with minor edits.
View gist:4113718
module Query
class Expression
attr_reader :field, :operator, :target
def initialize(field, operator, target)
@field, @operator, @target = field, operator, target