Skip to content

Instantly share code, notes, and snippets.

@temoto
temoto / output.dir-lvm.fio.txt
Created August 14, 2022 00:07
Benchmark fio 4k random write+fsync load in LXD VM (qemu) with different storage backends.
dir-lvm: (groupid=0, jobs=1): err= 0: pid=776: Sat Aug 13 18:55:00 2022
read: IOPS=108, BW=436KiB/s (446kB/s)(25.5MiB/60001msec)
slat (usec): min=36, max=547, avg=80.78, stdev=18.61
clat (usec): min=66, max=1767, avg=548.89, stdev=58.97
lat (usec): min=361, max=1835, avg=630.83, stdev=59.84
clat percentiles (usec):
| 1.00th=[ 404], 5.00th=[ 441], 10.00th=[ 469], 20.00th=[ 506],
| 30.00th=[ 523], 40.00th=[ 553], 50.00th=[ 570], 60.00th=[ 578],
| 70.00th=[ 586], 80.00th=[ 594], 90.00th=[ 603], 95.00th=[ 611],
| 99.00th=[ 635], 99.50th=[ 668], 99.90th=[ 791], 99.95th=[ 930],
@temoto
temoto / install-shiv.sh
Created March 23, 2022 19:00
(python management) install shiv, poetry, pdm into /usr/local/bin ; no need to create virtualenvs for tools anymore
python3 -m venv /usr/local/shiv-venv && /usr/local/shiv-venv/bin/pip install shiv && /usr/local/shiv-venv/bin/shiv -c shiv -o /usr/local/bin/shiv shiv
/usr/local/bin/shiv -c poetry -o /usr/local/bin/poetry poetry
/usr/local/bin/shiv -c pdm -o /usr/local/bin/pdm pdm
@temoto
temoto / bench.py
Created September 28, 2021 01:44
Code benchmarking approach with correctness and usefulness ambitions
"""Describes "a better way" to benchmark code and present results.
Key points:
- repeat benchmark 5-7 times, take only best time, translate to single operation speed/duration
- calculate relative delta (new/old-1) of single op speed/duration
- translate delta crossing of boundary values to human friendly labels
Take it as is or add to your awesome benchmarking library.
"""
import timeit
@temoto
temoto / guide.md
Created August 2, 2019 14:39
Atom + Go with modules config for 2019-08

How to setup Atom for Go development with 1.11+ modules support

For projects outside GOPATH.

  • go get github.com/saibing/bingo why: ckaznocha/ide-go#42 Run which bingo and have full path in clipboard.
  • (Atom) install package go-plus for format/build/test-on-save It's great, but go-plus autocomplete doesn't work with modules. Settings, packages, go-plus, Autocomplete, set Scope blacklist *
  • (Atom) install package ide-go
@temoto
temoto / mqtt-color-temp-control.py
Last active October 22, 2018 13:03
Automate lights color temperature via MQTT enabled dimmer (like Sonoff). Temporary location, will be moved to full repository.
#!/usr/bin/env python2
import os, sys, time
import astral, datetime
import paho.mqtt.client
# EDIT HERE TO CONFIGURE + run with env `mqtt_broker=addr:port mqtt_topic=cmnd/house/ct script.py`
config = 'midnight scale_down sunrise 0% noon scale_up sunset 100%'
lat, lng = (58.0, 56.316) # Perm
@temoto
temoto / parse.y.patch
Last active December 6, 2017 10:04
sqlite fail build with ENABLE_UPDATE_DELETE_LIMIT flag when sqlite3.c was configured without it, e.g. amalgamation from sqlite website
--- a/src/parse.y 2017-12-06 05:26:36.000000000 +0300
+++ b/src/parse.y 2017-12-06 05:22:53.000000000 +0300
@@ -758,6 +758,13 @@
}
%endif
%ifndef SQLITE_ENABLE_UPDATE_DELETE_LIMIT
+%include {
+#ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT
+ #error To build SQLite with -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT you have to run ./configure with --enable-update-limit flag. \
+Most likely you are building amalgamation from http://www.sqlite.org/download.html which is not compatible with this feature. \

Keybase proof

I hereby claim:

  • I am temoto on github.
  • I am temoto (https://keybase.io/temoto) on keybase.
  • I have a public key whose fingerprint is 1A40 5559 7839 D277 88D0 0647 F6C3 E55C 75EA CF08

To claim this, I am signing this object:

#!/usr/bin/env python3
import argparse
import bisect
import itertools
import sys
# % cat wordlist
# a b c
# pig bird
# rig sig
@temoto
temoto / mysql-loop
Last active July 31, 2016 11:32
Tool for DBA / Operations. Repeats command against chunks of large MySQL table, delay between runs adapts to minimise load (judged by mean execution time of N last runs).
#!/usr/bin/env python3
import argparse
import itertools
import subprocess
import sys
import time
pk_alphabet_level1 = '0123456789abcdefghijklmnopqrstuvwxyz'.replace('.', '')
pk_alphabet_level2 = '0.......8.......g.......o.....u.....'.replace('.', '')
@temoto
temoto / aws-iam-ssh-keys.py
Last active March 30, 2016 21:57
Sync (overwrite) IAM public SSH keys to my servers at regular intervals. Update keys immediately on change is possible but make it yourself. CloudTrail-CloudWatch-{write this poll service}.
#!/usr/bin/env python3
import botocore.session
import distutils.spawn
import codecs
import grp, pwd
import os
import shutil
import subprocess
import sys
from datetime import datetime