Skip to content

Instantly share code, notes, and snippets.

@fbender
fbender / xml-to-har.py
Last active September 14, 2020 11:19 — forked from craigds/xml-to-har.py
Convert Internet Explorer 'capture network traffic' XML to a HAR file (by @craigds, force-unicode-version).
#!/usr/bin/env python
"""
Converts Internet Explorer 'capture network traffic' XML to a HAR file.
Turns out that XML is just a HAR file anyways, but in XML form. So this
just converts it to JSON, and Bob's your uncle.
Requires Python 2.7+ and LXML.
"""
from __future__ import unicode_literals
@fbender
fbender / remount-usbdrive.sh
Last active December 19, 2023 17:23
Task source code to remount an ejected external USB drive in Synology DSM (e.g. to enable fully-automated Hyper Backup with auto-eject enabled)
# HOW TO SET UP
# - Go to Task Scheduler and create a new "user-defined script" task for "root" user.
# - Schedule task before e.g. next Hyper Backup run (my sequence is: 00:58 mount task, 01:00
# run drive integrity test, 03:00 run backup, which will eject drive again at the end).
# - Copy this file's content to the "user-defined script" field and save.
# - Make sure execution output logging is configured (e.g. saving to a shared folder).
# - Either run script once and follow next section's info, or run "lsusb" yourself via SSH.
# - Fill in device details in variables below (until "END OF CONFIGURATION").
set -euxo pipefail
lsusb
@fbender
fbender / setup-jupyter-py-sci-conda-env.sh
Last active January 16, 2024 16:25
Baseline Scientific Python conda enviroment using VSCode for Jupyter
#!/bin/sh -
#
# Install baseline scientific packages including Jupyter kernel (e.g. into 'base' enviroment):
conda install sympy tabulate seaborn scipy ipykernel
# That's it, you don't need to install all of Jupyter into the enviroment if you "connect" from another
# Jupyter instance, e.g. through VS Code with the Jupyter extension, to this enviroment; the 'ipykernel'
# is sufficient. NumPy, matplotlib, pandas, etc. are part of the dependencies of above packages. Install
# panda's recommended dependencies if numeric operations need a speed up, esp. for large data sets; ref.
# https://pandas.pydata.org/pandas-docs/stable/getting_started/install.html#install-recommended-dependencies
# Use 'pytables' or 'h5py' for very large data sets. For interactive plots, use 'bokeh'. Other interesting
@fbender
fbender / sleep-timer.scpt
Last active March 5, 2024 09:51
AppleScript to put your Mac to sleep after X minutes, fading out the system volume shortly before sleeping. Can be turned into an app via the "Export" feature of the AppleScript Editor.
-- written by Florian Bender, 2015
-- based on work by Michael Wyszomierski <https://wysz.com/wyszdom/2009/06/simple-sleep-timer-with-applescript/>
-- license: Public Domain / CC0 <http://creativecommons.org/publicdomain/zero/1.0/>
tell application "System Events"
set volumeSettings to get volume settings
set volumeValue to (output volume of volumeSettings)
set fadeTime to 10 -- time in seconds for fade change
set fadeChange to (volumeValue div fadeTime)
-- display alert "Volume: " & volumeValue & ", Delta: " & fadeChange
display dialog "Sleep time (min):" default answer "25"
@fbender
fbender / fbender.zsh-theme
Created March 22, 2024 23:27
Personal ZSH theme based on steeef from official OMZ repository, heavily modified and quite verbose (WIP)
### custom Oh-My-ZSH theme by fbender
#
# verbose theme based on "steeef" from official omz repository
# - vcs_info reduced to show type, name, and branch (if available) of repository only
# - built-in slightly modified "timer" plugin from official omz repository
# - extended Python virtual environment logic, i.a. adding conda support
# - multi-line input (PS2) and debug (PS4) formatting
# - more and different colors, date and time information, running job info, and more
#
# recommended setopts: EXTENDED_HISTORY, RM_STAR_WAIT, CORRECT, CORRECT_ALL