Skip to content

Instantly share code, notes, and snippets.

Avatar

Sviatoslav Abakumov Perlence

View GitHub Profile
@Perlence
Perlence / thread-pool.rkt
Last active Sep 21, 2021
Straight-forward thread pool implementation in Racket
View thread-pool.rkt
#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 Aug 15, 2021
Solarized Light and Dark themes for Firefox Reader
View reader-solarized.css
@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 Feb 26, 2021
Run all maps from subdirectories (Quake)
View sm.py
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',
View termcolors.awk
#!/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 Jan 24, 2014
Convert CSV file to SQLite table
View csv2sqlite.py
#!/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 Mar 17, 2019
FreePIE: Map MIDI notes to keyboard presses
View midi_to_key.py
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 Jun 12, 2014
Analog of Unix 'ln' for Windows since Vista
View ln.py
"""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
Decision table generator
View decisions.py
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 Dec 23, 2015
Solarized Dark theme for Windows Command Processor with reduced base colors
View solarized-dark.reg
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
; -- ------- ----------- --------- ------- --------
@Perlence
Perlence / clearSearchBar.uc.js
Created Nov 27, 2017
Clear search bar on submit
View clearSearchBar.uc.js
(function () {
function initSearchTextRemover () {
let searchbar = window.document.getElementById('searchbar');
if (!searchbar) return;
patchSearchbar(searchbar);
}
function patchSearchbar (searchbar) {
if (searchbar.__patched__) return;
let origDoSearch = searchbar.doSearch;