Skip to content

Instantly share code, notes, and snippets.

View wisonlin's full-sized avatar
🎯
Focusing

wison wisonlin

🎯
Focusing
View GitHub Profile
@jtbandes
jtbandes / Function.h
Last active April 21, 2020 16:51
fun with Obj-C "generics"
@import Foundation;
NS_ASSUME_NONNULL_BEGIN
@interface Function<__contravariant InType, __covariant OutType> : NSObject
{
// interestingly, this does work here (though OutType & InType are not available in the @implementation)
OutType (^_block)(InType);
}
@jspahrsummers
jspahrsummers / GHRunLoopWatchdog.h
Created January 28, 2015 20:50
A class for logging excessive blocking on the main thread
/// Observes a run loop to detect any stalling or blocking that occurs.
///
/// This class is thread-safe.
@interface GHRunLoopWatchdog : NSObject
/// Initializes the receiver to watch the specified run loop, using a default
/// stalling threshold.
- (id)initWithRunLoop:(CFRunLoopRef)runLoop;
/// Initializes the receiver to detect when the specified run loop blocks for
@andelf
andelf / EasyJSON.swift
Last active August 29, 2015 14:03
Swift JSON Helper
import Foundation
//let raw = String.stringWithContentsOfURL(NSURL(string: "http://www.weather.com.cn/data/sk/101010100.html"))
struct EasyJSON {
var _obj: AnyObject!
init(_ obj: AnyObject) {
//assert(NSJSONSerialization.isValidJSONObject(obj), "must be valid json object")
_obj = obj