Skip to content

Instantly share code, notes, and snippets.

@paulscott
paulscott / git-lfs-candidates
Created December 6, 2019 23:05
A script to find files that aren't under git-lfs, but should be
#!/bin/bash
if [ "$#" != "1" ]; then
echo "$0 requires a size argument. ex: 100k."
exit 1
fi
sizeParam="+${1}"
filesOverSize=$( find . -size ${sizeParam} | grep -v /.git | sed 's/^.\///g' )
@paulscott
paulscott / git-prune-squashed
Created August 10, 2019 01:07
Utility to show squash-merged branches that should be pruned
#!/bin/bash
git for-each-ref refs/heads/ "--format=%(refname:short)" |
while read branch; do
mergeBase=$(git merge-base HEAD "${branch}" )
tree=$(git rev-parse "${branch}^{tree}")
tempCommit=$(git commit-tree "${tree}" -p "${mergeBase}" -m "_" )
if [[ $(git cherry HEAD "${tempCommit}") == "-"* ]]; then
echo "git branch -D ${branch}"
fi
@paulscott
paulscott / usage_example.sh
Created March 21, 2019 21:36
A simple way to output command usage for shell scripts
#!/bin/bash
# A one line description of what the command does
#
# Usage:
# commandName
# what this command does with no arguments
# commandName --argument [--optionalArg=value]
# what this command does with these arguments. one of them is optional.
#
@paulscott
paulscott / bash_colors
Created January 24, 2019 19:46
A colors utility - a guide and a tool
#!/bin/bash
color() {
out=""
saved_in="$@"
saved_in=${saved_in[@]//test} # remove the word 'test'
while [ "${1-}" != "" ]; do
PARAM=`echo $1 | awk -F= '{print $1}'`
VALUE=`echo $1 | awk -F= '{print $2}'`
@paulscott
paulscott / git-changelog2
Created January 24, 2019 19:45
generate a changelog from the git commit messages between the current branch and the most recent ancestor tag, or between two named refs
#!/bin/bash
# gives a changelog from the most recent tag to the current HEAD, with blank lines removed
currentHead='HEAD'
lastTag=$(git describe --tags --abbrev=0 2>/dev/null)
if [ -z "${lastTag}" ]; then
fromType="initial commit"
lastTag=$(git rev-list HEAD --max-parents=0 | cut -c 1-10)
fi

Code Of Conduct

1. Overview

Having been encouraged by clients to adopt a written code of conduct, the SQLite developers elected to govern their interactions with each other, with their clients, and with the larger SQLite user community in accordance with the "instruments of good works" from chapter 4 of The Rule of St. Benedict. This code of conduct has proven its mettle in thousands of diverse communities for over 1,500 years, and has served as a baseline for many civil law codes since the time of Charlemagne.

This rule is strict, and none are able to comply perfectly. Grace is readily granted for minor transgressions. All are encouraged to follow this rule closely, as in so doing they may expect to live happier, healthier, and more productive lives. The entire rule is good and wholesome, and yet we make no enforcement of the more introspective aspects.

Everyone is free to use the SQLite source code, object code, and/or documentation regardless of their opinion of and adherence to this rule. SQLite

@paulscott
paulscott / grap
Created November 7, 2018 23:47
grep all text files in the current directory and subdirectories, case insensitive
#!/bin/bash
argstring=${@}
grep -riI "$argstring" *
@paulscott
paulscott / git-contains
Created November 7, 2018 23:28
List the local and remote git branches and tags that contain a commit, branch, tag, or object
#!/bin/bash
if [ -z "$1" ]; then
echo 'usage: git contains <commit|object>'
exit 1
fi
if [ ! $(git rev-parse --is-inside-work-tree 2>/dev/null) ]; then
echo "fatal: Not a git repository"
exit 1
@paulscott
paulscott / git-changelog
Last active January 24, 2019 19:29
generate a very simple changelog between the current branch and it's build branch, or other named branch
#!/bin/bash
# gives a changelog from the last build branch to the feature branch
currentBranch=$(git rev-parse --abbrev-ref HEAD)
currentBranch=${currentBranch#"build/"}
buildBranch="build/${currentBranch}"
# if no args, $buildBranch..$currentBranch
# if one arg, $1..$currentBranch
@paulscott
paulscott / git-prune-gone
Created October 23, 2018 17:38
One-liner to prune local branches whose remote tracking branch has been deleted
git branch -vv | grep ': gone]' | cut -f 3 -d ' ' | xargs -n1 git branch -d