This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Exits with error if there are uncommitted changes. | |
# This can be used as follows: | |
# $ ./git-safeguard.sh && <other commands> | |
# to only execute the other commands if there are no changes. | |
if [[ $(git status -s) ]]; then | |
echo "There are uncommitted changes:" | |
git status -s | |
exit 1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol MyFancyProtocol { | |
func requiredFunction() -> String | |
func optionalFunction() -> String | |
} | |
extension MyFancyProtocol { | |
func optionalFunction() -> String { | |
return "Default implementation of optionalFunction" | |
} | |
func nonProtocolFunction() -> String { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// (Swift 3) | |
// Given a number of functions that all have the signature () -> T? | |
// I want to try each of them, until I have a result (i.e. a non-optional). | |
// For instance: | |
let f1: () -> Int? = { _ in nil } | |
let f2: () -> Int? = { _ in nil } | |
let f3: () -> Int? = { _ in 2 } | |
let f4: () -> Int? = { _ in 3 } | |
// You could of course do the following: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Toine Heuvelmans, November 2016 | |
# A small script that helps you removing Xcode-related data. | |
# This can potentially save many Gigabytes. | |
# Just run `ruby xcode_cleanup.rb`. | |
require 'fileutils' | |
require 'date' | |
require 'rubygems' |