Skip to content

Instantly share code, notes, and snippets.

View briandw's full-sized avatar

Brian Williams briandw

  • Mountain View, Ca
View GitHub Profile
Verifying that +brianwilliams is my blockchain ID. https://onename.com/brianwilliams
@briandw
briandw / XCTestCase-RLWaitWithExpectation.m
Created July 8, 2015 18:33
Use this in your Xcode test cases to wait for something to happen while waiting on an exception
#import <XCTest/XCTest.h>
@interface XCTestCase (RLWaitWithExpectation)
- (void)waitFor:(NSTimeInterval)seconds withExpectationBlock:(BOOL (^)())block;
@end
@implementation XCTestCase (RLWaitWithExpectation)
@briandw
briandw / RLCrashyView.m
Created October 31, 2013 19:18
This will crash the Mac OS X Mavericks window server.
//
// RLCrashyView.m
// CrashyMcCrashy
//
// Created by brian on 10/31/13.
// Copyright (c) 2013 Rantlab. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@briandw
briandw / RLArrowView.m
Created June 24, 2013 16:54
rantlab 1 full arrow view
//
// RLArrowView.m
//
// Created by brian on 6/20/13.
// Copyright (c) 2013 RantLab. All rights reserved.
//
#import "RLArrowView.h"
@implementation RLArrowView
@briandw
briandw / gist:5851387
Created June 24, 2013 16:28
rantlab 1.4
- (void)wiggleFromPath:(CGPathRef)path target:(CGPoint)target amount:(CGFloat)amount
{
CGPoint middle = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds));
CGPathRef endPath = [RLArrowView createPathWithArrowFromPoint:middle
toPoint:target
tailWidth:2.0
headWidth:10.0
headLength:20.0
wiggle:amount];
@briandw
briandw / gist:5851365
Last active December 18, 2015 21:59
rantlab post 1.3
CGPathRef endPath = [RLArrowView createPathWithArrowFromPoint:middle
toPoint:target
tailWidth:2.0
headWidth:10.0
headLength:20.0
wiggle:0];
[NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){
@briandw
briandw / gist:5851343
Last active December 18, 2015 21:59
rantlab post 1.2
- (void)mouseDown:(NSEvent *)event
{
arrow = [CAShapeLayer layer];
CGFloat minMagnitude = 20;
CGPoint middle = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds));
CGPoint vector = CGPointMake(target.x-middle.x, target.y-middle.y);
CGFloat magnitude = sqrt(vector.x*vector.x+vector.y*vector.y);
CGPoint start = CGPointMake(middle.x+vector.x/magnitude*minMagnitude, middle.y+vector.y/magnitude*minMagnitude);
@briandw
briandw / gist:5851290
Last active December 18, 2015 21:59
rantlab post 1.1
+ (CGPathRef )createPathWithArrowFromPoint:(CGPoint)startPoint
toPoint:(CGPoint)endPoint
tailWidth:(CGFloat)tailWidth
headWidth:(CGFloat)headWidth
headLength:(CGFloat)headLength
wiggle:(CGFloat)wiggle
{
CGFloat length = hypotf(endPoint.x - startPoint.x, endPoint.y - startPoint.y);
CGPoint points[9];
//
// NSObject+BlockObservation.h
// Version 1.0
//
// Andy Matuschak
// andy@andymatuschak.org
// Public domain because I love you. Let me know how you use it.
//
#import <Cocoa/Cocoa.h>