Skip to content

Instantly share code, notes, and snippets.

View cb109's full-sized avatar
💭
🍴 🐘

Christoph Bülter cb109

💭
🍴 🐘
View GitHub Profile
@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
@cb109
cb109 / gothic_1_on_retroid_pocket_5.jpeg
Last active February 5, 2025 09:05
How to: Gothic 1 on the Retroid Pocket 5
gothic_1_on_retroid_pocket_5.jpeg
@cb109
cb109 / gameboy_emulator_save_file_locations.md
Last active December 27, 2024 18:55
Transferring Gameboy save states between Onion OS (using RetroArch e.g. on the Miyoo Mini) and Funkey OS (using PicoArch e.g. on the RG Nano)

Location for in game save files on Onion OS:

/mnt/SDCARD/Saves/CurrentProfile/saves/Gambatte/Mystic Quest (Europe).srm

Location for in game save files on DrUm78's Funkey OS:

/mnt/Funkey/.picoarch/data/gambatte/Mystic Quest (Europe).sav

Despite the different file extensions, these files are interchangeable. You can copy from one location to another and rename the file extension for the system (e.g. with Dingux Commander) and the emulator/game should detect it

@cb109
cb109 / check_for_git_merge_conflicts_on_master.sh
Last active August 16, 2024 08:26
Check for any merge conflicts as preparation for git pull (upstream VS local branch)
#!/bin/bash
# In this example we want to execute 'git pull' on the local 'master' branch, but we
# want to make sure that pull won't introduce conflicts and by that a broken checkout.
# The script below will do an in-memory merge of the upstream master and local master
# and exit with a non-zero code if that merge produced any conflicts.
#
# A snippet like this is useful for deployment scripts that involve 'git pull' to
# prevent breaking production if for some reason a conflict has bypassed CI.
#
@cb109
cb109 / cross_origin_request_cookie_ajax_links.md
Last active April 8, 2025 11:29
Sending/accepting cookies with/from cross-origin requests
@cb109
cb109 / recover_from_lost_django_migration_files.md
Last active July 1, 2024 11:36
Recover from losing Django migration files while preserving the database (tested on Django 3.2)

Let me point out that losing migration files is a very bad situation and should be avoided at all costs, but if it happens, having a step-by-step way to preserve the database is a good thing to have. It is a terrible situation to be in if your database/models/migrations are a shared state across multiple team members, and that would require a coordinated halt and cleanup so everyone can move forward from the same base state again, with a proper migration files workflow from then on.

Let's assume you have models, any number of migration files, all of those applied to your existing database. Now for some reason, poof!, all the migration files are gone.

@cb109
cb109 / remove_django_model_field_without_actually_removing_it.md
Last active May 8, 2024 08:59
Partially unmanaged models in Django ORM aka ignore certain columns/fields

Partially ignore table fields on a Django model

There may come a day where your table includes a field that your Django app should ignore and not even be aware of, while other clients may still need to use that field in production through normal SQL commands. How to achieve this?

Removing a model field will give you a migration step like this:

        migrations.RemoveField(
 model_name="mymodel",
@cb109
cb109 / ffmpeg_overlay_progressbar.py
Created April 23, 2024 07:48
Overlay a simple growing/moving progressbar on the bottom of a video using ffmpeg
import subprocess
def add_progressbar_on_top_of_video(
input_video_filepath: str,
output_video_filepath: str,
width: int,
height: int,
duration: float,
fps: float = 25.0,
progressbar_height: int = 8,
@cb109
cb109 / class_attribute_knows_its_name_on_parent_class.py
Created April 5, 2024 08:41
Give class attributes knowledge about how they are used on their parent class
class Bar:
def __init__(self):
self.parent_class_attr_name = None
class LetClassAttributesKnowTheirName(type):
def __new__(mcs, name, bases, attributes):
for attr_name, attr_value in attributes.items():
if isinstance(attr_value, Bar):
attr_value.parent_class_attr_name = attr_name
@cb109
cb109 / base_site.html
Last active February 22, 2024 12:51
Django Admin custom clientside Search for Index (tested with Django 3.2)
{% extends "admin/base_site.html" %}
{% block usertools %}
{% url 'admin:index' as admin_index_url %}
{% if request.get_full_path == admin_index_url %}
<input
type="text"
id="admin_base_search"
placeholder="Search..."
autofocus