Skip to content

Instantly share code, notes, and snippets.

@notsobad
notsobad / gist:aa252de8d23cae9f265d743f1d041be0
Created April 12, 2022 06:31
Use dns-reverse-proxy to route dns request to different server by domain name.
#!/bin/bash
# Get dns-reverse-proxy from https://github.com/notsobad/dns-reverse-proxy
pushd /xxx/dns-reverse-proxy
LAN_DNS=`systemd-resolve --status | grep 'DNS Servers'|cut -d ':' -f2|xargs`:53
echo "lan dns": $LAN_DNS
sudo ./dns-reverse-proxy\
-address 0.0.0.0:53 \
-default 114.114.114.114:53 \
@notsobad
notsobad / init.sh
Created April 12, 2022 06:27
Init script, so you can open several iterm2 tabs and ohter desktop apps.
#!/bin/bash
function tab () {
local cmd=""
local cdto="$PWD"
local args="$@"
if [ -d "$1" ]; then
cdto=`cd "$1"; pwd`
args="${@:2}"
@notsobad
notsobad / .gitlab-ci.yml
Created April 12, 2022 06:19
Use pylint in merge requests, only check the changed '.py' files in this MR.
stages:
- test
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
pylint-error-only:
stage: test
script:
@notsobad
notsobad / http408.py
Created January 26, 2021 06:39
HTTP 408
# python http408.py 127.0.0.1 80 25
import socket
import time
import sys
HOST = sys.argv[1]
PORT = int(sys.argv[2])
DELAY = int(sys.argv[3])
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#coding=utf-8
# https://zh.wikipedia.org/wiki/%E8%92%99%E6%8F%90%E9%9C%8D%E7%88%BE%E5%95%8F%E9%A1%8C
import sys
import random
stay = 0
change = 0
MAX_TRY = int(sys.argv[1])
for i in range(MAX_TRY):
docker run -v `pwd`:/data/ -e NODE_TLS_REJECT_UNAUTHORIZED=0 --rm -ti elasticdump/elasticsearch-dump \
--input=https://user:pass@domain.com/dir/ \
--input-index=index/type \
--searchBody="{\"query\":{\"term\":{\"key\": \"xxxx\"}}}" \
--output=/data/xxx.json \
--size=1000 \
--concurrency=5 \
--type=data
# https://askubuntu.com/questions/1049302/wired-ethernet-not-working-ubuntu-18-04
# ubuntu 18.04 桌面版,发现每次重启后,有线网络是off的状态,需要点击connect,才能连接,查了下,有不少人遇到同样问题,下面这个方法可以解决问题
service network-manager stop
rm /var/lib/NetworkManager/NetworkManager.state
service network-manager start