Skip to content

Instantly share code, notes, and snippets.

View janmoesen's full-sized avatar

Jan Moesen janmoesen

View GitHub Profile
<?php
/**
* Script to Make Afvalophalingskalender Great Again for Ivago (the municipal
* waste management company for Ghent, Belgium):
* - make events last all day (so they appear on top of the calendar on
* Google Calendar, for instance)
* - do not use ALL CAPS for event summaries
*
* 1. Go to https://www.ivago.be/nl/particulier/afval/ophaling
* 2. Download the ICS for your street.
@janmoesen
janmoesen / override-ssh-for-identities.sh
Created October 23, 2013 08:00
Override "ssh" to specify IdentityFile based on the host, but not in ~/.ssh/config. See http://serverfault.com/questions/450796/how-could-i-stop-ssh-offering-a-wrong-key/450807 for some background. Not really tested. Also, this is very naive and assumes your host does not appear in the other arguments.
# A wrapper for "ssh" to avoid having multiple keys sent. Leave the
# IdentityFile options out of your host sections in ~/.ssh/config. This
# function adds them based on the arguments.
function ssh {
local new_args=();
local arg;
for arg; do
if [ "$arg" = 'purplepixelhost' ]; then
new_args+=(-i ~/.ssh/purplepixelhost.id_rsa);
elif [ "$arg" = 'qiwib0xorz' ]; then
@janmoesen
janmoesen / camper-top-down-overview.js
Created August 21, 2013 12:12
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.
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');
});
})();
@janmoesen
janmoesen / over9000.sh
Last active December 20, 2015 15:59
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
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
function manneke {
:;:;:;:;:;:;:
:;:;:;:;:;:;:
<. :;:;:;:;:;:;:;:;:
[ ! ] ; [ ! ]
: :
: _ :
[ \_____/ ]
@janmoesen
janmoesen / bookmarklets → search → maps → bike.js
Created February 3, 2013 14:10
New way to "parametrise" my bookmarklets now that E4X is dead everywhere.
/**
* 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()
@janmoesen
janmoesen / varDump.php
Created October 16, 2012 12:04
Get the output of var_dump() for better legibility
<?php
/**
* Get the output of var_dump() for better legibility.
*
* @param mixed $arg1..N
*/
function getVarDump() {
$output = array();
@janmoesen
janmoesen / sporza.sh
Created September 24, 2012 13:03
Download Sporza videos based on web page URL
#!/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 / twatspam.pl
Created April 19, 2012 21:03
Twatspam for Irssi: expand tweets in channels
# == 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 / switcheroo.sh
Created November 1, 2011 22:14
Atomic symlink switcheroo test script for GNU mv
#!/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;