Skip to content

Instantly share code, notes, and snippets.

Avatar

Jan Moesen janmoesen

View GitHub Profile
@janmoesen
janmoesen / .bash_profile
Created Aug 19, 2011
Temporary .bash_profile
View .bash_profile
# ============== shell
# Case-insensitive globbing.
shopt -s nocaseglob;
# Do not overwrite files when redirecting using ">", ">&" or "<>".
# Note that you can still override this with ">|".
set -o noclobber;
# UTF-8 all the way.
export LC_ALL='en_GB.UTF-8';
@janmoesen
janmoesen / gist:1286835
Created Oct 14, 2011
Word of the day in Bash
View gist:1286835
# Read a random word from the dictionary and try to get its definition from
# Merriam-Webster.
function word-of-the-day {
local file="${1:-/usr/share/dict/words}";
if ! [ -r "$file" ]; then
echo "Cannot read from dictionary file: $file" 1>&2;
return 1;
fi;
local IFS=$'\n' words=($(<"$file"));
local num_words=${#words[@]};
@janmoesen
janmoesen / switcheroo.sh
Created Nov 1, 2011
Atomic symlink switcheroo test script for GNU mv
View switcheroo.sh
#!/bin/bash
# Make a temporary directory for our little test.
mkdir linkage.tmp || exit $?;
cd linkage.tmp;
# Create two directories and a symlink to the first.
rm -rvf v1 v2 current;
mkdir v1 v2;
ln -s v1 current;
@janmoesen
janmoesen / twatspam.pl
Created Apr 19, 2012
Twatspam for Irssi: expand tweets in channels
View twatspam.pl
# == WHAT
# Expand the tweets mentioned in a channel, as well as the tweets those tweets refer to.
#
# == WHO
# Jan Moesen, 2012
#
# == INSTALL
# Place these files in `~/.irssi/scripts/`.
# /script load twatspam.pl
@janmoesen
janmoesen / sporza.sh
Created Sep 24, 2012
Download Sporza videos based on web page URL
View sporza.sh
#!/bin/bash
function log {
echo "$@" 1>&2;
}
for page_url; do
log "Now processing page: $page_url";
# Assemble the playlist URL. It is stored in two JavaScript properties in
# the HTML page.
@janmoesen
janmoesen / varDump.php
Created Oct 16, 2012
Get the output of var_dump() for better legibility
View varDump.php
<?php
/**
* Get the output of var_dump() for better legibility.
*
* @param mixed $arg1..N
*/
function getVarDump() {
$output = array();
@janmoesen
janmoesen / bookmarklets → search → maps → bike.js
Created Feb 3, 2013
New way to "parametrise" my bookmarklets now that E4X is dead everywhere.
View bookmarklets → search → maps → bike.js
/**
* Search Google Maps for a bicycle route.
*
* @title Google Maps (for cyclists)
*/
(function ride() {
/* Try to get the parameter string from the bookmarklet/search query. */
/* Fall back to the current text selection, if any. If those options
/* both fail, prompt the user. */
var s = (function () { /*%s*/ }).toString()
View utterly-useless.sh
function manneke {
:;:;:;:;:;:;:
:;:;:;:;:;:;:
<. :;:;:;:;:;:;:;:;:
[ ! ] ; [ ! ]
: :
: _ :
[ \_____/ ]
@janmoesen
janmoesen / over9000.sh
Last active Dec 20, 2015
Not sure if I can ever forgive myself for this, but here goes: "automatically" creating "useful" aliases for "cd ../../../" etc. See https://twitter.com/padolsey/status/364416098474541056
View over9000.sh
stack=('');
for i in {1..10}; do
printf -v alias_name '.%s' "${stack[@]}";
printf -v path '../%s' "${stack[@]}";
alias ".$alias_name"="cd $path";
stack+=('');
done
@janmoesen
janmoesen / camper-top-down-overview.js
Created Aug 21, 2013
Use this on http://www.camper.com/en_BE/men/shoes/shoe to change the thumbnails to the top-down view. Useful for people with wide feet.
View camper-top-down-overview.js
javascript: (function () {
// Use this on http://www.camper.com/en_BE/men/shoes/shoe to change the
// thumbnails to the top-down view. Useful for people with wide feet.
var images = document.querySelectorAll('img[src*="JGVzaG9wNiQ="]');
Array.prototype.slice.call(images).forEach(function (img) {
img.src = img.src.replace('_L.jpg', '_C.jpg');
});
})();