Skip to content

Instantly share code, notes, and snippets.

View developerdong's full-sized avatar

Zhibin Dong developerdong

View GitHub Profile
@developerdong
developerdong / splice.go
Last active January 27, 2022 06:21
Go语言Splice系统调用的正确用法
const (
// spliceNonblock makes calls to splice(2) non-blocking.
spliceNonblock = 0x2
// maxSpliceSize is the maximum amount of data Splice asks the kernel to move in
// a single call to splice(2).
maxSpliceSize = 4 << 20
)
func Splice(reader, writer *os.File) (traffic int64, err error) {
@developerdong
developerdong / nginx-mirrors-redirect.conf
Last active July 9, 2020 04:27
Configuration of nginx for redirecting requests to different mirrors based on ip
events {
use epoll;
worker_connections 1024;
}
http {
geo $china_ip {
default 0;
1.0.1.0/24 1;
1.0.2.0/23 1;
@developerdong
developerdong / env.sh
Last active June 18, 2020 02:06
Shell script for initializing development environment in ubuntu:focal.
#!/usr/bin/env bash
# Shell script for initializing development environment in ubuntu
set -ex
export DEBIAN_FRONTEND=noninteractive
# Set locale, which takes effect after re-login
apt install -y language-pack-zh-hans
update-locale --reset LANG=zh_CN.UTF-8
@developerdong
developerdong / 5k_wallpaper_crawler.py
Created April 17, 2020 08:58
爬取5K分辨率超清唯美壁纸
# -*- coding:utf-8 -*-
from requests import get
from filetype import guess
from os import rename
from os import makedirs
from os.path import exists
from json import loads
from contextlib import closing
@developerdong
developerdong / RestRegularly.xml
Created April 1, 2020 03:11
Windows定时休息计划任务脚本
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2020-03-11T10:53:56.3761486</Date>
<Author>DESKTOP-EEQJ5NU\devel</Author>
<URI>\RestRegularly</URI>
</RegistrationInfo>
<Triggers>
<TimeTrigger>
<Repetition>
@developerdong
developerdong / bbr-build.sh
Last active April 28, 2021 08:02
Build linux kernel with bbr to generate debian package
set -e
KERNEL_TAG=${KERNEL_TAG:-"v5.10.32"}
# 安装编译依赖
sudo sed -i "s/# deb-src/deb-src/g" /etc/apt/sources.list
sudo apt-get update
sudo apt-get build-dep linux -y
# 下载内核源码
sudo apt-get install git -y
@developerdong
developerdong / .zshrc
Last active March 12, 2025 07:49
Configuration of Oh-My-Zsh
# If you come from bash you might have to change your $PATH.
export PATH=/snap/bin:$HOME/.local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="${HOME}/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
@developerdong
developerdong / ports_forwarding.ps1
Last active March 3, 2020 07:19
Ports forwarding from Windows to WSL2
# Run this script with PowerShell: PowerShell -ExecutionPolicy Bypass C:\path\to\scirpt
$remoteport = bash.exe -c "ifconfig eth0 | grep 'inet '"
$found = $remoteport -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';
if( $found ){
$remoteport = $matches[0];
} else{
echo "The Script Exited, the ip address of WSL 2 cannot be found";
exit;
}
@developerdong
developerdong / swap.sh
Last active February 25, 2020 11:37
Create and enable swap
mkdir /opt/images/
rm -f /opt/images/swap
# 2GB swap file
dd if=/dev/zero of=/opt/images/swap bs=1024 count=2097152
chmod 0600 /opt/images/swap
mkswap /opt/images/swap
swapon /opt/images/swap
@developerdong
developerdong / ReverseDomain.java
Created October 20, 2018 08:46
Get domains from input lines, then reverse them
import java.io.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
public static void main(String[] args) throws IOException {
System.out.println("args[0] = " + args[0]);
System.out.println("args[1] = " + args[1]);
BufferedReader bufferedReader = new BufferedReader(new FileReader(args[0]));