Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
#
# Usage
#
# python2nix my_pypi_package > my_package.nix
#
# TODO
# - accept 'format' as arg
# - prepopulate dependencies?
set -euo pipefail
$ nix-shell -p python3Packages.joblib 2.781s 15:53:29
these derivations will be built:
/nix/store/w6q794hqy3q4fi9arc8cx09hwhaixng7-python3.7-joblib-0.12.4.drv
building '/nix/store/w6q794hqy3q4fi9arc8cx09hwhaixng7-python3.7-joblib-0.12.4.drv'...
unpacking sources
unpacking source archive /nix/store/ch8lr3bkfqnhnrwbcbibj00pmbrgzgg2-source
source root is source
setting SOURCE_DATE_EPOCH to timestamp 315619200 of file source/setup.py
patching sources
configuring

Setup weechat relay, accessible via ssh-tunnel.

  1. Add tmux and weechat to environment.systemPackages.
  2. ssh into on server
  3. run weechat inside tmux
  4. Make sure port 8001 is blocked by firewall.
  5. inside weechat:
/relay add weechat 8001
@sveitser
sveitser / config.c
Last active January 8, 2019 14:50
Vortex pok3r with home row modifiers.
/*
* Copyright (c) 2018 Charlie Waters
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
#!/usr/bin/env bash
#
# Usage
#
# python2nix my_pypi_package > my_package.nix
#
# TODO
# - accept 'format' as arg
# - prepopulate dependencies?
set -euo pipefail
@sveitser
sveitser / bench.py
Created October 24, 2018 03:13
Untested, probably doesn't work.
#!/usr/bin/env python
#
# DANGEROUS!
#
# Benchmark drive with bonnie using ext4: vanilla, LUKS, LVM, LUKS + LVM
import os
import time
import sys
from sh import (
@sveitser
sveitser / bonnie-ssd-benchmark.sh
Created October 21, 2018 15:12
Bonnie, ext4, lvm, luks benchmark.
#!/bin/bash
#
# DANGEROUS!
#
# Benchmark drive with bonnie using ext4: vanilla, LUKS, LVM, LUKS + LVM
#
set -euxo pipefail
DISK="/dev/sda"
RUNS=3
# luks + lvm + ext4
Version 1.97 ------Sequential Output------ --Sequential Input- --Random-
Concurrency 1 -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP
lulus 63G 892 99 40625 2 222666 13 2307 99 530668 15 +++++ +++
Latency 9188us 55434ms 33401ms 3675us 16365us 390us
Version 1.97 ------Sequential Create------ --------Random Create--------
lulus -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
files /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP
@sveitser
sveitser / nixos-install-encrypted-root.sh
Last active May 30, 2021 09:28
Installs nixos on encrypted root from live CD.
#!/usr/bin/env bash
#
# Installs nixos with full disk encrypted root partition.
#
# - Prompts for password initially, after that no interaction should
# be required.
# - At the end it will prompt for a root password, could not make
# echo-ing it into nixos-install work.
# - Reserves 550MB for boot partition, rest for the root volume.
# - After booting, log in as root user and set password for normal user.
@sveitser
sveitser / defaultdict.ts
Last active April 30, 2022 22:35
Wannabe defaultdict for typescript. Not really tested.
class DefaultDict<T, Q> extends Map<T, Q> {
defaultFactory: () => Q
constructor(defaultFactory: () => Q) {
super()
this.defaultFactory = defaultFactory
}
get(name: T): Q {
if (this.has(name)) {
return super.get(name)!
} else {