Skip to content

Instantly share code, notes, and snippets.

@bluetech
bluetech / flake8_commas.py
Created January 14, 2023 17:38
Cleaned up flake8-commas
from typing import Iterator, TypedDict
import collections
import dataclasses
import enum
import tokenize
# A parenthesized expression list yields whatever that expression list
# yields: if the list contains at least one comma, it yields a tuple;
# otherwise, it yields the single expression that makes up the expression
@bluetech
bluetech / test.py
Last active May 30, 2018 18:49
Thread overhead
from subprocess import Popen
from concurrent.futures import ThreadPoolExecutor
from os import waitpid
import time
import asyncio
start = time.time()
for i in range(3000):
p1 = Popen(['/bin/true'])
@bluetech
bluetech / client.py
Last active December 12, 2017 10:14
Trio #369
import itertools
import logging
import trio
import attr
import protocol
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger('client')
@bluetech
bluetech / mask.c
Last active July 11, 2018 15:03
Websocket masking comparison
// gcc -O3 -march=native mask.c -o mask
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <immintrin.h>
@bluetech
bluetech / gist:ad130434c91ed5809156
Created July 3, 2015 23:01
warnings from libxkbcommon for kragen/xcompose as of b2e2ed153c6b8ea714753b716d46673557fa4ffe
xkbcommon: WARNING: /home/ran/.XCompose:14:40: this compose sequence already exists; overriding
xkbcommon: WARNING: /home/ran/.XCompose:16:43: a sequence already exists which is a prefix of this sequence; overriding
xkbcommon: WARNING: /home/ran/.XCompose:33:39: this compose sequence already exists; overriding
xkbcommon: WARNING: /home/ran/.XCompose:37:41: this compose sequence already exists; overriding
xkbcommon: WARNING: /home/ran/.XCompose:43:43: this compose sequence already exists; overriding
xkbcommon: WARNING: /home/ran/.XCompose:47:38: this compose sequence already exists; overriding
xkbcommon: WARNING: /home/ran/.XCompose:48:38: this compose sequence already exists; overriding
xkbcommon: WARNING: /home/ran/.XCompose:50:42: this compose sequence already exists; overriding
xkbcommon: WARNING: /home/ran/.XCompose:51:47: this compose sequence already exists; overriding
xkbcommon: WARNING: /home/ran/.XCompose:52:38: this compose sequence already exists; overriding
#!/usr/bin/python2
"""Display the error message for an Oracle error either from the internet
or from the cache db, based on the error code ("the query") you get when
confronted with the error."""
import sys, os, re, urllib2, urlparse, anydbm
from BeautifulSoup import BeautifulSoup
BASE_URL = "http://download.oracle.com/docs/cd/B19306_01/server.102/b14219/"
TOC_URL = BASE_URL + "toc.htm"
@bluetech
bluetech / redirect.c
Created February 4, 2015 09:56
Redirecting keycodes in the evdev layer
/* In linux, the evdev subsystem already has an indirection layer for
* keyboard keys. It allows to remap the evdev scancode it gets from
* the keyboard to another scancode (keycode). */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
@bluetech
bluetech / get_map.c
Created July 23, 2013 10:17
get_map.c
#include <assert.h>
#include <err.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <xcb/xcb.h>
#include <xcb/xkb.h>
@bluetech
bluetech / get_map_output
Created July 19, 2013 11:08
get_map output
minKeyCode: 8
maxKeyCode: 255
firstType: 0
totalType: 25
nTypes: 25
type 0:
mods_mask: 0
mods_mods: 0
mods_vmods: 0
numLevels: 1
@bluetech
bluetech / get_map.c
Last active June 16, 2020 02:46
xcb-xkb XkbGetMap test code
#include <err.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <xcb/xcb.h>
#include <xcb/xkb.h>