Skip to content

Instantly share code, notes, and snippets.

View tnychn's full-sized avatar

Tony Chan tnychn

View GitHub Profile
@tnychn
tnychn / pgxquery.go
Last active August 7, 2022 21:09
Useful query functions for jackc/pgx.v5 based on Go 1.18 generics.
package pgxquery
import (
"context"
"github.com/jackc/pgx/v5"
)
// Querier is implemented by *pgx.Conn and *pgxpool.Pool, and is a superset of pgx.Tx.
type Querier interface {
@tnychn
tnychn / eClassBatchDownloader.js
Last active July 28, 2022 09:53
A Tampermonkey script for downloading files in batch from eClass.
// ==UserScript==
// @name eClass Batch Downloader
// @version 1.0.0-fix
// @author tnychn
// @description Download files from eClass in batch.
// @match https://eclass.ktmc.edu.hk/eclass40/src/resource/eclass_files/eclass_files.php
// @run-at document-idle
// @grant GM_download
// @grant GM_registerMenuCommand
// ==/UserScript==
@tnychn
tnychn / eClassKeepAlive.js
Created February 8, 2022 21:11
A Tampermonkey script to keep eClass session alive to prevent timeout.
// ==UserScript==
// @name eClass Keep Alive
// @version 1.0.0
// @author tnychn
// @description Keep eClass session alive to prevent timeout.
// @match https://eclass.ktmc.edu.hk/*
// @run-at document-start
// @noframes
// ==/UserScript==
@tnychn
tnychn / eClassFileOpener.js
Last active April 5, 2022 03:33
A Tampermonkey script to allow opening multiple files in new tabs instead of replacing a new window on eClass.
// ==UserScript==
// @name eClass File Opener
// @version 2.0.1-fix
// @author tnychn
// @description Open multiple files in new tabs instead of replacing a new window.
// @match https://eclass.ktmc.edu.hk/eclass40/src/resource/eclass_files/eclass_files.php
// @run-at document-idle
// ==/UserScript==
(function() {
@tnychn
tnychn / hr.css
Last active November 3, 2021 13:52
<hr> stylized as dynamic width "==========".
hr {
height: 15px;
border: none;
overflow: hidden;
position: relative;
}
hr:after {
top: 0;
left: 0;
@tnychn
tnychn / #procwall.py
Last active February 19, 2022 05:44
(macOS) Set desktop picture to a word cloud of the current most resource-hungry processes.
#!/usr/bin/env python3
import os
import psutil
import subprocess
from pathlib import Path
from wordcloud import WordCloud
BG_COLOR = "#101010"
WIDTH, HEIGHT = 2880, 1800 # screen resoulution