Skip to content

Instantly share code, notes, and snippets.

View ChenSun-Phys's full-sized avatar

Chen Sun ChenSun-Phys

View GitHub Profile

TLP 1.4 Test: Battery Care for Samsung laptops

Read the overview document first.

Supported Features

Samsung laptops using the samsung_laptop driver have a feature called 'battery life extender', basically a fixed stop charge threshold at 80%. The hardware behaviour is:

  1. Connected to the charger, charging stops when the charge level reaches the stop threshold
@benigumocom
benigumocom / debug_from_qr.py
Last active June 12, 2024 14:56
Connect Wireless Debug from Terminal on Android11
#!/usr/bin/env python3
"""
Android11
Pair and connect devices for wireless debug on terminal
python-zeroconf: A pure python implementation of multicast DNS service discovery
https://github.com/jstasiak/python-zeroconf
"""
@mrpeardotnet
mrpeardotnet / PVE-host-backup.md
Created December 17, 2019 18:03
Proxmox PVE Host Config Backup Script

Proxmox PVE Host Config Backup Script

This script can be used to backup essential configuration files from the Proxmox Virtual Enivronment (PVE) host.

The script will create backups using tar with specified backup prefix and date and time stamp in the file name. Script will also delete backups that are older then number of days specified.

Create backup script file

To create backup script that will be executed every day we can create backup script in /etc/cron.daily/ folder. We need to make it writeable by root (creator) only, but readable and executable by everyone:

touch /etc/cron.daily/pvehost-backup
@vurpo
vurpo / surface-fix-eraser-and-touch.py
Last active May 27, 2022 12:20
https://github.com/StollD/linux-surface-fix-eraser but modified to also disable the touch screen when the pen is near the screen
#!/usr/bin/env python3
"""
Copyright 2019 StollD, 2019 vurpo
Original: https://github.com/StollD/linux-surface-fix-eraser
Licensed under GNU GPL version 3
"""
import os
import os.path
@nealfennimore
nealfennimore / wireguard.conf
Last active June 15, 2024 10:58
Wireguard VPN - Forward all traffic to server
# ------------------------------------------------
# Config files are located in /etc/wireguard/wg0
# ------------------------------------------------
# ---------- Server Config ----------
[Interface]
Address = 10.10.0.1/24 # IPV4 CIDR
Address = fd86:ea04:1111::1/64 # IPV6 CIDR
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE # Add forwarding when VPN is started
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE # Remove forwarding when VPN is shutdown
@TatriX
TatriX / exwm-panel.el
Created September 4, 2019 11:04
Pure Elisp panel for EXWM
(defun my-setup-header-line-format ()
"Hide header line if required."
(set-window-parameter (next-window) 'header-line-format
(unless (window-at-side-p (next-window) 'top)
'none)))
(add-hook 'exwm-update-class-hook #'my-setup-header-line-format)
(set-face-attribute 'header-line nil
:background "#000000"
@markosjal
markosjal / AirScan-eSCL.txt
Last active December 15, 2023 09:42
Reverse Engineering eSCL / Apple AirScan
Reverse Engineering the Apple Airscan / eSCL Protocol
I am not certain of the origins, one person involved in IPP printing claimed it was proprietary of HP , but then again they have their own protocol. AirScan/eSCL is used by other manufacturers too like Xerox, Kyocera, Canon and more. Mopria also seems to claim some responsibility for it but then again it seems not completely. In any case it seems shrouded in such secrecy that to date several years after its implementation, unless someone wants to take it all apart.
I offer this as my contribution. It is not perfect but almost there.
As I began looking for information to make a scanner more compatible, I could only find fragments of information. Even Apple Developer Forums offered zero help.
Server/Client in eSCL / AirScan:
There is a “server”and a “client” the client can be a desktop computer or mobile device. The server is a scanner or another device configured to emulate a hardware scanner, even a desktop computer. In my case I did this on Linux, so
@hagenw
hagenw / install_python_matlab_engine.sh
Created September 28, 2017 09:06
Install Matlab Engine API for python without root permissions
#!/bin/bash
# Go to $MATLABROOT/extern/engines/python and run the following line to build the python engine without root permissions.
# See https://uk.mathworks.com/help/matlab/matlab_external/install-matlab-engine-api-for-python-in-nondefault-locations.html
python setup.py build --build-base=$HOME/tmp/build install
@kafene
kafene / gpg-wkd.md
Last active June 2, 2024 20:45
Setting up WKD for self-hosted automatic key discovery

I just got this working so I figured I'd share what I found, since there's hardly any information about this anywhere online except an RFC, the GPG mailing list and one tutorial from the GnuPG blog.

You can use automatic key discovery with WKD (Web key directory) to make it easy for users to import your key, in GPG since version 2.1.12. Since this feature is fairly new, it isn't yet available in the current LTS release of Ubuntu (16.04; xenial), however it is available in Debian stable (stretch).

I couldn't add a DNS CERT or DANE / OPENPGPKEY record through my email service (which also hosts my nameservers). I tried making the PKA record - a foo._pka.example.com TXT record but GPG doesn't seem to recognize it and fails; I'm still investigating why.

So the last option for self-hosted auto-discovery was WKD.

First thing I had to do was add an email address to my key. My primary UID is just my name so the key represents my identity rather

@telegraphic
telegraphic / parse_nvidia_smi.py
Created September 23, 2016 00:37
Parse nvidia-smi from python
"""
Parse output of nvidia-smi into a python dictionary.
This is very basic!
"""
import subprocess
import pprint
sp = subprocess.Popen(['nvidia-smi', '-q'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)