Skip to content

Instantly share code, notes, and snippets.

View compactcode's full-sized avatar

Shanon McQuay compactcode

  • Melbourne, Australia
View GitHub Profile
@compactcode
compactcode / keybase.md
Created October 5, 2015 03:15
keybase.md

Keybase proof

I hereby claim:

  • I am compactcode on github.
  • I am shanon (https://keybase.io/shanon) on keybase.
  • I have a public key whose fingerprint is 1AE4 D070 B9A2 F189 982A 0C85 2548 3465 AAE9 77CE

To claim this, I am signing this object:

@compactcode
compactcode / hardcoded.rb
Last active August 29, 2015 13:57
Array Permutation
def self.permute(one, two, three)
result = []
one.each do |x|
two.each do |y|
three.each do |z|
result << [x, y, z]
end
end
end
result
@compactcode
compactcode / site.rb
Created October 5, 2013 04:53
Whats a good way to ensure that that the user assign to a site belongs to the same account?
class Site < ActiveRecord::Base
belongs_to :account
belongs_to :user
end
@compactcode
compactcode / page.rb
Last active December 23, 2015 21:08
RSpec features with page models.
class Page
include Capybara::DSL
def initialize(&block)
validate_title
yield self
end
private
@compactcode
compactcode / template.rb
Last active December 19, 2015 21:08
My preferred rails starter template.
environment do
<<-EOS
config.generators do |generate|
generate.javascripts false
generate.stylesheets false
generate.helper false
end
EOS
end
@compactcode
compactcode / 20130306225243_create_customers.rb
Last active December 14, 2015 15:08
Rails fun with a not null constraint and a default value.
class CreateCustomers < ActiveRecord::Migration
def change
create_table :customers do |t|
t.string :name, :null => false
t.boolean :subscribed, :null => false, :default => true
t.timestamps
end
end
end
@compactcode
compactcode / sphinx.rb
Created October 8, 2012 03:38 — forked from stefanoverna/sphinx.rb
Sphinx homebrew recipe with libstemmer support
require 'formula'
class Sphinx < Formula
url 'http://sphinxsearch.com/downloads/sphinx-0.9.9.tar.gz'
homepage 'http://www.sphinxsearch.com'
md5 '7b9b618cb9b378f949bb1b91ddcc4f54'
head 'http://sphinxsearch.googlecode.com/svn/trunk/'
fails_with_llvm "fails with: ld: rel32 out of range in _GetPrivateProfileString from /usr/lib/libodbc.a(SQLGetPrivateProfileString.o)"
@compactcode
compactcode / index.html
Created August 12, 2012 13:24
Fitting a d3 geographic map to a given canvas size.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<style type="text/css">
#container {
width: 455px;
margin: auto;
}
#small {
@compactcode
compactcode / your-chart.html
Created April 30, 2012 23:05
A skeleton html file for rendering high charts from a JSON endpoint.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<script src="https://jetstar.geckoboard.com/scripts/jquery/jquery.min.js" type="text/javascript"></script>
<script src="https://jetstar.geckoboard.com/scripts/highcharts.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$.getJSON("/charts/your-endpoint.json", function(config) {
new Highcharts.Chart(config);
@compactcode
compactcode / switch.sh
Created May 18, 2011 10:57
Switch OS X to the 32-bit kernel mode.
sudo systemsetup -setkernelbootarchitecture i386