Skip to content

Instantly share code, notes, and snippets.

👹
rer

Aarni Koskela akx

👹
rer
Block or report user

Report or block akx

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@akx
akx / Instructions.md
Last active Mar 6, 2020
Super simple flask thing
View Instructions.md

Developing/debugging a Flask app

  • Set up a virtualenv
  • pip install flask
  • add calc_server.py
  • debug/run with python calc_server.py (autoreloading, debugging, etc.)
  • Access e.g. http://localhost:9999/calculate/9652/343

Running in production in an EC2 box

View screen-recrop-ffmpeg.sh
ffmpeg \
-video_size 1200x400 \
-framerate 30 \
-f x11grab \
-i :0.0+0,0 \
-pix_fmt yuv420p \
-filter_complex "
color=size=800x800:c=black [base];
[0:v] setpts=PTS-STARTPTS, crop=w=800:h=400:x=0:y=0 [row1];
[0:v] setpts=PTS-STARTPTS, crop=w=400:h=400:x=800:y=0 [row2];
View clocktest.c
#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;
View connect-context.tsx
// 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>) {
@akx
akx / c2j.py
Created Jan 14, 2019
c2j -- dsl for generating json
View c2j.py
#!/usr/bin/env python3
import json
import sys
class c2j:
def __init__(self):
self.stack = []
self.root = None
View gist:ce7c0763a6c489fb7749039b9a18909a
/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.
View gist:987b719d0329da9a3140f90c649fa1f2
/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:068bb73742bd4264d6ff08d0b7ee62a7
Created Oct 24, 2018
The latest/last version of the Adblock for Finland list, with the politically charged entries commented out
View gist:068bb73742bd4264d6ff08d0b7ee62a7
[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 / allthemusic.py
Created Oct 8, 2018
play all the music???
View allthemusic.py
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 / compute-fonts.js
Created Jul 2, 2018
Console snippet to summarize the font variations used in the DOM of a page
View compute-fonts.js
// 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%
You can’t perform that action at this time.