Skip to content

Instantly share code, notes, and snippets.

View djtech42's full-sized avatar

Dan Turner djtech42

View GitHub Profile
@egel
egel / audio_extensions
Created April 15, 2015 20:07
Big group of extensions (audio, text)
.caf Core Audio File 4.5 stars
.abm Music Album 4.5 stars
.oga Ogg Vorbis Audio File
.omf Open Media Framework File
.pla Sansa Playlist File
.asd Ableton Live Sample Analysis File
.bnk Adlib Instrument Bank
.bun Cakewalk Bundle File
.csh Cubase Waveform File
.hsb HALion Sound Bank File
@mickmaccallum
mickmaccallum / classes.swift
Created May 5, 2015 17:50
Missing NSObject introspection methods. isStrictSubclassOfClass(), isStrictSuperclassOfClass() and isSuperclassOfClass()
extension NSObject {
class func isStrictSubclassOfClass(aClass: AnyClass) -> Bool {
return isSubclassOfClass(aClass) && self !== aClass.self
}
class func isStrictSuperclassOfClass(aClass: AnyClass) -> Bool {
return isSuperclassOfClass(aClass) && self !== aClass.self
}
class func isSuperclassOfClass(aClass: AnyClass) -> Bool {
@nicklockwood
nicklockwood / gist:21495c2015fd2dda56cf
Last active August 13, 2020 13:57
Thoughts on Swift 2 Errors

Thoughts on Swift 2 Errors

When Swift was first announced, I was gratified to see that one of the (few) philosophies that it shared with Objective-C was that exceptions should not be used for control flow, only for highlighting fatal programming errors at development time.

So it came as a surprise to me when Swift 2 brought (What appeared to be) traditional exception handling to the language.

Similarly surprised were the functional Swift programmers, who had put their faith in the Haskell-style approach to error handling, where every function returns an enum (or monad, if you like) containing either a valid result or an error. This seemed like a natural fit for Swift, so why did Apple instead opt for a solution originally designed for clumsy imperative languages?

I'm going to cover three things in this post:

@kreeger
kreeger / xcode-and-el-capitan.md
Last active August 29, 2015 14:24
Re-enables launching of older versions of Xcode on El Capitan. Do so at your own risk!

Xcode 6 & El Capitan

Re-enables launching of older versions of Xcode on El Capitan. Xcode 6 supposedly has issues creating corrupt archives on El Capitan, which is why it's been disabled. Do so at your own risk!

  • Disable rootless (temporarily) with sudo nvram boot-args="kext-dev-mode=1 rootless=0"
  • Then reboot
  • open /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/Exceptions.plist
  • change com.apple.dt.Xcode -> Item 0 -> HardDisabled from YES to NO
  • Reboot again, for good measure
  • Remove and reinstall Xcode, launch it, make sure it's good
@andymatuschak
andymatuschak / States-v3.md
Last active December 25, 2025 23:27
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

@JohnSundell
JohnSundell / xcode-switch.sh
Created June 17, 2017 13:29
A script that switches between the App Store & beta versions of Xcode
#!/usr/bin/env bash
# This script switches between the App Store version of Xcode and the beta
# Install it by copying it to /usr/local/bin/xcode-switch and running 'chmod +x' on it (to make it executable)
# Then run it using 'sudo xcode-switch'
if [ "$EUID" -ne 0 ]; then
echo "xcode-select requires you to run this script as root; 'sudo xcode-switch'"
exit
fi