Skip to content

Instantly share code, notes, and snippets.

View tmspzz's full-sized avatar

Tommaso Piazza tmspzz

View GitHub Profile
@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 / 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 / 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 / install-haskell-stack-arm.sh
Last active April 28, 2019 07:00
A scrip to install Haskell Stack and set up things properly on Raspbian
#!/bin/sh
# Update: As of March 24th 2017 this script won't work.
# The script at https://get.haskellstack.org/ is broken
# because the binary of Stack 1.4 for ARM is missing from https://www.stackage.org/stack/ .
# You can still get the binary for Stack 1.3.2 from
# https://github.com/commercialhaskell/stack/releases/download/v1.3.2/stack-1.3.2-linux-arm.tar.gz
# and place it at $USR_LOCAL_BIN/stack in your system.
# Once Stack is installed you can proceed with the Install LLVM step
@tmspzz
tmspzz / develop.rb
Last active January 18, 2022 09:37
An opinionated workflow for Carthage
#!/usr/bin/env ruby
# Copyright (c) 2016 Tommaso Piazza
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software
# and associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
# the Software.
@tmspzz
tmspzz / ListResult.swift
Last active March 3, 2016 01:16
ListResult<E,R> represents a series of computations that have succeeded or failed.
//
// ListResult.swift
//
// Created by Tommaso Piazza on 23/02/16.
import Foundation
import Swiftz
echo "************************"
echo "PRE ARCHIVE ACTION START"
echo "************************"
TARGET_DSYM=${DWARF_DSYM_FOLDER_PATH}/${PRODUCT_NAME}.app.dSYM
DWARF_DIR="Contents/Resources/DWARF"
for dSYM in "$DWARF_DSYM_FOLDER_PATH/"*.dSYM ; do
dSYM_NAME=`basename $dSYM`
@tmspzz
tmspzz / ParameterEncodingExt.swift
Last active October 24, 2017 10:43
Alamofire-GZIP-ParameterEncoding
// Actual gzipping from https://github.com/1024jp/NSData-GZIP
// Example: ParameterEncoding.JSON.gzipped
infix operator • { associativity left }
func • <A, B, C>(f: B -> C, g: A -> B) -> A -> C {
return { x in f(g(x)) }
}
extension ParameterEncoding {
#!/usr/bin/python
import sys
from operator import mul
if __name__ == "__main__":
try:
if len(sys.argv) > 1:
print reduce(mul, map(int, sys.argv[1:]), 1)
else:
print 0
#!/usr/bin/python
import sys
if __name__ == "__main__":
try:
print sum(map(int, sys.argv[1:]))
except:
print "Works only with integers"