Skip to content

Instantly share code, notes, and snippets.

View Morse-Code's full-sized avatar

Christopher Morse Morse-Code

View GitHub Profile
import Foundation
class Box<T> {
let unbox: T
init(_ value: T) { self.unbox = value }
}
struct Notification<A> {
let name: String
}
dispatch_group_t group = dispatch_group_create();
dispatch_semaphore_t semaphore = dispatch_semaphore_create(10);
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
for (int i = 0; i < 100; i++)
{
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
dispatch_group_async(group, queue, ^{
NSLog(@"%i",i);
sleep(2);
dispatch_semaphore_signal(semaphore);
$ sudo apachectl stop
$ sudo launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/
  Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep -H UI_APPEARANCE_SELECTOR ./* | sed 's/ __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0) UI_APPEARANCE_SELECTOR;//'

UIActivityIndicatorView

@Morse-Code
Morse-Code / gist:5318508
Last active December 15, 2015 20:28 — forked from irace/gist:5216137
Using Core Data as a cache; handling store migrations.
/*
Core Data is great but automatic migrations can be tricky. Migrations can take a long time, which could
result in [your app being terminated](http://stackoverflow.com/questions/13333289/core-data-timeout-adding-persistent-store-on-application-launch)
if it is happening on the main thread during application launch. Performing migrations on a background
thread is also a [bad idea](http://stackoverflow.com/a/2866725/503916), meaning your application really
needs to be able to fully launch *without a Core Data stack whatsoever* in order to safely migrate.
This can be a huge change to make to an existing app.
If you're really only using Core Data as a cache, you don't actually *need* to perform a migration.
Simply check if the existing store is compatible with your managed object model and if so, delete
@Morse-Code
Morse-Code / UntoggleableSwitch.h
Last active December 15, 2015 20:28 — forked from irace/gist:5272146
Custom UISwitch subclass to control switch state programmatically.
@interface UntoggleableSwitch : UISwitch
@end
@Morse-Code
Morse-Code / gist:4122759
Created November 21, 2012 03:03 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@Morse-Code
Morse-Code / .gitignore
Created October 27, 2012 19:05 — forked from adamgit/.gitignore
.gitignore file for Xcode4 / OS X Source projects
#########################
# .gitignore file for Xcode4 / OS X Source projects
#
# NB: if you are storing "built" products, this WILL NOT WORK,
# and you should use a different .gitignore (or none at all)
# This file is for SOURCE projects, where there are many extra
# files that we want to exclude
#
# For updates, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#########################
@Morse-Code
Morse-Code / ReverseString.java
Created April 24, 2012 03:15 — forked from samterrell/ReverseString.java
Recursive String Reverse
public class ReverseString {
public static void main(String[] argv) {
String origString = argv[0];
System.out.println(origString);
System.out.println(reverse(origString));
}
public static String reverse(String str) {
if(str.length()<=1) return str;
@Morse-Code
Morse-Code / EE_RSS_Feed
Created April 24, 2012 03:09
Expression engine Itunes RSS feed
{exp:channel:entries channel="podcast" status="open"}
///***********************************************************************************
// This if statement doesn't work. content is shown for everyone no matter what
//*************************************************************************************
{if (group_id == "1" OR group_id == "7") && subscription_podcast != ""}
<item>
<title>{exp:xml_encode}{title}{/exp:xml_encode}</title>
<itunes:author>Lex and Terry</itunes:author>
<itunes:summary>{exp:xml_encode}{description}{/exp:xml_encode}</itunes:summary>