Skip to content

Instantly share code, notes, and snippets.

@Szpadel
Szpadel / aws-sts-activate.bash
Created October 28, 2025 08:50
aws-sts-activate.fish - virtualenv like command for switching to different aws account using assume role. AI converted verions (untested) for bash and zsh
# Source this file in bash: source /path/to/aws-sts.bash
# Provides:
# - aws-sts-activate (alias for aws_sts_activate)
# - aws-sts-deactivate (alias for aws_sts_deactivate)
# Behavior mirrors your Fish version:
# * Loads/writes a cache file with credentials
# * Assumes role when cache is missing/near expiry
# * Shows the active profile in your prompt (left side, bash has no RPROMPT)
# * Auto-refreshes creds when <=30m to expiry (pre-exec and pre-prompt)

First we need to abstract using aws with sts AssumeRole. Put this file anywhere in your $PATH

~.local/bin/sts-aws

#!/usr/bin/env bash
set -euo pipefail

aws-sts() {
    local account=$1

This is instruction how to run multi level compression for zram swap

The idea is that we want to be able to quickly swap memory away when we need memory, but cold pages should be compressed further. This instruction also includes traditional block storage for uncompressible pages that would not decrease otherwise any memory usage. Zstd have nice property that decompression speed is basically independend from compression level, so using higher levels will only participate in compression speed. Using zstd for default compresor causes some ui lags when memory need to be paged out, therefore is okay, but not great solution. Using zstd for recompression in the background have very little effect assuming you do not use every cpu cycle, and compressing old pages make it failry safe that they will not be needed anytime soon. This might consume 1 cpu core during recompression (accounted for recompress-idle-ram script) but otherwise allows best from both worlds, fast memory reclaim, fast swap read and very good com

"""Virtual Environment Manager for Python Scripts.
This module provides automatic virtual environment management for Python scripts,
with cross-platform support for Linux, macOS, and Windows. It handles creation,
updating, and execution of scripts within isolated virtual environments.
Features:
- Automatic venv creation and management
- Cross-platform compatibility (Linux, macOS, Windows)
- Version-pinned dependencies
@Szpadel
Szpadel / rdcalc.py
Last active July 4, 2023 12:25
Resistor Divider CALCulator
#!/usr/bin/env python3
import argparse
import itertools
from rich import print
from rich.table import Table
def format_resistor_value(number):
formatted_number = format(number, ".1f").rstrip('0').rstrip('.')
return formatted_number
@Szpadel
Szpadel / Readme.md
Last active June 12, 2020 11:17
screeps-tracer

Note: Currently this only works via Steam client

Usage:

Trace single function/method

@trace
function something() {
}
#!/usr/bin/env bash
sudo -v
trap 'echo "Something went wrong, restart script to retry"' ERR
set -ex
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
downloadPkg() {
echo "Downloading $1..."
@Szpadel
Szpadel / meltdown-check.sh
Last active January 15, 2018 15:53
Script for checking system status against Meltdown issue
#!/usr/bin/env bash
CR="\e[0m"
CBAD="\e[41m"
CWRN="\e[33m"
COK="\e[32m"
CINF="\e[34m"
isPcidPresent() {
grep -q pcid /proc/cpuinfo
@Szpadel
Szpadel / google-maps-info-styles.js
Created June 3, 2015 15:20
Adds css classes to google maps popups
(function(){
function styleAllBoxes() {
var cnt = $('.gm-style-iw');
cnt.each(function(index){
styleBox($(cnt[index]));
});
}
function styleBox(item) {
@Szpadel
Szpadel / example.cpp
Last active August 29, 2015 13:57
MPI Datatybe Builder
#include <mpidatatypebuilder.h>
#include <mpi.h>
using namespace std;
struct DataSet {
double vectorA[131072];
double vectorB[131072];
double arg1;