Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View armcknight's full-sized avatar
🏔️

Andrew McKnight armcknight

🏔️
View GitHub Profile
@armcknight
armcknight / gitpretty
Last active August 29, 2015 14:10
View pretty git history graph in less
#!/bin/sh
git log --graph --full-history --all --color \
--pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s"
@armcknight
armcknight / deploy_xcode.sh
Last active October 7, 2015 15:36
Broad remote deployment of Xcode using DSH
#!/bin/sh
#
# deploy_xcode.sh
#
# Created by Andrew McKnight on 9/24/15.
#
# takes a local copy of a downloaded Xcode .dmg and install_xcode.sh and copies them to a collection of remote machines, and runs the install script on each
#
@armcknight
armcknight / tmux-cheatsheet.markdown
Created October 23, 2015 23:35 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@armcknight
armcknight / checkout-all-repos.sh
Last active February 10, 2016 20:46
Checkout all repos in a Github organization
curl --silent -X "GET" "https://api.github.com/orgs/<org>/repos" -H "Accept: application/vnd.github.v3+json" -u <github-username>:<access-token> | grep ssh_url | awk '{ print $2 }' | tr -d \"\, | xargs -I {} git clone {} --recurse-submodules
@armcknight
armcknight / Swift headerdoc examples
Last active March 24, 2016 15:24
Shows examples of all the markdown and keywords available for Swift headerdoc
/**
General description of the thing being documented. You can use:
- markdown-style `backticks`
- [urls pointing to pages like this one, that really helped me make this (thanks!)](http://ericasadun.com/2015/06/14/swift-header-documentation-in-xcode-7/)
- HTML-style ascii codes (see copyright below)
# Headers
## work
@armcknight
armcknight / snapping-angle-first-attempt.swift
Created March 16, 2017 08:00
First attempt at snapping to angle intervals in Trgnmtry
public func snappedAngle(snappingAngle: Angle) -> Angle {
if snappingAngle.radians == 0 {
return self
}
let interval = Int(degrees / (snappingAngle.degrees / 2))
if interval == 0 {
return .zero
} else if interval == Int(360 / (snappingAngle.degrees / 2) - 1) {
extension String where Element: Strideable {
func fuzzyBinarySearchRecursive(lowerBound: Int = 0, upperBound: Int? = nil, query: Element) -> Int {
let resolvedUpperBound = upperBound ?? count - 1
if lowerBound == resolvedUpperBound {
return lowerBound
}
if lowerBound == resolvedUpperBound - 1 {
@armcknight
armcknight / snapping-angle-second-attempt.swift
Last active March 16, 2017 08:22
Second attempt at snapping to angle intervals in Trgnmtry. This one works, and runs in linear time.
extension String {
func indexOfClosestSorted(toValue value: Degree) -> Int {
var smallestDifference = last!
var closestIntervalAngleIdx = 0
for i in 0 ..< count {
let closestValueCandidate = self[i]
var difference = fabs(closestValueCandidate - value)
if difference == 0 {
@armcknight
armcknight / tag-icons.sh
Created April 2, 2017 03:08
Xcode app target icon tagging logic
XCODE_ICON_TAGGER_SCRIPT_MODE="$1"
function invoke_tagger() {
XCODE_ICON_TAGGER_TOOL_MODE="$1"
OPTIONAL_CUSTOM_ICON_TAG_TEXT="$2"
sh ${SRCROOT}/Vendor/XcodeIconTagger/tagIcons.sh \
$XCODE_ICON_TAGGER_TOOL_MODE \
${SRCROOT}/Trgnmtry/Assets.xcassets/AppIcon.appiconset \
$OPTIONAL_CUSTOM_ICON_TAG_TEXT
@armcknight
armcknight / method-signature-block-literal-antipattern.h
Last active April 3, 2017 03:31
Example of an Objective C method signature with a block parameter defined in literal syntax.
@interface MyClass
- (void)someMethodWithInput:(NSObject *__nonnull)input completion:(void(^__nullable)(NSObject *__nullable a, NSObject *__nullable b, NSObject *__nullable c))completion;
@end