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 / DictBack.m
Created April 1, 2015 23:46
Backing ObjC class's properties with a dictionary automatically.
/*
* Demo of backing class properties with a dictionary instead of individual
* ivars.
*
* http://stackoverflow.com/questions/29158157/
*
* Created by Josh Caswell on 3/19/15.
* Released to the public domain on that date.
*/
@woolsweater
woolsweater / ClassyDelegate.m
Last active August 29, 2015 14:10
Class objects in id variables will respond to selectors that are the same as instance method names.
#import <Foundation/Foundation.h>
@interface Deleg : NSObject
+ (void)delegatorDidSomething;
- (void)delegatorDidSomething;
@end
@implementation Deleg
from random import Random
class IndependentRepeatableRandom(object):
def __init__(self):
self.randgen = Random()
self.origstate = self.randgen.getstate()
def random(self, val):
self.randgen.jumpahead(int(val))
@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 {