Skip to content

Instantly share code, notes, and snippets.

View notsobad's full-sized avatar

notsobad notsobad

View GitHub Profile
@notsobad
notsobad / chromedpTest.go
Last active August 16, 2023 06:47
使用 chromedp,加载一个网页,获取网页加载的所有资源地址,获取页面里的所有链接地址
// Command click is a chromedp example demonstrating how to use a selector to
// click on an element.
package main
import (
"context"
"fmt"
"log"
"strings"
"time"
@notsobad
notsobad / ana.sh
Created October 17, 2022 06:32
run this script on machine first.
#!/bin/bash
run(){
cmd=$@
echo ">> $cmd"
eval $cmd
echo
}
run uptime
>python3 blackjack.py -h
usage: blackjack.py [-h] -n NROUND [-j BLACKJACK_NUM] [-u PLAYER_HIT_UNTIL] [-s PLAYER_SKIP_LARGE] [--verbose]
Blackjack
optional arguments:
-h, --help show this help message and exit
-n NROUND, --nround NROUND
-j BLACKJACK_NUM, --blackjack_num BLACKJACK_NUM
-u PLAYER_HIT_UNTIL, --player_hit_until PLAYER_HIT_UNTIL
@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):