Skip to content

Instantly share code, notes, and snippets.

View sjmadsen's full-sized avatar

Steve Madsen sjmadsen

View GitHub Profile
@sjmadsen
sjmadsen / SaveButton.swift
Created January 22, 2016 14:10
ReactiveCocoa snippet
textField1.rac_textSignal().toSignalProducer()
.combineLatestWith(textField2.rac_textSignal().toSignalProducer())
.map { ($0.0 as! String, $0.1 as! String) }
.startWithNext { (first, second) in
self.saveButton.enabled = (first.characters.count + second.characters.count) > 0
}
@sjmadsen
sjmadsen / primefactors.rb
Created February 18, 2015 16:16
Compute the prime factors of a number
class PrimeFactors
def self.of(n)
factors(n).compact.reject { |x| !is_prime?(x) }
end
def self.factors(n)
return [1] if n == 1
(1..n / 2).map { |divisor| (n % divisor) == 0 ? divisor : nil }
end
@sjmadsen
sjmadsen / keybase.md
Last active October 5, 2017 02:01
keybase.io proof

Keybase proof

I hereby claim:

  • I am sjmadsen on github.
  • I am sjmadsen (https://keybase.io/sjmadsen) on keybase.
  • I have a public key ASAM2zDP8I9g7MOZ7_GhBSjPfksLotaHWhJdI0N-_zPBogo

To claim this, I am signing this object:

@sjmadsen
sjmadsen / increment-build-counter.rb
Created July 18, 2012 13:38
Automatic Git revision stamping for Xcode projects
# Xcode auto-versioning script for Git by Steve Madsen.
# Adapted from Subversion script by Axel Andersson.
#
# This is a Ruby script. Use /usr/bin/ruby as the shell.
build_counter_file = 'build-counter'
raise "#{$0}: Must be run from Xcode" unless ENV['BUILT_PRODUCTS_DIR']
def development?
@sjmadsen
sjmadsen / gist:2030348
Created March 13, 2012 18:06
id3lib installation errors
==> Downloading http://downloads.sourceforge.net/project/id3lib/id3lib/3.8.3/id3lib-3.8.3.tar.gz
File already downloaded in /Volumes/User/Steve/Library/Caches/Homebrew
/usr/bin/tar xf /Volumes/User/Steve/Library/Caches/Homebrew/id3lib-3.8.3.tar.gz
==> Patching
/usr/bin/patch -f -p1 -i 001-homebrew.diff
patching file src/mp3_parse.cpp
==> ./configure --prefix=/usr/local/Cellar/id3lib/3.8.3 --disable-debug --disable-dependency-tracking
./configure --prefix=/usr/local/Cellar/id3lib/3.8.3 --disable-debug --disable-dependency-tracking
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
macpro:~ steve$ rvm --trace install 1.9.2-head
+ [[ -z '' ]]
+ export 'PS4=+[${BASH_SOURCE}] : ${LINENO} : ${FUNCNAME[0]:+${FUNCNAME[0]}() $ }'
+ PS4='+[${BASH_SOURCE}] : ${LINENO} : ${FUNCNAME[0]:+${FUNCNAME[0]}() $ }'
+[/Volumes/Users/steve/.rvm/scripts/cli] : 570 : __rvm_parse_args() $ [[ -z '' ]]
+[/Volumes/Users/steve/.rvm/scripts/cli] : 570 : __rvm_parse_args() $ [[ -n '' ]]
+[/Volumes/Users/steve/.rvm/scripts/cli] : 572 : __rvm_parse_args() $ [[ 0 -eq 1 ]]
+[/Volumes/Users/steve/.rvm/scripts/cli] : 572 : __rvm_parse_args() $ [[ -n '' ]]
+[/Volumes/Users/steve/.rvm/scripts/cli] : 15 : __rvm_parse_args() $ [[ -n install ]]
+[/Volumes/Users/steve/.rvm/scripts/cli] : 17 : __rvm_parse_args() $ rvm_token=install