Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am mattt on github.
  • I am mattt (https://keybase.io/mattt) on keybase.
  • I have a public key whose fingerprint is 58FC 9E3A 40F3 5F72 E402 F6C0 2755 0012 282D EB01

To claim this, I am signing this object:

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager.requestSerializer setAuthorizationHeaderFieldWithUsername:@"user" password:@"Pa55w0rd"]
NSURL *filePath = [NSURL fileURLWithPath:@"file://path/to/image.png"];
[manager POST:@"http://example.com/resources.json" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileURL:filePath name:@"image" error:nil];
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Success: %@", responseObject);
require 'open-uri'
require 'nokogiri'
year = 2014
doc = Nokogiri::HTML(open("https://developer.apple.com/videos/wwdc/#{year}/"))
doc.search("p.download").each do |download|
href = download.at("a").attr('href')
uri = URI(href)
uri.path = uri.path.split('/')[0...-1].join('/') + '/'
postfix operator ‽ {}
postfix func ‽ (value: Bool) -> Bool {
return arc4random_uniform(2) == 0
}
prefix operator ⸘ {}
prefix func ⸘ (value: Bool) -> Bool {
return value‽
}
@mattt
mattt / もじれつ.swift
Last active August 29, 2015 14:05
Terrible misuse of Swift literal convertibles to automatically create Hiragana transliteration of string value.
struct もじれつ: Printable {
let description: String
init(string: String) {
var mutableString = NSMutableString(string: string) as CFMutableString
if CFStringTransform(mutableString, nil, kCFStringTransformLatinHiragana, 0) == 1 {
self.description = mutableString as NSString
} else {
self.description = string
}
module Keats
module Phones
IPA_CONSONANTS = {
"B" => "b", # b - Lower-case B <be> voiced bilabial plosive
"CH" => "t\312\203", # tʃ - T-Esh ligature <cheese> voiceless postalveolar affricate
"D" => "d", # d - Lower-case D <dee> voiced dental or alveolar plosive
"DH" => "\303\260", # ð - Eth <thee> voiced dental fricative
"F" => "f", # f - Lower-case F <fee> voiceless labiodental fricative
"G" => "g", # g - Lower-case G <green> voiced velar plosive
"HH" => "h", # h - Lower-case H <he> voiceless glottal fricative
@mattt
mattt / rocket.md
Created May 27, 2015 15:49
Rocket: a hybrid approach to real-time cloud applications

This document was originally posted on 8/1/2013.

Rocket is a technique for building real-time functionality on top of REST web services that leverages web standards like [Server-Sent Events][SSE] and [JSON Patch][RFC6902]. Most importantly, it fits comfortably with how you're already building applications.

A Tale of Two Paradigms

Just as light can act as both a particle and a wave, so information can be thought as both a document and a stream.

Each approach has its particular strengths and weaknesses:

/** NSAssertionHandler - Object encapsulation of assertions
Copyright (C) 1995, 1997 Free Software Foundation, Inc.
Written by: Adam Fedor <fedor@boulder.colorado.edu>
Date: Apr 1995
This file is part of the GNUstep Base Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
static NSString * const CCErrorDomain = @"com.apple.commoncrypto.error";
static NSString * CCDescriptionForStatus(CCCryptorStatus status) {
static NSString * const _CCStatusDescriptions[] = {
[-kCCSuccess] = @"Operation completed normally.",
[-kCCParamError] = @"Illegal parameter value.",
[-kCCBufferTooSmall] = @"Insufficent buffer provided for specified operation.",
[-kCCMemoryFailure] = @"Memory allocation failure.",
[-kCCAlignmentError] = @"Input size was not aligned properly.",
[-kCCDecodeError] = @"Input data did not decode or decrypt properly.",
@mattt
mattt / nshipster-new-years-2015.md
Created November 25, 2014 19:38
NSHipster New Year's 2015

Season's Greetings, NSHipsters!

As the year winds down, and we take a moment to reflect on our experiences over the past months, one thing is clear: 2014 has been an incredible year professionally for Apple developers. So much has happened in such a short timespan, and yet it's hard to remember our relationship to Objective-C before Swift, or what APIs could have captivated our imagination as much as iOS 8 or WatchKit.

It's an NSHipster tradition to ask you, dear readers, to send in your favorite tips and tricks from the past year for publication over the New Year's holiday. This year, with the deluge of new developments—both from Cupertino and the community at large—there should be no shortage of interesting tidbits to share.

Submit your favorite piece of Swift or Objective-C trivia, framework arcana, hidden Xcode feature, or anything else you think is cool, and you could have it featured in the year-end blowout article. Just comment on this gist below!

If you're wondering about what to post, look to