Skip to content

Instantly share code, notes, and snippets.

@tripleee
tripleee / git-wrapper
Last active September 11, 2022 12:29
git-wrapper to protect against accidental usage of a global user.email
#!/bin/sh
:<<'=cut'
=head1 NAME
git-wrapper - avoid committing as you@invalid
=head1 SYNOPSIS
@tripleee
tripleee / traceback
Last active July 21, 2022 01:43
make a shell command show a call trace on failure
#!/bin/sh
:<<'=cut'
=head1 NAME
traceback - make a shell command show a call trace on failure
=head1 SYNOPSIS
@tripleee
tripleee / bussar.html
Last active August 29, 2015 14:02
Matkahuolto Bookmarklet
<html>
<head><title>Matkahuolto Bookmarklet</title></head>
<body>
<h1>Bookmarklet Test</h1>
<p>
The unobvious part was that %C5bo in the query parameters had to be escaped as %25C5bo before this would work.
Symptoms in Firefox were that the Javascript became visible in the location bar but nothing happened.
</p>
<code> var d=new Date();
location.href='http://www.matkahuolto.info/lippu/sv/connectionsearch?stat=1' +
@tripleee
tripleee / bak+kab
Last active August 29, 2015 14:07
Create backups with successively more tildes
# Source this file
bak () {
# "local" is a Bashism -- comment out for POSIX
local f
for f; do
test -e "$f~" && bak "$f~"
mv "$f" "$f~"
done
}
@tripleee
tripleee / gist:93d9c4c152e99fa4d976
Last active August 29, 2015 14:17
Simple email regex test suite
#!/usr/bin/env python
# http://stackoverflow.com/questions/29264036/how-to-properly-escape-within-nested-parentheses-and-brackets
import urllib
import re
def tests ():
"""Download test suite; return a list of addresses to test with."""
tests_url = 'http://code.iamcal.com/php/rfc822/tests/tests.xml'
@tripleee
tripleee / pandoc.txt
Last active August 29, 2015 14:21
pandoc2 xubuntu 14.04 setup notes
xubuntu 14.04 live CD: location Ireland; Swedish keyboard
user era, password ... that one
install && reboot
reset download preference in Software & Updates to tut.fi
sudo apt-get install aptitude
-- https://github.com/CERNatschool/getting-started/wiki/Creating-a-Xubuntu-14.04-Virtual-Machine-with-VirtualBox
sudo aptitude install dkms
install virtualbox guest additions --
-- https://bugs.launchpad.net/ubuntu/+source/avahi/+bug/327362/comments/24
update /etc/default/avahi-daemon -- AVAHI_DAEMON_DETECT_LOCAL=0
@tripleee
tripleee / renumber-tables.el
Created June 10, 2015 12:10
Simple Emacs function to renumber tables in a document
(defun renumber-tables (n m)
"Renumber remaining tables starting with index N, adjust by M.
For example, `(renumber-tables 3 -1)` will renumber \"Table 3\" to
\"Table 2\", \"Table 4\" to \"Table 3\", etc."
(interactive "NStart at: \nNAdjust: ")
(save-excursion
(save-match-data
(while (re-search-forward "Table \\([1-9][0-9]*\\)" nil t)
(let ((i (string-to-number (match-string-no-properties 1))))
(when (>= i n)
@tripleee
tripleee / make-comment-fine.el
Created June 30, 2015 05:08
Comments in Make commands are fine
;; http://emacs.stackexchange.com/questions/7734/why-are-leading-spaces-colored-before-comments-in-makefile-mode
(setq makefile-font-lock-keywords
(delq (assoc "^\t+#" makefile-font-lock-keywords)
makefile-font-lock-keywords))
@tripleee
tripleee / activate.sh
Created July 2, 2015 07:24
activate function for virtualenv
# Add this to your .bash_profile or similar
activate ()
{
test -d "$1" && test -r "$1/bin/activate" && . "$1/bin/activate" && return;
echo "activate: $1 does not look like a valid virtualenv" 1>&2;
return 1
}
@tripleee
tripleee / screentitle.sh
Last active August 29, 2015 14:24
screentitle.sh - set window title in screen(1)
screentitle () { printf '\033k%s\033\' "$*"; }