Skip to content

Instantly share code, notes, and snippets.

View Unbinilium's full-sized avatar
🌃
lost in the nowhere

Unbinilium Unbinilium

🌃
lost in the nowhere
View GitHub Profile
@Unbinilium
Unbinilium / Simple-network-optimization-Linux.md
Last active October 30, 2019 05:54
Simple network optimization on Linux

It is required to edit /etc/sysctl.conf by sudo nano /etc/sysctl.conf and add the configuration below to the end of the file.

net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
net.ipv4.tcp_fastopen = 3

This means to config Google BBR and TCP fastopen support on your operation system. Want another choice or check if the Google BBR supported by default, type sysctl net.ipv4.tcp_available_congestion_control to show all supported congestion control modules.

Use sudo sysctl -p to apply the changes to your operation system. Check if BBR module is installed in kernelvuse lsmod | grep bbr and find if string bbr is in outputs.

@Unbinilium
Unbinilium / Expend-max-number-of-open-files-on-Linux.md
Last active October 30, 2019 11:33
Expend max number of open files on Linux

UNIX/Linux operating systems have the ability to limit the amount of various system resources available to a user process. These limitations include how many files a process can have open, how large of a file the user can create, and how much memory can be used by the different components of the process such as the stack, data and text segments.

To unlimit the max number of opened files, use sudo nano /etc/security/limits.conf to edit /etc/security/limits.conf and add something like this below.

*                soft    nofile           512000
*                hard    nofile          1024000

The soft is for enforcing the soft limits and the hard is for enforcing hard limits. For this both number type is unsigned integer.

@Unbinilium
Unbinilium / Update-Ubuntu-kernel.md
Last active October 30, 2019 05:23
Update Ubuntu kernel

For Ubuntu users who wandering to support newer versions of hardware or getting new features, it's recommaned to update Ubuntu kernel. We could do it by sudo gedit updatekernel.sh && chmod -x updatekernel.sh && bash updatekernel.sh to create a bash script named updatekernel.sh in current folder and paste the code below before saved. Then it automatically set executable permission and run to update your Ubuntu kernel to the newest version.

KERNELVER="$(wget -qO- http://kernel.ubuntu.com/~kernel-ppa/mainline/ | awk -F'\"v' '/v[4-9]./{print $2}' | cut -d/ -f1 | grep -v -  | sort -V | tail -1)"
SYSTYPE="$(dpkg --print-architecture)"
[ "$SYSTYPE" = "amd64" ] && KERNEL="$(wget -qO- http://kernel.ubuntu.com/~kernel-ppa/mainline/v${KERNELVER}/ | grep "linux-image" | grep "generic" | awk -F'\">' '/amd64.deb/{print $2}' | cut -d'<' -f1 | head -1)"
[ "$SYSTYPE" = "i386" ] && KERNEL="$(wget -qO- http://kernel.ubuntu.com/~kernel-ppa/mainline/v${KERNELVER}/ | grep "linux-image" | grep "generic" | awk -F'\">' '/
@Unbinilium
Unbinilium / Config-shadowsocks-libev-on-Linux.md
Last active May 4, 2022 15:22
Config shadowsocks-libev on Linux

With no time updating Twist, I wrote this extremly simple script to setup shadowsocks-libev both server and client.

apt-get update -y
apt-get upgrade -y
apt-get dist-upgrade -y
apt-get autoremove -y
apt-get install --no-install-recommends -y gettext build-essential autoconf libtool libpcre3-dev asciidoc xmlto libev-dev libc-ares-dev automake golang golang-go fail2ban apache2 unzip git
git clone https://github.com/jedisct1/libsodium --branch master
pushd libsodium
bash autogen.sh
@Unbinilium
Unbinilium / Config-Qt-Creator-with-OpenCV.md
Last active November 3, 2019 02:41
Config Qt Creator with OpenCV

Firstly we installed opencv by compiling it form its source and libraries installed in /usr/local/lib. We could show the files in this directory by la /usr/local/lib | grep libopencv then it shows:

libopencv_calib3d.so
libopencv_calib3d.so.4.1
libopencv_calib3d.so.4.1.2
libopencv_core.so
libopencv_core.so.4.1
libopencv_core.so.4.1.2
libopencv_dnn.so
libopencv_dnn.so.4.1
@Unbinilium
Unbinilium / Command-lines-proxy.md
Last active November 3, 2019 06:51
Command lines proxy

Usually we got a system based proxy but it not works in command line tools like the terminal. We could easily add such proxy by replacing the proxy information below and run them in terminal.

export http_proxy=protocol://username:password@proxyhost:port/
export ftp_proxy=protocol://username:password@proxyhost:port/
export telnet_proxy=protocol://username:password@proxyhost:port/

The protocol should be http, https or socks5 depends on what type of proxy you are using. Further more, we could add this to ~/.*shrc to initialize proxy when terminal start by sudo nano ~/.*shrc.

Let apt work with socks5 proxy, add -o Acquire::http::proxy="protocolh://proxyhost:proxyport/" as arguments, for example:

@Unbinilium
Unbinilium / Accelerate-CMake-build-speed-by-using-multi-cores.md
Last active October 30, 2019 04:55
Accelerate CMake build speed by using multi-cores

Normally we build from source code by sudo make, but it seems always slow in a more awkward way. Let's see the flags by sudo make -h:

Usage: make [options] [target] ...
Options:
  -b, -m                      Ignored for compatibility.
  -B, --always-make           Unconditionally make all targets.
  -C DIRECTORY, --directory=DIRECTORY
                              Change to DIRECTORY before doing anything.
  -d                          Print lots of debugging information.
  --debug[=FLAGS]             Print various types of debugging information.