Skip to content

Instantly share code, notes, and snippets.

View dirkjanfaber's full-sized avatar

Dirk-Jan Faber dirkjanfaber

View GitHub Profile
@dirkjanfaber
dirkjanfaber / keybase.md
Created September 12, 2014 14:37
keybase

Keybase proof

I hereby claim:

  • I am steviethecat on github.
  • I am darthfaber (https://keybase.io/darthfaber) on keybase.
  • I have a public key whose fingerprint is 57A3 C702 31FD B663 83A0 B075 7F48 8EA4 4650 6D38

To claim this, I am signing this object:

@dirkjanfaber
dirkjanfaber / pgagent-mutt.sh
Last active August 29, 2015 14:11
pgagent mail job
#!/bin/bash
export PGSERVICE=database
MAILTO=user@example.com
(
cat <<__EOT__
<html>
<body>
<pre>
@dirkjanfaber
dirkjanfaber / scansnap-managers-settings.sh
Created May 27, 2015 11:47
Script for updating the save folder of a Scansnap manager preference. This ought to be run from cron.
#!/bin/bash
# This script takes care of changing the Scansnap Manager
# save folder every month. This script ought to be run from
# cron.
#
# Dirk-Jan Faber
ROOTSAVE=~/Documents/scan
SAVEDIR="${ROOTSAVE}/$(date +'%Y/%m')"
@dirkjanfaber
dirkjanfaber / traffic4hue.sh
Last active August 29, 2015 14:23
Light up my hue if there is a traffic jam
#!/bin/bash
# Some environment variables ought to be set
: ${BINGMAP_API_KEY?"You need to set the BINGMAP_API_KEY"}
: ${HUE_BRIDGE?"You need to set the HUE_BRIDGE"}
: ${HUE_KEY?"You need to set the HUE_KEY"}
# preperation for storing the temp file
temp_dir=/tmp/$RANDOM-$$
install -d -m 700 "$temp_dir" || { echo "failed to create temp_dir" >&2; exit 1; }
@dirkjanfaber
dirkjanfaber / encode-xerox-pin.pl
Last active August 29, 2015 14:24
Encode Xerox PIN code
#/bin/env perl
#
# Simple script for encoding a Xerox PIN code.
for (0 .. 3 ) {
my @c = split(//, qw/@ABCDEFGHI [ZYX_^]\\SR TUVWPQRS\\] UTWVQPSR]\\/[$_]);
print @c[(split(//, $ARGV[0]))[$_]];
}
print "\n";
@dirkjanfaber
dirkjanfaber / at.sh
Created December 4, 2015 13:30
Script for wrapping at in a function. This fixes the garbled time in most cases.
function at {
unset IFS
MOMENT=$*
AT=$(which at)
# First try at to see if I finally figured out to produce non-garbled time
if ${AT} ${MOMENT} 2>/dev/null
then
# worked allright, we can exit
exit
@dirkjanfaber
dirkjanfaber / in_arpa.sql
Created December 10, 2015 20:41
Returns the in.arpa address for a given inet address. Check https://en.wikipedia.org/wiki/Reverse_DNS_lookup for more info.
create or replace function in_arpa(inet)
returns text
language plpgsql
as
$function$
declare
p_return text;
begin
case family($1)
when 4 then
@dirkjanfaber
dirkjanfaber / display_thingspeak.c
Created July 6, 2016 19:34
Display the last entry of a certain field for a specific channel with c.
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
@dirkjanfaber
dirkjanfaber / ledblink.ino
Created July 6, 2016 19:58
blink a led on either an arduino or an esp8266 (with platform.io)
@dirkjanfaber
dirkjanfaber / strftime.c
Created September 1, 2016 08:48
Using LC_TIME with strftime
/*
* The manualpage of strftime notes:
* "The environment variables TZ and LC_TIME are used."
*
* What it does not say is that in order to get the locale
* to actually work in your program is that 2 things are
* needed in the code:
* #include <locale.h>
* and
* setlocale(LC_TIME, "");