Skip to content

Instantly share code, notes, and snippets.

@enkore
enkore / poolfree
Last active September 13, 2023 16:02
Report pool usage on Samba shares using multiple ZFS datasets
#!/bin/bash
# Suppose you export a dataset via Samba, then Samba will do df(1), which will only
# show the space used by the dataset of the shared directory. If you have datasets nestled
# within, then the space used by them will not show up in the overall share space usage:
#
# /mnt/tank/ -- using X TB from the pool
# /mnt/tank/dataset1 -- using Y TB from the pool
# /mnt/tank/dataset2 -- using Z TB from the pool
#
@enkore
enkore / test.py
Created August 19, 2018 21:59
Coverage QThread Test
import time
from PyQt5.QtCore import QThread
class Worker(QThread):
def __init__(self):
QThread.__init__(self)
self.counter = 0
from PySide2 import QtWidgets, QtCore
class MyTableView(QtWidgets.QTableView):
SECTION_SIZE = 70
def __init__(self, parent=None):
super(MyTableView, self).__init__(parent)
def setModel(self, mdl):
super().setModel(mdl)
@enkore
enkore / borg_key_encrypt.rst
Last active May 20, 2017 16:22
What happens when you call key.encrypt(something) in Borg?

AESKeyBase

def encrypt(self, chunk):

data = self.compressor.compress(chunk)
CNONE: Allocate new string of size len(chunk) + 2, copy two type bytes, copy len(chunk) into it, point data at result.
#!/usr/bin/env python
# coding: utf-8
# Copyright (C) PyZMQ Developers
# Distributed under the terms of the Modified BSD License.
#
# Some original test code Copyright (c) 2007-2010 iMatix Corporation,
# Used under LGPLv3
import argparse
@enkore
enkore / _cache.c
Created March 9, 2017 19:30
f/fastcachesync
#include <msgpack.h>
// 2**32 - 1025
#define _MAX_VALUE ( (uint32_t) 4294966271 )
#define MIN(x, y) ((x) < (y) ? (x): (y))
typedef struct {
HashIndex *chunks;
//msgpack_sbuffer sbuf;
@enkore
enkore / qubes3.2-hidpi.rst
Created November 21, 2016 09:58
How to Hi-DPI with Qubes R3.2 and KDE

I use KDE in dom0, it looks much better than XFCE and is imho much easier to use (type-ahead search in the start menu for starters). Also, contrary to XFCE, which is based on Gtk2, even the relatively old version shipped in dom0 has decent Hi-DPI support, as opposed to none at all in XFCE. The best gtk2 can do is scale in 100 % (!) steps.

Hi-DPI is still a bit cumbersome, especially if you switch between lo DPI and hi DPI (eg. builtin screen and external screen).

static int
flags_from_portable(int pflags)
{
int flags = 0;
if ((pflags & SSH2_FXF_READ) &&
(pflags & SSH2_FXF_WRITE)) {
flags = O_RDWR;
} else if (pflags & SSH2_FXF_READ) {
flags = O_RDONLY;
@enkore
enkore / gist:2895fff15cee672c936448cb276e3c9c
Created November 12, 2016 11:11
OpenSSL 1.1+ ChaCha20-Poly1305 API test (RFC 7539 2.8.2)
#include <string.h>
#include <stdint.h>
#include <openssl/evp.h>
uint8_t data[] = {
0x4c, 0x61, 0x64, 0x69, 0x65, 0x73, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x47, 0x65, 0x6e, 0x74, 0x6c,
0x65, 0x6d, 0x65, 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6c, 0x61, 0x73,
0x73, 0x20, 0x6f, 0x66, 0x20, 0x27, 0x39, 0x39, 0x3a, 0x20, 0x49, 0x66, 0x20, 0x49, 0x20, 0x63,
0x6f, 0x75, 0x6c, 0x64, 0x20, 0x6f, 0x66, 0x66, 0x65, 0x72, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x6f,
0x6e, 0x6c, 0x79, 0x20, 0x6f, 0x6e, 0x65, 0x20, 0x74, 0x69, 0x70, 0x20, 0x66, 0x6f, 0x72, 0x20,
"""
show-odd-cache.py
-----------------
Usage:
python show-odd-cache.py <repository> [<column to sort on>] [<number of entries to show>]
Prints a list of the twenty cache entries with the highest reference count.
This makes certain kinds of cache corruption (by bad drives, RAM etc) easy.