Skip to content

Instantly share code, notes, and snippets.

@mbehan
mbehan / increment-build-number.sh
Created April 23, 2014 13:37
Add as a pre compile build phase in Xcode to auto increment your build number (bundle version). Format is revHash.user.number
last_commit=$(git rev-parse --short HEAD)$([[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]] && echo "*")
CFBundleVersion=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNum=${CFBundleVersion##*.}
buildNum=$((buildNum + 1))
CFBundleVersion=$last_commit"."$USER"."buildNum
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $CFBundleVersion" "$INFOPLIST_FILE"
@mbehan
mbehan / build-uploader.sh
Last active May 19, 2016 07:56
Uploads builds produced by Xcode bots
#!/bin/bash
files=/ci_scripts/*.plist
for f in $files
do
echo Processing $f "..."
productName="$(/usr/libexec/plistbuddy -c Print:ProductName: "$f")"
echo $productName

Keybase proof

I hereby claim:

  • I am mbehan on github.
  • I am michaelbehan (https://keybase.io/michaelbehan) on keybase.
  • I have a public key ASDdJfRf5elbvh7OeiCeKP54WC_DOrPPvDrRsusfFU1iSAo

To claim this, I am signing this object:

extension UIControl.Event: Hashable{
public var hashValue: Int{
return Int(self.rawValue)
}
static func == (lhs: UIControl.Event, rhs: UIControl.Event) -> Bool{
return lhs.rawValue == rhs.rawValue
}
}
@mbehan
mbehan / ElementaryCellularAutomata.swift
Created December 4, 2018 03:19
Swift playground for outputting elementary cellular automata
import Foundation
extension Bool {
init(_ char: Character) {
self = String(char).boolValue
}
}
extension String {
func character(at index: Int) -> Character {
@mbehan
mbehan / ForcePanGestureRecognizer.swift
Created November 11, 2016 23:11
A UIPanGestureRecognizer subclass to get the force of the gesture's touch (assumes a single touch)
import UIKit.UIGestureRecognizerSubclass
class ForcePanGestureRecognizer : UIPanGestureRecognizer {
private(set) var force = CGFloat(0) {
didSet {
if force > maxForce {
maxForce = force
}
}
@mbehan
mbehan / ComplicationLaunchSnippets.swift
Created October 18, 2016 12:20
Sample code demonstrating how to determine which complication family was tapped to launch your watchOS app
// 1.
class ComplicationTimeKeeper{
static let shared = ComplicationTimeKeeper()
var utilitarianLarge : Date?
var utilitarianSmall : Date?
var circularSmall : Date?
var modularLarge : Date?
var modularSmall : Date?