This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# klg, Dec 2018 | |
set -e | |
if ! [ '/--slave' = "/$1" ] | |
then | |
root_dir="${1:-.}"; ( cd "$root_dir"; ) | |
charset=$(locale charmap 2>/dev/null || :) | |
echo >&2 "Serving $root_dir on http://localhost:${PORT:=8000}/ ..." | |
exec env - "PATH=$PATH" "charset=$charset" "root_dir=$root_dir" \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# VT100 banner clock | |
# klg, Dec 2017; Apr 2018 | |
use strict; | |
use Time::HiRes qw/time sleep/; | |
use Time::Local 'timelocal'; | |
my @fonts; | |
while (<DATA>) { | |
s/#.*//; next if /^\s*$/; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Lower size of GIT_DIR with no regard to future performance | |
# klg, Feb 2019 | |
set -e | |
GIT_DIR=$(git rev-parse --git-dir) | |
# objects: prune and repack | |
git prune | |
case "$1" in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Open Terminal in chosen local directory from Caja; based on example from: | |
# <https://github.com/mate-desktop/python-caja/blob/master/examples/open-terminal.py> | |
# klg, Nov 2018 | |
import os | |
from gi.repository import Caja, GObject, Gio | |
TERMINAL_SCHEMA = 'org.mate.applications-terminal' | |
TERMINAL_KEY = 'exec' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* settai -- update kernel's TAI-UTC offset from tzdata | |
* klg, Oct 2018 */ | |
#define _POSIX_C_SOURCE 200809L | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
#include <sys/timex.h> | |
static void set_utctz(const char *tz) { | |
if (setenv("TZ", tz, 1) < 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const crypto = require('crypto') | |
const {promisify} = require('util') | |
let pwtokey = (pass, salt='', iter=100) => | |
promisify(crypto.pbkdf2)(pass, salt, iter, 16, 'sha256') | |
let encrypt = async (key, msg) => { | |
let iv = await promisify(crypto.randomBytes)(16) | |
let ctx = crypto.createCipheriv('aes-128-gcm', key, iv) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
一 | 1 | |
---|---|---|
乙 | 5 | |
二 | 11 | |
十 | 12 | |
丁 | 12 | |
厂 | 13 | |
七 | 15 | |
卜 | 24 | |
八 | 34 | |
人 | 34 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# klg, Jun 2017 | |
use strict; | |
use JSON; | |
my $j = JSON->new->utf8->allow_nonref; | |
my $c = 0; | |
local $| = 1; | |
while (1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html><meta charset=utf8><title>Tiny LZ77 for Javascript</title><body><script>var s;eval(s='0||function(z){function r(){return z.charCodeAt(p++)*289>>5&63}function q(a,x){for(x=56|a;x==63;)a+=x=r();return a}for(var m,l,e,p=0;p<z.length;){for(m=r(),e=r()<<6|r(),l=q(m>>3),m=q(m&7)+4,s+=z.substr(p,l),p+=l,l=s.slice(-e);e&&l.length<m;)l+=l;s+=l.slice(0,e&&m)}eval(s.slice(284))}')('zyX!jy/Hlz){"use strict";121Nt(n,t,rcN-er=+new Date+t.extent;r>xrQ9;)if(n())srG1FyXGTask(n){Uk5W9t=this;t.tid=setTimeout(UNKNkn(t)||(FGI2r,0))},0)}19Je.prototype={progress:0,jV29:40,kill:qG0N){clearN9dN9rcV0d)}},lz.decode=tVpUC,fyHtWVTo(dVDULyArJHwp>=VAA}nAHs=""RdCif(fNVAGd-rznzzBeqkXVt(o,e)?1|f(s,e.UNI9N=1):void(B3Cp/uzn)});bzP;!o();OkJstkJ2en.k59s,lClPo(tllPGs-lkt)VH9iFNszn*=l+1,m[n+m[n]+1]=dXNe]=(5l8)%lH3GuGkBkkDXezn,t8eern-=7,t="";n>Feuyt+=c[63],n-yyexWqO+(n>=0?c[n]:"")}QeXe=n1NWJ,t-=r&&4,c[((e|-(e>6))&7)<<3|(t|-(t8NO9]+c[r>>>6FyG2&63]+o(e)+.IgN+n}FGzwt,e,f,c,p,T,v){c=0;do{p=d,T=v,f=c;do d++,a=33*a-129*o(d-1FNk4d+3)&1023;wh |