NOTE: If you have Windows 11 there is now an official way to do this in WSL 2, use it if possible - see MS post here (WINDOWS 11 ONLY)
This guide will enable systemd
to run as normal under WSL 2. This will enable services like microk8s
, docker
and many more to just work
during a WSL session. Note: this was tested on Windows 10 Build 2004, running Ubuntu 20.04 LTS in WSL 2.
-
To enable
systemd
under WSL we require a tool calledsystemd-genie
-
Copy the contents of
install-sg.sh
to a new file/tmp/install-sg.sh
:
[Unit] | |
Description=firewalld reload hook - run a hook script on firewalld reload | |
Wants=dbus-broker.service | |
After=dbus-broker.service | |
[Service] | |
Type=simple | |
ExecStart=/bin/bash -c '/bin/busctl monitor --system --json=short --match "interface=org.fedoraproject.FirewallD1,member=Reloaded" | while read -r line ; do [ -x /usr/local/sbin/firewalld-reload-hook ] && /usr/local/sbin/firewalld-reload-hook ; done' | |
[Install] |
#!/bin/bash | |
set -euo pipefail | |
RELEASE="teleport-v4.2.3-linux-amd64-bin.tar.gz" | |
if [[ $EUID -ne 0 ]]; then | |
echo "--> Please run this script as root or sudo." | |
exit 1 | |
fi |
""" | |
A script to automatically export bookmarks from Firefox's SQLite database. | |
There does not seem to be a programmatic way to get Firefox to export its bookmarks in | |
the conventional HTML format. However, you can access the bookmark information directly | |
in Firefox's internal database, which is what this script does. | |
Always be careful when working with the internal database! If you delete data, you will | |
likely not be able to recover it. |
#!/bin/sh | |
############################################################################## | |
# Check whether vault files are encrypted: | |
FILES_PATTERN='.*vault.*\.yml$' | |
REQUIRED='ANSIBLE_VAULT' | |
UNENCRYPTED_FILES=() | |
for f in $(git diff --cached --diff-filter=d --name-only | grep -E $FILES_PATTERN) | |
do |
#!/usr/bin/python | |
# | |
# Skrypt pobierajacy obecne wskazniki spolek ze strony GPW, | |
# po czym dla kazdej spolki wczytujacy parametry jej notowan i akcji | |
# ze strony Money.pl. Rezultatem dzialania sa dwa pliki CSV gotowe do zaimportowania | |
# i obrobienia w Excelu. Pierwszy plik - out.csv zawiera wszystkie dane spolek, drugi | |
# csv_filtered zawiera dane odfiltrowane po restrykcyjnych kryteriach Benjamina Grahama, | |
# autora Inteligentnego Inwestora. | |
# |
In writing one’s own Base64 codec for the Cryptopals Crypto Challenge in Rust, one gets to a point where every chunk of four adjacent elements in an input vector has to be transformed into a chunk of three elements in an output vector.
That is, the string
SSdt
containing four ASCII bytes becomes the stringI'm
containing three ASCII bytes, andIGtp
becomeski
, and so on, so thatSSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t
is decoded toI'm killing your brain like a poisonous mushroom
.
I had a function to do this four-to-three downconversion but looping over the two arrays, lining up the indexes, the keeping track of magic threes and magic fours in my code gave me a headache as I worked through writing the following:
pub fn decode(s: &[u8]) -> Vec<u8> {
let mut out: Vec<u8> = vec![0; s.len() / 4 * 3];
for i in 0..ou