Skip to content

Instantly share code, notes, and snippets.

View lukeredpath's full-sized avatar
🏠
Working from home

Luke Redpath lukeredpath

🏠
Working from home
View GitHub Profile
@lukeredpath
lukeredpath / fizzbuzz_lambda.rb
Created April 4, 2012 12:56
Tom Stuart's lambda calculus version of FizzBuzz in Ruby
# Using constants in place of lambdas:
MAP[RANGE[ONE][HUNDRED]][-> n {
IF[IS_ZERO[MOD[n][FIFTEEN]]][
FIZZBUZZ
][IF[IS_ZERO[MOD[n][THREE]]][
FIZZ
][IF[IS_ZERO[MOD[n][FIVE]]][
BUZZ
][
@lukeredpath
lukeredpath / fizzbuzz.lol
Created April 4, 2012 12:46
LOLCode fizzbuzz
HAI
CAN HAS STDIO?
I HAS A VAR IZ 0
IM IN YR LOOP
UPZ VAR!!1
IZ VAR BIGR THAN 100?
GTFO.
KTHX
IZ VAR LEFTOVAR 15 LIEK 0?
VISIBLE "FIZZBUZZ"
@lukeredpath
lukeredpath / fizzbuzz.rb
Created April 4, 2012 12:42
Over-engineered fizzbuzz
# over-engineered version
module FizzBuzzer
def self.evenly_divisible_by?(number, by_number)
(number % by_number) == 0
end
class Fizz
def self.satisfied_by?(number)
FizzBuzzer.evenly_divisible_by?(number, 3)
@interface Foo : NSObject
- (void)doSomething;
@end
@implementation Foo
- (void)doSomething
{
[NSException raise:@"failed" format:@"failed"];
}
➜ {luke@macbookpro} libPusher $ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -fobjc-arc
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: unknown option character `f' in: -fobjc-arc
Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-sacLT]
Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -dynamic [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-o output] [-install_name name] [-compatibility_version #] [-current_version #] [-seg1addr 0x#] [-segs_read_only_addr 0x#] [-segs_read_write_addr 0x#] [-seg_addr_table <filename>] [-seg_addr_table_filename <file_system_path>] [-all_load] [-noall_load]
@lukeredpath
lukeredpath / gist:2171558
Created March 23, 2012 15:09
CocoaPods test failures
Pod::Downloader
for Git
- check's out a specific commit [FAILED]
Pod::Command
- searches for a pod with name matching the given query ignoring case [ERROR: SyntaxError]
- searches for a pod with name, summary, or description matching the given query ignoring case [ERROR: SyntaxError]
Pod::Generator::Documentation
- returns reads correctly the Pod documentation [FAILED]
# these obviously aren't real object IDs, just here for illustration
# #matches is a built-in matcher, #all_of is a custom DSL-defined matcher.
m1 = all_of(be_instance_of(Foo), has_attributes(id: 123))
m2 = all_of(be_instance_of(Bar), has_attributes(id: 456))
p m1.object_id # => 1
p m2.object_id # => 1
a1 = matches(/foo/)
a2 = matches(/bar/)
@lukeredpath
lukeredpath / user_signs_in_spec.rb
Created March 7, 2012 15:47
Abstracting away Capybara using "driver" proxies
require 'acceptance/acceptance_helper'
feature 'User signs in to the system' do
let(:user) { UIDriver.for Fabricate(:user, email: "user@example.com", password: "letmein") }
background do
user.visit_portal
end
➜ {luke@macbookpro} libPusher-4 $ ar -vt libPusher-iphonesimulator5.0.a
rw-r--r-- 501/20 8912 Mar 4 17:17 2012 __.SYMDEF
rw-r--r-- 501/20 7048 Mar 4 17:17 2012 NSDictionary+QueryString.o
rw-r--r-- 501/20 51888 Mar 4 17:17 2012 PTPusher.o
rw-r--r-- 501/20 16584 Mar 4 17:17 2012 PTPusherEvent.o
rw-r--r-- 501/20 8384 Mar 4 17:17 2012 NSString+Hashing.o
rw-r--r-- 501/20 53080 Mar 4 17:17 2012 PTPusherChannel.o
rw-r--r-- 501/20 24752 Mar 4 17:17 2012 PTPusherConnection.o
rw-r--r-- 501/20 16528 Mar 4 17:17 2012 PTPusherEventDispatcher.o
rw-r--r-- 501/20 12496 Mar 4 17:17 2012 PTTargetActionEventListener.o
@lukeredpath
lukeredpath / application.rb
Created March 6, 2012 12:35
Promise example
module MyApp
class Application < Rails::Application
require File.expand_path('../dependencies', __FILE__)
# mixes in some methods that return some app-wide dependencies,
# like the #sms_notifier used below.
include Dependencies
# sms_notifier is created automatically when we call application.sms_notifier