Skip to content

Instantly share code, notes, and snippets.

View c2h2's full-sized avatar

Yiling Cao c2h2

View GitHub Profile
@c2h2
c2h2 / httpbench.go
Created February 29, 2024 05:22
httpbench.go, go version of simplified ab
package main
import (
"flag"
"fmt"
"io"
"io/ioutil"
"net/http"
"sync"
"time"
id_rsa:$sshng$6$16$51abbdb90f62c1b60d256c1bcd40a857$1894$6f70656e7373682d6b65792d7631000000000a6165733235362d63747200000006626372797074000000180000001051abbdb90f62c1b60d256c1bcd40a857000000100000000100000197000000077373682d727361000000030100010000018100d2f191a9d9180efb2cc5c2b776e47faf4b39223940518c02f1bb33060898c4ff3fe67f7c1d696b44d0cb1ac936b9e2a8a067393a4d1abc6d7844c11ecfbf9c053d91541f40971586c394b360c0e038d0f3bc458af0c86a87f0015bc60f883feb339939e5eabbbc77c12a8f7d79f090b436ecea9d0ec0f15631daf66a66ffdd60e480729bf579afe1a15a762bc086a9659b8cfced152cafc7716089918fd8e7d7265a740a8f5748bb726b93d11b928a0d12815094213ca5c04817cf276a79fe5706a8f7b35dc00dfd639f0d18960c3424852d3defc7625e47b4e963d3d31dfcc6bcbd796d1970887e170888d9c82d0c58ad36a6a1bb422347a795c1df921fba93aeed39fccb959da6ed368f0ecd75e9afca21e863f3d6e27507549c98c6c077484e8c129c07429e427f65dbf0d906803da922ebed409d9847e243d361202560dc24b440f309e233a1d4c458923c6cbfe3d7d6b88e1b9b0b7cdf8c81efe460a5dc09eff75d9a9ac26f9c7b69b00ec49959b98109839902069bb8b8d6037f4e66f7000
import json
import subprocess
import datetime
import time
MAX_SPD=80
MIN_SPD=22
ipmi_host="192.168.2.145"
ipmi_pass="xxxxxx"
@c2h2
c2h2 / ddns6.sh
Created June 11, 2023 13:25
cloudflare ipv6 ddns
#!/usr/bin/env bash
# Step 1: Fill in EMAIL, TOKEN, DOMAIN and SUBDOMAIN. Your API token is here: https://www.cloudflare.com/a/account/my-account
# Make sure the token is the Global token, or has these permissions: #zone:read, #dns_record:read, #dns_records:edit
# Step 2: Create an A record on Cloudflare with the subdomain you chose
# Step 3: Run "./ddns.sh -l" to get the zone_id and rec_id of the record you created.
# Fill in ZONE_ID and REC_ID below
# This step is optional, but will save you 2 requests every time you this script
# Step 4: Run "./ddns.sh". It should tell you that record was updated or that it didn't need updating.
# Step 5: Run it every hour with cron. Use the '-s' flag to silence normal output
@c2h2
c2h2 / get_ipv6_addr.sh
Created June 10, 2023 17:02
get my ipv6 global address slaac
ip -6 addr | grep inet6 | grep global | grep -v "temp" | grep -v "mngtmpaddr" | grep -v "fd" | awk -F '[ \t]+|/' '{print $3}'
#set my addr example:
#ip -6 addr add 2001:19f0::00e3 dev eth0
import minimalmodbus
import time
import serial
import datetime
import redis
import pickle
rconn = redis.Redis('localhost')
@c2h2
c2h2 / get_cpu0_temp.py
Created June 9, 2023 03:56
python script to get intel cpu temperautre package temp
import subprocess
import json
cmd = "sensors -j"
x=subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
temps=json.loads(x)
temp0=(temps['coretemp-isa-0000']['Package id 0']['temp1_input'])
print(temp0)
@c2h2
c2h2 / powersave.sh
Created June 5, 2023 04:17
save your server cpu power this summer, powersave.sh
#!/bin/bash
#apt-get install linux-cpupower
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
echo "Setting to Powersave"
cpupower frequency-set --governor powersave
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
@c2h2
c2h2 / frps
Created May 25, 2023 17:24 — forked from KyonLi/frps
frps init.d script
#!/bin/sh
### BEGIN INIT INFO
# Provides: frps
# Required-Start: $local_fs $network
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: frps service deamon
# Description: frps service daemon
@c2h2
c2h2 / read_rs485_modbus_temp.py
Created May 5, 2023 13:58
read_rs485_modbus_temp.py
import minimalmodbus
import time
import serial
import datetime
instrument = minimalmodbus.Instrument('/dev/ttyUSB0', 1, debug=False) # port name, slave address (in decimal)
instrument.serial.port = '/dev/ttyUSB0' # this is the serial port name
instrument.serial.baudrate = 9600 # Baud
instrument.serial.bytesize = 8
instrument.serial.parity = serial.PARITY_NONE