Skip to content

Instantly share code, notes, and snippets.

View madewulf's full-sized avatar
🤷‍♂️
Multitasking.

Martin De Wulf madewulf

🤷‍♂️
Multitasking.
View GitHub Profile
@madewulf
madewulf / gist:4ebec292b77db3dd4e3a
Created July 12, 2015 19:18
IAP receipt on device verification
- (void)paymentQueue:(SKPaymentQueue *)queue
updatedTransactions:(NSArray *)transactions
{
for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchased:
{
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSData *receipt = [NSData dataWithContentsOfURL:receiptURL];
NSDictionary *requestContents = @{
@madewulf
madewulf / gist:def19e6f3a2c2836318e
Last active August 29, 2015 14:19
Listing available fonts on iOS.
for (NSString * familyName in [UIFont familyNames])
{
NSLog(@"---------------- %@ ---------------", familyName);
for (NSString * fontName in [UIFont fontNamesForFamilyName:familyName])
{
NSLog(@"- %@", fontName);
}
}

I'm not 100% sure this is all accurate but:

It seems as though share extension predicates are a lot more specific than we originally thought. For example, if Instapaper declares support for only NSExtensionActivationSupportsWebURLWithMaxCount = 1, this means that activity controllers configured with a URL but also some other item types too, e.g. a string, won't show Instapaper.

So basically if you have multiple items in your activity items array, your controller will only show extensions that support all types. I imagine this would be extremely limiting, and as such, think the best option is to:

  • Only include a single provider in your items array. The provider would have a placeholder of a single type that will be provided to any activity or extension that isn't specifically accounted for
  • In the provider, specifically hardcode alternative item types for activities that need an alternative to the placeholder type:
    • "Copy" activity could use photo data, if present
  • "Mail" activity woul
@madewulf
madewulf / gist:3255752b28acd52a6bc4
Created June 9, 2014 18:40
Matchador App Store description jokes.
Testimonials:
------------
This is better than paying taxes!
-- A good friend
Best game that I ever played!
-- My Mom
It's so fun that I have a sudden need to kiss you
@madewulf
madewulf / gist:7907886
Created December 11, 2013 10:03
Mini CSV example
import csv
reader = csv.reader(open('file.csv', 'rU'))
for row in reader:
print row[0]
//
// CommonMacros.h
// Created by Tom Adriaenssen (@inferis)
//
/*
* How to use this file:
* 1. Find your .pch file
* 2. Import this file
* 3. Make sure to import this file after UIKit and Foundation

Contract Killer 3

Revised date: 07/11/2012

Between us [company name] and you [customer name]

Summary:

We’ll always do our best to fulfil your needs and meet your expectations, but it’s important to have things written down so that we both know what’s what, who should do what and when, and what will happen if something goes wrong. In this contract you won’t find any complicated legal terms or long passages of unreadable text. We’ve no desire to trick you into signing something that you might later regret. What we do want is what’s best for both parties, now and in the future.

#import <objc/runtime.h>
#import <objc/message.h>
#import <QuartzCore/QuartzCore.h>
#define PROPERTY(propName) NSStringFromSelector(@selector(propName))
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
#ifdef DEBUG
static void PSPDFSwizzleMethod(Class c, SEL orig, SEL new) {
@interface UIImage(ImmediateLoad)
+ (UIImage*)imageImmediateLoadWithContentsOfFile:(NSString*)path;
@end
@implementation UIImage(ImmediateLoad)
+ (UIImage*)imageImmediateLoadWithContentsOfFile:(NSString*)path {
UIImage *image = [[UIImage alloc] initWithContentsOfFile:path];
@madewulf
madewulf / gist:3149407
Created July 20, 2012 07:55
Readme migrationsmap.net
MigrationsMap.net
=================
This is the code of the site [http://migrationsmap.net](http://migrationsmap.net), including the scripts
used to generate the JSON data files.
The code is under MIT license.
Don't hesitate to contact me at [email protected], or via twitter: http://twitter.com/madewulf if you have