Skip to content

Instantly share code, notes, and snippets.

View Aupajo's full-sized avatar

Pete Nicholls Aupajo

  • Christchurch, New Zealand
View GitHub Profile
class OAuthState
attr_reader :request
def initialize(request)
@request = request
end
def match_and_unpack_state
match?.tap { unpack_state }
end
Africa - Abidjan
Africa - Accra
Africa - Addis Ababa
Africa - Algiers
Africa - Asmara
Africa - Asmera
Africa - Bamako
Africa - Bangui
Africa - Banjul
Africa - Bissau
@Aupajo
Aupajo / scheduler-rails-logging.md
Last active August 29, 2015 14:24
Heroku scheduler, Rails, and logging

Script

puts "Plain puts"
warn "Plain warn"

$stdout.puts "Explicit stdout puts"
$stderr.puts "Explicit stderr puts"

# Rails log level is set to INFO (although future versions of Rails will default to DEBUG in production)
@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)
@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
# Usage
# sequence = AtomicSequence["cats"]
# sequence.current # => 0
# sequence.next # => 1
# sequence.next # => 2
# sequence.current # => 2
# sequence.reset!
# sequence.current # => 0
# sequence.next # => 1
// 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.

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:

@Aupajo
Aupajo / restforce.md
Last active May 11, 2019 14:48
How Restforce handles refreshing OAuth tokens

Summary

You can hook into authentication success by passing an authentication_callback to the client.

If you're happy relying on an internal API call, you can make sure your token is fresh by calling:

restforce_client.authenticate!
@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),