Skip to content

Instantly share code, notes, and snippets.

View tmspzz's full-sized avatar

Tommaso Piazza tmspzz

View GitHub Profile
@tmspzz
tmspzz / cv.md
Last active May 12, 2021 07:54
My CV in Markdown

Tommaso Piazza

I have developed applications for iOS since iOS 3, as a hobby, in academia and professionally. During my tenure as an engineering lead, I had the pleasure to help teams succeed, building a strong engineering culture along the way.

My list of competences include:

  • Objective C, Swift, Python, Ruby, C, Java
  • Haskell, Scala
  • Cocoa, Cocoa Touch, Foundation, UIKit, Cocos2D
@tmspzz
tmspzz / Tutple-unsplatting-SE-0110.md
Last active June 2, 2017 19:26
Add Tuple unsplatting - Removed by SE-0110

Add Tuple unsplatting

As a side effect of SE-0110 tuple unsplating was removed from the language.

While this claims to make tooling like the type checker faster, it deals quite a blow to expressivity.

Filterting dictionaries is just an example and maybe not the best. However I hope the point gets across. Let's compare to other languages.

Examples of pattern matching in closure parameters:

Swift

@tmspzz
tmspzz / NRFileManager.swift
Last active August 27, 2024 20:29
A method to calculate the accumulated size of a directory on the volume in bytes.
public extension FileManager {
/// This method calculates the accumulated size of a directory on the volume in bytes.
///
/// As there's no simple way to get this information from the file system it has to crawl the entire hierarchy,
/// accumulating the overall sum on the way. The resulting value is roughly equivalent with the amount of bytes
/// that would become available on the volume if the directory would be deleted.
///
/// - note: There are a couple of oddities that are not taken into account (like symbolic links, meta data of
/// directories, hard links, ...).
@tmspzz
tmspzz / Rakefile
Created July 11, 2017 16:06
Download HLint via a Rake task
# @example
#
# rake hlint:install[2.0.9]
namespace :hlint do
desc "Download and install hlint"
task :install, :version do |task, args|
REPO = "https://github.com/ndmitchell/hlint"
VERSION = args[:version].to_s
@tmspzz
tmspzz / CodableRawTypeEnum.swift
Last active February 1, 2018 21:37
Decodable Conformance of Enum backed with RawType Struct conforming to ExpressibleByStringLiteral
import Foundation
public struct Bar: Codable {
let value: String
public init(bar: Bar) {
self.value = bar.value
}
import Foundation
public struct CaseInsensitiveString: Codable {
let value: String
public init(caseInsensitiveString: CaseInsensitiveString) {
self.value = caseInsensitiveString.value
}
@tmspzz
tmspzz / Color.swift
Last active June 12, 2019 09:19
Dynamic Member Lookup Colors
@dynamicMemberLookup
struct Color {
subscript(dynamicMember member: String) -> UIColor {
guard let intValue = Int(member.dropFirst().dropFirst(), radix: 16) else { return .black }
return UIColor(hexValue: intValue)
}
@tmspzz
tmspzz / TrieCleanup.swift
Last active October 10, 2019 22:42
PrefixTrie Cleanup
public struct PrefixTrie<Key: Collection, Value> where Key.Element: Hashable {
internal class Node {
var value: Value?
var step: Key.Element?
var next = [Key.Element: Node]()
var parent: Node?
init(value: Value?, step: Key.Element? = nil, parent: Node? = nil) {
self.value = value
self.parent = parent
@tmspzz
tmspzz / awesome_macOS_dev_tricks.md
Last active February 15, 2022 09:06
A list of tricks useful when developing on macOS

A list of tricks useful when developing on macOS

Git & Github

$ git credential-osxkeychain erase
host=github.com
protocol=https
> [Press Return]
@tmspzz
tmspzz / UUID+UInt64.swift
Created April 14, 2020 09:07
UUID from and to two UInt64
extension UUID {
init(numbers: (UInt64, UInt64)) {
var firstNumber = numbers.0
var secondNumber = numbers.1
let firstData = Data(bytes: &firstNumber, count: MemoryLayout<UInt64>.size)
let secondData = Data(bytes: &secondNumber, count: MemoryLayout<UInt64>.size)
let bytes = [UInt8](firstData) + [UInt8](secondData)
let tuple: uuid_t = (bytes[0], bytes[1], bytes[2], bytes[3],