Skip to content

Instantly share code, notes, and snippets.

View armcknight's full-sized avatar
🏔️

Andrew McKnight armcknight

🏔️
View GitHub Profile
@armcknight
armcknight / ugh
Last active May 25, 2021 21:53
UGH - uncrustify git history
#!/bin/sh
# ugh.sh
#
#
# Created by Andrew McKnight on 11/27/14.
#
# UGH: uncrustify git history.
# Creates a new branch and cherry picks a range of commits, uncrustifying any modified .h/.m files.
@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 / install_xcode.sh
Last active February 26, 2021 22:35
Install Xcode via command line
#!/bin/sh
#
# install_xcode.sh
#
# Created by Andrew McKnight on 9/24/15
#
# takes a downloaded .dmg containing Xcode and installs it to a specified location/name, or defaults to /Applications and the DMG's filename
#
@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) {
@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 {
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 {