Skip to content

Instantly share code, notes, and snippets.

禁用Lid-Sleep的命令(保持系统唤醒):

sudo pmset -b sleep 0; sudo pmset -b disablesleep 1

激活Lid-Sleep的命令(让系统再次正常休眠):

sudo pmset -b sleep 5; sudo pmset -b disablesleep 0
@Carry00
Carry00 / AdGuardHome.ini
Last active December 31, 2021 17:15
supervisor配置文件
[program:dns]
directory=/usr/local/AdGuardHome/
command=/usr/local/AdGuardHome/AdGuardHome
autostart = true
autorestart = true
startsecs=1
user = root
stdout_logfile=/data/log/dns.log
redirect_stderr = true
stdout_logfile_maxbytes = 20MB
@Carry00
Carry00 / kafk2es.conf
Last active March 20, 2022 02:56
logstash配置文件
input{
kafka {
bootstrap_servers => "10.10.10.13:9092, 10.10.10.14:9092, 10.10.10.15:9092, 10.10.10.16:9092, 10.10.10.17:9092"
topics => ["dba-audit"] #读取的topic名称
group_id => "dba-audit" #消费组名称,logstash集群消费kafka集群的身份标识,必须集群相同且唯一
auto_offset_reset => "earliest"
codec => "json"
consumer_threads => 10 #消费线程数,集群中所有logstash相加最好等于 topic 分区数
client_id => "client-dba-audit"
max_poll_records => "150"
@Carry00
Carry00 / binlog_analyze.sh
Last active March 20, 2022 03:05
binlog分析脚本
#!/bin/bash
## 给定binlog目录及文件名称
BINLOG_FILE=$*
# 确保mysqlbinlog可用
BINLOG_CLI=${BINLOG_CLI:-mysqlbinlog}
which "$BINLOG_CLI" >/dev/null 2>&1
if test $? -ne 0; then
echo -e " \033[1;33m Example1:bash $(basename $0) mysql_bin.000750 \033[m"
echo -e " \033[1;33m Example2:bash $(basename $0) /data/dblogs/mysql3366/binlogs/mysql_bin.000749 \033[m"
exit 1
{
"aria2c": "https://gist.githubusercontent.com/Carry00/555036a4d62cbb745f3fc25d7cd4cbc8/raw/e2fb3a60e3375f4aab2cd405285b10358d17781b/aria2c",
"iptables": "https://gist.githubusercontent.com/Carry00/21dbc4dccafdb2147133a971ae6f03e2/raw/d99478c9dda28c6b98e23ec587bd3a14e9460bd6/iptables",
"systemd":"https://gist.githubusercontent.com/Carry00/7a49cd662a82e81519b952505017207e/raw/de6310d9aa908deaa6964521dcb1930964257f2c/systemd"
}
#!/bin/bash
# 映射 URL 的接口
mapping_url="https://gist.githubusercontent.com/Carry00/6e526b8751f667f667a9be540d015939/raw/fd8b0224f17ef3c4d2d49e2196bafc2f82dba1a1/command_mapping"
# 函数:获取所有命令及其对应的 Gist URL
get_all_commands() {
curl -s "${mapping_url}" | jq -r 'keys[]'
}
# 允许 IP 192.168.1.100
iptables -A INPUT -s 192.168.1.100 -j ACCEPT -m comment --comment "Allow IP 192.168.1.100"
# 允许 IP 192.168.1.100 访问端口 80
iptables -A INPUT -s 192.168.1.100 -p tcp --dport 80 -j ACCEPT -m comment --comment "Allow IP 192.168.1.100 on port 80"
# 允许 IP 192.168.1.100 访问端口 80 和 443
iptables -A INPUT -s 192.168.1.100 -p tcp -m multiport --dports 80,443 -j ACCEPT -m comment --comment "Allow IP 192.168.1.100 on ports 80,443"
# 允许 IP 范围 192.168.1.100 到 192.168.1.200
[Unit]
Description=My Custom Service
After=network.target
[Service]
Type=simple
User=myuser
Group=mygroup
WorkingDirectory=/path/to/working/directory
ExecStart=/path/to/executable --option1 value1 --option2 value2