Skip to content

Instantly share code, notes, and snippets.

View zh4n7wm's full-sized avatar
🎯
Focusing

Hydra zh4n7wm

🎯
Focusing
View GitHub Profile
@zh4n7wm
zh4n7wm / podman-tips.md
Created March 4, 2021 09:29
podman tips
@zh4n7wm
zh4n7wm / verify-aws-ec2-key-pair-fingerprint.md
Created December 30, 2020 13:57 — forked from msoe/verify-aws-ec2-key-pair-fingerprint.md
Verifying AWS EC2 Key Pair's Fingerprint

If you created your key pair using AWS, you can use the OpenSSL tools to generate a fingerprint as follows:

$ openssl pkcs8 -in path_to_private_key -inform PEM -outform DER -topk8 -nocrypt | openssl sha1 -c

If you created a key pair using a third-party tool and uploaded the public key to AWS, you can use the OpenSSL tools to generate the fingerprint as follows:

$ openssl rsa -in path_to_private_key -pubout -outform DER | openssl md5 -c
@zh4n7wm
zh4n7wm / archlinux-tips.md
Last active December 18, 2020 13:06
Arch Linux Tips

wireless

install wpa_supplicant and dhcpcd

sudo pacman -S wpa_supplicant dhcpcd

get wireless network interface

@zh4n7wm
zh4n7wm / main.go
Last active December 8, 2020 09:35
remove duplicate files
// remove duplicate files
// if file content with same sha256, they are same
// usage: go run remove-duplicate-files.go <your-directory> [your-dir1 you-dir2 ...]
// run with `-dryrun` if you just want to find the duplicate files
package main
import (
"crypto/sha256"
"flag"
"fmt"
@zh4n7wm
zh4n7wm / nginx-tips.md
Last active November 25, 2020 13:57
nginx tips

NGINX to reverse proxy websockets

主要看 location 中的,注意:

  • proxy_read_timeout,默认是 60s,如果不设置长一点,会看到 websocket server 收到大量请求;然后从浏览器看,前端每分钟都在创建新的 websocket 连接;详见:http://nginx.org/en/docs/http/websocket.html
  • 如果用 uvicorn,nginx 不能开启 keepalive ,否则 websocket server 会报 WARNING: Invalid HTTP request received.
map $http_upgrade $connection_upgrade {
    default upgrade;
@zh4n7wm
zh4n7wm / extend-virtualbox-disk.md
Created November 18, 2020 08:03
extend VirtualBox Disk

extend virtualbox disk

shutdown guest OS

show disk info

VBoxManage showhdinfo ~/VirtualBox\ VMs/Ubuntu/Ubuntu.vdi
@zh4n7wm
zh4n7wm / apt-fast
Created November 18, 2020 03:19 — forked from voyeg3r/apt-fast
apt-fast with aria2c
#!/bin/sh
# Last Change: 2011/10/06
# apt-fast v0.02 by Matt Parnell http://www.mattparnell.com, this thing is fully open-source
# if you do anything cool with it, let me know so I can publish or host it for you
# contact me at admin@mattparnell.com
# Special thanks to Travis/travisn000 from the PCLinux Forums for making improvements that allow
# for more complex apt-get commands. See the thread: http://www.pclinuxos.com/forum/index.php/topic,66385.0.html
# adicionar suporte aos metalinks no aria2: http://ubuntuforums.org/showthread.php?t=1493421
# veja também apt-metalink: http://github.com/tatsuhiro-t/apt-metalink
@zh4n7wm
zh4n7wm / generate-signed-urls-and-cookies-for-cloudfront-with-python-and-golang.md
Last active July 12, 2023 21:27
AWS CloudFront generate signed urls and cookies with Python and Golang
@zh4n7wm
zh4n7wm / crop_image.md
Created September 1, 2020 09:40
crop image

crop image

import os

from PIL import Image


def crop_image(filename, w_h_ratio=0.75):
 img = Image.open(filename)
@zh4n7wm
zh4n7wm / systemd-tips.md
Created August 18, 2020 02:08
systemd tips

journal disk usage

check journal disk usage

journalctl --disk-usage

reduce journal size