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 bash | |
set -eu | |
removeLines() { | |
for i in $(seq ${1}); do | |
echo -en "\r\033[A\033[1K" | |
done | |
} | |
echo -e "first line\nmuch longer second line - enough to wrap maybe" |
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
guard let response = readLine(stripNewline: true) else { | |
fatalError("Expecting input!") | |
} | |
let withoutSpaces = response.characters.filter { $0 != " " } | |
let length = withoutSpaces.count | |
let minRows = Int(floor(sqrt(Double(length)))) | |
let columns = minRows * minRows >= length ? minRows : minRows + 1 | |
var output = "" |
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
public struct SourceLocation: CustomDebugStringConvertible { | |
init(file: String = __FILE__, line: Int = __LINE__, column: Int = __COLUMN__, function: String = __FUNCTION__) { | |
self.file = file | |
self.line = line | |
self.column = column | |
self.function = function | |
} | |
public let file: String | |
public let line: Int |
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
[alias] | |
swap-last-two-commits = "!f() {\n\ | |
set -eu \n\ | |
if [ ! -z \"`git diff HEAD`\" ]; then \n\ | |
echo \"Found uncommited changes... exiting.\" 1>&2 \n\ | |
exit 1 \n\ | |
fi \n\ | |
HEAD_0=\"$(git rev-parse --verify HEAD)\" \n\ | |
HEAD_1=\"$(git rev-parse --verify HEAD~1)\" \n\ | |
echo \"swapping ${HEAD_0} and ${HEAD_1}\" \n\ |
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
import Nimble | |
import Quick | |
public func errorOf<T>(expression: () throws -> T?) -> ErrorType? { | |
do { | |
try expression() | |
} | |
catch { | |
return error | |
} |
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
// | |
// NSArray+MergeSorted.h | |
// NSArray Merge Sorted Category | |
// | |
// Created by Andrew Bennett on 31/05/12. | |
// Copyright (c) 2012 Andrew Bennett. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
NewerOlder