Skip to content

Instantly share code, notes, and snippets.

View jowagner's full-sized avatar

Joachim Wagner jowagner

View GitHub Profile
@jowagner
jowagner / domain-map-2-punch-holes.py
Created February 23, 2022 17:13
Helper for punching holes into a disk image where partclone says that blocks are not in use
#!/usr/bin/env python
import sys
offset = int(sys.argv[1])
img_name = sys.argv[2]
# skip current_pos
while True:
line = sys.stdin.readline()
@jowagner
jowagner / make-snapshot-of-device.sh
Last active January 16, 2023 14:32
Make snapshot of non-busy block device with device mapper in Linux
NAME=nameofsnapshot
DEVRO=/dev/read-only-backing-device
DEVCOW=/dev/space-for-writing-changes
SECTORS=$(blockdev --getsz $DEVRO)
TABLE=$(mktemp)
echo 0 $SECTORS snapshot $DEVRO $DEVCOW N 16 >> $TABLE
echo "Setting up $NAME with"
@jowagner
jowagner / loading_wikipedia.py
Last active June 18, 2020 14:10 — forked from thomwolf/loading_wikipedia.py
Load full English Wikipedia dataset in HuggingFace nlp library
#!/usr/bin/env python
# based on https://gist.github.com/thomwolf/13ca2b2b172b2d17ac66685aa2eeba62
# support for --len adapted from https://gist.github.com/lhoestq/8f317e47c6f8b6bc50ef1275f655a3a3
# support for --count-spaces Joachim Wagner 2020-06-17
# support for --read-first Joachim Wagner 2020-06-18
# requirements: pip install nlp psutil six
import os; import psutil; import timeit
@jowagner
jowagner / howto-git-add-remote.md
Last active October 10, 2019 10:50
gogs to github backup

Setup:

  1. Create empty repo in github (click create and do not add any readme or licence)

  2. Run:

git pull
git remote add backup git@github.com:user/repo-name.git
git push -u backup master
git remote -v