Skip to content

Instantly share code, notes, and snippets.

Ian Dundas iandundas

Block or report user

Report or block iandundas

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@iandundas
iandundas / xcode-downloader.rb
Created Feb 21, 2017
Script for reliably downloading binaries (e.g. Xcode) from Apple's CDN
View xcode-downloader.rb
#!/usr/bin/env ruby
print "What is the URL of your Apple Downloads resource?\nURL:"
url = gets.strip
print "What is the ADCDownloadAuth cookie token:\nADCDownloadAuth: "
token = gets.strip
command = "aria2c --header \"Host: adcdownload.apple.com\" --header \"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\" --header \"Upgrade-Insecure-Requests: 1\" --header \"Cookie: ADCDownloadAuth=#{token}\" --header \"User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 10_1 like Mac OS X) AppleWebKit/602.2.14 (KHTML, like Gecko) Version/10.0 Mobile/14B72 Safari/602.1\" --header \"Accept-Language: en-us\" -x 16 -s 16 #{url} -d ~/Downloads"
@iandundas
iandundas / theme.swift
Last active Jul 3, 2016
Example of creating an App Theme using structs
View theme.swift
public protocol ThemeScheme{
var fonts: FontScheme {get}
var colours: ColourScheme {get}
}
public struct Theme: ThemeScheme{
public let fonts: FontScheme
public let colours: ColourScheme
View String+emoji.swift
// Returns a random Emoji 🌿
extension String{
func randomEmoji()->String{
let range = 0x1F601...0x1F64F
let ascii = range.startIndex + Int(arc4random_uniform(UInt32(range.count)))
let emoji = String(UnicodeScalar(ascii))
return emoji
}
}
@iandundas
iandundas / UIImagePickerController+cats.m
Created Mar 16, 2015
How to detect iOS Photo library or Camera permissions (>iOS8)
View UIImagePickerController+cats.m
//
// Created by Ian Dundas on 16/03/15.
//
#import "UIImagePickerController+cats.h"
#import <AVFoundation/AVFoundation.h>
#import "Photos/Photos.h"
/*
example usage:
@iandundas
iandundas / gist:697732f20a7fd6907bf9
Created Oct 15, 2014
How to make a POST in #AFNetworking
View gist:697732f20a7fd6907bf9
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *parameters = @{@"name": @"Ian"};
[manager POST:@"http://google.com"
parameters:parameters
success:^(AFHTTPRequestOperation *operation, id responseObject) {
// e.g. responseObject[@"user"];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
@iandundas
iandundas / gist:c952249d343a75350972
Last active Sep 11, 2018
How to get response body in an AFNetworking failure block #AFNetworking
View gist:c952249d343a75350972
// I can never, ever remember how to do this, so here's how:
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSData *data= error.userInfo[AFNetworkingOperationFailingURLResponseDataErrorKey];
NSString *failureResponse = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"Failure response: %@", failureResponse);
}
View 2014-04-09-introducing-tacks.markdown

#Introducing Tacks [first published 2014-04-09 13:18]

There's an app that I've been working on in my spare time, which I've actually been using personally for several months, but which I've not managed to pat together into an App store release.

It's a simple app based on something I needed each time I found myself in a new city when I was travelling: when you arrive, you constantly see lots of places you'd like to return to, and it would be super handy if you could just drop a pin there, add a short title and thus remember it for later. After a while, you'll see a map studded with interesting places that you yourself have added, and it's simple to find your way back later on. When you go to the next city, you start a new map, etc.

Inspired by Sam Soffes talking passionately about developing Cheddar on the Founders Talk podcast, I'm going to open-source this app and blog about its development

View gist:7863c6c248f76e14a3a8
# strip out iBooks citation
sed -E -e 's/^[ ]?[0-9]* //g' | sed -E -e 's/“[ ]?[0-9]?[ ]?//g' | sed -E -e 's/”$//g' | sed -E -e 's/^(Excerpt From).*//g'
View Gemfile
source 'https://rubygems.org'
gem 'nokogiri'
@iandundas
iandundas / new_gist_file
Created May 23, 2013
Get AutoLayout Debug Trace in #RubyMotion
View new_gist_file
printf UIWindow.keyWindow._autolayoutTrace
You can’t perform that action at this time.