Skip to content

Instantly share code, notes, and snippets.

Michael Behan mbehan

Block or report user

Report or block mbehan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View SwiftyButton.swift
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
0xced /
Created Aug 30, 2017
Extract certificate + public key + pin from a TLS server
#!/usr/bin/env bash -e
# For file naming, see
# For HTTP Public Key Pinning (HPKP), see
mbehan / ForcePanGestureRecognizer.swift
Created Nov 11, 2016
A UIPanGestureRecognizer subclass to get the force of the gesture's touch (assumes a single touch)
View ForcePanGestureRecognizer.swift
import UIKit.UIGestureRecognizerSubclass
class ForcePanGestureRecognizer : UIPanGestureRecognizer {
private(set) var force = CGFloat(0) {
didSet {
if force > maxForce {
maxForce = force
mbehan /
Created Apr 23, 2014
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=$((buildNum + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $CFBundleVersion" "$INFOPLIST_FILE"
mbehan /
Last active May 19, 2016
Uploads builds produced by Xcode bots
for f in $files
echo Processing $f "..."
productName="$(/usr/libexec/plistbuddy -c Print:ProductName: "$f")"
echo $productName
hatfinch / CGAffineTransformFromRectToRect.m
Created Aug 17, 2011
CGAffineTransformFromRectToRect (not working)
View CGAffineTransformFromRectToRect.m
CGAffineTransform CGAffineTransformFromRectToRect(CGRect fromRect, CGRect toRect)
CGSize scale = CGSizeMake(toRect.size.width / fromRect.size.width, toRect.size.height / fromRect.size.height);
CGRect scaledFromRect = CGRectMake(fromRect.origin.x * scale.width, fromRect.origin.y * scale.height,
fromRect.size.width * scale.width, fromRect.size.height * scale.height);
CGSize translation = CGSizeMake(fromRect.origin.x - scaledFromRect.origin.x, fromRect.origin.y - scaledFromRect.origin.y);
return CGAffineTransformMake(scale.width, 0.0, 0.0, scale.height, translation.width, translation.height);
zoul / AVAssetExportSession+Testing.m
Created Nov 8, 2010
Export assets synchronously. Good for testing.
View AVAssetExportSession+Testing.m
@implementation AVAssetExportSession (Testing)
- (void) exportSynchronously
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
[self exportAsynchronouslyWithCompletionHandler:^{
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
zoul / UIImage+ForceLoad.m
Created Sep 14, 2010
Forces UIImage to load and decode its data
View UIImage+ForceLoad.m
@implementation UIImage (ForceLoading)
- (void) forceLoad
const CGImageRef cgImage = [self CGImage];
const int width = CGImageGetWidth(cgImage);
const int height = CGImageGetHeight(cgImage);
const CGColorSpaceRef colorspace = CGImageGetColorSpace(cgImage);
You can’t perform that action at this time.