Skip to content

Instantly share code, notes, and snippets.

View dnth's full-sized avatar
🏠
Working from home

Dickson Neoh dnth

🏠
Working from home
View GitHub Profile
@bsdnoobz
bsdnoobz / read-camera.py
Last active December 22, 2023 18:20
Displaying webcam feed using OpenCV and Python+PySide.
#!/usr/bin/env python
from PySide.QtCore import *
from PySide.QtGui import *
import cv2
import sys
class MainApp(QWidget):
def __init__(self):
@andrebrait
andrebrait / keychron_linux.md
Last active July 28, 2024 20:23
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.

from timm import create_model
from fastai.vision.learner import _add_norm
class TimmBody(nn.Module):
def __init__(self, arch:str, pretrained:bool=True, cut=None, n_in:int=3):
super().__init__()
model = create_model(arch, pretrained=pretrained, num_classes=0, in_chans=n_in)
if isinstance(cut, int): self.model = nn.Sequential(*list(model.children())[:cut])
elif callable(cut): self.model = cut(model)
elif cut is None: self.model = model