Skip to content

Instantly share code, notes, and snippets.

View Frankacy's full-sized avatar

Frank Courville Frankacy

View GitHub Profile
@hboon
hboon / gist:278281
Created January 15, 2010 18:12
Script to Remove Core Data's SQLite Database File During Development Cycles
#!/bin/sh
# Adapted from http://furbo.org/2009/03/03/open-sesame/
if [ -z "$1" ]; then
echo "usage: $0 <app> [ Preferences | <document> ]"
else
app=`ls -1td ~/Library/Application\ Support/iPhone\ Simulator/User/Applications/*/$1.app | head -1`
dir=`dirname "$app"`
if [ "$2" = "Preferences" ]; then
@sburlot
sburlot / xc_ramdisk.sh
Created March 8, 2014 15:03
Creates a ramdisk and start Xcode with the DerivedData stored in ramdisk. Also deletes the ramdisk and reset Xcode prefs.
#!/bin/bash
# Creates a ramdisk and start Xcode with the DerivedData stored in ramdisk. Also deletes the ramdisk and reset Xcode prefs.
# xc_ramdisk.sh
# - creates a ramdisk, set Xcode DerivedData to this disk and start Xcode.
# - umount a ramdisk, set Xcode DerivedData to default
# Stephan Burlot, Coriolis Technologies, http://www.coriolis.ch
#
# based on Alex Shevchenko xcode_ramdisk.sh script (https://gist.github.com/skeeet/2367298)
# based on Diego Freniche xc-launch.sh script (https://github.com/dfreniche/xc-launch)
@angelolloqui
angelolloqui / AGCommand.h
Last active April 26, 2016 06:17
Example combining generic DataSources with the Chain Of Responsility command with custom command objects. DataSource can fully configure any table or collection view, and fires commands by calling the factory method on click. Code is taken from a real project where advance features have been implemented like customizable chain, cell animations, …
typedef enum {
AGCommandPriorityLow = -10,
AGCommandPriorityDefault = 0,
AGCommandPriorityHigh = 10
} AGCommandPriority;
@interface AGCommand : NSObject
@property(nonatomic, weak) NSObject *firingObject;
@property(nonatomic, readonly) SEL action;
@andymatuschak
andymatuschak / States-v3.md
Last active November 14, 2024 18:33
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,

#import <UIKit/UIKit.h>
typedef NS_ENUM(NSInteger, DBGInterfaceStyleOverride) {
DBGInterfaceStyleOverrideNone = 0,
DBGInterfaceStyleOverrideLight,
DBGInterfaceStyleOverrideDark,
};
#ifdef __cplusplus
extern "C" {
@RuiAAPeres
RuiAAPeres / opaqueEquivalent.swift
Last active February 18, 2020 07:50
Extension to provide an equivalent opaque UIColor to a UIColor with alpha channel. So: f(r,g,b,a) == (r,g,b,1)
import UIKit
public extension UIColor {
var components: (red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) {
var red: CGFloat = 0
var green: CGFloat = 0
var blue: CGFloat = 0
var alpha: CGFloat = 0
@IsaacXen
IsaacXen / README.md
Last active November 3, 2024 04:19
(Almost) Every WWDC videos download links for aria2c.
@jklausa
jklausa / xcode-curl.sh
Last active April 20, 2022 14:24
curl Xcode
#!/bin/bash
# Useful for downloading Xcode on machines where you don't want to log-in with your Apple ID (e.g. CI
# machines, or other low-trust environemnts).
# Requires you to manually log-in to the Apple Dev Portal, and extract contents of the ADCDownloadAuth cookie
# (easiest way to do it is using Web Inspector, going to the "Storage" Pane, selecting "Cookies" in the left sidebar,
# and copying the appropriate value.
#
# Usage:
# curl https://gist.githubusercontent.com/jklausa/5780d5126d97f73b70a91aeab58f7f4a/raw/ | bash -s -- XCODE-URL COOKIE_VALUE
@nicklockwood
nicklockwood / Shape.swift
Created December 31, 2022 18:56
PolymorphicCoding.swift
import Foundation
// Here's a pretty typical scenario where you want to encode a polymorphic type -
// in this case a Shape type that can be either a Square or Circle. Swift provides
// a nice pattern for doing this in a type-safe way using enums:
struct Circle: Codable {
var radius: Int
}