Skip to content

Instantly share code, notes, and snippets.

View iandundas's full-sized avatar

Ian Dundas iandundas

View GitHub Profile
@iandundas
iandundas / new_gist_file
Created May 20, 2013 04:44
Convert files to Unix line endings
find * -name "*.js" -print0 | xargs -0 /usr/bin/dos2unix
find * -name "*.css" -print0 | xargs -0 /usr/bin/dos2unix
find * -name "*.htm" -print0 | xargs -0 /usr/bin/dos2unix
find * -name "*.html" -print0 | xargs -0 /usr/bin/dos2unix
find * -name "*.php" -print0 | xargs -0 /usr/bin/dos2unix
#etc
#where /usr/bin/dos2unix is:
#!/bin/sh
@iandundas
iandundas / new_gist_file
Created May 20, 2013 04:43
Catch-all Redirect .htaccess
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.gamehorizonconference.com/ [R=301,L]
</IfModule>
@iandundas
iandundas / new_gist_file
Created May 20, 2013 04:42
NSJSONSerialization usage
NSDictionary *data = [NSDictionary dictionaryWithObjectsAndKeys:@"Object", @"Key" , nil];
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:data options:0 error:nil]; // can give option NSJSONWritingPrettyPrinted
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
@iandundas
iandundas / new_gist_file
Created May 20, 2013 04:41
Format Specifiers for NSDateFormatter
NSDateFormatter specifiers:
a: AM/PM
A: 0~86399999 (Millisecond of Day)
c/cc: 1~7 (Day of Week)
ccc: Sun/Mon/Tue/Wed/Thu/Fri/Sat
cccc: Sunday/Monday/Tuesday/Wednesday/Thursday/Friday/Saturday
d: 1~31 (0 padded Day of Month)
D: 1~366 (0 padded Day of Year)
@iandundas
iandundas / new_gist_file
Created May 20, 2013 04:41
NSString format specifiers
// Format specifiers:
%@ NSString*
%d Signed Integer
%i Signed Integer
%u Unsigned Integer
%f Float / Double
%x Hexidecimal Integer
%X Hexidecimal Integer
%o Octal Integer
%zu size_t
@iandundas
iandundas / new_gist_file
Created May 20, 2013 04:40
NSDateComponents example
NSDate *today = [NSDate date];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
[gregorian setLocale:[NSLocale currentLocale]];
NSDateComponents *nowComponents = [gregorian components:NSYearCalendarUnit | NSWeekCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit fromDate:today];
[nowComponents setWeekday:2]; //Monday
[nowComponents setHour:0]; //1 a.m.
[nowComponents setMinute:0];
[nowComponents setSecond:0];
@iandundas
iandundas / new_gist_file
Created May 20, 2013 04:40
Node.js hot reload
/*
* This file is part of the Spludo Framework.
* Copyright (c) 2009-2010 DracoBlue, http://dracoblue.net/
*
* Licensed under the terms of MIT License. For the full copyright and license
* information, please see the LICENSE file in the root folder.
*/
var server_filename = "server.js";
@iandundas
iandundas / new_gist_file
Created May 20, 2013 04:39
Inspect Javascript Object
/* inspect a javascript object
http://codeinthehole.com/writing/inspecting-javascript-objects/
Usage: Inspect.properties(variable);
Inspect.methods(variable);
*/
var Inspect = {
TYPE_FUNCTION: 'function',
// Returns an array of (the names of) all methods
methods: function(obj) {
@iandundas
iandundas / gist:697732f20a7fd6907bf9
Created October 15, 2014 15:53
How to make a POST in #AFNetworking
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) {

#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