Skip to content

Instantly share code, notes, and snippets.

View zats's full-sized avatar

Sash Zats zats

View GitHub Profile
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];
@prabirshrestha
prabirshrestha / TextFieldChanges.m
Created August 2, 2012 13:53
Reactive Cocoa examples
@synthesize firstName = _firstName;
@synthesize txtFirstName = _txtFirstName;
[RACAbleSelf(self.firstName) subscribeNext:^(id x) { [self firstNameChanged:x]; }];
[self rac_bind:RAC_KEYPATH_SELF(self.firstName) to:self.txtFirstName.rac_textSubscribable];
- (void) firstNameChanged:(id)firstName {
NSLog(@"changed: %@", firstName);
}
@kristopherjohnson
kristopherjohnson / makeNewUUIDString-ARC.m
Created April 30, 2012 15:40
Create a new UUID string, ARC-compatible
+ (NSString *)makeNewUUIDString {
CFUUIDRef uuid = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, uuid);
CFRelease(uuid);
return (__bridge_transfer NSString *)(string);
}
@evandrix
evandrix / pep20_by_example.py
Created March 13, 2012 18:45
PEP 20 (The Zen of Python) by example
#!/usr/bin/env python
"""
=====================================
PEP 20 (The Zen of Python) by example
=====================================
Usage: %prog
:Author: Hunter Blanks, hblanks@artifex.org / hblanks@monetate.com
@0xced
0xced / NSData+Base64.h
Created February 24, 2012 15:03
NSData Base64 category
//
// Created by Cédric Luthi on 2012-02-24.
// Copyright (c) 2012 Cédric Luthi. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSData (Base64)
+ (id) dataWithBase64Encoding_xcd:(NSString *)base64String;
@0xc010d
0xc010d / ReCodeSign
Created November 14, 2011 22:38
Codesign an iOS app, with a different distribution certificate and mobileprovisioning file.
- Copy the delivered ipa into a directory to work in.
- export PlistBuddy="/usr/libexec/PlistBuddy" to get the PlistBuddy tool to your shell. If it is not added, all references to PlistBuddy
will need to be written as the full path.
- Take the delivered App.ipa and unzip it using the unzip command. This should produce a Payload directory containing the app and its
resources.
- Enter the command "codesign -d --entitlements :enterprise.plist Payload/PathToApp.app/" This pulls the entitlements out of the app, and
prints them to a plist, without a leading "blob" of data. Pay particular attention to the colon before the enterprise.plist file name.