Skip to content

Instantly share code, notes, and snippets.

@jwarby
jwarby / glu
Created November 11, 2014 07:09
View all unpushed commits (excluding merges)
git log --no-merges --author="`git config user.name`" `git rev-parse --abbrev-ref --symbolic-full-name @{u}`..HEAD
@jwarby
jwarby / git-duf
Last active February 11, 2019 15:45
Delete untracked files and folders from git repositories - place on your `$PATH` as `git-duf` and use as `git duf`
#! /bin/bash
#
# Delete untracked files in a git repository.
# https://gist.github.com/jwarby/697a81fe3941474b3509
#
# Options:
#
# -h, --help
# show usage information
# -f, --force
@jwarby
jwarby / recompile-less
Last active August 29, 2015 14:01
Recompile all LESS files in a specified directory
#! /bin/bash
#
# Recompiles all LESS files found (recursively) in the specified directory, e.g.
#
# [someome /public/css]$ recompile-less .
# or
# [someone /myapp]$ recompile-less public/css
find "$1" -name '*.less' | while read line; do
echo "Recompiling $line..."
REPLACE=`echo $line | sed "s|\.less|\.css|"`
@jwarby
jwarby / pdf-singleify
Last active August 29, 2015 14:01
Split PDFs which have 2-page spreads into 1-per-page PDF - usage ./pdf-singleify input.pdf output.pdf. Requires pdfinfo, ghostscript and pdftk
#! /bin/bash
file="$1"
function getDimensions() {
local page_size=`pdfinfo "$file" | grep "Page size"`
[[ $page_size =~ ([0-9\.]+)[[:space:]x]+([0-9\.]+) ]]
let page_width="${BASH_REMATCH[1]/.*} / 2"
let page_height="${BASH_REMATCH[2]/.*}"
let offset="-$page_width"
}
@jwarby
jwarby / ..s
Last active August 29, 2015 14:00
..s - change up to a parent directory by specifying it's name
#! /bin/bash
# Change to a directory higher in the tree by name.
#
# Usage:
# [someone@apc /var/www/mysite/mysubfolder] $ ..s www
# [someone@apc /var/www] $
#
function ..s() {
CUR_PATH=`pwd`