Skip to content

Instantly share code, notes, and snippets.

View sljeff's full-sized avatar
🚩
Flag

Kind Jeff sljeff

🚩
Flag
View GitHub Profile
@sljeff
sljeff / pip-upgrade-all-packages.py
Created October 8, 2016 00:51
pip upgrade all packages
import pip
from subprocess import call
for dist in pip.get_installed_distributions():
call("pip install --upgrade " + dist.project_name, shell=True)
from PIL import Image
img = Image.open("QQwhite.jpg")
width, height = img.size
result = Image.new('RGB', (width, height))
data = list(img.getdata())
for i, t in enumerate(data):
if set(t) == {255}:
@sljeff
sljeff / video_to_audio.py
Created November 25, 2016 02:44
python. convert video to audio.
# coding: utf-8
import moviepy.editor as mp
import sys
def convert(video_file_name, audio_file_name=None):
if audio_file_name is None:
audio_file_name = video_file_name + '.mp3'
try:
clip = mp.VideoFileClip(video_file_name)
clip.audio.write_audiofile(audio_file_name)
clash
🏆 205 Contributions in year 2020
📦 Used 24 MB in GitHub's Storage
📜 7 Public Gists
🔑 5 Public Keys
💼 Opted to Hire
#!/bin/bash
install_ipset() {
yum install -y ipset ipvsadm
}
load_mod() {
echo "#!/bin/bash
modprobe -- ip_vs
modprobe -- ip_vs_rr
{
"configurations":{
"Debug GRPC":{
"adapter":"vscode-go",
"configuration":{
"type":"go",
"request":"launch",
"mode":"debug",
"remotePath":"",
"port":2345,

下面都是说的无状态服务,有状态的类似,除了 1 2 再多一句话就能描述

最开始的状态:不云,但原生

没有好用的隔离方案,通常会在一个机器上部署一个东西:

  1. 我们知道机器的资源(这个进程最多能用多少 CPU 内存)
    • 以便让服务运行在资源足够的地方
  2. 我们知道哪些机器运行着这个服务(服务发现),服务可能直接监听 80 这样的端口
  • 以便做负载均衡
import sys
import json
def filter(har_file, contains):
with open(har_file) as f:
har = json.load(f)
entries = har['log']['entries']
filtered = [e for e in entries if contains in e['request']['url']]