Skip to content

Instantly share code, notes, and snippets.

View michealzh's full-sized avatar
😎
interesting

michealzh michealzh

😎
interesting
View GitHub Profile
@ThaddeusJiang
ThaddeusJiang / my-tech-interview-flow.md
Last active March 28, 2023 01:10
My tech interview flow

My tech interview flow

背景

  1. 为什么应聘我们公司?

有明确判断标准

  1. bugfix of your own code
  2. add feature of your own code
@Victrid
Victrid / gitgraft.sh
Created August 29, 2022 17:09
Find which commit your no-git friend is working on and generate patches for attaching their works onto git tree.
#!/bin/bash
hash git 2>/dev/null || { echo >&2 "Required command 'git' is not installed. ( hmm... why are you using this? ) Aborting."; exit 1; }
hash realpath 2>/dev/null || { echo >&2 "Required command 'realpath' is not installed. Aborting."; exit 1; }
hash pwd 2>/dev/null || { echo >&2 "Required command 'pwd' is not installed. Aborting."; exit 1; }
hash cd 2>/dev/null || { echo >&2 "Required command 'cd' is not installed. Aborting."; exit 1; }
hash echo 2>/dev/null || { echo >&2 "Required command 'echo' is not installed. Aborting."; exit 1; }
hash mv 2>/dev/null || { echo >&2 "Required command 'mv' is not installed. Aborting."; exit 1; }
hash diff 2>/dev/null || { echo >&2 "Required command 'diff' is not installed. Aborting."; exit 1; }
hash diffstat 2>/dev/null || { echo >&2 "Required command 'diffstat' is not installed. Aborting."; exit 1; }
@syhily
syhily / download_talebook.sh
Last active January 9, 2023 08:01
Download all the books from a talebook website. The https://curl.se/ and https://stedolan.github.io/jq/ are required for using this script.
#!/usr/bin/env bash
# Download metadata, modify these as your needs.
## The directory to save the downloaded files.
download_directory="/volume1/Download/EPUB"
## The website you want to visit.
calibre_site="http://soulseeker.myds.me:25788"
## The formats you want to download. We only download the first present format.
## All the formats should be upper case.
allow_formats=( EPUB MOBI AZW3 )

mTLS 配置

对于mTLS的配置的证书来说,有如下的提示。

  • 三个文件。 对于大多数系统,如:MySQL, Redis,PostgreSQL。会需要三个文件:CA证书 + CERT 和 KEY。可以在我的这个开源项目(https://github.com/haoel/mTLS/tree/main/certs )中找到我生成的CA,以及 Server 和 Client的 .crt.key 文件。生成的方法也在我的那个开源项目中了。

  • 两个文件。 对于有的系统,比如:MongoDB,他只要两个文件,一个是CA,一个是 pem 文件,对于pem文件,你可以直接把上面的 .crt 和 .key 合并了就好了。如:cat server.crt server.key > server.pem

  • JKS文件。 对于一些系统,比如:Kafka 和 Zookeeper。他要的不是上面的明文的格式,他要的是一种jks的格式,这是Java的格式。怎么从上面的明文的方式转到jks的文件。需要经过下面几步。

@DannyWhyte
DannyWhyte / gist.md
Created December 11, 2019 09:40
Cross-Platform AES-GCM-256 Encryption & Decryption using JAVA to encrypt and NODE to decrypt

This snippet is about cross-platform AES-GCM-256 encryption & decryption, Where payload is being encrypted using JAVA and decrypted using NODE

sample config :

{
    "masterKey": "sfcpnnjFG6dULJfo1BEGqczpfN0SmwZ6bgKO5FcDRfI=",
    "iterations": 2333,
    "keyLength": 32,

"digest": "sha512"

@missdeer
missdeer / gen_Corefile.sh
Last active April 12, 2024 10:08
generate Corefile which uses your ISP's DNS servers to resolve domain names in China and uses OpenDNS/Cloudflare/Google DNS servers to resolve domain names outside China for CoreDNS. You should change 119.29.29.29/223.5.5.5 to your ISP's DNS server address or use public DNS server such as 114/DNSPod etc. directly.
#!/bin/sh
echo 'use "curl -sSL git.io/corefile | bash" to update Corefile'
echo "remember to change 192.168.1.1 to your ISP's DNS server address or use public DNS server such as 114/DNSPod etc. directly"
china=`curl -sSL https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf | while read line; do awk -F '/' '{print $2}' | grep -v '#' ; done | paste -sd " " -`
apple=`curl -sSL https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/apple.china.conf | while read line; do awk -F '/' '{print $2}' | grep -v '#' ; done | paste -sd " " -`
google=`curl -sSL https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/google.china.conf | while read line; do awk -F '/' '{print $2}' | grep -v '#' ; done | paste -sd " " -`
bogus=`curl -sSL https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/bogus-nxdomain.china.conf | grep "=" | while read line; do awk -F '=' '{print $2}' | grep -v '#' ; done | paste -sd " " -`
cat>Corefile
@zhangv
zhangv / pkcs1topkcs8.php
Created January 28, 2018 09:50
convert RSA PKCS#1 to PKCS#8
function convertPKCS1toPKCS8($pkcs1){
$start_key = $pkcs1;
$start_key = str_replace('-----BEGIN RSA PUBLIC KEY-----', '', $start_key);
$start_key = trim(str_replace('-----END RSA PUBLIC KEY-----', '', $start_key));
$key = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A' . str_replace("\n", '', $start_key);
$key = "-----BEGIN PUBLIC KEY-----\n" . wordwrap($key, 64, "\n", true) . "\n-----END PUBLIC KEY-----";
return $key;
}
@tupunco
tupunco / vscode-go 插件安装.md
Last active April 18, 2023 09:13
vscode-go 配置

ctrl+shift+p

  • 安装 vscode-go 插件:
> ext install Go
  • 安装 go tools:
> Go Install/Update Tools
@tzmartin
tzmartin / m3u8-to-mp4.md
Last active April 26, 2024 01:50
m3u8 stream to mp4 using ffmpeg

1. Copy m3u8 link

Alt text

2. Run command

echo "Enter m3u8 link:";read link;echo "Enter output filename:";read filename;ffmpeg -i "$link" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 $filename.mp4
@ryanscherler
ryanscherler / php-openssl.md
Last active August 16, 2018 20:06
Use Homebrew PHP with OpenSSL instead of SecureTransport