Skip to content

Instantly share code, notes, and snippets.

View mattt's full-sized avatar
🌴
On vacation

Mattt mattt

🌴
On vacation
View GitHub Profile
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
static NSInteger NSJSONReadingFuckNSNulls = (1UL << 3);
@implementation NSJSONSerialization (FuckNulls)
+ (void)load {
Method originalMethod = class_getClassMethod(self, @selector(JSONObjectWithData:options:error:));
IMP swizzledImplementation = imp_implementationWithBlock([^id (id _self, NSData *_data, NSJSONReadingOptions _opt, NSError **_error){
NSInputStream *stream = [NSInputStream inputStreamWithData:_data];
[stream open];
@mattt
mattt / NSHipster-Call-For-Tricks-And-Tips.md
Created November 26, 2012 13:59
NSHipster Call for Tips & Tricks!

Howdy howdy, NSHipsters!

If you alloc init an NSCalendar, you'll notice that New Year's Eve falls on a Monday this year, a.k.a. "the day NSHipster is published every week". What fun!

So in celebration of the upcoming year++, I thought it'd be fun to compile a list of some of your favorite tips and tricks of the trade. Submit your favorite piece of 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!

Here are a few examples of the kind of things I'd like to see:

/** 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
@mattt
mattt / uiappearance-selector.md
Last active March 19, 2024 12:52
A list of methods and properties conforming to `UIAppearance` as of iOS 12 Beta 3

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep UI_APPEARANCE_SELECTOR ./*     | \
  sed 's/NS_AVAILABLE_IOS(.*)//g'     | \
  sed 's/NS_DEPRECATED_IOS(.*)//g'    | \
  sed 's/API_AVAILABLE(.*)//g'        | \
  sed 's/API_UNAVAILABLE(.*)//g'      | \
 sed 's/UI_APPEARANCE_SELECTOR//g' | \
@mattt
mattt / UIImageForSwatchOfColorWithSize.h
Created September 27, 2013 01:25
Create a UIImage swatch of a color with a specified size.
static UIImage * UIImageForSwatchOfColorWithSize(UIColor *color, CGSize size) {
UIImage *image = nil;
CGRect rect = CGRectMake(0.0f, 0.0f, size.width, size.height);
UIGraphicsBeginImageContext(rect.size);
{
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(c, [color CGColor]);
@mattt
mattt / alfred-wwdc.url
Last active September 25, 2018 10:01
Alfred ASCIIwwdc Web Search
alfred://customsearch/Search%20WWDC%20Sessions/wwdc/utf8/noplus/http://asciiwwdc.com/search?q={query}

Greetings, NSHipsters!

As we prepare to increment our NSDateComponents -year by 1, it's time once again for NSHipster end-of-the-year Reader Submissions! Last year, we got some mind-blowing tips and tricks. With the release of iOS 7 & Mavericks, and a year's worth of new developments in the Objective-C ecosystem, there should be a ton of new stuff to write up for this year.

Submit your favorite piece of 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!

Here are a few examples of the kind of things I'd like to see:

  • Using NSStringFromSelector(@selector()) as a safer way to do KVC / KVO / NSCoding.
  • Panic's [rather surprising discovery about the internals of the Lightning Digital AV Adapter](http://www.panic.com/blog/the-lightning-di
@mattt
mattt / Emoji.plist
Created December 30, 2013 17:26
Emoji grouped by category, as extracted by by private APIs on the iPhone simulator, via [Cédric Luthi](https://github.com/0xced).
<?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>People</key>
<array>
<string>😄</string>
<string>😃</string>
<string>😀</string>
<string>😊</string>
@mattt
mattt / NSRange-Conventional.h
Last active January 22, 2020 23:32
Re-declaration of existing `NSRange` functions and implementation of new functions to match conventions of comparable Foundation and Core Foundation types.
NS_INLINE NSRange NSRangeMake(NSUInteger loc, NSUInteger len) {
return NSMakeRange(loc, len);
}
NS_INLINE NSUInteger NSRangeMax(NSRange range) {
return NSMaxRange(range);
}
NS_INLINE BOOL NSRangeContainsLocation(NSUInteger loc, NSRange range) {
return NSLocationInRange(loc, range);