Skip to content

Instantly share code, notes, and snippets.

View asmallteapot's full-sized avatar
😴
😴

Ellen Teapot asmallteapot

😴
😴
View GitHub Profile
@asmallteapot
asmallteapot / MonolithViewController.swift
Created September 12, 2015 03:56
Handling storyboard segues with enumerations in Swift
class MonolithViewController: UIViewController {
enum InnerSegueType {
case WebView
case Inspector
static func match(segue: UIStoryboardSegue, _ sender: AnyObject?) -> InnerSegueType? {
if segue.identifier == "WebView" {
return .WebView
}
if segue.identifier == "Inspector" {
@asmallteapot
asmallteapot / ASTRuntimeSynthesize.h
Last active August 29, 2015 14:27
Objective-C macro for synthesizing properties as associated objects. Useful primarily for properties declared in categories.
#import <objc/runtime.h>
#define ASTRuntimeSynthesize(T, GetterName, SetterName, AssociationType) \
- (T)GetterName {\
return objc_getAssociatedObject(self, @selector(GetterName));\
}\
- (void)SetterName(T)object {\
objc_setAssociatedObject(self, @selector(GetterName), object, AssociationType);\
}
@asmallteapot
asmallteapot / scrollback.sh
Created January 28, 2015 06:42
Scrollback before killing a rust build from source
rustc: x86_64-apple-darwin/stage1/lib/rustlib/x86_64-apple-darwin/lib/libfmt_macros
rustc: x86_64-apple-darwin/stage1/lib/rustlib/x86_64-apple-darwin/lib/libsyntax
rustc: x86_64-apple-darwin/stage1/lib/rustlib/x86_64-apple-darwin/lib/librbml
rustc: x86_64-apple-darwin/stage1/lib/rustlib/x86_64-apple-darwin/lib/librustc_llvm
rustc: x86_64-apple-darwin/stage1/lib/rustlib/x86_64-apple-darwin/lib/librustc_back
rustc: x86_64-apple-darwin/stage1/lib/rustlib/x86_64-apple-darwin/lib/librustc
^Cmake: *** [x86_64-apple-darwin/stage1/lib/rustlib/x86_64-apple-darwin/lib/stamp.rustc] Interrupt: 2
@asmallteapot
asmallteapot / gist:8621eaeb6d38f6173713
Last active August 29, 2015 14:13
Review of Amazon's pilot for a TV adaptation of "The Man in the High Castle"

I'm a big fan of the original "The Man in the High Castle" book and a resident of San Francisco. The city's portrayal is inconsistent with reality: there are no cable cars on Mission Street, and it does not have a view of the Golden Gate Bridge; and SFO/Hirohito Airport is south of the city, not north. This is incredibly distracting from what was otherwise a well-executed adaptation of one of my favorite books.

I did, however, appreciate the clever conceit of changing "The Grasshopper Lies Heavy" from a book to news reels. The metaphysical aspects of both the in-universe book/newsreel and the original book are fairly unique in both alternative history fiction and modern mass-audience television, and I hope to see these aspects explored in depth as the series continues (if picked up).

The opportunity educate viewers about our timeline's history should also not be missed. I would wager that many people my age couldn't name any of the important battles of World War II other than Pearl Harbor, and that very few

@asmallteapot
asmallteapot / install.sh
Created January 5, 2015 23:13
Parse CLI installation process as of 2015-01-05.
curl -s https://www.parse.com/downloads/cloud_code/installer.sh | sudo /bin/bash
@asmallteapot
asmallteapot / gist:0253be0b15e2ec317f37
Last active August 29, 2015 14:10
Macros for bolting some semblance of type safety onto NSArray.
#define VLMAssertArrayContainsItemsOfClass(A, T) for (id I in A) { NSAssert([I isKindOfClass:T], @"expected %@; got %@", T, [I class]); }
#define VLMAssertIdIsArrayContainingItemsOfClass(U, T) NSAssert([U isKindOfClass:[NSArray class]], @"expected array of %@; got %@", T, U); VLMAssertArrayContainsItemsOfClass(U, T);
@asmallteapot
asmallteapot / gist:28bfcf6d5b5c03311e87
Created July 8, 2014 02:36
Alfred.app custom search for OpenStreetMap.
alfred://customsearch/Search%20OpenStreetMap%20for%20%E2%80%9C%7Bquery%7D%E2%80%9D/osm/utf8/noplus/http://www.openstreetmap.org/search?query={query}
@asmallteapot
asmallteapot / bart.go
Last active August 29, 2015 14:03
Access the BART advisories API with Go.
package main
import (
"encoding/xml"
"net/http"
"code.google.com/p/go-charset/charset"
_ "code.google.com/p/go-charset/data"
)
@asmallteapot
asmallteapot / .gitattributes
Last active September 15, 2024 12:58
Diff Xcode localizable strings files in Git.
*.strings utf16 diff=localizablestrings
@asmallteapot
asmallteapot / gist:8551031
Last active January 4, 2016 01:49
How I envision share intents working on iOS.
  1. Apps that provide share intents register a child bundle with the system, containing:
    • The name of the intent
    • The icon for the intent
    • The type of content accepted
    • A binary containing XPC code
  2. Apps that use share intents simply provide sharable content; the system will automatically populate any UIActivityViewController instances with the relevant intents.
  3. When the user selects a share intent, UIActivityViewController loads the intent's bundle and calls an XPC function with the shared content (UIActivityItem, IIRC), a context in which to load/display any user interface elements, and a callback for when the sharing has completed
  4. When the share intent completes, it calls the callback provided by the system, allowing control to fully return to the parent app. Alternately, the system can kill it if the process hangs or times out.