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 / hyperGeoDistriSeq.js
Last active July 14, 2018 14:17
Hypergeometric Distribution Sequence
'use strict'
function fact(n) {
if (n > 1) return n * fact(n - 1)
else return 1
}
function combination(n, m) {
/* C(n, m) = n * (n-1) * ... * (n-m+1) / m! */
if (!(n >= m)) console.error(new Error("m must be smaller than n"))
@chuangzhu
chuangzhu / color.sh.py
Created August 28, 2018 15:30
Shell color cheatsheet.
#!/usr/bin/python
from __future__ import print_function
print()
for i in range(0, 10):
print(i, end=' ')
print('\033[{}m'.format(i), end='')
print('AaBbCcDdEeFfGg', end='')
print('\033[0m')
print()
@chuangzhu
chuangzhu / Makefile
Created June 19, 2019 15:56
Programming AVR on Linux
MCU = atmega32
F_CPU = 16000000
PROGRAMMER = -c usbasp
AVRDUDE = avrdude $(PROGRAMMER) -p $(MCU)
CC = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) -mmcu=$(MCU)
.PHONY: hex flash clean
@chuangzhu
chuangzhu / tree.sh
Last active June 20, 2019 00:26
`tree` util implemented in pure bash
#!/bin/bash
# all files (include dirs) under a dir
_allunder() {
local f; for f in $1/* $1/.*; do
case $f in
"$1/*" | "$1/.*" | "$1/." | "$1/..") ;;
*) printf "$f " ;;
esac
done
@chuangzhu
chuangzhu / draw_exponential_func.py
Last active April 8, 2020 03:04
Draw a __NEGATIVE BASED__ exponential function diagram using `matplotlib.mplot3d`.
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
SIZE = 10 # How big you'd like to draw
fig = plt.figure()
# OR USING `ax = fig.add_subplot(1, 1, 1, projection='3d')`
ax = Axes3D(fig)
@chuangzhu
chuangzhu / gemoji.dict.yaml
Last active April 27, 2020 16:26
GitHub emoji dict for RIME
---
name: gemoji
version: "2020.4.28"
sort: by_weight
use_preset_vocabulary: true
...
😀 ugrinning
😃 usmiley
@chuangzhu
chuangzhu / breeze-dark.css
Last active October 18, 2020 12:35
Breeze dark theme for Standard Notes (desktop only). https://listed.to/p/ZuCytDdDW8
:root {
--background-1: #31363b;
--background-2: #232629;
--foreground-color: #eff0f1;
--border-color: #616569;
--highlight-color: #3daee9;
--highlight-contrast: #3daee9;
--sn-stylekit-info-color: #3daee9;
--sn-stylekit-info-contrast-color: #cccccc;
--sn-stylekit-neutral-color: #3daee9;
@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 = ['', ')']
@chuangzhu
chuangzhu / spectrogram_to_audio.ipynb
Created October 30, 2021 05:56
ustclug-hackergame-2021-write-up
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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