Skip to content

Instantly share code, notes, and snippets.

View caugner's full-sized avatar
💭
I may be slow to respond.

Claas Augner caugner

💭
I may be slow to respond.
  • Mozilla
  • Paris, France
  • 05:19 (UTC +02:00)
  • X @ClaasAug
View GitHub Profile
@caugner
caugner / git-fixup-per-file.sh
Last active June 18, 2018 07:42
`git commit --fixup` all changes per file to the last commit of the file
#!/usr/bin/env bash
gfxpf() {
git reset
for file in $(git ls-files --modified)
do
git add $file
git commit --fixup=$(git log -1 --pretty=format:%h $file)
done
}
### Keybase proof
I hereby claim:
* I am caugner on github.
* I am claasaug (https://keybase.io/claasaug) on keybase.
* I have a public key ASBWqNBZQNznG4rKSKlkmZcRQBEMfA48b-Ygrdj9ychEHgo
To claim this, I am signing this object:
### Keybase proof
I hereby claim:
* I am caugner on github.
* I am claasaug (https://keybase.io/claasaug) on keybase.
* I have a public key ASBQ69ueLmRHw5Gfg1Wg7p5CGAENouEwq5NzTszec0qRowo
To claim this, I am signing this object:
@caugner
caugner / agnoster.zsh-theme
Created September 14, 2017 20:30
prompt_hg()
prompt_hg() {
(( $+commands[hg] )) || return
local rev status
if $(hg root 2> /dev/null); then
if $(hg prompt >/dev/null 2>&1); then
if [[ $(hg prompt "{status|unknown}") = "?" ]]; then
# if files are not added
prompt_segment red white
st='±'
elif [[ -n $(hg prompt "{status|modified}") ]]; then
@caugner
caugner / trac-attachments-migrate-0.10-to-1.0.php
Created August 25, 2017 17:46
Migrate Trac 0.10 attachments to 1.0 attachments.
<?php
/**
* Migrates Trac 0.10 attachments to 1.0 attachments.
*
* Based on:
* - https://trac.edgewall.org/browser/branches/1.0-stable/trac/upgrades/db28.py
* - https://trac.edgewall.org/browser/branches/1.0-stable/trac/attachment.py
*/
if ($argc != 3) {
printf("USAGE: %s INPUT_DIR OUTPUT_DIR", $argv[0]);
@caugner
caugner / es6-templates-to-es5.php
Created July 27, 2017 11:52
Convert ES5 Template Literals to ES6 Strings
<?php
$file = isset($argv[1]) ? $argv[1] : null;
if (empty($file)) {
printf("USAGE: %s file.js", $argv[0]);
exit;
}
if (!is_file($file)) {
printf("ERROR: File does not exist: %s", $file);
}
@caugner
caugner / latex-bracket-depth.rb
Created February 22, 2017 22:41
Visualise bracket depth of a LaTeX document.
# Usage:
# $ cat file.tex | ruby latex-bracket-depth.rb
# $ echo "\textbf{ \textit{foobar} }" | ruby latex-bracket-depth.rb
# \textbf{1\111111{222222}1}
content = STDIN.read
len = content.size
level = 0
@caugner
caugner / git-cac.sh
Created February 9, 2017 11:22
A git commit alias to commit at time of last change.
#!/bin/bash
# cac = commit-at-changetime
alias git-cac=git commit --date="$(git ls-files --modified | xargs stat | grep "Modify: " | sort | tail -1 | awk '{gsub("Modify: ", "", $0); print $0}')"
@caugner
caugner / backup-ftp.sh
Created November 20, 2016 20:54
Secured parallel mirroring using lftp.
#!/bin/bash
if (( $# != 3 )); then
echo "Usage: $0 ftp.example.com ftp-user ftp-password"
exit 1
fi
SERVER=$1
USER=$2
PASS=$3
@caugner
caugner / nightly.desktop
Created July 31, 2016 00:06
A simple application menu entry for Mozilla Firefox Nightly.
[Desktop Entry]
Version=1.0
Name=Nightly
Exec=/opt/nightly/firefox %u
Icon=/opt/nightly/browser/icons/mozicon128.png
Terminal=false
Type=Application
MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https;
StartupNotify=true
Categories=Network;WebBrowser;