Skip to content

Instantly share code, notes, and snippets.

View ChenSun-Phys's full-sized avatar

Chen Sun ChenSun-Phys

View GitHub Profile
@vjt
vjt / copy-from-time-machine.sh
Last active June 20, 2024 15:03
Copy data from a Time Machine volume mounted on a Linux box.
#!/bin/bash
#
# Copy data from a Time Machine volume mounted on a Linux box.
#
# Usage: copy-from-time-machine.sh <source> <target>
#
# source: the source directory inside a time machine backup
# target: the target directory in which to copy the reconstructed
# directory trees. Created if it does not exists.
#
@baojie
baojie / scan.sh
Last active April 27, 2023 03:57
Double-sided scanning in linux and converting to pdf. Dependency: sudo apt-get install xsane imagemagick
#!/bin/bash
scanimage --batch --batch-double
read -p "Flip papers in the feeder, last page on top. Press [Enter] key to start..."
endpage=$(echo "$(ls *.pnm -1 | wc -l) * 2" | bc)
scanimage --batch --batch-increment -2 --batch-start $endpage
for file in *.pnm; do convert $file $file.jpg; done
rm *.pnm
convert $(ls *.jpg -1v | paste) -compress jpeg -page A4 output.pdf
@lukas-h
lukas-h / license-badges.md
Last active June 25, 2024 11:34
Markdown License Badges for your Project

Markdown License badges

Collection of License badges for your Project's README file.
This list includes the most common open source and open data licenses.
Easily copy and paste the code under the badges into your Markdown files.

Notes

  • The badges do not fully replace the license informations for your projects, they are only emblems for the README, that the user can see the License at first glance.

Translations: (No guarantee that the translations are up-to-date)

@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)
@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

@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
@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
@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"
@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
@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