Skip to content

Instantly share code, notes, and snippets.

import Foundation
/**
A decodable type that expects its data to be enclosed in a
keyed container.
For example, using JSON, a `User` object might be delivered
inside another object, with `"user"` as the key:
```
{ "user" : { "name" : "Alice", "rank" : "Colonel" } }
```
import Foundation
/**
A decodable type that expects its data to be enclosed in a
keyed container.
For example, using JSON, a `User` object might be delivered
inside another object, with `"user"` as the key:
```
{ "user" : { "name" : "Alice", "rank" : "Colonel" } }
```
@woolsweater
woolsweater / Package.swift
Created June 23, 2019 22:37
Attempted update to package manifest for SourceKittenDaemon
// swift-tools-version:5.0
import PackageDescription
var package = Package(
name: "SourceKittenDaemon",
dependencies: [
.package(url: "https://github.com/Carthage/Commandant.git", Version(0, 12, 0)..<Version(0, 15, .max)),
.package(url: "https://github.com/jpsim/SourceKitten.git", .upToNextMajor(from: "0.21.0")),
.package(url: "https://github.com/envoy/Embassy.git", .upToNextMajor(from: "4.0.0")),
@woolsweater
woolsweater / .lldbinit
Last active September 12, 2018 01:59
Break on unsatisfiable constraints and send to wtfautolayout
command script import ~/.lldbscripts/break_unsatisfiable.py
@woolsweater
woolsweater / WorkingCopyRetrieve.py
Last active March 12, 2018 10:18
Overwrite directory in Pythonista with Working Copy repo of the same name
import os
import sys
import urllib
from base64 import b64decode
from zipfile import ZipFile
from cStringIO import StringIO
from uuid import uuid4 as uuid
import editor
import console
@woolsweater
woolsweater / ifObjectImplicitCast.m
Last active December 27, 2015 06:39
Lowest sizeof(signed char) bits of an object pointer determine truth? No.
#if !__has_feature(objc_arc)
#define __unsafe_unretained
#define __bridge
#endif
int main(int argc, const char * argv[])
{
@autoreleasepool {
@woolsweater
woolsweater / PropInCat.m
Created July 11, 2013 19:49
Getting metadata for property in category.
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
@interface Rigby : NSObject
@end
@implementation Rigby
@end
@interface Rigby (Eleanor)
@woolsweater
woolsweater / DispatchQueueThreads.m
Created June 28, 2013 04:38
Background queues sometimes execute their blocks on the main thread.
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
dispatch_queue_t q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_sync(q, ^{
NSLog(@"Sync on main: %@", [NSThread isMainThread] ? @"YES" : @"NO");
@woolsweater
woolsweater / nowplaying.py
Last active December 12, 2015 12:39
Display recently played tracks on All Classical.
import sys
import urllib
import re
import argparse
from datetime import datetime, timedelta
from bs4 import BeautifulSoup
parser = argparse.ArgumentParser(description="Display recently played tracks on All Classical.")
parser.add_argument("-p", "--performer", action="store_true",
help="Include performer information in output")