Skip to content

Instantly share code, notes, and snippets.

View RSWeakifySelf.h
* Several macros simplifying use of weak references to self inside blocks
* which goal is to reduce risk of retain cycles.
* Example:
* @code
@interface Example : NSObject{
int _i;
View UIView+FrameAdditions.h
#import <UIKit/UIKit.h>
@interface UIView (SMFrameAdditions)
@property (nonatomic, assign) CGPoint $origin;
@property (nonatomic, assign) CGSize $size;
@property (nonatomic, assign) CGFloat $x, $y, $width, $height; // normal rect properties
@property (nonatomic, assign) CGFloat $left, $top, $right, $bottom; // these will stretch the rect
View UIImage+fixOrientation.h
@interface UIImage (fixOrientation)
- (UIImage *)fixOrientation;
scorpiozj / PSPDFUIKitMainThreadGuard.m
Created August 30, 2016 07:17 — forked from steipete/PSPDFUIKitMainThreadGuard.m
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
View PSPDFUIKitMainThreadGuard.m
// Taken from the commercial iOS PDF framework
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 ( if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>
scorpiozj / neural.c
Created September 6, 2016 02:24 — forked from hollance/neural.c
Playing with BNNS on macOS 10.12. The "hello world" of neural networks.
View neural.c
The "hello world" of neural networks: a simple 3-layer feed-forward
network that implements an XOR logic gate.
The first layer is the input layer. It has two neurons a and b, which
are the two inputs to the XOR gate.
The middle layer is the hidden layer. This has two neurons h1, h2 that
will learn what it means to be an XOR gate.
scorpiozj / viewController.swift
Created August 15, 2017 06:39
Swift Error Handling
View viewController.swift
// ViewController.swift
// ErrorTest
// Created by ZhuJiang on 2017/8/15.
// Copyright © 2017年 Charles. All rights reserved.
import UIKit