Skip to content

Instantly share code, notes, and snippets.

View Richardn2002's full-sized avatar

Richardn Richardn2002

View GitHub Profile
@Richardn2002
Richardn2002 / index.js
Last active September 13, 2023 02:05
Zhihu chat history logger.
const fs = require('fs');
const secret = JSON.parse(fs.readFileSync('secret.json'));
const IMAGE_PATH = './out/images';
const STICKER_PATH = './out/stickers';
let historyPath;
let rawHistoryPath;
const STATUS_PATH = './status.json';
if (!fs.existsSync(IMAGE_PATH)) {
fs.mkdirSync(IMAGE_PATH, {recursive: true});
}
@Richardn2002
Richardn2002 / procedure.md
Last active June 24, 2022 16:11
Request HTTPS Certificate without IPv4 and port 80

To not use port 80, the only challenge mode left is TLS-ALPN-01 (WRONG! We still have DNS Validation. Seems like my knowledge base is a bit outdated. But at least this is a cute little automated method.). The process involves:

  • A pair of self-signed SSL certificate and key.
  • An ALPN challenge responder.
  • A certificate request initiater.

The .pem and the .key

openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout ssl-cert-snakeoil.key -out ssl-cert-snakeoil.pem
@Richardn2002
Richardn2002 / ranksum.cpp
Last active August 1, 2023 20:30
Wilcoxon Ranksum Test in C++
#include <algorithm>
#include <cmath>
#include <vector>
using std::erfc;
using std::sort;
using std::sqrt;
using std::vector;
double calc(const vector<double> &sample1, const vector<double> &sample2) {
@Richardn2002
Richardn2002 / main.c
Created October 5, 2023 23:26
Blinky on GP4 for PIC12F529T39A
#pragma config OSC = INTRC
#pragma config WDT = OFF
#pragma config PARITY = SET
#pragma config MCLRE = ON
#pragma config IOSCFS = 8MHz
#pragma config CPDF = OFF
#pragma config CP = DISABLE
#include <xc.h>