Skip to content

Instantly share code, notes, and snippets.

View billbonney's full-sized avatar

Bill Bonney billbonney

  • Communis Tech Inc
View GitHub Profile
billbonney / pre-commit
Created August 24, 2021 20:23
swift-format git pre-commit hook
if which swift-format >/dev/null; then
git diff --diff-filter=d --staged --name-only | grep -e '\(.*\).swift$' | while read line; do
swift-format -m format -i "${line}";
git add "$line";
exit 0
echo "warning: swift-format not installed"
billbonney / .gitconfig
Last active July 27, 2023 07:03
gitconfig shortcuts and default settings
# .gitconfig with simple shortcuts for common actions
name = <>
email = <>
br = branch
ci = commit
billbonney / ColorPicker.swift
Last active April 3, 2018 02:13
Simple Color Picker UIView for iOS
// Copyright (c) 2018 Bill Bonney <>. All rights reserved.
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
billbonney / android_dev_studio.xml
Created March 18, 2015 05:27
Android Dev Studio Theme for Qt Creator
<?xml version="1.0" encoding="UTF-8"?>
<style-scheme version="1.0" name="Android Dev Studio">
<style name="Text" foreground="#a8b7c7" background="#2b2b2b"/>
<style name="Link" foreground="#009dff"/>
<style name="Selection" foreground="#000000" background="#a8b7c7"/>
<style name="LineNumber" foreground="#888888" background="#232323"/>
<style name="SearchResult" background="#555500"/>
<style name="SearchScope" background="#222200"/>
<style name="Parentheses" foreground="#f1d031" background="#0f5903" italic="true"/>
<style name="CurrentLine" background="#054100"/>
billbonney /
Last active November 9, 2021 23:24
How to fix master when it diverges using git

If your master branch of your fork has diverged from upstream master you can check your master by typing

git checkout master
git fetch upstream master
git merge --ff-only upstream/master # if this fails your master is not the same as upstream i.e. it won't fast-forward

To clean up your master try (Option 2 is simpler, Option 1 downloads less)

# (Option 1) Fix master from point of divergence
#WARNING: you will lose your changes to master
billbonney / ASwiftTour.playground.swift
Last active July 27, 2023 06:53
A Swift Tour - The Swift Programming Language - Solutions
// Copyright © 2023 Bill Bonney. All rights reserved.
// The Swift Programming Language: Swift by Tutorials (solutions)
// Author: Bill Bonney <billbonney (at)>
// This is all the code in The Swift Tour section in the Apple Book on Swift.
// This should allow you to play with the code and see behaviours, and help
// solve any paticulars you get stuck on when doing the Experiments.