Skip to content

Instantly share code, notes, and snippets.

View iljaiwas's full-sized avatar

Ilja Iwas iljaiwas

View GitHub Profile
@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 }
}
@rmcdongit
rmcdongit / macOS_SytemPrefs.md
Last active November 15, 2024 11:57
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
@yusuke024
yusuke024 / ViewController.swift
Created November 16, 2018 03:15
Recording video with AVAssetWriter
import UIKit
import AVFoundation
class ViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
switch AVCaptureDevice.authorizationStatus(for: .video) {
case .notDetermined:
@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 ;

@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"
@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];
}
@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
@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");
@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/"
@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;