Skip to content

Instantly share code, notes, and snippets.

View ddkasa's full-sized avatar
🎯
Focusing

David Kasakaitis ddkasa

🎯
Focusing
  • London, United Kingdom
  • 11:18 (UTC +01:00)
View GitHub Profile
@m3nu
m3nu / simpletreemodel.py
Last active October 10, 2024 01:23
QTreeView with Custom QAbstractItemModel and Lazy Loading
"""
This is an adjusted version of the official simpletreemodel[1] that adds lazy loading and uses a dict as backend.
Instead of the dict it could also use a database or similar. Items are only loaded when expanded, which allows
for speedy startup-time, even with 2.5m items.
1: https://github.com/baoboa/pyqt5/tree/master/examples/itemviews/simpletreemodel
"""
import sys
@ckrybus
ckrybus / 1integrate-django-filter-django-tables2-django-crispy-forms.md
Last active March 30, 2025 05:44
How to integrate django-crispy-forms, django-tables2 and django-filter in order to display a paginated table with filter functionality.
@andrebrait
andrebrait / keychron_linux.md
Last active May 17, 2025 04:39
Keychron keyboards on Linux + Bluetooth fixes

Here is the best setup (I think so :D) for K-series Keychron keyboards on Linux.

Note: many newer Keychron keyboards use QMK as firmware and most tips here do not apply to them. Maybe the ones related to Bluetooth can be useful, but everything related to Apple's keyboard module (hid_apple) on Linux, won't work. As far as I know, all QMK-based boards use the hid_generic module instead. Examples of QMK-based boards are: Q, Q-Pro, V, K-Pro, etc.

Most of these commands have been tested on Ubuntu 20.04 and should also work on most Debian-based distributions. If a command happens not to work for you, take a look in the comment section.

Make Fn + F-keys work (NOT FOR QMK-BASED BOARDS)

Older Keychron keyboards (those not based on QMK) use the hid_apple driver on Linux, even in the Windows/Android mode, both in Bluetooth and Wired modes.

@mikeboiko
mikeboiko / git-credential-rbw
Last active December 21, 2024 22:11
Use bitwarden rbw as git-credential helper
#!/usr/bin/env bash
# rbw git-credential helper
# Based on https://github.com/lastpass/lastpass-cli/blob/master/contrib/examples/git-credential-lastpass
# A credential helper for git to retrieve usernames and passwords from rbw.
# For general usage, see https://git-scm.com/docs/gitcredentials.
# Here's a quick version:
# 1. Put this somewhere in your path.
# 2. git config --global credential.helper rbw
@daxburatto
daxburatto / Validating a Hex Value.md
Last active February 2, 2025 10:02
Validating a Hex Value with Regex

Validating a Hex Value

/^#?([a-f0-9]{6}|[a-f0-9]{3})$/

Summary

A Regular expression, or Regex, is a method of validating a specific piece of text by use of a sequence of characters each including their own fundimental principles. Regex can be used to validate emails, hex values, URLs, and HTML. In this case we will be focusing on Hex values which are typically a # with 6 numbers or letters following it.

Table of Contents

@rochacbruno
rochacbruno / validate_dataclass.py
Created September 30, 2021 11:13
Validate Dataclass Python
from typing import Union, List
from dataclasses import dataclass
class Validations:
def __post_init__(self):
"""Run validation methods if declared.
The validation method can be a simple check
that raises ValueError or a transformation to
@ispanos
ispanos / package_history.py
Created October 10, 2023 19:23
dnf 'exclusively' installed packages
import subprocess
import re
import sys
def get_pks_repoquery():
# Use repoquery to create a list of userinstalled packages
return set(subprocess.check_output(
'dnf repoquery --userinstalled --qf "%{name}"', shell=True, text=True
).splitlines())