Skip to content

Instantly share code, notes, and snippets.

View neilkimmett's full-sized avatar

Neil Kimmett neilkimmett

View GitHub Profile
@Sephiroth87
Sephiroth87 / ⦅╯°□°⦆╯
Created February 17, 2015 17:42
Swift flipping operator ⦅╯°□°⦆╯
let conversionMap: [Character: Character] = [
"\u{0021}" : "\u{00A1}",
"\u{0022}" : "\u{201E}",
"\u{0026}" : "\u{214B}",
"\u{0027}" : "\u{002C}",
"\u{0028}" : "\u{0029}",
"\u{002E}" : "\u{02D9}",
"\u{0033}" : "\u{0190}",
"\u{0034}" : "\u{152D}",
"\u{0036}" : "\u{0039}",
@pietbrauer
pietbrauer / Rakefile
Created April 14, 2015 12:02
Rake task for cleaning header comments from objc files
namespace :housekeeping do
desc "Remove all header-comments"
task :remove_header_comments do
["Classes", "Tests"].each do |directory|
files = Dir["./#{directory}/**/*"].select { |value| File.file?(value) }
files.each do |file|
lines_array = File.open(file).readlines
if lines_array.first.match(/^\/\//) && !lines_array.first.match(/^\/\/ DO NOT EDIT/)
text = lines_array.drop_while { |line| line.match(/^\/\/|^\n/) }
File.open(file, 'w') do |f|
@irace
irace / CenteringView.swift
Last active November 29, 2017 19:31
I’m building a complex new app entirely with programmatic Auto Layout. It only supports iOS 9 so that means `UIStackView` and `NSLayoutAnchor` exclusively. These two classes have been very handy thus far, in the spirit of composition over inheritance.
final class CenteringView: UIView {
// MARK: - Initialization
init(contentView: UIView) {
super.init(frame: .zero)
addSubview(contentView)
contentView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activateConstraints([
@KingOfBrian
KingOfBrian / PublicationCenter.swift
Last active February 4, 2022 11:49
PublicationCenter
//
// PublicationCenter.swift
//
// Created by Brian King on 5/17/16.
// Copyright © 2016 Raizlabs. All rights reserved.
//
import Foundation
/// PublicationCenter is an NSNotificationCenter style object that
@khanlou
khanlou / Enum+CaseCountable.swift
Created November 15, 2016 18:19
count and allValues on Int-based enums
protocol CaseCountable { }
extension CaseCountable where Self : RawRepresentable, Self.RawValue == Int {
static var count: Int {
var count = 0
while let _ = Self(rawValue: count) { count+=1 }
return count
}
struct APIError: NetworkError {
let json: JSON
let apiCode: Int?
let message: String?
let httpResponse: HTTPURLResponse