Skip to content

Instantly share code, notes, and snippets.

import UIKit
import YogaKit
final class FlatHierarchyController: UIViewController {
private let layoutA = YGLayoutContainer(), layoutB = YGLayoutContainer()
private var currentLayout: YGLayoutContainer?
override func viewDidLoad() {
view.backgroundColor = .white
#!/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))
#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
#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;
// 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 February 24, 2016 03:29
KVC does not work with typedefs
#import <Foundation/Foundation.h>
typedef NSObject Foobar;
@interface Klass : Foobar
@property Foobar *baz;
@end
@implementation Klass
@end
int main(int argc, char *argv[]) {

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:

Where:

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

The following:

    LEDataRange const dataRange = self.dataRange;
    if(LEDataRangeLength(dataRange) == 0)
 return NO;
// 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 August 29, 2015 14:25
No DRYer way?
enum Question {
case Confirmation
case Photo
enum Answer {
case Confirmation(Bool)
case Photo(UIImage)
}
}