Skip to content

Instantly share code, notes, and snippets.

View tmspzz's full-sized avatar

Tommaso Piazza tmspzz

View GitHub Profile
@tmspzz
tmspzz / aww.js
Last active August 29, 2015 13:56
// npm install jsdom
// present a random Aww jpg
// problem: /r/aww/random seems to update the URI on a timer, not per request
function aww_image(title, url, img){
this.title = title;
this.url = url;
this.img = img;
}
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "Itinerary API"
},
"host": "localhost",
"basePath": "/v1",
"produces": [
"application/json"
@tmspzz
tmspzz / rome.sh
Created August 18, 2015 11:39
Wrapper for Carthage dSYM Copy
#!/bin/bash -e
carthage $@
CARTHAGE_BIN_CACHES_DIR=~/Library/Caches/org.carthage.CarthageKit/binaries
ZM_FRAMEWORKS=( $(ls -d $CARTHAGE_BIN_CACHES_DIR/zm*/*/*) )
echo $ZM_FRAMEWORKS
DSYM_TARGET_DIR=`pwd`/Carthage/Build/iOS/
#!/usr/bin/python
import sys
if __name__ == "__main__":
try:
print sum(map(int, sys.argv[1:]))
except:
print "Works only with integers"
#!/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
@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 {
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 / 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
@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 / 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