Skip to content

Instantly share code, notes, and snippets.

@tianskylan
tianskylan / commit-msg
Created November 29, 2016 21:34
Prefix branch name to commit messages
#!/bin/sh
#
# Automatically adds branch name and branch description to every commit message.
# I made this a commit-msg hook to get it working with GitUp client. Otherwise, prepare-commit-msg hook should work as well.
#
# Usage:
# 1. Save this file in PROJECT_NAME/.git/hooks, with name `commit-msg`
# 2. chmod 755 commit-msg
# 3. Profit.
NAME=$(git branch | grep '*' | sed 's/* //')
@tianskylan
tianskylan / Flights.swift
Last active May 20, 2016 19:15
My initial take on a itinerary problem
struct Flight {
let fromCity: String
let toCity: String
}
let originCities = itinerary1.map { $0.fromCity }
let destinationCities = itinerary1.map { $0.toCity }
var travelLog: [String: Int] = [:]
@tianskylan
tianskylan / CellDecorationAndConfiguration.swift
Created April 25, 2016 02:22
An attempt of UICollectionViewCell Decoration and Configuration
import Foundation
import UIKit
// MARK: - Decorator and Configurator protocols
protocol Decorator {
associatedtype Decoratable
init(dependencyManager: VDependencyManager)
func decorate(cell: Decoratable)