Skip to content

Instantly share code, notes, and snippets.

View futuretap's full-sized avatar

Ortwin Gentz, FutureTap futuretap

View GitHub Profile
/*
Maps.app uses its own custom marker annotations. Their icon is smaller (FB10143146), the title can be colored (FB9739380)
which is all pretty nice. Unfortunately, they’re not exposed as API. (Hence the feedbacks to expose them.)
Out of curiosity, I tried to hack around with MapKit to display them. Unfortunately, I didn’t succeed. Here’s what I tried:
I discovered _MKBalloonLabelMarkerView and its superclass _MKLabelMarkerView which might be the ones I’m looking for
(I might be wrong).
We can instantiate them using:
//
// XPathQuery.m
// FuelFinder
//
// Created by Matt Gallagher on 4/08/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
// Permission is given to use this source code file, free of charge, in any
// project, commercial or otherwise, entirely at your risk, with the condition
// that any redistribution (in part or whole) of source code must retain
@futuretap
futuretap / gist:69c6289e791b10b43fba
Created October 21, 2014 20:19
Download the last 12 months of Financial Reports from iTunes Connect (uses Apples Autoingestion tool)
#!/bin/bash
VENDORID=80012345
DATAFOLDER="${HOME}/Sales Reports"
CLASSPATH="${HOME}/bin"
ZVENDORID=`printf %.10d ${VENDORID}`
for i in 1 2 3 4 5 6 7 8 9 10 11 12; do
for REGION in "AE" "AU" "CA" "CH" "CN" "DK" "EU" "GB" "HK" "ID" "IL" "IN" "JP" "MX" "NO" "NZ" "RU" "SA" "SE" "SG" "TR" "TW" "US" "WW" "ZA" ; do
@futuretap
futuretap / NSDate+Additions.m
Created March 22, 2018 10:22
relative time formatter
- (NSString*)localizedRelativeTime {
NSDateComponentsFormatter *formatter = [[NSDateComponentsFormatter alloc] init];
formatter.allowedUnits = NSCalendarUnitHour | NSCalendarUnitMinute;
formatter.unitsStyle = NSDateComponentsFormatterUnitsStyleShort;
if (self.timeIntervalSinceNow < 60 && self.timeIntervalSinceNow > -60) {
return NSLocalizedString(@"right now", @"from MapKit/Maps");
} else if (self.timeIntervalSinceNow > 0) {
NSString *start = [formatter stringFromDate:NSDate.date toDate:self];
return [NSString stringWithFormat:NSLocalizedString(@"in %@", @"placeholder: minutes/hours"), start];
} else {
@futuretap
futuretap / WebViewController.m
Created November 8, 2010 17:11
Intercept mailto URLs in a UIWebView and send them to a MFMailComposeViewController
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if ([[[request URL] scheme] isEqualToString:@"mailto"]) {
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
mailViewController.mailComposeDelegate = self;
NSArray *rawURLparts = [[[request URL] resourceSpecifier] componentsSeparatedByString:@"?"];
if (rawURLparts.count > 2) {
return NO; // invalid URL
}
@futuretap
futuretap / UIResponder+FTAdditions.h
Created September 14, 2016 18:18
Block based interface to UIKeyCommand
//
// UIResponder+FTAdditions.h
// Streets
//
// Created by Ortwin Gentz on 09.05.16.
// Copyright © 2016 FutureTap. All rights reserved.
//
#import <UIKit/UIKit.h>
Pod::Spec.new do |spec|
spec.name = 'DTCoreText'
spec.version = '1.6.9'
spec.platform = :ios, '4.3'
spec.license = 'BSD'
spec.source = { :git => 'https://github.com/Cocoanetics/DTCoreText.git', :tag => spec.version.to_s }
spec.source_files = 'Core/Source/*.{h,m,c}'
spec.dependency 'DTFoundation/Core', '~>1.6.0'
spec.dependency 'DTFoundation/UIKit', '~>1.6.0'
spec.dependency 'DTFoundation/DTHTMLParser', '~>1.6.0'
pod --verbose install
Analyzing dependencies
Updating spec repositories
Updating spec repo `master`
$ /usr/bin/git pull
Already up-to-date.
Resolving dependencies of `Podfile`
@futuretap
futuretap / gist:6920492
Last active December 25, 2015 04:49
Logs iOS device color and device enclosure color. Attention: private API, do not use in App Store builds!
UIDevice *device = [UIDevice currentDevice];
SEL selector = NSSelectorFromString([device.systemVersion hasPrefix:@"7"] ? @"_deviceInfoForKey:" : @"deviceInfoForKey:");
NSLog(@"DeviceColor: %@ DeviceEnclosureColor: %@", [device performSelector:selector withObject:@"DeviceColor"], [device performSelector:selector withObject:@"DeviceEnclosureColor"]);
@futuretap
futuretap / createAllTestLocalizables.php
Created December 17, 2012 20:37
Script to create a Javascript hash out of all Localizable.strings files. Essential if you're using UIAutomation and want to address buttons etc. by localized title. More info: http://www.innoq.com/blog/phaus/2011/01/using_uiautomation_for_multila.html This is a slightly modified version of the script presented in the blog post that correctly dea…
<?php
//please replace with your settings...
$i18n_folder = "Custom/Resources";
$uiAutomationFolder = "Test/UIAutomationTests/lib";
if(substr($i18n_folder, -1) != "/"){
$i18n_folder.="/";
}
$langs = array();
$ihandle = opendir($i18n_folder);