Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View AliSoftware's full-sized avatar

Olivier Halligon AliSoftware

View GitHub Profile
@AliSoftware
AliSoftware / ProtocolGenericsSelf.swift
Last active February 13, 2016 00:31
Use of "Self" vs "self" in "static var" + generic protocol implementation
protocol Fooable {
static var staticBigSelf: String { get }
static var staticSmallSelf: String { get }
var instanceBigSelf: String { get }
var instanceSmallSelf: String { get }
init()
}
extension Fooable {
static var staticBigSelf: String { return String(Self) }
@AliSoftware
AliSoftware / dict-release-crash.swift
Last active February 9, 2016 13:17
Crash with EXC_BAD_ACCESS on release
enum Crash: ErrorType { case Key(String) }
func kaboom(str: String) throws -> String {
throw Crash.Key(str)
}
// Crash with EXC_BAD_ACCESS, not every time but quite often
func test1() throws -> [String:[String]] {
return [
"foo": try [kaboom("test1a"), kaboom("test1b")]
]
@AliSoftware
AliSoftware / Coordinator.swift
Last active July 10, 2022 14:32
Coordinators & StateMachine - Concept
struct Coordinator {
let window: UIWindow
let navCtrl: UINavigationController?
func start() {
presentWelcomeScreen()
}
private func presentWelcomeScreen() {
let vc = WelcomeScreenViewController() // Instanciate from code, XIB, Storyboard, whatever your jam is

Keybase proof

I hereby claim:

  • I am AliSoftware on github.
  • I am aligatr (https://keybase.io/aligatr) on keybase.
  • I have a public key whose fingerprint is 172F 2268 1A5A BD88 4FFF D1B3 F6D2 6970 231A FBDE

To claim this, I am signing this object:

@AliSoftware
AliSoftware / GHDiff-HidePods.js
Last active February 13, 2017 11:40
Hide Pods/* related files in a GitHub diff page
// When you are in the diff page of a GitHub PR
// And want to hide all the Pods/* files in that diff page, use this:
// Paste that in your Web Inspector's console
var nodes = document.evaluate("//div[@class='file-header' and starts-with(@data-path,'Pods/')]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null );
for(i=0; i<nodes.snapshotLength; ++i) {
nodes.snapshotItem(i).parentNode.hidden = true
}
// Or even better, create a bookmark with this code for easy quick access:
@AliSoftware
AliSoftware / README-UIKonf17-Talk.md
Last active May 17, 2017 20:46
UIKonf talk - CodeGeneration in Swift - Links & Snippets

This is a reference of all the useful links to follow my UIKonf'17 talk on Code Generation in Swift

@AliSoftware
AliSoftware / keywords.md
Last active June 5, 2017 00:02
Introducing Role Keywords to Protocol Implementations

Introducing Role Keywords to Protocol Implementations to Reduce Code Errors

Introduction

This proposal enhances protocol safety at compile time by incorporating role keywords to discourage two categories of potential user errors. This proposal can be phased in first over time and language release.

@AliSoftware
AliSoftware / git-gerrit
Last active August 30, 2018 21:37
A "git squash" command to squash multiple commits into one automatically
#!/bin/bash
#####
#
# git-gerrit v1.1
# O. Halligon, 2017.08.18
#
#####
#
# Usage:
#
@AliSoftware
AliSoftware / morphing.swift
Created August 3, 2017 13:07
A simple demo of doing some morphing using CAShapeLayer & UIBezierPath
import UIKit
import PlaygroundSupport
// Create a view to display the result in playground
let view = UIView(frame: CGRect(x: 0, y: 0, width: 500, height: 500))
view.backgroundColor = .white
PlaygroundPage.current.liveView = view;
@AliSoftware
AliSoftware / SwiftCopying.swift
Last active August 18, 2021 19:41
TypeSafe copy()/mutableCopy() (NSCopying/NSMutableCopying) in Swift
import Foundation
//: Swift type-safe protocol versions of (Mutable)Copying
protocol SwiftCopying {
associatedtype NonMutableType = Self
func clone() -> NonMutableType
}
extension SwiftCopying where Self: NSCopying {
func clone() -> NonMutableType {
return self.copy() as! NonMutableType