Skip to content

Instantly share code, notes, and snippets.

@Semmu
Semmu / README.md
Created March 30, 2024 14:42
Shell script to test block device write speed at multiple locations

this simple shell script tests the write speed of a block device.

it splits the device into $NUM_TESTS parts and writes $WRITE_SIZE_IN_MB data at each location using dd. then it does a last write test at the very end of the device.

it can be used to print the write speed of the device on its whole range instead of just the beginning, like what a typical dd would do. this is important for e.g. HDDs, where the speed usually decreases at the end, because of the constant angular velocity but varying bit "density".

the first couple of lines define the default values for some arguments, and they can be overridden by invoking the script like this:

NUM_TESTS=3 WRITE_SIZE_IN_MB=10 ./block_device_multiple_dd_write_test.sh /dev/sdX
@Semmu
Semmu / README
Last active October 12, 2023 23:15
1. replace `!!!` everywhere with meaningful values
- your cookie in the fetch headers
- your tokens in the fetch URLs
grab them from your browser devtools network tab and copy the requests as nodejs fetch commands to make it easy
2. first run `node scrape_archived.js`
3. then run `./scrape.sh`
FYI it only scrapes the archived messages of your saved items (saved messages has 3 possible states: in-progress, complete, and archived)
@Semmu
Semmu / Dockerfile
Last active September 21, 2022 00:38
super simple shell-based host monitor script wrapped in Docker publishing availability to the local MQTT broker
FROM eclipse-mosquitto:latest # as we need mosquitto_pub
COPY monitor.sh .
CMD ["/bin/sh", "monitor.sh"]
@Semmu
Semmu / .bash_aliases
Created September 3, 2022 23:09
alias docker-compose
alias docker-compose="docker run --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "$PWD:$PWD" \
-w="$PWD" \
docker/compose"
@Semmu
Semmu / wacom.sh
Last active February 21, 2022 16:41
my xsetwacom commands
# setup keybinding for those 4 buttons
xsetwacom --set "Wacom Bamboo Pad pad" Button 1 "key +ctrl z -ctrl" # <
xsetwacom --set "Wacom Bamboo Pad pad" Button 3 "key backspace" # >
xsetwacom --set "Wacom Bamboo Pad pad" Button 1 "key +ctrl s -ctrl" # FN1
xsetwacom --set "Wacom Bamboo Pad pad" Button 3 "key +super up -super" # FN2
# map to output
export $STYLUSID=$(xinput list | grep stylus | cut -c 55-57)
export $ERASERID=$(xinput list | grep eraser | cut -c 55-57)
export $DISPLAYID= # run xrandr and substitute needed display id here, like HDMI-1, DP-1-2 or eDP-1
@Semmu
Semmu / .bashrc
Created January 17, 2018 16:20
Descriptive git bash prompt
RESET='\[\033[0m\]'
RED='\[\033[00;31m\]'
GREEN='\[\033[00;32m\]'
YELLOW='\[\033[00;33m\]'
BLUE='\[\033[00;34m\]'
PURPLE='\[\033[00;35m\]'
CYAN='\[\033[00;36m\]'
LIGHTGRAY='\[\033[00;37m\]'
@Semmu
Semmu / bkmrk.sh
Last active September 12, 2017 14:46
#!/bin/bash
#
# SIMPLE FILESYSTEM BOOKMARK MANAGEMENT
#
# usage:
# - create a bookmark for your current working directory with `bkmrk $NAME`
# - cd to any of your bookmarks with `jump $NAME`
# - list your bookmarks and their destinations with `lsbkmrks`
@Semmu
Semmu / bug.py
Created August 7, 2017 14:02
Sublime Text color scheme force-refresh (sometimes different open windows don't register the change)
[ v.settings().erase("color_scheme") for views in [ w.views() for w in sublime.windows() ] for v in views ]
@Semmu
Semmu / shout.sh
Created July 14, 2017 22:30
Small convenience function to notify when a long running command finishes
# small convenience function to notify when a long running command finishes
#
# usage:
# shout [full command with arguments and whatnot]
#
# eg. shout sudo apt update
#
function shout {
@Semmu
Semmu / ripper.sh
Created January 6, 2017 19:13
VGM ripper (http://downloads.khinsider.com/), batch download whole albums. First argument to the script must be an album URL.
#!/bin/bash
TRACKS=$(curl -v --silent ${1} 2>/dev/null | grep ".mp3\">Download" | sed -e 's/.*href=\"\(.*\)\">Download.*/\1/')
for TRACK in ${TRACKS}; do
URL=$(curl -v --silent ${TRACK} 2>/dev/null | grep "Click here" | sed -e 's/.*href=\"\(.*\)\">Click.*/\1/')
wget ${URL}
done