Skip to content

Instantly share code, notes, and snippets.

View ba0f3's full-sized avatar
🇻🇳
Paracel islands and Spratly islands belong to Vietnam

Huy Doan ba0f3

🇻🇳
Paracel islands and Spratly islands belong to Vietnam
View GitHub Profile
@ba0f3
ba0f3 / gist:8709b57e85c75103759f698d8471a1e3
Created April 11, 2020 05:20 — forked from sielay/gist:0aa4077829f35f5e0310f9e0cc9fdc71
Haproxy - Capture client IP when behind CloudFlare or not. Also keep x-forwarded-for in logs
frontend www-http
bind :80
bind *:443 ssl crt /etc/haproxy/certs no-sslv3
capture request header X-Forwarded-For len 50
acl is_cf req.hdr(cf-connecting-ip) -m found
http-request set-header X-Client-IP %[src] if !is_cf
http-request set-header X-Client-IP %[hdr(cf-connecting-ip)] if is_cf
@ba0f3
ba0f3 / compile-glibc-214.sh
Created March 19, 2020 09:28
Compile GlibC 2.14 on Centos 6, copied from https://unix.stackexchange.com/a/299665
#!/bin/bash
mkdir ~/glibc_install; cd ~/glibc_install
wget http://ftp.gnu.org/gnu/glibc/glibc-2.14.tar.gz
tar zxvf glibc-2.14.tar.gz
cd glibc-2.14
@ba0f3
ba0f3 / default.nim
Last active February 25, 2020 15:14
assign default values for object's members
import macros
template value(x: untyped) {.pragma.}
proc init[T](t: typedesc[T]): T =
for k, v in result.fieldPairs:
if v.hasCustomPragma(value):
v = v.getCustomPragmaVal(value)
type
MyObj = object
@ba0f3
ba0f3 / 1111.sh
Last active February 15, 2020 14:48
Cloudflare Warp+ 1.1.1.1 data boost script, only curl required
#!/bin/bash
command -v curl >/dev/null 2>&1 || { echo >&2 "curl is required"; exit 1; }
if [ "$1" == "" ]; then
echo "Usage: ${0} <warp+ id>"
exit 1
fi
RUNNING=true
BOOSTED=0
import prompt, unicode, terminal
proc autoComplete(line: seq[Rune], cursorpos: int): seq[string] {.gcsafe.} =
if line.len == 0:
return @[]
if $line == "hi":
result = @["Hello", "Xin chao", "Bonjour"]
else:
var data = file.readFile()
var filedata = splitToChunks(data,24)
echo filedata
for i in filedata:
echo i
client.send(i & "\r\L")
client.send("DONE" & "\r\L")
@ba0f3
ba0f3 / socat-tcp-to-unix-socket.sh
Created August 29, 2019 08:34 — forked from ljjjustin/socat-tcp-to-unix-socket.sh
socat-unix-socket-to-tcp.sh
#!/bin/bash
if [ $# -ne 3 ]; then
echo "usage: $0 <unix socket file> <host> <listen port>"
exit
fi
SOCK=$1
HOST=$2
PORT=$3
@ba0f3
ba0f3 / gtk.css
Last active July 1, 2019 04:24
hide title bar on maximized windows (works on gnome-shell 3.32)
/*
CREDIT: Josh Sherman (https://joshtronic.com/2017/07/26/hide-title-bars-in-gnome-shell)
USAGE: copy and paste the code bellow in to ~/.config/gtk-3.0/gtk.css
*/
window.ssd.maximized separator:first-child + headerbar:backdrop,
window.ssd.maximized separator:first-child + headerbar,
window.ssd.maximized headerbar:first-child:backdrop,
window.ssd.maximized headerbar:first-child,
const NULL* = "\0"
type Row = seq[string]
let r: Row = @["qwe", NULL]
#!/usr/bin/perl
use strict;
# Usage:
# make_classless_option({ "subnet/mask" => "router", "subnet/mask" => "router", ... });
# subnet the subnet address, 4 dot-separated numbers
# mask the subnet mask length (e.g. /24 corresponds to 255.255.255.0, /8 corresponds to 255.0.0.0)
# router the router address, 4 dot-separated numbers
sub make_classless_option{
my $routes = shift;