Skip to content

Instantly share code, notes, and snippets.

View warrenburton's full-sized avatar

Warren Burton warrenburton

View GitHub Profile
@warrenburton
warrenburton / enumify.pl
Created March 14, 2014 10:34
converts a typical C style enum declaration into a corresponding switch/case block
#! /usr/bin/perl
#enumify.pl
#converts a typical enum declaration into a corresponding switch/case block
#e.g.
# typedef enum {
# Foo,
# Bar,
# Baz
@warrenburton
warrenburton / imageset-repair
Last active August 29, 2015 14:04
A command line tool for repairing Xcode xcasset sets which have gained a bunch of "unassigned image" warnings. Strips any dictionaries which have no "filename" reference from the images dictionary. Point it at the .imageset folder you wish to repair.
//
// main.m
// imageset-repair
//
// Created by Warren Burton on 25/07/2014.
// Create a new Xcode commmand line project and paste into main.m
// Use with a source control system
// May have unintended consequnces so you will want the ability to revert.
//
@warrenburton
warrenburton / spliticon.pl
Last active August 29, 2015 14:13
Down samples a base png at 3x to 2x and 1x and outputs 3 UIKit style named files usage: spliticon.pl masterfile.png
#! /usr/bin/perl
#usage spliticon.pl masterfile.png
#e.g masterfile.png at 90*60
#outputs 3 files into subdir spliticons of cwd
#spliticons/masterfile.png at 30*20
#spliticons/masterfile@2x.png at 60*40
#spliticons/masterfile@3x.png at 90*60
use File::Basename;
@warrenburton
warrenburton / generate_icons.sh
Last active December 23, 2015 13:56
Batch script for creating iOS icon sizes
#!/bin/bash
#Usage:
#generate_icons.sh /path/to/mastericon.png
#Assumes your master icon image is larger than 180px by 180px at least
i=0
sizes=(76 72 50 40 29 57 60 167)
@warrenburton
warrenburton / String+Substitution.swift
Last active May 31, 2016 19:18
String substitution utility - pass a dictionary of substitution values to a tagged string to globally replace. Supports basic looping
extension NSRange {
func toStringRange( string:String ) -> Range<String.Index>? {
guard location != NSNotFound else { return nil }
return string.startIndex.advancedBy(location)..<string.startIndex.advancedBy(location + length)
}
}
extension String {
/**
@warrenburton
warrenburton / generate_icns.sh
Created December 11, 2017 16:55
generate ICNS file from master PNG image
#!/bin/bash
#Usage:
#generate_icns.sh /path/to/mastericon.png
if [ $# -ne 1 ]; then
echo "error: $# arguments expected 1"
echo "usage: generate_icns.sh /path/to/mastericon.png"
exit 1
fi
@warrenburton
warrenburton / StoryBoardGUIDGenerator.swift
Created May 9, 2018 16:51
Generate the 3-2-3 pattern GUID used by an Xcode storyboard id attribute. Useful for templating.
import Foundation
class StoryBoardGUIDGenerator {
private let legalChars: [Character] = {
let lower = "abcdefghiklmnopqrstuvwxyz"
let upper = "ABCDEFGHIKLMNOPQRSTUVWXYZ"
let number = "0123456789"
let legal = lower+upper+number
return Array(legal)
@warrenburton
warrenburton / FindFile.swift
Last active June 9, 2018 10:11
Simple recursive file search utility.
import Foundation
/// An object to perform a case sensitive recursive directory search for a **file**
/// Will not enter packages/bundles
class FileFinder: NSObject {
private let filename: String
private let rootDirectory: String
var maxDepth: Int = 5
/// - parameter filename: File to find
@warrenburton
warrenburton / Uncrustify.cfg
Created June 25, 2018 14:32
Uncrustify.cfg for Objective-C
#
# Uncrustify Configuration File
# File Created With UncrustifyX 0.4.3 (252)
#
# Alignment
# ---------
## Alignment
@warrenburton
warrenburton / PrivacyPolicy.md
Last active November 5, 2018 15:06
Privacy Policy for DevSketch App

DevSketch Privacy Policy

2018-11-05

  1. DevSketch collects NO data from the user. All diagrams generated, remain within the owners document space.
  2. File access is only used for generating DevSketch diagrams on the users personal computer.
  3. In the event you contact Digital-Dirtbag for issues relating to DevSketch your email address is NOT stored. Any messages you receive will be directly related to the immediate conversation.