Skip to content

Instantly share code, notes, and snippets.

View akx's full-sized avatar
👹
rer

Aarni Koskela akx

👹
rer
View GitHub Profile
~/b/babel-usage (master) $ python3 find_no_upper_limits.py -p --project-threshold=0
1129 babel>=1.3
/ 83 nova
/ 47 horizon
/ 31 cinder
/ 25 invenio
/ 20 wtforms
/ 16 heat
/ 16 rally
@akx
akx / gist:0c36fc1f532755ef5667a73986bdc299
Created April 13, 2018 11:46
DecodeLatin1URIComponent
/* Table generated with python3:
import json
characters = [bytes([ch]).decode('iso-8859-1') for ch in range(256)]
print(json.dumps(characters))
*/
const latin1ToCodepoint = ["\u0000", "\u0001", "\u0002", "\u0003", "\u0004", "\u0005", "\u0006", "\u0007", "\b", "\t", "\n", "\u000b", "\f", "\r", "\u000e", "\u000f", "\u0010", "\u0011", "\u0012", "\u0013", "\u0014", "\u0015", "\u0016", "\u0017", "\u0018", "\u0019", "\u001a", "\u001b", "\u001c", "\u001d", "\u001e", "\u001f", " ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<", "=", ">", "?", "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[", "\\", "]", "^", "_", "`", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "~", "\u007f", "\u0080", "\u0081", "\u0082", "\u0083", "\u0084", "\u0085", "\
@akx
akx / compute-fonts.js
Created July 2, 2018 07:18
Console snippet to summarize the font variations used in the DOM of a page
// Usage: paste in your console, run `computeFonts()` (or `computeFonts(true)` if you care about sizes)
function computeFonts(sizes) {
const map = {};
const filterKV = ([k, v]) => {
if (k === "font") return false; // ignore the combined "font" prop
if (!k.startsWith("font")) return false; // ignore non-fonts
if (!v || v === "normal") return false; // ignore non-values or "normal"s
if (k === "fontKerning" && v === "auto") return false; // ignore font-kerning=auto
if (k === "fontStretch" && v === "100%") return false; // ignore font-stretch=100%
@akx
akx / allthemusic.py
Created October 8, 2018 13:34
play all the music???
import subprocess
import random
pth = "/Users/akx/Music"
files = subprocess.check_output('gfind "%s" -name \'*.mp3\'' % pth, shell=True).splitlines()
random.shuffle(files)
files = files[:10]
cmd = [
@akx
akx / gist:068bb73742bd4264d6ff08d0b7ee62a7
Created October 24, 2018 15:33
The latest/last version of the Adblock for Finland list, with the politically charged entries commented out
[Adblock]
! Version: 20181022
! Title: Adblock List for Finland
! Description: Finnish adblock list
! Last modified: 22st of October 2018
! Expires: 7 days (update frequency)
! Facebook: https://www.facebook.com/AdblockerForFinland
! License: http://unlicense.org/
@akx
akx / gist:987b719d0329da9a3140f90c649fa1f2
Created December 18, 2018 12:08
opustags docker test result
/src/t/opustags.t .. 1/34
# Failed test 'complex tag editing'
# at /src/t/opustags.t line 116.
Wide character in print at /usr/share/perl/5.26/Test2/Formatter/TAP.pm line 105.
# Structures begin differing at:
# $got->[1] = 'error: Could not encode argument into UTF-8: Could not convert string 'TITLE=七面鳥': Invalid or incomplete multibyte or wide character
# '
# $expected->[1] = ''
# Failed test 'check the footprint'
@akx
akx / gist:ce7c0763a6c489fb7749039b9a18909a
Created December 18, 2018 12:11
opustags macos test result
/Users/akx/build/opustags/t/opustags.t ...... 1/34 utf8 "\xEF" does not map to Unicode at /Users/akx/build/opustags/t/opustags.t line 34, <GEN138> chunk 1.
# Failed test 'set all in ISO-8859-1'
# at /Users/akx/build/opustags/t/opustags.t line 220.
# Structures begin differing at:
# $got->[0] = ''
# $expected->[0] = 'T=���
# '
utf8 "\xF9" does not map to Unicode at /Users/akx/build/opustags/t/opustags.t line 34, <GEN144> chunk 1.
@akx
akx / c2j.py
Created January 14, 2019 12:19
c2j -- dsl for generating json
#!/usr/bin/env python3
import json
import sys
class c2j:
def __init__(self):
self.stack = []
self.root = None
// h/t @japsu for the idea. had to type it.
import React from "react";
function connect<C, P>(
ContextClass: React.Context<C>,
propName: keyof P,
): ((
component: React.FunctionComponent<P> | React.ComponentClass<P>,
) => React.FunctionComponent<P>) {
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
static long long ts_usecs(struct timespec t) {
return (t.tv_sec * 1000000000 + t.tv_nsec);
}
int main() {
struct timespec t0, t1;