Skip to content

Instantly share code, notes, and snippets.

@dstd
dstd / palette_fix.py
Created October 17, 2026 23:04
[mitmproxy] fix of transparency on syntax-highlighted content when `console_palette_transparent: false`
from mitmproxy import ctx
from mitmproxy.tools.console import palettes
_orig_palette = palettes.Palette.palette
def _patched_palette(self, transparent: bool):
lst = []
if transparent:
highback, lowback = None, None
else:
@dstd
dstd / default.conf
Created March 15, 2026 23:04
keyd mapping configuration
[ids]
*
[main]
leftalt = timeout(overload(alt, C-A-M-1), 300, layer(alt))
rightalt = timeout(overload(alt, C-A-M-2), 300, layer(alt))
control = layer(control)
capslock = layer(caps)
[alt]
@dstd
dstd / flowkill_addon.py
Created March 2, 2026 21:18
[mitmproxy][dirtyhack] Fixed version of flow.kill that really terminates the connections, rather just marking flows as killed
# Managed to workaround my problem via a dirty hack.
# Not quite good, but it works and solves my daily tasks.
class FlowKillFix:
def kill_flow(self, flow):
server = ctx.master.addons.get("proxyserver")
conn = flow.client_conn
handler = server.connections.get(conn.id)
dropped = []
if handler is not None:
handler.close_connection(conn, False)
@dstd
dstd / capslock.json
Last active March 2, 2026 21:19
[karabiner] bunch of modifications for karabiner
{
"description": "Swap input source while capslock being held; capslock+left/right/up/down as home/end/pgup/pgdn; capslock+\\ as capslock",
"manipulators": [
{
"conditions": [{
"input_sources": [{ "language": "en" }],
"type": "input_source_if"
}],
"from": {
"key_code": "caps_lock",
@dstd
dstd / pingavail.sh
Created February 11, 2022 21:53
Utility to monitor host availability changes by ping, with timestamps and durations
#!/bin/bash -l
# Utility to monitor host availability changes by ping, with timestamps and durations
HOST="$1"
ONLINE_INTERVAL=5
OFFLINE_INTERVAL=1
TIMEOUT=500
if [ "x$HOST" == "x" ]; then
echo "usage: $(basename "$0") host"
exit
@dstd
dstd / input_source_switch.json
Last active November 30, 2020 22:28
Input language switching mods for Karabiner
{
"title":"Input source change",
"rules": [
{
"description": "If pressed alone, CmdL for English, CmdR for Russian",
"manipulators": [
{
"from": {
"key_code": "left_command",
"modifiers": {"optional": ["any"]}
@dstd
dstd / git_find_file_in_history.sh
Created January 30, 2019 11:23
Find specific file in GIT history
#!/usr/bin/env bash
# Find specific file in GIT history
if [ "$1" = "" ]; then
echo "Usage: ./$(basename ${0}) file" && exit 1
fi
_file=$1
blob=`git hash-object $_file`
@dstd
dstd / customrules.js
Created February 27, 2018 13:07
[Fiddler] JSON response modification
// ...
static function OnBeforeResponse(oSession: Session) {
// ...
if (oSession.uriContains("/someMethod")) {
var json = Fiddler.WebFormats.JSON.JsonDecode(oSession.GetResponseBodyAsString()).JSONObject;
var p = json["field"]["subfield"]["subsubfield"];
p["field1"] = 0 != 1;
p["anotherfield2"] = 0 != 0;
p["yaf3"] = 0 != 1;
@dstd
dstd / customrules.js
Last active February 27, 2018 13:02
[Fiddler] Sessions coloring
// ...
static function OnBeforeRequest(oSession: Session) {
// ...
var clientColors = ["red", "blue", "green", "gold", "orange", "purple"];
var clientId = oSession.oRequest.headers["User-Agent"] + oSession.oRequest.headers["Authorization"];
oSession["ui-color"] = clientColors[Math.abs(clientId.GetHashCode()) % clientColors.length];
// ...
}
// ...
@dstd
dstd / get_path_true_case.sh
Created February 2, 2017 21:20
Bash function to get correctly-cased path from case insensitive value
get_path_true_case()
{
local C_PATH="/"
local C=""
local OLD_IFS="$IFS"
IFS=/
for C in $1; do
if [ "$C_PATH" = "/" ]; then
C_PATH=`find "$C_PATH" -maxdepth 1 -type d -ipath "$C_PATH$C"`
else