Skip to content

Instantly share code, notes, and snippets.

@Chion82
Chion82 / virtualbox_ports.png
Created June 2, 2022 14:42 — forked from snb/virtualbox_ports.png
virtualbox serial console
virtualbox_ports.png
package main
import (
"net"
"os"
"syscall"
"time"
)
func main() {
strEcho := "Halo"
@Chion82
Chion82 / debian-mips64el-on-qemu.md
Created March 19, 2022 01:33 — forked from sergev/debian-mips64el-on-qemu.md
Installing Debian MIPS64 on QEMU

Let's install Debian 9.0 "Stretch" on QEMU MIPS64 under Ubuntu.

Step 1: Install QEMU

sudo apt install qemu-system-mips

Step 2: Download Linux kernel and installation image

wget http://ftp.debian.org/debian/dists/stretch/main/installer-mips64el/current/images/malta/netboot/vmlinux-4.9.0-8-5kc-malta
DIR=$(dirname $(readlink -f $0))
if [ ${#DIR} -gt 0 ]; then
cd $DIR
fi
@Chion82
Chion82 / gen_compile_commands.py
Created August 24, 2021 06:25
Script to get compile_commands.json form linux kernel
#!/usr/bin/env python
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (C) Google LLC, 2018
#
# Author: Tom Roeder <tmroeder@google.com>
#
"""A tool for generating compile_commands.json in the Linux kernel."""
import argparse
@Chion82
Chion82 / get_cn_ip.sh
Last active November 29, 2020 03:41
get_cn_ip.sh
wget -O- 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' | awk -F\| '/CN\|ipv4/ { printf("%s/%d\n", $4, 32-log($5)/log(2)) }' > your_chn_list.txt
@Chion82
Chion82 / Golang static build
Last active October 14, 2020 10:07 — forked from PurpleBooth/Dockerfile
Create a static binary in go
go build -ldflags "-linkmode external -extldflags -static"
diff --git a/xt_FULLCONENAT.c b/xt_FULLCONENAT.c
index 8555b54..8edaf7b 100644
--- a/xt_FULLCONENAT.c
+++ b/xt_FULLCONENAT.c
@@ -21,6 +21,7 @@
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
#include <linux/netfilter/x_tables.h>
+#include <linux/notifier.h>
#include <net/netfilter/nf_nat.h>
@Chion82
Chion82 / discounted_rewards.py
Created April 2, 2020 15:25
Implementations of discount function used to calculate discounted rewards in Reinforcement Learning
import numpy as np
from scipy.signal import lfilter
def discount_readable(r, gamma):
""" Compute the gamma-discounted rewards over an episode
"""
discounted_r, cumul_r = np.zeros_like(r), 0
for t in reversed(range(0, len(r))):
cumul_r = r[t] + cumul_r * gamma
discounted_r[t] = cumul_r
@Chion82
Chion82 / build_static_libcurl.sh
Last active March 4, 2020 14:13
Build static PHP binary (tested on 7.1.4)
LDFLAGS="-static" LIBS=-ldl ./configure --disable-shared --enable-static
make V=1 curl_LDFLAGS=-all-static -j4