Skip to content

Instantly share code, notes, and snippets.

Avatar

Steve Madsen sjmadsen

View GitHub Profile
@sjmadsen
sjmadsen / SaveButton.swift
Created Jan 22, 2016
ReactiveCocoa snippet
View SaveButton.swift
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 Feb 18, 2015
Compute the prime factors of a number
View primefactors.rb
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 Oct 5, 2017
keybase.io proof
View keybase.md

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 Jul 18, 2012
Automatic Git revision stamping for Xcode projects
View increment-build-counter.rb
# 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 Mar 13, 2012
id3lib installation errors
View gist:2030348
==> 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
View gist:592982
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
You can’t perform that action at this time.