Skip to content

Instantly share code, notes, and snippets.


George Lyon GeorgeLyon

View GitHub Profile
GeorgeLyon / Rebasing a chain of
Last active Sep 25, 2019
A simpler mechanism for rebasing a chain of commits
View Rebasing a chain of

Rebasing a chain of commits


The following uses some complex git commands, so it should be undertaken with caution. That said, the mechanisms involved are fairly straightforward so someone reasonably familiar with git should be able to follow along. While it is possible to mess up your local checkout, nothing below is destructive, and you should be able to reference all your original commits by hash were something to go wrong.


Let's say you are working on a big feature with changes A, B and C, which you want to merge incrementally. Initially your commit graph would look something like this:

View swift-ui-commandline-tool.swift
#!/usr/bin/env xcrun -sdk macosx swift
// Displays UI in an NSWindow which can interact with the commandline
// Usage: `echo "Bar" | ./swift-ui-commandline-tool.swift`
import Foundation
import SwiftUI
extension CommandLine {
static let input: String = { AnyIterator { readLine() }.joined() }()
GeorgeLyon / Git Worktree
Last active Oct 24, 2019
Git Worktree Overview
View Git Worktree

git worktree

What is it?

Git worktree it a git feature which allows you to checkout a single repository into multiple locations on your filesystem. It has a few rough edges, but if you follow a few simple rules it can be make context switching much easier than git's other mechanisms, such as stashing or switching branches. My folder structure will usually look something like this:

MyRepo/ master/ ← The original checkout, using something like git clone <repo url> master

View Binary Search using Range.swift
var range = 0...elements.count
while range.count > 1 {
let pivot = (range.lowerBound + range.upperBound)/2
if areInIncreasingOrder(elements[pivot], element) {
range = (pivot + 1)...range.upperBound
} else if areInIncreasingOrder(element, elements[pivot]) {
range = range.lowerBound...pivot
} else {
range = pivot...pivot
GeorgeLyon / Rust vs.
Last active Oct 14, 2019
A list of advantages Swift has over Rust
View Rust vs.

Note This is a little out of date. Rust has made some progress on some points, however many points still apply.


Progressive disclosure

Swift shares Rust's enthusiasm for zero-cost abstractions, but also emphasizes progressive disclosure. Progressive disclosure requires that language features should be added in a way that doesn't complicate the rest of the language. This means that Swift aims to be simple for simple tasks, and only as complex as needed for complex tasks.

The compiler works for you

You can’t perform that action at this time.