Skip to content

Instantly share code, notes, and snippets.

@Inferis
Inferis / gist:2714c636a6a443de4581
Last active Aug 29, 2015
Smashables and Values
View gist:2714c636a6a443de4581
//: 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
Auto NSCoding?
View Example.m
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 Sep 19, 2020
Calculate InterfaceOrientation from a transition coordinator transform
View orientation.m
- (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 Aug 29, 2015
Velo script for ye olde Hubot.
View velo.coffee
# Description:
# Shows how many velos are free on "nearby" Velo stations.
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
@Inferis
Inferis / ViewController.swift
Last active Dec 1, 2019
Beginnings of a GCD wrapper in swift
View ViewController.swift
import UIKit
import QuartzCore
class ViewController: UIViewController {
@IBOutlet weak var label: UILabel
@IBOutlet weak var counter: UILabel
override func viewDidLoad() {
super.viewDidLoad()
View gist:10011952
### 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:
View CLOC
➤ 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 Mar 20, 2017
A throw at accessing build settings from within your app. * See the first comment for more info.
View Build.h
// 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 Nov 26, 2013
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.
View Animations.m
_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 Feb 5, 2018
Common Macros for Xcode projects.
View CommonMacros.h
//
// 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