Skip to content

Instantly share code, notes, and snippets.

View EkriirkE's full-sized avatar
😴
Schlafen

Erik Johnson EkriirkE

😴
Schlafen
View GitHub Profile
@EkriirkE
EkriirkE / pyproject.toml
Last active May 3, 2026 21:10
Preferred python checks and balances
[tool.black]
line-length = 999999
[tool.ruff]
line-length = 65535
indent-width = 4
show-fixes = true
select = [
#"ALL",
#"D", # docstring
@EkriirkE
EkriirkE / vscode-python-tabs.md
Last active April 29, 2026 19:35
VSCode: Python Formatters with superior TAB indentation

Spaces for indentation are a sin against *.deity, especially for python! Why would you use mulitples of alignment characters for an indentation-sensitive language? After trying a handful of formatters out there, Black did the best job for my tastes. Except for its enshittification of indentations.
VSCode has built-in converters for indentation, which is great, and they can be used to repair Black's errors;

  1. First convert the code to Space indent to make Black happy ( optional due to an old black-specific bug psf/black#3667 )
  2. Run Format Doucument (using default formatter, so this can be language independent)
  3. Convert back to Tabs

And you can write a VSCode task for this to go in 1 click/keypress! Put in your tasks.json (File > Preferences > Tasks):

# EkriirkE 2025 - These steps will turn a (non)-square photo into a square version of itself:
# 1) The original image is stretch/squished to fit a square in the larger dimention
# 2) This distorted image is then blurred to become a background
# 3) The original photo is placed unaltered in the centre; so either the top+bottom, or left+right edges are filled with a "continuation" of the original
$InputFile = "MyRectangularPhoto.jpg"
$OutputFile = "MySquarePhoto.jpg"
#Squarify image by adding blur to empty space
#Load original

Atlassian Cloud does not provide a way to sync user photos. They mention steps in certain provisioning processes - but for us within MS/Entra/Azure, the documentation is outdated and broken. (MS does not support sending photos data via provisioning)

Various online searches just result in closed atlassian Jira issues, ignoring pleas for an official API.

The frontend https://admin.atlassian.com/o/{orgId}/users admin panel has the ability to set user photos, though. Simply spying on the web requests shows a multipart form PUT to https://admin.atlassian.com/gateway/api/users/{userId}/manage/avatar.

After some experimentation, an API key from the org admin /api-keys page used as an Authorization: Bearer token works fine on that endpoint! The return data is a JSON string with the new user avatar URL {"url":"https://..."}

**CAVEAT: The photo(s) should be square. This endpoint will squish a non-square image into a square, distorting it. So pre-process the images you upload with this method accordi

@EkriirkE
EkriirkE / .git_hooks_pre-commit
Created February 12, 2026 16:24
Preserve file ownership and timestamps of entire working folder with git commits
#EkriirkE stats
IGNORE=("." ".stats")
if [ -f .statsignore ]; then
while read -r l; do
[[ ! -z "$l" ]] && IGNORE+=("$l")
done < .statsignore
fi
if [ -f .gitignore ]; then
while read -r l; do
[[ ! -z "$l" ]] && IGNORE+=("$l")
@EkriirkE
EkriirkE / datesync.py
Created February 12, 2026 09:56
Syncronise file timestamps between two locations
import os
import pathlib
#For every file and folder found in "old", check if it exists in "new". If it does, update the "new" timestamp to the "old" couterpart.
old="/home/erik/Development.new/"
new="/home/erik/Development/"
i=e=0
for f in pathlib.Path(old).rglob("*"):
lf=os.path.join(new,f.as_posix()[len(old):])
@EkriirkE
EkriirkE / shared_preferences.preferences_pb.py
Last active February 12, 2026 10:09
Android app storing settings in a binary format. I don't know the name of this format but this is what I deduced and worked for me
#Android app was storing settings in a binary format. I don't know the name of this format but this is what I deduced and worked for my usecase
prefs={}
with open("shared_preferences.preferences_pb","rb") as x:
while True:
if len(x.read(1))<1: break#0A
l=x.read(1)[0]
if l & 0x80: l=(l&0x7F)|(x.read(1)[0]<<7)
t=x.read(l)
if len(t)<1: break
@EkriirkE
EkriirkE / wifireset.sh.md
Last active February 12, 2026 10:02
rtw_8821cu USB WiFi dongle intermittently disabling

I have a cheap chinese USB WiFi dongle identifying as 0bda:c811 Realtek Semiconductor Corp. 802.11ac NIC, using the rtw_8821cu drivers/firmware.
It tries to appear as a drivers "CD" every boot/insertion but usb_modeswitch takes care of that.
It works great, except when it doesn't; it will randomly go offline/disappear and dmesg looks something like this every time:

[94250.702748] rtw_8821cu 4-1:1.0: unused phy status page (6)
[99560.537336] rtw_8821cu 4-1:1.0: unused phy status page (8)
[101755.068962] rtw_8821cu 4-1:1.0: unused phy status page (10)
[102762.647001] rtw_8821cu 4-1:1.0: failed to get urb length:32768
[102762.647788] rtw_8821cu 4-1:1.0: unused phy status page (8)
@EkriirkE
EkriirkE / FridaUnpin.md
Last active December 27, 2025 19:44
Random android crap

On-device SSL Unpinning with Frida

I like mitmproxy, it worked great until apps started pinning SSL certs.
Then LSposed module SSLUnpinning was found and worked great until apps started using more broad detection.
Then I read about Frida but could not figure out how to get it to work. Most examples involve USB + ADB which I was not too keen on.
I wanted to have it all working on-device with termux. frida-server seemed to run fine, but frida (frida-tools) itself was not cooperating.
Eventually I got to the point where frida seems to want to run but was running into a permission issue with Magisk and the zygote process:
# frida --codeshare Q0120S/bypass-ssl-pinning -f com.theapp.name results in Failed to spawn: unable to access PID 20107 (zygote) while preparing for app launch; try disabling Magisk Hide in case it is active

After searching around there was a hint to use the PID of the app instead - what seems to happen is if you pass the app name it attempts to launch and attach via zyg

#!/usr/bin/env python3
BACKUP_FILE = 'backup.ab'
# Constants
# ref: https://github.com/omnirom/android_bootable_recovery/blob/android-7.1/adbbu/twadbstream.h
TWRP = b'TWRP' + b'\x00\x00\x00\x00'
TWSTREAMHDR = b'twstreamheader'
TWFN = b'twfilename'