家里有一个闲置的极路由2,试试刷个openwrt,结果一不小心刷成砖头了。开机不能通电,没有指示灯亮。本来想着就这样丢了,再弄个查查咸鱼,二手的都要100多。果断找找解决办法。找这篇文章极路由X编程器救砖教程编程器刷PandoraBox,根据这篇文章,到万能的淘宝买了CH341A编程器 + 烧录夹
最新文章
需求是这样的:
有个外部app给我们小程序做推广,在他们那领取优惠券码。然后到我们小程序领取优惠券,使用优惠券下单。同时,需要我们推送订单。还要接受他们那变更优惠券的状态。
去年在刷招聘网站的时候,偶然认识了rust开发语言,留了个心眼,刚好这段时间不太忙,就先初步认识一下。
官方网站是这样介绍的:
一个赋予每个人构建可靠且高效软件能力的语言。
参考地址:https://go-zero.dev/cn/docs/quick-start/micro-service#%E5%88%9B%E5%BB%BAuser-rpc%E6%9C%8D%E5%8A%A1
go-zero介绍
go-zero(收录于 CNCF 云原生技术全景图:https://landscape.cncf.io/?selected=go-zero)是一个集成了各种工程实践的 web 和 rpc 框架。通过弹性设计保障了大并发服务端的稳定性,经受了充分的实战检验。
beego中数据库分页
func PageDB(limit int, page int, count int64) (int, int) {
pageSetNum := limit // 每页条数
pageCount := math.Ceil((float64(count)) / (float64(pageSetNum))) // 总页数
pageNum := page // 当前页码
if pageNum > int(pageCount) { // 如果传入的页码超出范围
pageNum = int(pageCount)
}
offset := pageSetNum * (pageNum - 1)
if offset < 0 {
offset = 0
}
return pageSetNum, offset
}
- 韵达签名
func YunDaSign(structData interface{}) ([]byte, string, string) {
jsonData, _ := json.Marshal(structData)
appKey := "你的key"
appSecret := "你的秘钥"
newStr := string(jsonData) + "_" + appSecret
md := md5.New()
md.Write([]byte(newStr))
md5Str := hex.EncodeToString(md.Sum(nil))
return jsonData, appKey, md5Str
}
func PKCS7Padding(ciphertext []byte, blockSize int) []byte {
padding := blockSize - len(ciphertext)%blockSize
//Repeat()函数的功能是把切片[]byte{byte(padding)}复制padding个,然后合并成新的字节切片返回
padtext := bytes.Repeat([]byte{byte(padding)}, padding)
return append(ciphertext, padtext...)
}
获取部分时间范围
//获得当前月的初始和结束日期
func GetMonthDay(types int) (string, string) {
now := time.Now()
currentYear, currentMonth, _ := now.Date()
currentLocation := now.Location()
firstOfMonth := time.Date(currentYear, currentMonth, 1, 0, 0, 0, 0, currentLocation)
lastOfMonth := firstOfMonth.AddDate(0, 1, -1)
f := firstOfMonth.Unix()
l := lastOfMonth.Unix()
if types == 1 {
return time.Unix(f, 0).Format("2006-01-02"), time.Unix(l, 0).Format("2006-01-02")
}
return time.Unix(f, 0).Format("2006-01-02") + " 00:00:00", time.Unix(l, 0).Format("2006-01-02") + " 23:59:59"
}
go中类型转换的搜集
func StringToInt(a string) int {
d, _ := strconv.Atoi(a)
return d
}
一个简单但是非常实用的pdf生成器!
安装:
go get github.com/jung-kurt/gofpdf