Skip to content

Instantly share code, notes, and snippets.

sqlite> CREATE TABLE widget1 ( id INTEGER PRIMARY KEY AUTOINCREMENT, t TIMESTAMP DEFAULT (DATETIME('2020-12-04 04:22:00')), width int);
sqlite> CREATE TABLE widget2 ( id INTEGER PRIMARY KEY AUTOINCREMENT, t TIMESTAMP DEFAULT (DATETIME('2020-12-04 04:22:00')), width int);
sqlite> insert into widget1 (width) values (74);
sqlite> insert into widget1 (width) values (1345);
sqlite> insert into widget1 (width) values (445);
sqlite> insert into widget1 (width) values (6);
sqlite> insert into widget2 (width) values (9999);
sqlite> insert into widget2 (width) values (1);
sqlite> insert into widget2 (width) values (12);
sqlite> insert into widget2 (width) values (4563);
#!/usr/bin/env bash
FILE=`which file 2>/dev/null` || exit 1
finish_writing() {
local file=$1; shift
if [ $still_growing_timeout -gt 0 ]; then
printf "waiting for $file to finish\n" >$stderr
wait_file $file
! file "$file" "$mime_type" && return
@s1037989
s1037989 / gist:53ad6513eef6cf8232d734697f8c19d8
Last active November 7, 2020 04:07
Bash manage child processes
#!/usr/bin/env bash
cleanup() {
flock unlock
exit
}
die() {
echo "$*"
exit
set -x
/home/stefan/perl5/perlbrew/perls/perl-5.18.4/bin/perl -MExtUtils::Command -e 'mkpath' -- blib/lib/List
chmod 755 blib/lib/List
touch blib/lib/List/.exists
/home/stefan/perl5/perlbrew/perls/perl-5.18.4/bin/perl -MExtUtils::Command -e 'mkpath' -- blib/arch
chmod 755 blib/arch
touch blib/arch/.exists
/home/stefan/perl5/perlbrew/perls/perl-5.18.4/bin/perl -MExtUtils::Command -e 'mkpath' -- blib/lib/auto/List/Util
chmod 755 blib/lib/auto/List/Util
touch blib/lib/auto/List/Util/.exists
@s1037989
s1037989 / job_queue
Last active July 31, 2020 03:52
Bash Job Queue
#!/usr/bin/env bash
# Original: https://hackthology.com/a-job-queue-in-bash.html
# This is a modification that adds receiving "work" from a named pipeline
# Run the job queue and then just pass "work" to it whenever:
# $ q H1 ls -l /tmp
# $ q H2 date
# $ q H1 sleep 4
# $ q H3 echo hi
usage() {
$ echo -n -e "\x3c\x97\x0e\x1d\x3f\x07\xf8\x32\xe4\xc0\x48\xab\x00\x02\x61\x62" | sudo socat -t 1 -lu -x -d -d -d -d - SOCKET-SENDTO:17:3:0:x0003x02000000x0000x00x06x3c970e1d3f070000
2020/06/22 04:34:56.306263 socat[762494] D getpid()
2020/06/22 04:34:56.306315 socat[762494] D getpid() -> 762494
2020/06/22 04:34:56.306322 socat[762494] D setenv("SOCAT_PID", "762494", 1)
2020/06/22 04:34:56.306329 socat[762494] D setenv() -> 0
2020/06/22 04:34:56.306332 socat[762494] D setenv("SOCAT_PPID", "762494", 1)
2020/06/22 04:34:56.306337 socat[762494] D setenv() -> 0
2020/06/22 04:34:56.306341 socat[762494] I socat by Gerhard Rieger and contributors - see www.dest-unreach.org
2020/06/22 04:34:56.306345 socat[762494] I This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org/)
2020/06/22 04:34:56.306349 socat[762494] I This product includes software written by Tim Hudson ([email protected])
use strict;
use warnings;
use Fcntl;
use Mojo::File qw(path);
use Mojo::Util qw(getopt);
use Socket qw(SOCK_RAW);
use Socket::Packet qw(
PF_PACKET
ETH_P_ALL
pack_sockaddr_ll unpack_sockaddr_ll recv_len
@s1037989
s1037989 / gist:271e9f560bd7306c493e51fba1458cfa
Last active June 11, 2020 00:50
Nonblocking network socket programming
http://dwise1.net/pgm/sockets/blocking.html
https://gist.github.com/Alexey-N-Chernyshov/4634731
https://jameshfisher.com/2017/04/05/set_socket_nonblocking/
https://opensourceforu.com/2015/03/a-guide-to-using-raw-sockets/
https://squidarth.com/networking/systems/rc/2018/05/28/using-raw-sockets.html
Text::Unidecode (unidecode)
http://www.theunixschool.com/2012/08/getopts-how-to-pass-command-line-options-shell-script-Linux.html
$ diff -y Untitled\ Document\ 1 Untitled\ Document\ 2
+ local cur prev words cword split + local cur prev words cword split
+ _init_completion -s + _init_completion -s
+ local exclude= flag outx errx inx OPTIND=1 + local exclude= flag outx errx inx OPTIND=1
+ getopts n:e:o:i:s flag -s + getopts n:e:o:i:s flag -s
+ case $flag in + case $flag in
+ split=false + split=false
+ exclude+== + exclude+==
+ getopts n:e:o:i:s flag -s + getopts n:e:o:i:s flag -s
+ COMPREPLY=() + COMPREPLY=()
package Provider;
use Mojo::Base -base, -signatures;
has 'log' => sub { Mojo::Log->new };
has 'model';
has [qw/ident token/] => sub { die };
sub get_token {
my ($self, $ident) = @_;
$self->ident($ident)->token(_token($ident)) if $ident;