Skip to content

Instantly share code, notes, and snippets.

View leafsummer's full-sized avatar
🎯
Focusing

LeafSummer leafsummer

🎯
Focusing
View GitHub Profile
@leafsummer
leafsummer / aes_python.py
Created March 5, 2021 02:08
[python aes cbc encrypt]
#!/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
@leafsummer
leafsummer / redistools.py
Created January 11, 2021 10:02
[redis_tools]
#!/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
@leafsummer
leafsummer / arch_aws.plantuml
Created September 1, 2020 07:19
[plantuml learning]
@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>
@leafsummer
leafsummer / sample.py
Created November 19, 2019 05:28
sample data
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 August 22, 2019 07:57
[start a daemon with ubuntu shell]
#!/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 August 22, 2019 07:56
[start a daemon with centos shell]
#!/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
@leafsummer
leafsummer / collect_linux_info.py
Created July 23, 2019 10:59
[collect_linux_info]
import sys
import socket
from zipfile import ZipFile
import logging
from datetime import datetime
import os
import shutil
import subprocess
import glob
import pwd
@leafsummer
leafsummer / uping.py
Created July 9, 2019 08:34
[ping forever]
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os
import time
import commands
import sys
class Pinger():
STYLE = {
@leafsummer
leafsummer / zbench.sh
Last active July 9, 2019 08:24
[zbench for vps]
# 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
@leafsummer
leafsummer / mkxml.sh
Created July 2, 2019 04:05
[make the centos xml file of packages for installing]
#!/usr/bin/bash
# $1 -> rpmdir $2 -> id
set -e
array=()
i=1
#change dir to destdir
cd `pwd`/$1