Skip to content

Instantly share code, notes, and snippets.

asalom /
Last active Apr 22, 2020
Alex Salom's tools & more
  1. iTerm 2
  2. Oh My Zsh
  3. Powerline shell: path bars, edit config and remove username and hostname
  4. Meslo Powerline Font as you need a font that supports the directory characters for powerline
  5. Homebrew
  6. RVM
  7. Bundler
  8. direnv: Unclutter your .profile
  9. z: quickly jump between projects. Like Alfred but for your Terminal reduced to folder search only
  10. echo "gem: --no-document" >> ~/.gemrc to stop installing docs every time you install a gem
asalom / commit-msg
Created Nov 27, 2018
Prefix every commit with the JIRA ticket, given that the ticket can be found in the current branch's name
View commit-msg
COMMIT_MSG=$(cat $1)
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
JIRA_ID=$(echo "$CURRENT_BRANCH" | grep -Eo "[A-Z0-9]{1,10}-?[A-Z0-9]+-\d+")
if [ ! -z "$JIRA_ID" ]; then
echo "JIRA ID '$JIRA_ID', matched in current branch name, prepended to commit message. (Use --no-verify to skip)"
View RVM use gemset
rvm use ruby-2.0.0@project_name --ruby-version --create
asalom / VersionNumber.swift
Created May 17, 2017
Compare version numbers for the format MAJOR.MINOR.REVISION in Swift
View VersionNumber.swift
public struct VersionNumber: Equatable, Comparable {
public let version: String
public init(version: String) {
self.version = version
// Returns 1 if lhs > rhs, -1 if lhs < rhs and 0 if lhs = rhs
private func compare(_ lhs: VersionNumber, _ rhs: VersionNumber) -> Int {
View ABTester.swift
public class ABTester {
public init() {}
/** Randomly chooses a weighted generic item from a list of item
- item: a weighted item
- more: more weighted items as a variadic parameter
- randomNumberGenerator: random number generator
- returns: the selected generic item
- discussion:
We force the first item to be provided so we ensure that we don't end up with an empty list of items
View String+Localizable.swift
public extension String {
public func localize(tableName tableName: String? = nil, bundle: NSBundle = NSBundle.mainBundle(), comment: String = "") -> String {
return NSLocalizedString(
tableName: tableName,
bundle: bundle,
value: "",
comment: comment)