Skip to content

Instantly share code, notes, and snippets.

@Perlence
Perlence / prosody-entrypoint.sh
Created February 11, 2016 12:58
Using envsubst with Docker in entrypoint
#!/bin/bash
set -e
# Substitute environment variables in Prosody configs
for tpl in /etc/prosody/*.tpl; do
envsubst < $tpl > ${tpl%\.tpl}
done
exec su -s /bin/bash -c "$*" prosody
@Perlence
Perlence / thread-pool.rkt
Last active September 21, 2021 22:41
Straight-forward thread pool implementation in Racket
#lang racket/base
(require racket/match
racket/async-channel
net/http-client)
(define urls '(["icanhazip.com" "/"]
["icanhazepoch.com" "/"]
["example.com" "/"]))
@Perlence
Perlence / reader-solarized.css
Last active August 15, 2021 06:59
Solarized Light and Dark themes for Firefox Reader
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document url-prefix("about:reader") {
body.light {
color: #657b83; /* base00 */
background-color: #fdf6e3; /* base3 */
}
body.dark {
color: #839496; /* base0 */
@Perlence
Perlence / sm.py
Last active February 26, 2021 01:55
Run all maps from subdirectories (Quake)
from __future__ import print_function
import sys
import subprocess
from os.path import isfile, join, splitext, sep, normpath
from glob import glob
ENGINE = 'quakespasm\\0.91.0\\quakespasm.exe'
GAME = 'sm'
QARGS = ['-heapsize', '256000',
#!/usr/bin/awk -f
BEGIN {
# first the system ones:
print "System colors:"
for (color = 0; color < 8; color++) {
printf "\x1b[48;5;" color "m "
}
print "\x1b[0m"
for (color = 8; color < 16; color++) {
printf "\x1b[48;5;" color "m "
@Perlence
Perlence / csv2sqlite.py
Created January 24, 2014 12:24
Convert CSV file to SQLite table
#!/usr/bin/python
import re
import csv
import sqlite3
from contextlib import closing
TYPES = [
('INTEGER', re.compile('^[-+]?(\d+,)*\d+$')),
('REAL', re.compile('^[-+]?((\d+,)*\d+)?\.?[0-9]+([eE][-+]?[0-9]+)?$')),
@Perlence
Perlence / midi_to_key.py
Last active March 17, 2019 13:31
FreePIE: Map MIDI notes to keyboard presses
NOTE_TO_KEY = {
36: Key.Q,
38: Key.W,
40: Key.E,
41: Key.R,
}
def update(midi):
data = midi.data
@Perlence
Perlence / ln.py
Created June 12, 2014 10:05
Analog of Unix 'ln' for Windows since Vista
"""Analog of Unix ``ln`` for Windows since Vista."""
import sys
import os
import subprocess
if len(sys.argv) < 3:
sys.exit('usage: ln.py TARGETS DEST')
args = map(os.path.abspath, sys.argv[1:])
targets, dest = args[:-1], args[-1]
os.chdir(dest)
@Perlence
Perlence / decisions.py
Created May 1, 2018 19:08
Decision table generator
import csv
import itertools
import sys
def main():
reader = csv.reader(sys.stdin, delimiter='\t')
conditions = {} # ordered dict is assumed
for line in reader:
if not line:
@Perlence
Perlence / solarized-dark.reg
Created December 23, 2015 22:36
Solarized Dark theme for Windows Command Processor with reduced base colors
Windows Registry Editor Version 5.00
; Registry file that maps the solarized palette to the 16 avaliable colors
; in a Windows command prompt. Note, hex values in the table are RGB but byte
; ordering of a DWORD is BGR, e.g. "ColorTable<##>"=dword:00<B><G><R>
;
; Solarized color table from http://ethanschoonover.com/solarized.
;
; NR cmd.exe PowerShell SOLARIZED HEX DWORD
; -- ------- ----------- --------- ------- --------