Skip to content

Instantly share code, notes, and snippets.

@vinsonzou
vinsonzou / Mac_M1_virtualization.md
Last active September 25, 2021 12:06
Mac M1虚拟机解决方案(>= MacOS 11)
@vinsonzou
vinsonzou / anticc.lua
Created September 11, 2021 03:29
anticc.lua
local require = require
local ngx = ngx
local ipmatcher = require("resty.ipmatcher")
local ngxvar = require("resty.ngxvar")
local ngx_md5 = ngx.md5
-- config
local CCcount = 60
local CCseconds = 60
local blockseconds = 3600
@vinsonzou
vinsonzou / gitea_sso_feishu.lua
Last active March 22, 2024 04:09
Gitea通过飞书开放平台实现SSO
--[[
通过飞书登录获取用户email字段(用户飞书中必须添加email属性,否则无法登录!!!),如email地址为test@example.com,则gitea用户为test
登录后设定cookie,cookie有效期10小时
飞书开放平台的企业自建应用设置:
1、配置 安全设置-重定向URL,如此示例中的https://git.example.com
2、权限:获取用户邮箱信息
自动注册后,需管理员调整如下信息:
1、自定义名称
@vinsonzou
vinsonzou / test.c
Created July 13, 2021 09:05 — forked from sbernard31/test.c
UDP load balancer proto using bcc (XDP/Bpf)
#define KBUILD_MODNAME "foo"
#include <uapi/linux/bpf.h>
#include <linux/bpf.h>
#include <linux/icmp.h>
#include <linux/if_ether.h>
#include <linux/if_vlan.h>
#include <linux/in.h>
#include <linux/ip.h>
#include <linux/tcp.h>
#include <linux/udp.h>
@vinsonzou
vinsonzou / download_access.lua
Created June 11, 2021 09:07
nginx授权下载,主要实现ipa和apk授权下载
local require = require
local ngx = ngx
local ngx_re = require "ngx.re"
local re_find = ngx.re.find
local key = "自定义key"
local uri = ngx.var.uri
local realFile, sign, ts
if re_find(uri, [[^/[A-Za-z0-9_]+.ipa/[a-z0-9]+/[0-9]+$]], "joi") then
@vinsonzou
vinsonzou / wechat_ops.lua
Created June 11, 2021 08:12
企业微信接口,示例为联系人tag调整,可以自定义任何想实现功能。
local require = require
local ngx = ngx
local http = require "resty.http" -- https://github.com/ledgetech/lua-resty-http
local wxcrypt = require "resty.crypt" -- https://github.com/vinsonzou/WXBizMsgCrypt
local xml2lua = require "xml2lua" -- https://github.com/manoelcampos/xml2lua
local handler = require "xmlhandler.tree"
local cjson = require "cjson.safe"
local ngx_re = require "ngx.re"
local json_encode = cjson.encode
local json_decode = cjson.decode
@vinsonzou
vinsonzou / image_convert.py
Created June 7, 2021 13:55
照片尺寸转换
# pip install opencv-python
import cv2
class ImageSize:
def __init__(self):
# 小一寸
self._lt_one_inch_w = 260
self._lt_one_inch_h = 390
self._lt_one_ratio = self._lt_one_inch_w / self._lt_one_inch_h
@vinsonzou
vinsonzou / vcrypt.go
Created May 19, 2021 12:51
encrypt/decrypt by MacOS keychain
package main
import (
"flag"
"fmt"
"os"
"os/signal"
"runtime"
"syscall"
@vinsonzou
vinsonzou / script.sh
Created May 18, 2021 13:15 — forked from vielhuber/script.sh
ffmpeg: Video convert m2ts to mp4, mp4 to webm, mp4 to ogv #tools
MP4 TO MP4 (MEDIUM)
ffmpeg -i input.mp4 -b 1000000 output.mp4
M2TS TO MP4
ffmpeg -i input.m2ts -vcodec libx264 -crf 20 -acodec ac3 -vf "yadif" output.mp4
MP4 TO WEBM (HIGH)
ffmpeg -i input.mp4 -aq 5 -ac 2 -qmax 25 -threads 2 output.webm
MP4 TO WEBM (MEDIUM)
@vinsonzou
vinsonzou / README.md
Created May 14, 2021 09:55 — forked from akihikodaki/README.en.md
Linux Desktop on Apple Silicon/M1 in Practice

Linux Desktop on Apple Silicon/M1 in Practice

I bought M1 MacBook Air. It is the fastest computer I have, and I have been a GNOME/GNU/Linux user for long time. It is obvious conclusion that I need practical Linux desktop environment on Apple Silicon/M1.

Fortunately, Linux already works on Apple Silicon/M1. But how practical is it?