Skip to content

Instantly share code, notes, and snippets.

View c2h2's full-sized avatar

Yiling Cao c2h2

View GitHub Profile
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
@c2h2
c2h2 / arduino_esp8266_dht11_https_send.c
Last active February 14, 2023 16:10
arduino_esp8266_dht11_https_send.c
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>
#include <WiFiClientSecureBearSSL.h>
#include "DHT.h"
DHT dht2(2, DHT11);
const char* ssid = "ssid";
const char* password = "xxxx";
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>
#include "DHT.h"
DHT dht2(2,DHT11);
const char* ssid = "ssid";
const char* password = "xxxxxx";
@c2h2
c2h2 / arduino_esp8266_wifi-client_web-server_pin_ctl.c
Last active January 13, 2023 16:32
eso8266 connects home wifi router and accepts http request to control pins, for home ventilation automation
/*
arduino_esp8266_wifi-client_web-server_pin_ctl.c
compiled on arduino 2.0.4 and using ESP-01 8pin module and a relay.
WiFi Client, HTTP Web Server, to control 2 pins and relays.
*/
#include <ESP8266WiFi.h>
@c2h2
c2h2 / combine_aiports.py
Created January 11, 2023 02:59
combine_aiports.py
import urllib.request
import base64
import json
import ssl
url="https://jmssub.net/" #change to your url
content = urllib.request.urlopen(url).read().strip()
servers_sub = base64.b64decode(content).decode()
output = []
@c2h2
c2h2 / ping_for_awhile.sh
Last active September 19, 2022 05:58
ping_for_awhile.sh
#!/bin/bash
ts=`date '+%Y%m%d-%H%M%S'`
fn=${ts}_pingresults.txt
function ping_for_awhile(){
myip=`curl -s --insecure https://f.g77k.com/ip.php`
srvtime=`curl -s --insecure https://f.g77k.com/time.php`
date | tee $fn