Skip to content

Instantly share code, notes, and snippets.

View sepastian's full-sized avatar
💭
\_ . |‾‾‾| o-`o

Sebastian Gassner sepastian

💭
\_ . |‾‾‾| o-`o
View GitHub Profile
@sepastian
sepastian / nmcli_eduroam_uni_passau.sh
Last active April 3, 2023 13:57
Add nmcli connection for eduroam at university of Passau
# Setup eduroam connection using personal certificate (802-1.x WPA EAP)
# at the University of Passau.
#
# PREREQUISITES
#
# Instructions based on "Manuelle Einrichtung" [1] and Stackoverflow [2].
#
# 0) mkdir ~/.eduroam # create dir holding certificate files
# 1) download private key in PKCS#12 format [3], save as ~/.eduroam/eduroam.p12
# 2) download radius root certificate [4], save as ~/.eduroam/radius_rootcert.pem
@sepastian
sepastian / ext4_fs_tuning.md
Last active March 10, 2023 16:36
ext4 file system tuning
@sepastian
sepastian / multi_cartesian_product.rb
Last active January 11, 2023 09:26
Build the cartesian product of multiple arrays in Ruby.
# Given an array of arrays s = [ [1,2,3], [4,5,6], ... ]
# compute the Cartesian product among the elements of s.
require 'pp'
s = [[1, 2], [3, 4, 5], [6, 7, 8, 9]]
pp s[1..-1].inject(s[0]){ |m,v| m = m.product(v).map(&:flatten) }
[[1, 3, 6],
[1, 3, 7],
[1, 3, 8],
@sepastian
sepastian / qemu_win10_guest.md
Last active December 19, 2022 15:15
QEMU: Win10 guest on Debian host
@sepastian
sepastian / record_left_monitor.zsh
Last active November 2, 2022 11:25
Record left monitor from CLI
# Oh-My-ZSH custom function to record left monitor from CLI.
#
# Place in $ZSH/.oh-my-zsh/custom.
#
# Two monitors at screen 0, the left one connected at DP-1:
#
# xrandr
# Screen 0: minimum 320 x 200, current 3840 x 1200, maximum 16384 x 16384
# DP-1 connected primary 1920x1200+1920+0 (normal left inverted right x axis y axis) 518mm x 324mm
# 1920x1200 59.95*+
@sepastian
sepastian / compress_pdf.zsh
Last active November 2, 2022 11:15
Compress PDF custom Oh-My-ZSH function
# Place in $ZSH/.oh-my-zsh/custom.
#
# The following ZSH function uses GhostScript's `gs` command to reduce the file size of a PDF file.
# The result of compressing `test.pdf` will be written to `test.compressed.pdf`.
# If `test.compressed.pdf` exists, it will only be overwritten after confirmation.
#
# Now, restart/open a new shell and compress PDFs with:
#
# compress_pdf test.pdf
# File exists: test.compressed.pdf, overwrite (Y/n)?
@sepastian
sepastian / jupyter_remote_via_ssh_tunnel.txt
Last active October 26, 2022 09:25
Jupyter notebook on remote host via SSH tunnel
# 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
@sepastian
sepastian / determine_dpi.sh
Last active October 14, 2022 09:16
Determine Image DPI
# Based on https://apple.stackexchange.com/a/389067/453491
# In order to calculate DPI, determine units and resolution first.
identify -verbose warc2corpus@2x_300dpi.png | grep -E -i "resolution|units"
# Resolution: 118.11x118.11
# Units: PixelsPerCentimeter
# png:pHYs: x_res=11811, y_res=11811, units=1
# 1 PixelsPerCentimeter corresponds to 2.54 DPI.
# Calculate DPI using the following command.
@sepastian
sepastian / heap.rb
Last active October 3, 2022 13:54
Heap in Ruby
class Heap
def initialize(*elems)
@h= heapify(elems)
end
def inspect
return '(empty)' if @h.empty?
@h
.group_by.with_index{ Math.log2(_2+1).to_i }
.map{ |l,vs| vs.join(' ') }
.join("\n")
@sepastian
sepastian / OpenWRT_TP-LINK_MR3220_V2.2.md
Last active September 29, 2022 14:27
Installing OpenWRT on a TP-LINK MR3220 V2.2.