Skip to content

Instantly share code, notes, and snippets.

View bloatfan's full-sized avatar
🤒
Out sick

bloatfan bloatfan

🤒
Out sick
View GitHub Profile
@bloatfan
bloatfan / yumcentos7.sh
Created October 19, 2024 10:49
yumcentos7
#!/bin/bash
# 检查系统版本
if [ -f /etc/redhat-release ]; then
OS_VERSION=$(grep -oE '[0-9]+\.[0-9]+' /etc/redhat-release)
else
echo "未找到 /etc/redhat-release 文件。请确保您运行的是 CentOS 系统。"
exit 1
fi
@bloatfan
bloatfan / optimize.sh
Last active February 24, 2024 12:38 — forked from taurusxin/optimize.sh
Linux Optimization Script
#!/usr/bin/env bash
echo=echo
for cmd in echo /bin/echo; do
$cmd >/dev/null 2>&1 || continue
if ! $cmd -e "" | grep -qE '^-e'; then
echo=$cmd
break
fi
done
@bloatfan
bloatfan / vagrant-vmware-tech-preview-apple-m1-pro.md
Created March 30, 2022 12:08 — forked from sbailliez/vagrant-vmware-tech-preview-apple-m1-pro.md
Vagrant and VMWare Tech Preview on Apple M1 Pro

Vagrant and VMWare Tech Preview on Apple M1 Pro

This document summarizes notes taken while to make the VMWare Tech preview work on Apple M1 Pro, it originated from discussions in hashicorp/vagrant-vmware-desktop#22

Installing Rosetta

First install Rosetta if not already done, this is needed to run x86 code:

@bloatfan
bloatfan / vpn-utilities.applescript
Created September 12, 2021 08:52 — forked from iloveitaly/vpn-utilities.applescript
Configure / create VPN connections via applescript
-- Author: Michael Bianco <http://mabblog.com/>
-- Some help from: http://discussions.info.apple.com/message.jspa?messageID=10363317
on create_vpn_service(vpn_name)
tell application "System Preferences"
reveal pane "Network"
activate
tell application "System Events"
tell process "System Preferences"
@bloatfan
bloatfan / utf8.php
Created May 9, 2017 13:57
gbk utf8 check
<?php
// refer: http://hustnaive.github.io/php/2015/08/21/php-detect-encoding.html
/**
* 检测字符串编码(注意:存在误判的可能性,降低误判的几率的唯一方式是给出尽可能多的样本$line)
* 检测原理:对给定的字符串的每一个字节进行判断,如果误差与gb18030在指定误差内,则判定为gb18030;与utf-8在指定误差范围内,则判定为utf-8;否则判定为utf-16
* @param string $line
* @return string 中文字符集,返回gb18030(兼容gbk,gb2312,ascii);西文字符集,返回utf-8(兼容ascii);其他,返回utf-16(双字节unicode)
* @author fangl
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias ll='ls -al'
# Source global definitions
@bloatfan
bloatfan / bash-zsh-auto-complete.sh
Last active May 26, 2021 15:20
bash 补全文件
# bash
https://stackoverflow.com/questions/33632668/bash-tab-completion-of-filenames-after-arguments
complete -D -o default
# zsh
https://unix.stackexchange.com/questions/333530/zsh-path-file-name-completion-on-file-arguments/333543#333543?newreg=65c5031ab2d6429984db9f2c4a26ac3c
@bloatfan
bloatfan / iptables-block-use.md
Last active May 26, 2021 15:12 — forked from vdw/gist:09efee4f264bb2630345
Kill tcp connection with tcpkill on CentOS

Install tcpkill
yum -y install dsniff --enablerepo=epel

View connections
netstat -tnpa | grep ESTABLISHED.*sshd.

Block with ip tables
iptables -A INPUT -s IP-ADDRESS -j DROP

Kill connection

@bloatfan
bloatfan / go_graceful_restart.go
Last active April 12, 2021 14:45
[Go平滑重启实现的Demo]
// https://juejin.im/post/5b3629cbf265da59645b1ac5
package main
import (
"context"
"encoding/json"
"flag"
"fmt"
"net"
@bloatfan
bloatfan / ssh-multi.sh
Created October 26, 2020 05:41 — forked from dmytro/ssh-multi.sh
Start multiple synchronized SSH connections with Tmux
#!/bin/bash
# ssh-multi
# D.Kovalov
# Based on http://linuxpixies.blogspot.jp/2011/06/tmux-copy-mode-and-how-to-control.html
# a script to ssh multiple servers over multiple tmux panes
starttmux() {
if [ -z "$HOSTS" ]; then