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 / notify json
Last active September 11, 2017 05:14
JSON notify message for PostgreSQL
select pg_notify('json', row_to_json(x)::text) as notify
from (select 'hello world' as message, 42 as answer ) x;
@dirkjanfaber
dirkjanfaber / pgagent-mutt.sh
Last active August 29, 2015 14:11
pgagent mail job
#!/bin/bash
export PGSERVICE=database
[email protected]
(
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 / watchdog.ino
Last active January 3, 2019 08:19
A watchdog timer for ESP8266 (or just the Arduino). Based on the code of https://www.youtube.com/watch?v=D_7ciW_TCac
#include <Ticker.h>
Ticker secondTick;
#define debug 1
volatile int watchdogCount = 0;
void ISRwatchdog() {
watchdogCount++;
@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, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which