Skip to content

Instantly share code, notes, and snippets.

@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
{
@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 / 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 / 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 / ViewController.swift
Last active December 1, 2019 23:27
Beginnings of a GCD wrapper in swift
import UIKit
import QuartzCore
class ViewController: UIViewController {
@IBOutlet weak var label: UILabel
@IBOutlet weak var counter: UILabel
override func viewDidLoad() {
super.viewDidLoad()
### Keybase proof
I hereby claim:
* I am inferis on github.
* I am inferis (https://keybase.io/inferis) on keybase.
* I have a public key whose fingerprint is F010 B286 2F49 1AB8 484F 2211 B7CE DECA C646 8A5C
To claim this, I am signing this object:
➤ cloc .
6759 text files.
2025 unique files.
3376 files ignored.
http://cloc.sourceforge.net v 1.58 T=19.0 s (84.0 files/s, 9102.7 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
Objective C 829 27043 15909 97896
@Inferis
Inferis / Build.h
Last active March 20, 2017 15:55
A throw at accessing build settings from within your app. * See the first comment for more info.
// Build.h
// -- autogenerated file by zettings.rb on 2013-12-10 00:09:25 +0100
#import "GeneratedBuild.h"
@interface Build : GeneratedBuild
+ (instancetype)settings;
// add properties here for custom behavior
@Inferis
Inferis / Animations.m
Created November 26, 2013 10:53
Logs "finished = 0" When I remove the changes in the animations block, finished = 1 The changes are applied, but immediately. Duration = 0.3 but setting any value does not matter.
_blurView.alpha = 0;
CGAffineTransform toTransform = _snapshotView.transform;
_snapshotView.transform = CGAffineTransformIdentity;
[UIView animateWithDuration:[self transitionDuration:transitionContext]
delay:0
usingSpringWithDamping:0.8
initialSpringVelocity:0.2
options:UIViewAnimationOptionCurveEaseOut
animations:^{
@Inferis
Inferis / CommonMacros.h
Last active February 5, 2018 03:01
Common Macros for Xcode projects.
//
// CommonMacros.h
// Created by Tom Adriaenssen (@inferis)
// Inspired by the awesome work by Piet Jaspers (@pjaspers)
//
/*
* How to use this file:
* 1. Find your .pch file
* 2. Import this file