Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View malesch's full-sized avatar

Marcus Spiegel malesch

  • Bern, Switzerland
View GitHub Profile
@malesch
malesch / gist:e15b0bc814250777fae6
Last active August 29, 2015 14:19
Validation Git precommit hock
#!/bin/sh
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
@malesch
malesch / strip_trailing_whitespaces.sh
Last active August 29, 2015 14:10
Strip trailing whitespaces in project
#!/bin/bash
###########################################################
#
# Strip all trailing whitespaces and normalize line endings
# (\n [0x0A]).
#
# Due to RegEx problems with the standard sed under OS X I
# use gnu-sed. Install gnu-sed before, e.g. with brew:
# > brew install gnu-sed

Keybase proof

I hereby claim:

  • I am malesch on github.
  • I am malesch (https://keybase.io/malesch) on keybase.
  • I have a public key whose fingerprint is 28D7 772C DEA1 09B1 FE07 DC5C AEFA D7BF ADE2 2769

To claim this, I am signing this object:

@malesch
malesch / gist:4503984
Last active December 10, 2015 22:38
Wrapper for duplicity for backing up system files and user directories (with local exclusion configuration)
#!/bin/bash
#
# Perform a system backup and backups of the specified additional
# directories (ADD_DIRS).
# The additional directories are checked for the exclusion file
# '.backup-exclude-list', holding relative paths, line-by-line.
# Alternatively directories can be excluded by putting the file
# '.backup-ignore' in the corresponding location (sub-directries
# are also excluded from the backup).
@malesch
malesch / gist:3376712
Created August 17, 2012 07:26
Creation of RAID-1
> parted /dev/sda
> (parted) mklabel gpt
> (parted) mkpart primary 1 -1
> (parted) p
> parted /dev/sdb
> (parted) mklabel gpt
> (parted) mkpart primary 1 -1
> (parted) p
> mdadm --zero-superblock /dev/sda1 /dev/sdb1
@malesch
malesch / gist:1225683
Created September 18, 2011 22:50
XML formatter (glob aware)
#!/bin/bash
if [ $# == 0 ]
then
echo "Usage: xmlformat <file selector>"
echo "Examples: xmlformat test.xml"
echo " xmlformat foo*.xml"
fi
for filename in $*
do