Skip to content

Instantly share code, notes, and snippets.

@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 / 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()
@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
@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 / UIColor+Hex.h
Created January 13, 2011 23:24
Hex + CSS extensions to create UIColors from hex colour values or CSS colour strings.
//
// UIColor+Hex.h
//
// Created by Tom Adriaenssen on 13/01/11.
//
@interface UIColor (Hex)
+ (UIColor*) colorWithCSS: (NSString*) css;
+ (UIColor*) colorWithHex: (NSUInteger) hex;
@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 / UIView+RoundedOverlay.h
Created October 9, 2012 19:21
Apply a rounded overlay to a viewcontroller.
//
// UIView+RoundedOverlay.h
//
// Created by Tom Adriaenssen on 05/04/12.
//
#import <UIKit/UIKit.h>
@interface UIViewController (RoundedOverlay)
//
// Speciaal voor @junkiesxl
// ######## YES nil N, 10000000 iterations
// 0 0.376909: if
// 0 0.456258: if-equivalent statement
// 0 0.312767: statement
// 0 0.368508: statement-equivalent ifs
// 1 0.309485: if
// 1 0.324720: if-equivalent statement
@Inferis
Inferis / caveatPatchor.js
Created August 19, 2011 18:54
caveatPatcher.js inferis
/*
As of version 1.1.2, Propane will load and execute the contents of
~Library/Application Support/Propane/unsupported/caveatPatchor.js
immediately following the execution of its own enhancer.js file.
You can use this mechanism to add your own customizations to Campfire
in Propane.
Below you'll find two customization examples.
@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
{