Skip to content

Instantly share code, notes, and snippets.

@stubbetje
stubbetje / audio.gpi
Created April 15, 2016 08:31
wave form from audio
#set output format and size
set term png size 320,180
#set output file
set output "audio.png"
# set y range
set yr [-1:1]
# we want just the data
tree file 4: 17679000 records
btree file 4: 17680000 records
btree file 4: 17681000 records
btree file 4: 17682000 records
btree file 4: 17683000 records
btree file 4: 17684000 records
btree file 4: 17685000 records
btree file 4: 17686000 records
btree file 4: 17687000 records
btree file 4: 17688000 records
@stubbetje
stubbetje / README.md
Last active August 29, 2015 14:13
script_path -- portable `readlink -f`

(source: ValveSoftware/steam-for-linux#3671 (comment))

@TcM1911 Determining the path of the script being invoked, in a fully portable (w.r.t. platforms) and completely reliable manner, even in the face of symlinks, is a tricky problem and all too easy to get wrong. The only bullet proof way of doing it, of which I'm aware, is provided below (assumes bash); could be prepended to any script needing this functionality.

Keybase proof

I hereby claim:

  • I am stubbetje on github.
  • I am stubbetje (https://keybase.io/stubbetje) on keybase.
  • I have a public key whose fingerprint is B20F 9E66 AD99 6AE0 27F3 5343 1D40 0EBE 161B A202

To claim this, I am signing this object:

@stubbetje
stubbetje / gist:b45b173ec10a5bc26d4a
Last active August 29, 2015 14:01
Calling COBOL from C with variable arguments
#include <stdio.h>
#include <stdarg.h>
/*
COBOL will be calling the function like this:
CALL "calling_c" USING BY REFERENCE
"d" & x"00"
"FOO" & x"00" WS-DEPTH-1 *> ws-depth-1 and ws-depth-2 are PIC 9(4) COMP-5
"BAR" & x"00" WS-DEPTH-2
request = (body,callback) ->
alert( body.toSource() )
class Robot
http: (url) ->
httpClient = {}
methods = [ 'get', 'post', 'put', 'del', 'head' ]
methods.forEach (method) ->
httpClient[ method ] = (body,callback) ->
request( {
@stubbetje
stubbetje / README.md
Created December 19, 2012 11:12
Installation notes of monitoring setup with graphite and statsd

Installation notes of monitoring setup with graphite and statsd

These are the notes for installing graphite and statsd.

To minimize system impact, all installations are done as a separate non-root user "mon". The resulting installation can be found in $HOME/graphite.

The only requirements that should be installed system wide are python and python-dev packages. Of course, the usual gcc chain should also be available

@stubbetje
stubbetje / .htaccess
Created March 7, 2012 11:54
RewriteBase problem with usage in multiple different directories
RewriteEngine On
RewriteBase /
RewriteRule ^SESS.{13}/(.*)$ $1 [L,QSA]
# all others, check if exists and if not, redirect to index.php (front controller)
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
@stubbetje
stubbetje / strace.sh
Created February 17, 2012 20:42
strace all running httpd processes for troubleshooting
#!/bin/bash
#strace -s2048 -f $(ps auxfww | egrep -- php.*--fpm | egrep -v egrep | cut -d' ' -f 4 | sed -e 's/^/-p/g')
strace -f $(ps auxfww | egrep [h]ttpd | awk '{print $2}' | sed 's/^/-p/g') 2>&1
@stubbetje
stubbetje / error_levels.php
Created July 8, 2011 14:14
Show what error levels are included in a given error_reporting() value
<?php
if( $_SERVER['argc'] === 1 ) {
printf(
'No error level specified as argument (%s <errorlevel>), using current error_reporting value...' . PHP_EOL
, $_SERVER['argv'][0]
);
$errorlevel = error_reporting();
} else {