Skip to content

Instantly share code, notes, and snippets.

@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 / script.sh
Created May 18, 2021 13:15 — forked from vielhuber/README.MD
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?

@vinsonzou
vinsonzou / socks5_proxy.go
Created December 15, 2020 06:45 — forked from felix021/socks5_proxy.go
Minimal socks5 proxy implementation in Golang
package main
import (
"encoding/binary"
"errors"
"fmt"
"io"
"net"
)
@vinsonzou
vinsonzou / Readme.md
Created August 23, 2019 09:15 — forked from ledongthuc/Readme.md
[Github Actions][Go] Check pull requests before merging

Create template actions that's used to verify Go language pull requests before merging. It's easy to custom the flow, tools with your case.

Put pr_checker.yml or pr_checker_simple.yml to .github/workflows/ and see how it works with your pull requests. Make sure you are allows to use actions of Github.

  • pr_checker.yml is using by mine with full checking tools. It will make sure every Go langauge pull requests will be buildable, testable, passed security checking and error-able code checking.
  • pr_checker_simple.yml is more simpler with buildable, testable.

References:

FROM centos:7.3.1611
RUN yum update -y && yum install -y wget make gcc gcc-c++ unzip git patch readline-devel \
bzip2 zlib zlib-devel
ENV BUILD_PATH=/tmp/build
RUN mkdir --verbose -p "$BUILD_PATH"
ENV PCRE_VERSION=8.43
@vinsonzou
vinsonzou / auth.go
Created March 28, 2018 05:22 — forked from jebjerg/auth.go
nginx 2fa authentication layer (lua + Go)
// Swap values for CHANGE FOR YOURSELF, and OBS: it's a novelty authentication, so improvements can and will happen
package main
import (
"bufio"
"crypto/hmac"
"crypto/sha1"
"fmt"
"github.com/craigmj/gototp"
@vinsonzou
vinsonzou / nginx.conf
Last active December 6, 2017 07:59 — forked from lloydzhou/nginx.conf
nginx srcache module to server stale data, using lua-resty-lock to make one request to create new cache, and using "lua-resty-http" + "ngx.timer.at" to update new cache in background.
upstream www {
server 127.0.0.1:9999;
}
upstream redis {
server 127.0.0.1:6379;
keepalive 1024;
}
lua_shared_dict srcache_locks 100k;
server {
@vinsonzou
vinsonzou / dns_server.lua
Created May 26, 2017 04:46 — forked from agentzh/dns_server.lua
My first hacked version of silly Lua DNS server atop NGINX (with patched ngx_stream_lua_module).
local bit = require "bit"
local byte = string.byte
local lshift = bit.lshift
local rshift = bit.rshift
local concat = table.concat
local insert = table.insert
local char = string.char
local band = bit.band
local sub = string.sub
local gsub = string.gsub
@vinsonzou
vinsonzou / gist:b72ee3ca3b697a685d0d4d1286f0b2b2
Created September 1, 2016 05:35 — forked from perusio/gist:1326701
Mobile device detection in Nginx with just 7 lines of configuration
### Testing if the client is a mobile or a desktop.
### The selection is based on the usual UA strings for desktop browsers.
## Testing a user agent using a method that reverts the logic of the
## UA detection. Inspired by notnotmobile.appspot.com.
map $http_user_agent $is_desktop {
default 0;
~*linux.*android|windows\s+(?:ce|phone) 0; # exceptions to the rule
~*spider|crawl|slurp|bot 1; # bots
~*windows|linux|os\s+x\s*[\d\._]+|solaris|bsd 1; # OSes