View remove-old-kernels-example.sh
## TL;DR
# Simulate purging all kernels apart from the two most recent ones:
dpkg-query -Wf'${binary:Package}\n' 'linux*-3.*.*-*' | sort -t. -k2 | head -n-8 | xargs apt-get -s purge
# Purge all kernels apart from the two most recent ones:
dpkg-query -Wf'${binary:Package}\n' 'linux*-3.*.*-*' | sort -t. -k2 | head -n-8 | xargs sudo apt-get -y purge
## Explanation
View npp
#!/bin/bash
# 9th July 2014
lang() {
lang=
if [ -f "$1" ]; then
# keep reading until $line non empty
# ':' means "Do Nothing"
while read line && [ -z "$line" ]; do :; done < "$1"
View unity.sh
#!/bin/bash
# 11th July 2014
UNITY="C:\Program Files\Unity\Editor\Unity.exe"
LOG="Library/ImportedPackages.txt"
usage() {
cat << EOF
A simple launcher and batch package importer for the Unity Editor
Download the editor from: http://unity3d.com
View trim
#!/bin/bash
for file in "$@"; do
TEMP=temp.$RANDOM
sed "s/\s*$//" "$file" | # Trim whitespace from ends of lines
cat -s | # Collapse consecutive blank lines into one
tr "\n" "\0" | # Replace new line characters with nulls
sed "s/\x0*$//" | # Trim nulls from the end
tr "\0" "\n" > "$TEMP" # Replace nulls with new line characters
View gist.md

Here's an example of how to embed a Gist on GitHub Pages:

{% gist 5555251 %}

All you need to do is copy and paste the Gist's ID from the URL (here 5555251), and add it to a gist tag surrounded by {% and %}.

View 25_pre-os-prober
#! /bin/sh
set -e
# Save the $timeout and $timeout_style values set by /etc/grub.d/00_header
# before /etc/grub.d/30_os-prober messes them up.
cat << EOF
set timeout_bak=\${timeout}
set timeout_style_bak=\${timeout_style}
EOF