Skip to content

Instantly share code, notes, and snippets.

@cocoaNib
cocoaNib / exportOptionsAdHoc.plist
Last active April 2, 2024 01:41
Xcode build with exportOptionsPlist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>ad-hoc</string>
</dict>
</plist>
@jakubpetrik
jakubpetrik / handle-signal.swift
Created September 23, 2015 21:34
Signal handling in Swift
/**
http://rosettacode.org/wiki/Handle_a_signal
Most general purpose operating systems provide interrupt facilities, sometimes called signals.
Unhandled signals generally terminate a program in a disorderly manner. Signal handlers are
created so that the program behaves in a well-defined manner upon receipt of a signal.
For this task you will provide a program that displays a single integer on each line of output at
the rate of one integer in each half second. Upon receipt of the SigInt signal (often created by the user typing ctrl-C)
the program will cease printing integers to its output, print the number of seconds the program has run,
@JadenGeller
JadenGeller / AnySet.swift
Created March 30, 2015 22:13
Swift Set of "Any" Type
// Examples
var set = AnySet()
set.insert(3)
set.insert("hello")
set.insert("hi")
set.insert(2.3)
set.contains(6) // -> false
set.contains(3) // -> true
@natecook1000
natecook1000 / NSScanner+Swift.swift
Created March 3, 2015 20:13
Swift-friendly NSScanner methods
// NSScanner+Swift.swift
// A set of Swift-idiomatic methods for NSScanner
//
// (c) 2015 Nate Cook, licensed under the MIT license
import Foundation
extension NSScanner {
// MARK: Strings
@seanlilmateus
seanlilmateus / channel.swift
Last active November 22, 2017 14:02
swift Go like channels
import Foundation
// Playground - noun: a place where people can play
class Channel<T> {
var stream: Array<T>
let queue: dispatch_queue_t
let semaphore: dispatch_semaphore_t
init() {
self.stream = []
@jessepeterson
jessepeterson / app_map.c
Last active October 23, 2023 07:32
_CFPreferencesCopyApplicationMap example
/* re-implementation of the behaviour that the /usr/bin/defaults application
* uses to read sandboxed preference data */
#include <CoreFoundation/CoreFoundation.h>
#define EX_BUNDLE_ID "com.apple.mail"
#define EX_KEY "JunkMailBehavior"
// undocumented, internal CFPreferences API call
extern CFDictionaryRef _CFPreferencesCopyApplicationMap(CFStringRef userName, CFStringRef hostName);
@jverkoey
jverkoey / NSManagedObjectContext+DebugSwizzling.m
Created April 14, 2014 11:52
Core Data Managed Object Context Debugging
// NSManagedObjectContext+DebugSwizzling.h
#import <CoreData/CoreData.h>
#if DEBUG
/**
* Toggles debugging of Core Data managed object contexts.
*
* When enabled, will fire NSLogs in the following cases:
@XVilka
XVilka / TrueColour.md
Last active April 8, 2024 14:02
True Colour (16 million colours) support in various terminal applications and terminals

THIS GIST WAS MOVED TO TERMSTANDARD/COLORS REPOSITORY.

PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!

@rickharrison
rickharrison / UIViewController.m
Created August 16, 2013 05:56
iOS 7 Messages Gradient Experimentation
//
// NRTRootViewController.m
// GradientTableView
//
// Created by Rick Harrison on 8/15/13.
// Copyright (c) 2013 Rick Harrison. All rights reserved.
//
#import "NRTRootViewController.h"
@jamiew
jamiew / mp4box_hacks.sh
Created March 7, 2013 18:56
Adding subtitles and audio tracks to an MP4 video with MP4Box
# Add subtitle track
MP4Box -add minecraft_uncut.srt:lang=eng:layout=0x60x0x-1:group=2:hdlr="sbtl:tx3g" Minecraft2_mobile.mp4
# Add audio track
# 1. doesnt work in quicktime/itunes
MP4Box -add commentary_audio.aac Minecraft2_mobile.mp4
# 2. supposed to work in quicktime/itunes but doesn't seem to; :name at least is definitely not supported
MP4Box -add commentary_audio.aac:disable:group1:lang=en:name="Director's Commentary" Minecraft2_mobile.mp4