Skip to content

Instantly share code, notes, and snippets.

View Aupajo's full-sized avatar

Pete Nicholls Aupajo

  • Christchurch, New Zealand
View GitHub Profile
@Aupajo
Aupajo / calendar.md
Created November 6, 2014 20:47
Proposed Almanack JSON

Event source

An event source will always have the following properties:

{
  "name": "Event source",
  "type": "static"
}
@Aupajo
Aupajo / autochain.md
Last active August 29, 2015 14:10
Autochain

Like autotune for your objects.

class Autochain
  attr_reader :subject

  def initialize(subject)
    @subject = subject
  end
@Aupajo
Aupajo / jsp_tag_parser.rb
Last active August 29, 2015 14:10
JSP tag parser in Ruby using Parslet
class JSPTagParser < Parslet::Parser
rule(:java) { (str('%>').absent? >> any).repeat.as(:java) }
rule(:jsp) { java.as(:code) }
rule(:jsp_with_tags) { str('<%') >> jsp >> str('%>') }
rule(:text) { (str('<%').absent? >> any).repeat(1) }
rule(:text_with_java) { (text.as(:text) | jsp_with_tags).repeat.as(:text) }
root(:text_with_java)
end
@Aupajo
Aupajo / gist:3387
Created July 31, 2008 02:02
Toggles hidden files in Finder on Mac OS X. Useful for finding those pesky .htaccess files.
#!/bin/bash
if [ `defaults read com.apple.finder AppleShowAllFiles` == 1 ]
then
echo "Hiding hidden files."
defaults write com.apple.finder AppleShowAllFiles -bool false
else
echo "Showing hidden files."
defaults write com.apple.finder AppleShowAllFiles -bool true
fi
@Aupajo
Aupajo / application.scss
Last active August 29, 2015 14:17
Sass maps
@import "palette";
body {
font: 20pt "Helvetica Neue", sans-serif;
}
$actions: (
primary: (
link: $blue,
hover: lighten($blue, 0.1),

Keybase proof

I hereby claim:

  • I am aupajo on github.
  • I am aupajo (https://keybase.io/aupajo) on keybase.
  • I have a public key whose fingerprint is 8819 C913 E4DE 44FA 6BA7 6EE8 8C16 9D73 4717 116C

To claim this, I am signing this object:

// Decoding JSON
// A JSON string
let data = ...
// We create an optional type which is nil to begin with.
var parseError: NSError?
// We parse the JSON, passing the nil parseError by reference. It will be set to
// an instance of NSError if anything goes wrong.
# Usage
# sequence = AtomicSequence["cats"]
# sequence.current # => 0
# sequence.next # => 1
# sequence.next # => 2
# sequence.current # => 2
# sequence.reset!
# sequence.current # => 0
# sequence.next # => 1
@Aupajo
Aupajo / demo.rb
Last active August 29, 2015 14:21
class TodoItem < ActiveRecord::Base
extend TimeState
# Scopes added: finished, not_finished
# Instance methods added: finished?, finish!
time_state :finished_at
end
todo_item = TodoItem.create
todo_item.finished_at # => nil
@Aupajo
Aupajo / 🍻.md
Last active August 29, 2015 14:22
Colorado beers

Colorado beers

The following is a list of beers I recommend trying if you ever find yourself in Boulder, Colorado as I did. Places where I found these beers are indicated in brackets.

  1. Mountain Sun – Isadore Java Porter (Mountain)
  2. Mountain Sun – Jah Mon Ginger Wheat (Mountain Sun)
  3. Mountain Sun – Resinous Rye (Mountain Sun)
  4. Boulevard Brewing – 80-Acre Hoppy Wheat (Mountain Sun)
  5. West Flanders – Mr. Chain Blue Lighting (West Flanders)
  6. West Flanders – Lionheart (West Flanders)