Skip to content

Instantly share code, notes, and snippets.

View iljaiwas's full-sized avatar

Ilja Iwas iljaiwas

View GitHub Profile
@steipete
steipete / PSPDFUIKitMainThreadGuard.m
Last active May 27, 2024 12:11
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>
@chbeer
chbeer / NSDate ISO methods
Created June 10, 2013 09:33
Methods to create and parse ISO date strings without NSDateFormatter.
NSDate *CBCBDateFromISOString(NSString *iso)
{
struct tm tm;
time_t t;
if (iso.length == 10) {
strptime([iso cStringUsingEncoding:NSUTF8StringEncoding], "%Y-%m-%d", &tm);
tm.tm_isdst = -1;
tm.tm_sec = 0;
@anagromataf
anagromataf / post-checkout
Created July 11, 2014 12:49
post-checkout-Hook for using Cocoa Pods together with the Xcode CI Server
#!/bin/sh
##
## Create a folder at /var/teamsserver/ and set the user and group to _teamsserver
## Copy this script to /Applications/Xcode.app/Contents/Developer/usr/share/git-core/templates/hooks/post-checkout
##
export LC_ALL="en_US.UTF-8"
export HOME="/var/teamsserver/"
@choefele
choefele / extension
Last active August 29, 2015 14:15
How to know at run-time whether your code runs inside an iOS extension
NSDictionary *extensionInfo = [NSBundle.mainBundle objectForInfoDictionaryKey:@"NSExtension"];
NSString *extensionPointIdentifier = extensionInfo[@"NSExtensionPointIdentifier"];
if ([extensionPointIdentifier isEqualToString:@"com.apple.watchkit"]) {
NSLog(@"WatchKit extension");
} else if ([extensionPointIdentifier isEqualToString:@"com.apple.widget-extension"]) {
NSLog(@"Widget extension");
} else if (extensionPointIdentifier == nil) {
NSLog(@"iOS app");
} else {
NSLog(@"Unknown extension type");
@mackuba
mackuba / wwdc15.md
Last active August 6, 2022 17:28
New stuff from WWDC 2015

Here's my own list of the interesting stuff announced during this year's WWDC, collected from the keynotes, various Apple docs, blog posts and tweets.

If you're planning to watch the videos, I really recommend this Mac app that helps you download and watch them: https://github.com/insidegui/WWDC.

OS X El Capitan

http://www.apple.com/osx/elcapitan-preview/

  • split view - two apps side by side on full screen
@chriseidhof
chriseidhof / qsort.m
Last active September 17, 2015 10:07
qsort
#import <Foundation/Foundation.h>
int stringComp(const void *a, const void *b) {
NSString *aO = *(NSString *__autoreleasing*)a;
NSString *bO = *(NSString *__autoreleasing*)b;
return [aO caseInsensitiveCompare:bO];
}
@wpuricz
wpuricz / gist:c25d71409cc00340b85d8494c0dfc16a
Created February 1, 2017 14:13
Multipart upload using vapor
drop.post("upload") { request in
print(request.multipart?["image"]?.file?.data)
guard let fileData = request.multipart?["image"]?.file?.data else {
throw Abort.custom(status: .badRequest, message: "No file in request")
}
let workPath = drop.workDir
let name = UUID().uuidString + ".png"
@catlan
catlan / README.md
Last active May 10, 2024 15:04 — forked from zrxq/.lldbinit
Execute lldb command and open its output in Kaleidoscope diff

Diff output of two lldb commands

Setup

  1. Copy the contents of the last snippet (lldbinit) from the gist page, and paste into your .lldbinit file. This makes the ksdiff macro known inside lldb.
  2. Put file ksdiff.py in ~/.lldb/
  3. sudo pip install temp
  4. Restart Xcode debug session

Example

(lldb) ksdiff ;

@rmcdongit
rmcdongit / macOS_SytemPrefs.md
Last active July 11, 2024 07:21
Apple System Preferences URL Schemes

macOS 10.15 System Preference Panes

Below are a list of System Preference pane URLs and paths that can be accessed with scripting to assist users with enabling macOS security settings without having to walk them through launching System Preferences, finding panes, and scrolling to settings. Not all panes have an accessible anchor and some are OS specific.

To find the Pane ID of a specific pane, open the System Preferences app and select the desired Preference Pane. With the pane selected, open the ScriptEditor.app and run the following script to copy the current Pane ID to your clipboard and display any available anchors:

tell application "System Preferences"
	set CurrentPane to the id of the current pane
	set the clipboard to CurrentPane
@ZevEisenberg
ZevEisenberg / TypedMutableCopying.swift
Last active August 18, 2021 20:37
Adds typed mutable copying to NSMutableCopying conformers
import Foundation
protocol TypedMutableCopying {
associatedtype ConstantVersion
associatedtype MutableVersion
var typedCopy: ConstantVersion { get }
var typedMutableCopy: MutableVersion { get }
}