Skip to content

Instantly share code, notes, and snippets.

View alexeckermann's full-sized avatar

Alex Eckermann alexeckermann

View GitHub Profile
@alexeckermann
alexeckermann / oauth_mocking.rb
Created September 8, 2011 12:56
OmniAuth testing in RSpec + Capybara
module OauthMocking
def login_with_oauth(provider = :twitter)
visit "/auth/#{provider}"
end
end
@alexeckermann
alexeckermann / golden.scss
Created January 24, 2012 05:55
Golden CSS3-POINT-OH
$golden-ratio: 1.61803399; // Everyone's doing it!
@function golden-division($value, $times: 1) {
@for $i from 1 through $times {
$value: $value / $golden-ratio;
}
@return round($value);
}
@alexeckermann
alexeckermann / doesnt_work_1.rb
Created March 1, 2012 00:14
How can this be done without calling a private method?
# app/models/registration.rb
class Registration
attr_accessor :current_step
end
# Registration then ONLY has :current_step in it and the other methods from the engine are blasted
@alexeckermann
alexeckermann / postcodes.rb
Last active November 7, 2017 07:44
Australian Postcode regex hellhole
StatePostcodeMatchers = { SA: /^5([0-9]){3}/, ACT: /^[2](?:[6](?:[0][0-9]|[1][0-8])|[9](?:[0-1][0-9]|20))/,
VIC: /^3([0-9]){3}/, QLD: /^4([0-9]){3}/, NT: /^08(?:[0-9]){2}/, TAS: /^7[0-7](?:[0-9]){2}/, WA: /^6(?:[0-6](?:[0-9]){2}|[7](?:[0-8][0-9]|[9][0-7]))/,
NSW: /^2(?:[0-6](?:[0-9]){2}|[6](?:[1][9]|[2-7][0-9])|[7](?:[0-9]{2})|[8](?:[0-8](?:[0-9]){1}|[9][0-8])|[9](?:[2][1-9]|[3-9][0-9]))/ }
# Probably dont do this.
@alexeckermann
alexeckermann / keybase.md
Created March 29, 2014 13:19
keybase.md

Keybase proof

I hereby claim:

  • I am alexeckermann on github.
  • I am alexeckermann (https://keybase.io/alexeckermann) on keybase.
  • I have a public key whose fingerprint is CBAA 4632 B67F B4A3 0D03 3832 6446 9476 2557 891E

To claim this, I am signing this object:

# Better… not really. Nicer… maybe.
$search = $('#main-navbar .search')
$search.find('input').css
border: '1px solid #cccccc'
$search.find('button').hide()
$search.find('.results').html(loading)
$search.find('.active, .results').show()
@alexeckermann
alexeckermann / iphone6.rb
Created October 3, 2014 01:11
iPhone 6 Reservation Availability in Australia
# iPhone 6 Reservation Availability in Australia
# !! Please use responsibly. Personal use only !!
# `ruby iphone6.rb` - list all available models in all stores
# `ruby iphone6.rb R405` - list available models for a specific store, Rundle Place in this example.
require 'open-uri'
require 'json'
MODEL_NAMES = {
"MG4A2X/A" => "iPhone 6 Space Grey 128GB",
@alexeckermann
alexeckermann / gist:95b4cfb6d10538ed7c62
Created October 20, 2014 04:49
Fix yo Postgres, Fix yo Yosemite
# Put this in your shell and smoke it
mkdir -p /usr/local/var/postgres/{pg_tblspc,pg_twophase,pg_stat_tmp}
@alexeckermann
alexeckermann / SwiftLoopTest.playground
Created November 10, 2014 09:21
GCD dispatch_resume test for Swift
import Foundation
import XCPlayground
import Dispatch
class Looper {
var loopQueue : dispatch_queue_t!
var tickSource : dispatch_source_t!
init() {
@alexeckermann
alexeckermann / iphone7.rb
Created September 12, 2016 11:07
iPhone 7 Pick Up Availability in Australia
# iPhone 6 Reservation Availability in Australia
# !! Please use responsibly. Personal use only !!
# `ruby iphone6.rb` - list all available models in all stores
# `ruby iphone6.rb R405` - list available models for a specific store, Rundle Place in this example.
require 'open-uri'
require 'json'
MODEL_NAMES = {
"MN8X2X/A" => "7 32 Black",
"MN8Y2X/A" => "7 32 Silver",