This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SSH into remote host "R", startup Jupyter on port XXXX. | |
ssh user@remotehost.com | |
jupyer notebook --no-browser --port=XXXX | |
# On the localhost "L", accessing jupyter via the browser: | |
# create a reverse tunnel, forwarding YYYY (L) to XXXX (R). | |
ssh -N -L YYYY:localhost:XXXX user@remotehost.com | |
---- --------- ---- | |
| | | | |
| | ` port on remote where Jupyer is listening |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Current directory contains a folder named 'img', | |
# which contains images nested in subfolders, e.g. | |
# | |
# img | |
# folder1 | |
# img1.jpg | |
# img2.jpg | |
# folder2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Using go get can be confusing, here's what I learned. | |
# | |
# When go get ./... failed in a Dockerfile on Dockerhub, I listed and installed dependencies manually. | |
# Inspired by https://dave.cheney.net/2014/09/14/go-list-your-swiss-army-knife | |
# | |
# Recursively search for dependencies in $GOPATH/src; install dependencies using go get. | |
find "${GOPATH}/src" -type d \ | |
-exec go list -f '{{ join .Imports "\n" }}' -e {} + \ | |
| sort -u \ | |
| xargs go get -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First, install certificate with https://www.zim.uni-passau.de/dienstleistungen/netzwerk-und-server/netzwerkzugang/eduroam/fuer-uniangehoerige/linux/ | |
# This will created ~/.cat_installer/user.p12 and ~/.cat_installer/ca.pem, which are the certificates required to connect. | |
# Create eduroam config for wpa_supplicant. | |
# ZIMID is your ZIM identifier, e.g. abcdef99 | |
cat > /tmp/eduroam.conf <<EOF | |
network={ | |
ssid="eduroam" | |
key_mgmt=WPA-EAP | |
pairwise=CCMP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://en.wikipedia.org/wiki/Magic_SysRq_key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prerequisites: | |
# - gdal2tiles.py (https://gdal.org/) | |
# - map.tit, a GeoTIFF file generated, for example, by QGIS | |
$ sudo apt install gdal-bin | |
$ gdal2tiles.py map.tif tiles | |
$ cd tiles && python -m http.server | |
# Go to http://localhost:8000/leaflet.html; | |
# place tiles/ on a web server and create a L.tileLayer using the tiles. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Extract is a nested document, which exists in some documents only. | |
// | |
// Collection data defines a partial index on extract.created_at. | |
// | |
// Finding documents which have extract set takes long, if the collection is large. | |
// | |
// Use hint() to search the index extarct.created_at in determining, if extract exists. | |
db.data.getIndices() | |
/* | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
IFS=$'\n\t' | |
# From https://unix.stackexchange.com/a/18631/56290 | |
# Rotate even pages by 180 degrees, don't rotate odd pages. | |
pdftk A=infile.pdf shuffle Aoddnorth Aevensouth output outfile.pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Touch a file containing self-signed certificates to be used by git. | |
touch ~/.git-certs | |
chmod 600 ~/.git-certs | |
# Append the certificate to the file created aboe. | |
# https://stackoverflow.com/questions/7885785/using-openssl-to-get-the-certificate-from-a-server#comment26410932_7886248 | |
echo \ | |
| openssl s_client -connect my.server.com:443 2>&1 \ | |
| sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' \ | |
>> ~/.git-certs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Match .msg against case-insensitive regex; | |
# output .name and .time of matching documents. | |
jq 'select(.msg|test("aggregating variable";"i")) | .name,.time' input.json | |
# Output single line, as CSV. | |
jq -c 'select(.msg|test("aggregating variable";"i")) | .name,.time' input.json | tr -d '[]' | |
# Output value, default to 0, if field is missing. | |
jq '.value // 0' input.json |