Skip to content

Instantly share code, notes, and snippets.

View void-main's full-sized avatar
💭
I may be slow to respond.

Void Main void-main

💭
I may be slow to respond.
View GitHub Profile
@void-main
void-main / VMJsonableObject
Created May 1, 2014 13:38
VMJsonableObject helps developer to easily fill an NSObject with NSDictionary (probably parsed from a JSON string).
// For example, let's define a VMUser class that saves user login info.
// VMUser.h
@interface VMUser : VMJsonableObject
@property (nonatomic)NSString *userId;
@property (nonatomic)NSString *userName;
@property (nonatomic)NSString *email;
@end
@steipete
steipete / PSPDFThreadSafeMutableDictionary.m
Last active December 10, 2022 09:37
Simple implementation of a thread safe mutable dictionary. In most cases, you want NSCache instead, but it can be useful in situations where you want to manually control what is evicted from the cache in low memory situations.**Warning:** I only use this for setting/getting keys. Enumeration is not thread safe here and will still throw exception…
//
// PSPDFThreadSafeMutableDictionary.m
//
// Copyright (c) 2013 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
@steipete
steipete / PSPDFUIKitMainThreadGuard.m
Last active March 10, 2024 19:23
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, 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…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/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 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>
@SaitoWu
SaitoWu / graph.rb
Last active December 25, 2017 07:30
Github Contribution Graph
require 'date'
author = "Saito"
email = "saitowu@gmail.com"
date = Date.new(2012, 7, 30)
s = %w{
. . . . . . .
. . o o o . .
. o . . . . .
@xjones
xjones / TransitionController.h
Created November 26, 2011 03:48
TransitionController for animating iOS view controller transitions w/o a controller stack
//
// TransitionController.h
//
// Created by XJones on 11/25/11.
//
#import <UIKit/UIKit.h>
@interface TransitionController : UIViewController
//
// UIColor-HSVAdditions.h
//
// Created by Matt Reagan (bravobug.com) on 12/31/09.
//
//
// Copyright 2010 Fabián Cañas. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@jpwatts
jpwatts / xcode-git-version.sh
Created May 11, 2011 16:42
This Xcode 4 build phase script automatically sets the version and short version string of an application bundle based on information from the containing Git repository.
#!/bin/bash
# This script automatically sets the version and short version string of
# an Xcode project from the Git repository containing the project.
#
# To use this script in Xcode 4, add the contents to a "Run Script" build
# phase for your application target.
set -o errexit
set -o nounset