Skip to content

Instantly share code, notes, and snippets.

View FlatHierarchyViewController.swift
import UIKit
import YogaKit
final class FlatHierarchyController: UIViewController {
private let layoutA = YGLayoutContainer(), layoutB = YGLayoutContainer()
private var currentLayout: YGLayoutContainer?
override func viewDidLoad() {
view.backgroundColor = .white
View hexdump.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
def hexdump(src, length=16):
lines = []
for c in xrange(0, len(src), length):
chars = src[c:c+length]
hex = ' '.join(["%02x" % ord(x) for x in chars])
printable = ''.join(["%s" % ((ord(x) <= 127 and x) or '.') for x in chars])
lines.append("%04x %-*s %s\n" % (c, length*3, hex, printable))
View nightShift.m
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
//
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#pragma mark Blocks
View removeLastOddDigit.c
#include <stdio.h>
int removeLastOddDigit(int num)
{
for (int base = 1; num/base != 0; base *= 10) {
if ((num/base) % 2 != 0) {
return base * (num/(base*10)) + num%base;
}
}
return num;
View threadguard.m
// Borrowed from PSPDFKit: https://gist.github.com/steipete/5664345
#define ENABLE_UIKIT_THREAD_ASSERTS (0)
#if ENABLE_UIKIT_THREAD_ASSERTS && defined(DEBUG)
#import <UIKit/UIKit.h>
#import <objc/runtime.h>
#import <objc/message.h>
@fjolnir
fjolnir / justwow.m
Created Feb 24, 2016
KVC does not work with typedefs
View justwow.m
#import <Foundation/Foundation.h>
typedef NSObject Foobar;
@interface Klass : Foobar
@property Foobar *baz;
@end
@implementation Klass
@end
int main(int argc, char *argv[]) {
View keybase.md

Keybase proof

I hereby claim:

  • I am fjolnir on github.
  • I am fjolnir (https://keybase.io/fjolnir) on keybase.
  • I have a public key ASDszqSQKUrZcS6H607ZpE_vyscXDiNDaQjV-t1h2DdrnAo

To claim this, I am signing this object:

View staticanalyzer.md

Where:

  NSUInteger LEDataRangeLength(LEDataRange aRange) __attribute__((const));

The following:

    LEDataRange const dataRange = self.dataRange;
    if(LEDataRangeLength(dataRange) == 0)
        return NO;
View LEShapeLayer.h
// Simply animates it's path along with bound change animations (if the path is changed along with the bounds that is)
@interface LEShapeLayer : CAShapeLayer
@end
@interface LEShapeView : UIView
@property(nonatomic, readonly) LEShapeLayer *shapeLayer;
@property(nonatomic, readonly) CGPathRef hitTestPath;
@end
@fjolnir
fjolnir / QA.swift
Last active Aug 29, 2015
No DRYer way?
View QA.swift
enum Question {
case Confirmation
case Photo
enum Answer {
case Confirmation(Bool)
case Photo(UIImage)
}
}