Skip to content

Instantly share code, notes, and snippets.

View leafsummer's full-sized avatar
🎯
Focusing

LeafSummer leafsummer

🎯
Focusing
View GitHub Profile
@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 / install_pstree
Created May 23, 2016 02:45
install pstree
Linux pstree shows running processes as a tree. The tree is rooted at either pid or init if pid is omitted. If a user name is specified, all process trees rooted at processes owned by that user are shown.
Install pstree
#On Mac OS
brew install pstree
#On Fedora/Red Hat/CentOS
yum install psmisc #using psmisc package for pstree
#On Ubuntu/Debian APT
@leafsummer
leafsummer / nvd_cve_data_download.sh
Created January 11, 2024 06:29
use shell to download the nvd cve datasource to save in the local files
#!/bin/sh
# 下载nvd的数据源备份
data_source="https://nvd.nist.gov/feeds/json/cve/1.1/"
download_dir="/data/SFTP/data/SDA/release/NVD/"
# file_name="nvdcve-1.1-{}.json.gz"
@leafsummer
leafsummer / chatfairy_app.py
Created December 1, 2023 04:10
This is a minimal chat application with no dependancy but Flask! I call it Chatfairy.
from functools import wraps
from flask import (
Flask,
json,
redirect,
render_template_string,
request,
session,
url_for,
@leafsummer
leafsummer / txt2speech.py
Created October 31, 2023 04:01
text2speed by azure sdk
import os
from tqdm import tqdm
import azure.cognitiveservices.speech as speechsdk
key = "写你自己的key"
region = "eastasia"
endpoint = "https://eastasia.api.cognitive.microsoft.com/sts/v1.0/issuetoken"
# Read user input
filename = input("Please enter the name of the text file to convert: ")
@leafsummer
leafsummer / test_network.sh
Created April 13, 2023 06:11
test network latency and packet loss
#!/bin/bash
log_file=/var/log/curl_error.log
max_age=86400 # one day in seconds
max_loop=1000 # maximum number of loops to execute
loop_count=0 # current number of loops executed
if [ ! -f "$log_file" ]; then
touch "$log_file"
fi
@leafsummer
leafsummer / password_serializer.py
Last active March 22, 2023 23:30
integrate django password validators with django rest framework validate_password
import django.contrib.auth.password_validation as validators
from rest_framework import serializers
class RegisterUserSerializer(serializers.ModelSerializer):
password = serializers.CharField(style={'input_type': 'password'}, write_only=True)
class Meta:
model = User
fields = ('id', 'username', 'email, 'password')
@leafsummer
leafsummer / install_v2ray.sh
Created December 8, 2017 07:48
install the v2ray script
#!/bin/bash
# This file is accessible as https://install.direct/go.sh
# Original source is located at github.com/v2ray/v2ray-core/release/install-release.sh
CUR_VER=""
NEW_VER=""
ARCH=""
VDIS="64"
ZIPFILE="/tmp/v2ray/v2ray.zip"
@leafsummer
leafsummer / commit_message.md
Created August 5, 2022 03:56
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@leafsummer
leafsummer / make_zero_seed.md
Last active May 17, 2022 11:54
zeronet auto make seed

Become a Seeder: If you have a spare node (like a Raspberry PI with external HDD), you can setup a ZeroNet node here, which can automatically download and seen each new site published here.

Script to download new sites:


ZERO_DIR=~/ZeroNet-master
ZERO_HOST=127.0.0.1