Skip to content

Instantly share code, notes, and snippets.

View chuangzhu's full-sized avatar
😅
GitHub IPv6 when

Chuang Zhu chuangzhu

😅
GitHub IPv6 when
  • ~
View GitHub Profile
@chuangzhu
chuangzhu / prometheus-bmp280-exporter.py
Last active July 10, 2026 09:43
Prometheus exporters for various air sensors
#!/usr/bin/env python3
import iio
import datetime
import logging
import time
from prometheus_client import start_http_server, Gauge
GAUGE_PRESSURE = Gauge('pressure',
'Temperature (kPa)',
@chuangzhu
chuangzhu / shell.nix
Last active April 14, 2026 22:22
Nix devShell for Zephyr on ESP32C3/BL602
{
nixpkgs ? <nixpkgs>,
system ? builtins.currentSystem,
}:
(import nixpkgs {
localSystem = { inherit system; };
crossSystem = {
config = "riscv32-none-elf";
libc = "newlib";
@chuangzhu
chuangzhu / mcmods.nix
Created January 7, 2024 20:51
A example for packaging Minecraft mods from Modrinth and Curseforge in Nix, with updaters, which I use personally with https://github.com/Ninlives/minecraft.nix
{ lib, fetchurl, writeShellScript, curl, jq, common-updater-scripts }:
let
fetchModrinth = { meta, passthru ? {}, ... } @ args: fetchurl args // {
meta = meta // {
position = let p = builtins.unsafeGetAttrPos "url" args; in "${p.file}:${toString p.line}";
};
passthru = passthru // {
updateScript = writeShellScript "update" ''
set -xeu -o pipefail
@chuangzhu
chuangzhu / phosh.patch
Created February 23, 2023 05:26
Set bottom bar the same height as status bar, move the clock to the right
diff --git a/src/home.h b/src/home.h
index a34b7155..7f6fb730 100644
--- a/src/home.h
+++ b/src/home.h
@@ -12,7 +12,7 @@
#define PHOSH_TYPE_HOME (phosh_home_get_type())
-#define PHOSH_HOME_BUTTON_HEIGHT 40
+#define PHOSH_HOME_BUTTON_HEIGHT 32
@chuangzhu
chuangzhu / dgutcourses2ics.py
Last active September 19, 2023 19:39
Convert DGUT courses table to iCalendar
#!/usr/bin/env python3
# SPDX-License-Identifier: AGPL-3.0
# Convert courses table from https://jw.dgut.edu.cn → 学生服务→ 网上选课→ 选课结果 to iCalendar
# Usage: copy the query result to a spreadsheet application, export it as CSV, then run:
# ./dgutcourses2ics.py 2023-09-04 < courses.csv > courses.ics
# ^ first monday of the semester
import csv
import sys
from datetime import datetime, date, time, timedelta
👀
@chuangzhu
chuangzhu / gnome-mobile.nix
Last active October 28, 2022 11:51
An attempt to run gnome mobile on NixOS
{
services.xserver.enable = true;
services.xserver.videoDrivers = [ ];
services.xserver.displayManager.gdm.enable = true;
services.xserver.desktopManager.gnome.enable = true;
nixpkgs.overlays = [
(final: prev: {
gnome = prev.gnome // rec {
mutter = prev.gnome.mutter.overrideAttrs (super: rec {
version = "0ab630277d225cd0b5a15eac44e31ee16cec6676"; # mobile-shell
@chuangzhu
chuangzhu / spectrogram_to_audio.ipynb
Created October 30, 2021 05:56
ustclug-hackergame-2021-write-up
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
requests==2.28.1
pycryptodome==3.15.0
@chuangzhu
chuangzhu / 114514.py
Last active November 8, 2020 17:27
ustclug-hackergame-2020-write-up
inner_op = ['', '+', '-', '*', '//', '%', '^', '&', '|',
'*-', '//-', '%-', '+~', '-~', '+~-', '*~', '%~',
'^-', '&-', '|-', '//~', '^~', '&~', '|~',
'+(', '-(', '*(', '%(', '^(', '&(', '|(', ')',
# '+((', '-((', '*((', '//((', '%((', '^((', '&((', '|((', '))',
')+(', ')-(', ')*(', ')//(', ')%(', ')^(', ')&(', ')|(']
# leading_op = ['', '-', '~', '-(', '-((', '~(', '~((', '(', '((']
leading_op = ['', '-', '~', '-(', '~(', '(']
# trailing_op = ['', ')', '))']
trailing_op = ['', ')']