Skip to content

Instantly share code, notes, and snippets.

View JackAtOmenApps's full-sized avatar
💭
Happily typing away

Jack at Omen Apps JackAtOmenApps

💭
Happily typing away
View GitHub Profile
@smcoll
smcoll / django_migration_pk_to_uuid.py
Last active August 6, 2024 20:14
Django migration converting integer pk table to UUID pk table
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import uuid
from django.db import migrations, models
def fill_mymodel_uuid(apps, schema_editor):
db_alias = schema_editor.connection.alias
MyModel = apps.get_model('myapp', 'MyModel')
@danzig666
danzig666 / geopackage_whole_project.py
Created August 11, 2020 09:22
Save whole QGIS project to geopackage
# input: all layers
# save path: save_layerpath project property / current project majority path
# replaces all postgis datasources with gpkg!
##########################
from qgis.utils import iface
from qgis.core import *
from qgis.PyQt.QtWidgets import *
from PyQt5.QtCore import *
from processing.tools import dataobjects
@cvanelteren
cvanelteren / multilayer_layout.py
Last active January 8, 2024 20:53
Flat multilayer layout networkx
import proplot as plt, cmasher as cmr, pandas as pd, numpy as np, os, sys, networkx as nx, warnings
def multilayer_layout(
G: nx.Graph,
subset_key="layer",
layout=nx.spring_layout,
separation: float = 10.0,
) -> dict:
# set positions
@lmann4
lmann4 / show_db_queries.py
Last active November 7, 2024 18:18
A utilitiy for adding printing and debugging queries.
import inspect
import logging
import shutil
import sys
from time import time
from types import MethodType
from typing import Optional
from django.conf import settings
from django.db import DEFAULT_DB_ALIAS, connections