Skip to content

Instantly share code, notes, and snippets.

//
// NSObject+BlockObservation.h
// Version 1.0
//
// Andy Matuschak
// andy@andymatuschak.org
// Public domain because I love you. Let me know how you use it.
//
#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
typedef enum _WRSideIdentifier {
kWRSideLeft = 1 << 0,
kWRSideRight = 1 << 1,
kWRSideBottom = 1 << 2,
kWRSideTop = 1 << 3
} WRSideIdentifier
@interface WRSides : NSObject
@qwzybug
qwzybug / build_settings.yml
Created September 8, 2011 19:35
Ruby script to build, tag, archive, and distribute an app and its dSYM file, in one fell swoop.
TF_API_TOKEN: <your TestFlight API token>
TF_TEAM_TOKEN: <your TestFlight team token>
TF_DISTRIBUTION: <name of distribution list to notify>
HOCKEY_APP_ID: <your HockeyApp public App ID>
HOCKEY_APP_TOKEN: <your HockeyApp API token>
DEVELOPER_PREFIX: <path to your developer directory, e.g., /Developer-4.2>
ARCHIVE_DIRECTORY: <path for saving archived builds>
@mmorey
mmorey / StyleSettings.plist
Created January 24, 2014 11:53
Style Settings for Objective-Clean
<?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>kRequireSpaceAfterMethodType</key>
<true/>
<key>kRequireSpaceAfterReturnType</key>
<false/>
<key>kRequireSpaceAfterColon</key>
<false/>
@mattt
mattt / regex.swift
Created August 11, 2014 18:08
Creating a regular expression object from a String literal
class Regex {
let pattern: String
let options: NSRegularExpressionOptions!
private var matcher: NSRegularExpression {
return NSRegularExpression(pattern: self.pattern, options: nil, error: nil)
}
required init(pattern: String, options: NSRegularExpressionOptions = nil) {
self.pattern = pattern
enum ComparisonOrdering: Int {
case Ascending = 1
case Descending = -1
case Same = 0
}
infix operator <=> { precedence 130 }
protocol CombinedComparable: Comparable, Equatable {
func <=>(lhs: Self, rhs: Self) -> ComparisonOrdering
}
@fwenzel
fwenzel / plex_restart.sh
Created April 26, 2012 03:17
Simple watchdog script to restart plex media server if it becomes unresponsive.
#!/bin/bash
# If plex is not running, don't do anything.
plex_running=`ps ax | grep "\./Plex Media Server" | awk '{ print $1 }' | wc -l`
if [ "$plex_running" -eq 1 ]; then
exit 0
fi
# Test Plex web interface. If it's dead, this'll time out in a few seconds.
curl -I -m 8 "http://localhost:32400/library/sections" > /dev/null 2>&1
@AlanQuatermain
AlanQuatermain / insert-bsd-header-snippet
Last active September 1, 2020 21:48
A TextMate snippet to create a BSD License header for your source file.
/*
* $TM_FILENAME
* ${1:`echo "$TM_FILEPATH" | awk -F"/" '{x=NF-1}{print $x}'`}
*
* Created by `id -P | awk -F ":" '{ print $8 }'` on `date "+%d/%m/%Y"`.
*
* Copyright (c) `date +%Y` ${2:$TM_ORGANIZATION_NAME}
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
- (void)loadDefaultSettings
{
NSMutableDictionary *defaults = [NSMutableDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Default-Settings" ofType:@"plist"]];
// other setup...
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithDictionary:defaults]];
}
- (void)resetDefaultSettings
@rnapier
rnapier / fix-xcode
Last active March 18, 2022 01:17
Links Xcode SDKs from the /SDKs directory (which you maintain yourself)
#!/usr/bin/python
# fix-xcode
# Rob Napier <robnapier@gmail.com>
# Script to link in all your old SDKs every time you upgrade Xcode
# Create a directory called /SDKs (or modify source_path).
# Under it, put all the platform directories:
# MacOSX.platform iPhoneOS.platform iPhoneSimulator.platform
# Under those, store the SDKs: