Skip to content

Instantly share code, notes, and snippets.

View ddkasa's full-sized avatar
🎯
Focusing

David Kasakaitis ddkasa

🎯
Focusing
  • London, United Kingdom
  • 07:09 (UTC +01:00)
View GitHub Profile
@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())
@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
@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

@mikeboiko
mikeboiko / git-credential-rbw
Last active June 13, 2025 10:41
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
@andrebrait
andrebrait / keychron_linux.md
Last active May 28, 2025 09:46
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.

@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.
@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
# Credit for this: Nicholas Swift
# as found at https://medium.com/@nicholas.w.swift/easy-a-star-pathfinding-7e6689c7f7b2
from warnings import warn
import heapq
class Node:
"""
A node class for A* Pathfinding
"""
@jnhmcknight
jnhmcknight / colour-inverter.py
Created June 15, 2018 14:09
Invert all colours in a CSS file.
#!/usr/bin/env python
# Concept taken from http://code.activestate.com/recipes/527747-invert-css-hex-colors/
# Modified to take the css filename as an argument and also handle rgb() and rgba() values
#
# To run:
# python ./colour-inverter.py <path/to/file.css>
import os
import re
@plembo
plembo / CalibreServerOnLinux.md
Last active May 21, 2025 19:03
Calibre Server on Linux

Calibre Server on Linux

Introduction

Calibre is a powerful cross-platform, open source, ebook manager and editing platform. Its calibre-server component can be used to publish an e-book library on a local network. While you can launch calibre-server as a desktop application, it can also be run as a daemon on a headless Linux server.

This tutorial on setting up calibre-server using Ubuntu 14.04 is very good, but dated.