Skip to content

Instantly share code, notes, and snippets.

@Inferis
Inferis / velo.coffee
Last active August 29, 2015 14:08
Velo script for ye olde Hubot.
# Description:
# Shows how many velos are free on "nearby" Velo stations.
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
@Inferis
Inferis / orientation.m
Last active September 19, 2020 21:02
Calculate InterfaceOrientation from a transition coordinator transform
- (UIInterfaceOrientation)orientationByTransforming:(CGAffineTransform)transform fromOrientation:(UIInterfaceOrientation)c
{
CGFloat angle = atan2f(transform.b, transform.a);
NSInteger multiplier = (NSInteger)roundf(angle / M_PI_2);
UIInterfaceOrientation orientation = self.interfaceOrientation;
if (multiplier < 0) {
// clockwise rotation
while (multiplier++ < 0) {
switch (orientation) {
@Inferis
Inferis / Example.m
Created May 27, 2015 21:07
Auto NSCoding?
TestModel *model = [TestModel new];
model.aString = @"abc";
model.aDate = [NSDate new];
model.anURL = [NSURL URLWithString:@"http://inferis.org"];
model.subModel = [SubModel new];
model.subModel.aNumber = @123;
model.subModel.aValue = [NSValue valueWithCGAffineTransform:CGAffineTransformIdentity];
model.things = @[[SubModel new], [TestModel new]];
model.reference = @{ @"sm": [SubModel new] };
@Inferis
Inferis / gist:2714c636a6a443de4581
Last active August 29, 2015 14:23
Smashables and Values
//: Playground - noun: a place where people can play
protocol HeterogenousEquatable
{
func isEqual(other: HeterogenousEquatable) -> Bool
}
protocol Value: HeterogenousEquatable
{