Skip to content

Instantly share code, notes, and snippets.

@apfelchips
apfelchips / cdm_fio.sh
Last active February 5, 2024 23:48 — forked from snizovtsev/cdm_fio.sh
Reproducing CrystalDiskMark tests with fio - fixes for https://unix.stackexchange.com/revisions/480191/9
#!/usr/bin/env bash
## This script is based on https://unix.stackexchange.com/revisions/480191/9 and https://gist.github.com/snizovtsev/1e57da4bf1cdae16599d59619600ee07
LOOPS=1 #How many times to run each test
SIZE=32 #Size of each test, multiples of 32 recommended for Q32 tests to give the most accurate results.
WRITEZERO=0 #Set whether to write zeroes or randoms to testfile (random is the default for both fio and crystaldiskmark); dd benchmarks typically only write zeroes which is why there can be a speed difference.
QSIZE=$(($SIZE / 32)) #Size of Q32Seq tests
SIZE+=m
@apfelchips
apfelchips / .stignore_synced
Last active August 21, 2024 13:22
Backup / Sync exclusion patterns
// https://docs.syncthing.net/users/ignoring
// (?d) prefix to allow deletion of ignored files
// (?i) prefix makes the matching case insensitive
// echo #include .stignore_synced >> .stignore
(?d)(?i).Trash
(?d).DS_Store
._*
(?d)(?i)Thumbs.db
#!/usr/bin/env python3
# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/
# generate server.pem with the following command:
# openssl req -new -x509 -keyout key.pem -out server.pem -days 365 -nodes
# run as follows:
# python simple-https-server.py
# then in your browser, visit:
# https://localhost:8443
import http.server
# docs: https://github.com/fsquillace/junest#installation
# git clone https://github.com/fsquillace/junest.git ~/.local/share/junest
if [ $BASH_VERSION ] && [ $JUNEST_ENV ]; then
export debian_chroot="junest"
fi
if [ ! $JUNEST_ENV ] && [ -d "$HOME/.local/share/junest/bin" ]; then
export PATH="$HOME/.local/share/junest/bin:$PATH"
fi
@apfelchips
apfelchips / aliexpress_en.js
Last active August 6, 2024 19:08
userscript that forces aliexpress.com to be in english
// ==UserScript==
// @name aliexpress_en
// @version 0.2
// @description always redirect to aliexpress.com and reset the location/language/currency settings. This script pins locale settings cookie. Please clear cookies on all "aliexpress" domains before using this userscript.
// @author @attero@mastodon.social
// @match *://www.aliexpress.com/*
// @match *://*.aliexpress.com/*
// @match *://www.aliexpress.ru/*
// @match *://*.aliexpress.ru/*
// @noframes
@apfelchips
apfelchips / serv.py
Last active December 15, 2022 16:11 — forked from phrawzty/2serv.py
simple python http server to dump request headers
#!/usr/bin/env python3
"""
inspiration:
https://gist.github.com/phrawzty/62540f146ee5e74ea1ab?permalink_comment_id=2358615
https://gist.github.com/nitaku/10d0662536f37a087e1b#file-server-py
example:
curl -s -H "X-Something: yeah" localhost:8080
curl --data "{\"this\":\"is a test\"}" localhost:8080
@apfelchips
apfelchips / _bash_script_template.sh
Last active September 2, 2024 19:25
BASH helpers / backports / shims
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
SCRIPT_DIR=$(realpath -- $(dirname -- $0))
SCRIPT_NAME=$(basename "$0")
#SCRIPT_TMP=$(mktemp -d "${TMPDIR:-/tmp}/${SCRIPT_NAME}_XXXXXXX")
SCRIPT_VERSION='0.0.1'
VERBOSITY=0
TARGET_USER=
@apfelchips
apfelchips / add-ssh-keys.yml
Created March 29, 2022 21:04 — forked from EntropyWorks/add-ssh-keys.yml
Add all the hosts from your ansible inventory to your .ssh/known_hosts and also use ssh-copy-id to add keys to the hosts
---
# Original idea found at http://stackoverflow.com/a/39083724
#
# ansible -i inventory.ini add-ssh-keys.yml
#
- name: Store known hosts of 'all' the hosts in the inventory file
hosts: localhost
connection: local
vars:
ssh_known_hosts_command: "ssh-keyscan -T 10"
@apfelchips
apfelchips / url-open.sh
Last active February 11, 2024 11:32
url-open.sh - open links contained in .URL and .webloc files in your default browser
#!/bin/bash
# src: https://gist.github.com/apfelchips/001b4ffb22c0578220595623f5546107
# mkdir -p "$HOME/bin" && curl -L "https://git.io/JKGha" -o "$HOME/bin/url-open.sh" && chmod +x "$HOME/bin/url-open.sh" && url-open.sh
install_desktop_file(){
# MimeSpec: https://gitlab.freedesktop.org/xdg/shared-mime-info/-/blob/master/data/freedesktop.org.xml.in
# Desktop Entry Spec: https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s07.html
echo "creating .desktop entry"
@apfelchips
apfelchips / ngrok.service
Last active August 2, 2021 14:38
autostart ngrok with systemd - put binary and ngrok.yml into /opt/ngrok/
# put me in: /etc/systemd/system/
# ngrok binary: https://ngrok.com/download
# sudo chmod +x /opt/ngrok/ngrok
[Unit]
Description=ngrok
After=network.target
[Service]
ExecStart=/opt/ngrok/ngrok start --all --config /opt/ngrok/ngrok.yml
ExecReload=/bin/kill -HUP $MAINPID