Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Hydra ox0spy

🎯
Focusing
View GitHub Profile
View podman-tips.md
View verify-aws-ec2-key-pair-fingerprint.md

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
@ox0spy
ox0spy / archlinux-tips.md
Last active Dec 18, 2020
Arch Linux Tips
View archlinux-tips.md

wireless

install wpa_supplicant and dhcpcd

sudo pacman -S wpa_supplicant dhcpcd

get wireless network interface

@ox0spy
ox0spy / main.go
Last active Dec 8, 2020
remove duplicate files
View main.go
// 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"
View nginx-tips.md

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;
View extend-virtualbox-disk.md

extend virtualbox disk

shutdown guest OS

show disk info

VBoxManage showhdinfo ~/VirtualBox\ VMs/Ubuntu/Ubuntu.vdi
@ox0spy
ox0spy / apt-fast
Created Nov 18, 2020 — forked from voyeg3r/apt-fast
apt-fast with aria2c
View apt-fast
#!/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
View crop_image.md

crop image

import os

from PIL import Image


def crop_image(filename, w_h_ratio=0.75):
    img = Image.open(filename)
View systemd-tips.md

journal disk usage

check journal disk usage

journalctl --disk-usage

reduce journal size