Skip to content

Instantly share code, notes, and snippets.

View listrophy's full-sized avatar

Brad Grzesiak listrophy

View GitHub Profile
@listrophy
listrophy / application.rb
Last active December 15, 2015 14:09
Quick, roll-your-own key-boolean caching
module MyApplication
class Application < Rails::Application
config.cache_store = :memory_store, {:size => 4.megabytes}
end
end
ATID 2718 # personal area network ID (must match other XBee's ATID)
ATMY 1 # my address (must match other XBee's ATIA)
ATDH 0 # destination address high
ATDL 2 # destination address low (must match other XBee's ATMY)
ATD0 3 # Set AD/DIO 0 (pin 20) to digital input
ATIR 14 # sample rate
ATPR 0 # no pull-up resistors
ATWR # save settings
@listrophy
listrophy / gist:6530215
Created September 11, 2013 21:46
bwoken v2 alpha instructions

In your Gemfile, change the bwoken line to:

gem 'bwoken', :github => 'bendyworks/bwoken', :branch => 'deprecate_rake'

Then run bundle and try running:

bwoken test

See the flags available with:

@listrophy
listrophy / shrink_plus_ones.js
Created September 22, 2013 02:49
Shrink +1's on github comments
$('.discussion-bubble').filter(function() {
var body = $(this).find('.comment-body').text().trim();
return body === "+1" ||
body === '' && $(this).find('.comment-body img.emoji[title=":+1:"]').length > 0;
}).each(function() {
$(this).find('.comment-content').remove().end().
find('.comment-header-action-text a').html("+1'ed");
});
@listrophy
listrophy / composeAndApply.swift
Last active August 29, 2015 14:02
composeAndApply in swift
func composeAndApply<T>(funcs: (T -> T)[], val: T) -> T {
return funcs.reduce(val, combine: { (memo, aFunc) in aFunc(memo) })
}
func square(val: Int) -> Int {
return val * val
}
func double(val: Int) -> Int {
return val * 2
@listrophy
listrophy / Mutator.swift
Created January 7, 2015 00:42
Quick does not instantiate new objects for each test
class Mutator {
var mutated: Bool
init() {
mutated = false
}
func mutate() {
mutated = true
}
}
@listrophy
listrophy / rpsls.rb
Created February 21, 2015 20:11
Rock, Paper, Scissors, Lizard, Spock
# Exactly 140 characters! :)
# We rescue StandardError and re-raise a RuntimeError
# because that's nicer than getting NoMethodError or TypeError
def play a, b
t = %w(scissors paper rock lizard spock)
['tie', b, a, b, a][(t.index(a)-t.index(b)) % 5]
rescue StandardError
raise 'invalid'
end
@listrophy
listrophy / unwrap.swift
Last active August 29, 2015 14:23
if-let => try
func unwrap<T>(wrapped: T?) throws -> T {
guard let unwrapped = wrapped else {
throw NSError(domain: "custom", code: 1, userInfo: nil)
}
return unwrapped
}
@listrophy
listrophy / Glob.swift
Created June 25, 2015 17:14
Wrap glob(3) in Swift
//
// Glob.swift
//
// Created by Brad Grzesiak on 6/25/15.
// Copyright © 2015 Bendyworks Inc.
// Released under the Apache v2 License.
//
import Foundation
@listrophy
listrophy / keybase.md
Created February 15, 2016 17:02
keybase.md

Keybase proof

I hereby claim:

  • I am listrophy on github.
  • I am listrophy (https://keybase.io/listrophy) on keybase.
  • I have a public key ASA6atdQXkcOVAjd_ssdipntcPZj2b-l8w6dEWIODpAWiwo

To claim this, I am signing this object: