Skip to content

Instantly share code, notes, and snippets.

View cloverstd's full-sized avatar
🀄
Working for living

cloverstd cloverstd

🀄
Working for living
View GitHub Profile
#!/bin/sh
apt update && apt install -y curl sudo && \
adduser --gecos "" cloverstd && \
usermod -aG sudo cloverstd && \
echo "cloverstd ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/90-cloverstd && \
runuser -u cloverstd -- bash -c "ssh-import-id-lp cloverstd && ssh-import-id-gh cloverstd" && \
echo "PasswordAuthentication no" >> /etc/ssh/sshd_config && \
echo "PermitRootLogin no" >> /etc/ssh/sshd_config && \
systemctl reload ssh && \
@cloverstd
cloverstd / id_rsa_vps.pub
Created February 25, 2023 07:10
id_rsa_vps.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDI+CFCrtFoUCO5StL3hFD5nyvPNutLmkazMEHC43nLQfj+ZtsOHJUyhj5TSsFHogoi3XdTi1MexFk5zPfwgRnXvWAYRlhqiG0fx7zKaqy/1RI2t/+JWcOGhEy91s2t8gHOj2Tub/vAzKWvgJRzhTjDlZ+LumkpuWL3tIHXcd9X2R16JQ92PpkTwgSefpcogOObiQbuYVTpjq9WCCjKktxR7G/BxfeoOjQbDjzhEkqI96Bsl73cMPn9VyLazZVXacLF0C7KZ19GWSER0+3d3KYOFSUdS22OfnirwVwaoFnDvCX7bBStzVdpT4q2M/6uSTRpp5JjL69hiXwFemjksWOT cloverstd@hui.lu
@cloverstd
cloverstd / temp.lua
Created February 8, 2023 11:19
OpenWrt temperature monitor for prometheus-collectors
--[[
function print_metric(metric, labels, value)
local label_string = ""
if labels then
for label,value in pairs(labels) do
label_string = label_string .. label .. '="' .. value .. '",'
end
label_string = "{" .. string.sub(label_string, 1, -2) .. "}"
end
io.write(string.format("%s%s %s", metric, label_string, value))
<script>
/**
* [js-sha3]{@link https://github.com/emn178/js-sha3}
*
* @version 0.8.0
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2015-2018
* @license MIT
*/
@cloverstd
cloverstd / main.go
Last active April 21, 2021 09:43
publish npm package by Golang
package main
import (
"archive/tar"
"bytes"
"compress/gzip"
"crypto/sha1"
"crypto/sha512"
"encoding/base64"
"encoding/hex"
@cloverstd
cloverstd / script.sh
Created April 15, 2021 04:48
Convert RFC4716 private id_rsa to PEM
ssh-keygen -f id_rsa -m pem -p
@cloverstd
cloverstd / cors.lua
Created April 1, 2021 09:02
Nginx cors by lua
local origin_pattern = [=[(\.hui\.lu|\.cloverstd\.com)(:\d+)?$]=]
local headers = ngx.req.get_headers()
ngx.header['Access-Control-Max-Age'] = '3600'
ngx.header['Access-Control-Allow-Credentials'] = 'true'
local origin = headers['Origin']
if origin then
local m, err = ngx.re.match(origin, origin_pattern, "jo")
if m then
@cloverstd
cloverstd / main.go
Created September 24, 2020 02:53
access value via unsafe
func main() {
var i interface{} = 100
/**
type eface struct {
_type *_type
data unsafe.Pointer
}
*/
n := *(*int)(*(*unsafe.Pointer)(unsafe.Pointer(uintptr(unsafe.Pointer(&i)) + unsafe.Alignof(i))))
fmt.Println(n)
@cloverstd
cloverstd / config.yml
Last active March 5, 2023 16:46
clash 旁路由配置
mixed-port: 17890
redir-port: 17892
allow-lan: true
mode: rule
log-level: info
@cloverstd
cloverstd / recover.js
Created March 29, 2020 07:25
坚果云恢复文件
function getParams() {
const pairs = window.location.hash.substr(1).split('::');
if (!pairs) {
throw new Error('取不到参数');
}
return {
sndId: pairs[1].split('=')[1],
sndMagic: pairs[2].split('=')[1]
};
}