Skip to content

Instantly share code, notes, and snippets.

View JackyCZJ's full-sized avatar
🎯
Focusing

Jacky Chan JackyCZJ

🎯
Focusing
View GitHub Profile
@JackyCZJ
JackyCZJ / publish.go
Last active July 2, 2020 10:17
looper
viper.SetDefault("push.frequency", 100)
d.timer = time.NewTicker(viper.GetDuration("push.frequency") * time.Millisecond)
//Make interface for netInterface we need to watch.
for bn := range bCache {
if d.InterfaceCache[bn] == nil {
inter, err := net.InterfaceByName(bn)
if err != nil {
return
}
d.InterfaceCache[bn] = inter
@JackyCZJ
JackyCZJ / protobuf_enc.go
Created June 15, 2020 02:49
nats protobuf encoding
package protobuf_nats
import (
"errors"
"github.com/nats-io/nats.go"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
@JackyCZJ
JackyCZJ / Makefile
Last active November 29, 2022 08:00
How to cross compile an openwrt CGO program
TARGET= GreatCGOProgram
OPENWRT_SDK=/home/user/openwrt
STAGING_DIR=$(OPENWRT_SDK)/staging_dir
CC=$(BUILD_DIR)/$(OPENWRT_SDK)/staging_dir/$(toolchain_dir)/bin/$(ARCH)-openwrt-linux-gcc
# example:
# toolchain-aarch64_cortex-a53+crypto_gcc-8.4.0_musl
# aarch64-openwrt-linux-gcc
@JackyCZJ
JackyCZJ / main_test.go
Last active March 6, 2023 02:12
AT+QCFG Band Calculation
package test
import (
"math/big"
"reflect"
"strconv"
"testing"
)
//How to calculate the band mask greater than 64 for AT+QCFG="band"
@JackyCZJ
JackyCZJ / list_status.py
Last active May 10, 2024 07:35
list sa without ujson
#!/usr/local/bin/python3
#copy from https://github.com/opnsense/core/blob/30a9195437c00085fed7b5c3989b4c3bfef9e34c/src/opnsense/scripts/ipsec/list_status.py
import sys
import socket
import json
import vici
try:
s = vici.Session()
@JackyCZJ
JackyCZJ / fuction_mail.php
Last active June 28, 2024 13:53
让Discuz!支持starttls发送邮件
<?php
//在131行处添加
if ($_G['setting']['mail']['port'] == '587'){
//Need to start TLS
fputs($fp, "STARTTLS\r\n");
$lastmessage = fgets($fp, 512);
if(substr($lastmessage, 0, 3) != 220) {
fputs($fp, "QUIT\r\n");
runlog('SMTP', "({$_G['setting']['mail']['server']}:{$_G['setting']['mail']['port']}) STARTTLS - $lastmessage", 0);
return false;