Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

LeafSummer leafsummer

🎯
Focusing
View GitHub Profile
@leafsummer
leafsummer / gist:8b74d99bee233514db8f96239a2fb004
Created Apr 10, 2021 — forked from david415/gist:8274636
/etc/ufw/before.rules - for use with tor...
View gist:8b74d99bee233514db8f96239a2fb004
#
# rules.before
#
# Rules that should be run before the ufw command line added rules. Custom
# rules should be added to one of these chains:
# ufw-before-input
# ufw-before-output
# ufw-before-forward
#
@leafsummer
leafsummer / aes_python.py
Created Mar 5, 2021
[python aes cbc encrypt]
View aes_python.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# FileName : aes_python.py
# must install the pycrypto at frist, cmd: pip install pycrypto
import hashlib
from Crypto.Cipher import AES
import base64
View redistools.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# FileName : redistools.py
# Author : wuqingfeng@
from functools import wraps
try:
import cPickle as pickle
except ImportError:
import pickle
View arch_aws.plantuml
@startuml Basic Sample
!include <awslib/AWSCommon>
!includeurl https://raw.githubusercontent.com/RicardoNiepel/C4-PlantUML/release/1-0/C4_Container.puml
' Uncomment the following line to create simplified view
' !include <awslib/AWSSimplified>
!include <awslib/General/all>
!include <awslib/NetworkingAndContentDelivery/all>
View sample.py
this_max = min(sample["this"], sample["this"] * sample["max"] / sample["total"] + 1)
sample_a = 1
if this_max > 1:
sample_b = math.log(sample["this"]) / math.log(this_max)
else:
sample_b = 1
sample_target = int(sample_a * ((line_num + 1) ** sample_b) + 0.5) # line_no >= sample_target
@leafsummer
leafsummer / daemon_ubuntu.sh
Created Aug 22, 2019
[start a daemon with ubuntu shell]
View daemon_ubuntu.sh
#!/bin/sh
### BEGIN INIT INFO
# Provides: apache2
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: true
# Short-Description: Start/stop apache2 web server
# Description: Start the web server and associated helpers
@leafsummer
leafsummer / daemon_centos.sh
Created Aug 22, 2019
[start a daemon with centos shell]
View daemon_centos.sh
#!/bin/sh
#
# Startup script for program
#
# chkconfig: 345 85 15 - start or stop process definition within the boot process
# description: Description of program
# processname: process-name
# pidfile: /var/run/process-name.pid
# Source function library. This creates the operating environment for the process to be started
View collect_linux_info.py
import sys
import socket
from zipfile import ZipFile
import logging
from datetime import datetime
import os
import shutil
import subprocess
import glob
import pwd
View uping.py
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os
import time
import commands
import sys
class Pinger():
STYLE = {
@leafsummer
leafsummer / zbench.sh
Last active Jul 9, 2019
[zbench for vps]
View zbench.sh
# Check if user is root
[ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
# Check if wget installed
if [ ! -e '/usr/bin/wget' ]; then
echo "Error: wget command not found. You must be install wget command at first."
exit 1
fi
# read -p "请输入你的服务器提供商: " Provider