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 / 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 / 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 / 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 / caddy.sh
Last active February 6, 2023 10:45 — forked from Jamesits/caddy.sh
Install Caddy Server on Debian/Ubuntu with Systemd.
# Should work on all Debian based distros with systemd; tested on Ubuntu 16.04+.
# This will by default install all plugins; you can customize this behavior on line 6. Selecting too many plugins can cause issues when downloading.
# Run as root (or sudo before every line) please. Note this is not designed to be run automatically; I recommend executing this line by line.
apt install curl
curl https://getcaddy.com | bash -s personal dns,docker,dyndns,hook.service,http.authz,http.awses,http.awslambda,http.cache,http.cgi,http.cors,http.datadog,http.expires,http.filemanager,http.filter,http.forwardproxy,http.geoip,http.git,http.gopkg,http.grpc,http.hugo,http.ipfilter,http.jekyll,http.jwt,http.locale,http.login,http.mailout,http.minify,http.nobots,http.prometheus,http.proxyprotocol,http.ratelimit,http.realip,http.reauth,http.restic,http.upload,http.webdav,net,tls.dns.auroradns,tls.dns.azure,tls.dns.cloudflare,tls.dns.cloudxns,tls.dns.digitalocean,tls.dns.dnsimple,tls.dns.dnsmadeeasy,tls.dns.dnspod,tls.dns.dyn,tls.
@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 / 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 / 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 / 114514.py
Last active November 8, 2020 17:27
ustclug-hackergame-2020-write-up
inner_op = ['', '+', '-', '*', '//', '%', '^', '&', '|',
'*-', '//-', '%-', '+~', '-~', '+~-', '*~', '%~',
'^-', '&-', '|-', '//~', '^~', '&~', '|~',
'+(', '-(', '*(', '%(', '^(', '&(', '|(', ')',
# '+((', '-((', '*((', '//((', '%((', '^((', '&((', '|((', '))',
')+(', ')-(', ')*(', ')//(', ')%(', ')^(', ')&(', ')|(']
# leading_op = ['', '-', '~', '-(', '-((', '~(', '~((', '(', '((']
leading_op = ['', '-', '~', '-(', '~(', '(']
# trailing_op = ['', ')', '))']
trailing_op = ['', ')']
requests==2.28.1
pycryptodome==3.15.0