Skip to content

Instantly share code, notes, and snippets.

View eonist's full-sized avatar
🎯
Focusing

André J eonist

🎯
Focusing
View GitHub Profile
function flatten(arr) {
return arr.reduce((acc, val) => acc.concat(Array.isArray(val) ? flatten(val) : val), []);
}
@eonist
eonist / String+HTML.swift
Created March 2, 2017 22:10 — forked from ollieatkinson/String+HTML.swift
Unescape HTML entities in Swift 3 == £ -> £
extension String {
func unescapeHTMLEntities() throws -> String {
guard contains("&#") else {
return self
}
guard let data = data(using: .utf8) else {
return self
@eonist
eonist / diff.mdown
Last active March 5, 2017 09:49 — forked from ndarville/diff.mdown
Paul Heckel's Diff Algorithm

oliveratkinson [12:50 AM] Paul Heckel's Diff Algorithm

[12:50]
http://dl.acm.org/citation.cfm?id=359467

eonist [12:53 AM] Instagram iOS dev interview question: How would you explain the “Paul Heckel's Diff Algorithm” to a child? go...

oliveratkinson [12:54 AM]

@eonist
eonist / TypeErasure.swift
Created March 11, 2017 10:48 — forked from russbishop/TypeErasure.swift
Type erasure with multiple adopting types
// Paste me into a playground!
import Cocoa
//: # Basic Setup
protocol FancyProtocol {
associatedtype Thing
func holdPinkyUp(x: Thing)
}
import Cocoa
// Only needed until we have class variables
var __SwizzleSayHello = { (who:String) -> String in
return "Hello, \(who)"
}
class Swizzle {
//Only needed until we have class variables
class var _sayHello : (String)->String { get{ return __SwizzleSayHello } set (swizzle) {__SwizzleSayHello = swizzle} }
@eonist
eonist / ProtocolAssociatedType.swift
Created March 27, 2017 17:47 — forked from troystribling/ProtocolAssociatedType.swift
A swift protocol with associated type used as type parameter in generic function
protocol Thing {
typealias argType
func doit(val:argType) -> argType
}
class IntThing : Thing {
func doit(val: Int) -> Int {
return val + 1
}
}