Skip to content

Instantly share code, notes, and snippets.

View cb109's full-sized avatar
💭
🍴 🐘

Christoph Bülter cb109

💭
🍴 🐘
View GitHub Profile
@cb109
cb109 / json_example.png
Last active April 20, 2026 12:50
Poor Man's JSON Syntax Highlighting
json_example.png
@cb109
cb109 / inspect_hoverable_ui.md
Created April 20, 2026 11:29
How to inspect Web-UI elements in dev-tools that depend on volatile JavaScript behavior e.g. hover
  • Open Chrome dev-tools via e.g. F12
  • Open the "Run Command" window e.g. via Ctrl+Shift+P
  • Start typing "Disable JavaScript" to preselect that command (do not confirm it yet)
  • Hover your mouse where needed to show the UI element to inspect e.g. a tooltip dialog
  • Hit enter to confirm disabling JavaScript, which will hopefully make the element stay where it is

You can now inspect the element in dev-tools as needed. Run the command "Enable JavaScript" once you are done.

@cb109
cb109 / README.md
Last active March 11, 2026 10:08
chrome extension to automatically click "Request review from Copilot" for a new/existing PR

To create a PR and trigger a copilot review, first install the GitHub CLI on your machine, then also this extension to your browser, then do e.g.:

gh pr create --base master --head develop --title "my title" --body "" --label my-label
open "$(gh pr list --head develop --base master --json url -q '.[0].url')?copilot_review=1"
@cb109
cb109 / background.js
Last active March 24, 2026 08:34
chrome extension to auto-increment cache busting query parameter in url
/**
* Installation: chrome://extensions -> Load unpacked -> Select folder
*
* Bind e.g. Ctrl+Shift+R as a shortcut for "cachebust-refresh" in
* chrome://extensions/shortcuts (e.g. Ctrl+Shift+R)
*/
async function bust(tab) {
if (!tab.url) return;
@cb109
cb109 / hard_reset_django_migrations.md
Last active November 12, 2025 10:02
Hard-reset all Django migrations
@cb109
cb109 / analysing_and_improving_python_import_times.md
Last active November 10, 2025 10:04
Analysing and improving Python import times

Run some command that initializes your codebase, e.g. for a Django project do:

time python -X importtime manage.py --version 2> importtimes.txt

Visualize and analyse contents of importtimes.txt with: https://kmichel.github.io/python-importtime-graph/

Defer imports by moving them inside functions/methods. With Python 3.15+ we will also be able to mark imports as lazy like lazy import xyz within the top level module scope, neat.

With deferring the largest/slowest few imports the startup time for any python commands can easily be halved or more, making everything noticeably faster!

@cb109
cb109 / chromeworker.service
Last active August 28, 2025 08:22
Reusable Chrome Instance for Puppeteer using Django Model and Management Command
[Unit]
Description=Chrome Browser Worker
After=network.target
[Service]
Environment=PYTHONUNBUFFERED=1
Environment=DJANGO_DEPLOYMENT_TYPE=prod
User=www-data
Group=www-data
WorkingDirectory=/opt/myproject
@cb109
cb109 / conftest.py
Last active May 30, 2025 06:51
Passing information from pytest to cypress for e2e tests using an env var and a test-specific view
import os
def e2e_my_test(db):
"""We assume this fixture is run before launching the cypress spec using the same name."""
my_object = ...
# Note: We may have to make this URL relative or replace its domain
# with live_server.url to avoid running into same-origin constraints
# in the browser. Though cypress v12 upwards is fine with that!
os.environ["MY_DYNAMIC_URL"] = my_object.url
@cb109
cb109 / django-media-filer-nginx.conf
Last active April 24, 2025 07:36
nginx CORS header for Django media (and django-filer) resources
# Explicitly set Access-Control-Allow-Origin header for certain
# responses and domains that ask for files. This helps e.g. with test
# setups on the development machine and an accompanying smartphone
# (assuming we point it to the machine's IP in local network, 10.33.1.XX
# here), as well as production setups that involve several domains.
#
server {
...
# django-filer has unchanging canonical URLs for any uploaded files,
@cb109
cb109 / conquest.bat
Created February 6, 2025 21:07
Conquest of the New World in DOSBox on Linux
mount c ~/dosgames
imgmount d "~/dosgames/conqstND/cd/Conquest.cue" -t iso -fs iso
c:
cd CONQSTND
cnwmain.exe -usecd