Skip to content

Instantly share code, notes, and snippets.

@wrhb123
wrhb123 / .Cloud.md
Created November 29, 2024 09:25 — forked from imba-tjd/.Cloud.md
☁️ 一些免费的云资源

  • IaaS指提供系统(可以自己选)或者储存空间之类的硬件,软件要自己手动装。PaaS提供语言环境和框架(可以自己选)。SaaS只能使用开发好的软件(卖软件本身,如税务会计、表格文字)。BaaS一般类似于非关系数据库,但各家不通用
  • 云服务的特点:零前期成本&按需付费&弹性(类似于租,可随时多加、退掉;但没有残值)、高可用(放在机房中,不同AZ间水电隔离)

其他人的集合

@wrhb123
wrhb123 / golang_prometheus_metric_counter.go
Created November 10, 2022 06:31 — forked from ggzeng/golang_prometheus_metric_counter.go
prometheus golang 客户端中的各类metric写法
//step1:初始一个counter, with help string
pushCounter = prometheus.NewCounter(prometheus.CounterOpts{
Name: "repository_pushes",
Help: "Number of pushes to external repository.",
})
//setp2: 注册容器
err = prometheus.Register(pushCounter)
if err != nil {
fmt.Println("Push counter couldn't be registered AGAIN, no counting will happen:", err)
@wrhb123
wrhb123 / nginx-cors.conf
Created July 6, 2020 07:17 — forked from sbuzonas/nginx-cors.conf
Nginx CORS maps
map $http_origin $allow_origin {
default "";
"~^https?://(?:[^/]*\.)?(stevebuzonas\.(?:com|local))(?::[0-9]+)?$" "$http_origin";
}
map $request_method $cors_method {
default "allowed";
"OPTIONS" "preflight";
}
@wrhb123
wrhb123 / profiler.py
Created May 1, 2020 08:37 — forked from adisonhuang/profiler.py
python 函数执行时间工具类
from functools import wraps
import cProfile
from line_profiler import LineProfiler
import time
def func_time(f):
"""
import collections
def get_paths(source):
paths = []
if isinstance(source, collections.MutableMapping): # found a dict-like structure...
for k, v in source.items(): # iterate over it; Python 2.x: source.iteritems()
paths.append([k]) # add the current child path
paths += [[k] + x for x in get_paths(v)] # get sub-paths, extend with the current
# else, check if a list-like structure, remove if you don't want list paths included
elif isinstance(source, collections.Sequence) and not isinstance(source, str):
import json
class find_path():
def __init__(self,target):
self.target=target
def find_the_value(self,target,value,path='',path_list=None):
'''完全匹配,每经过一层(list、dict)都会记录path,到了最后一层且当前target就是要找的目标,才把对应的path记录下来
:param target: 被搜索的目标
:param value: 要搜索的关键字
def update_json_conf(filepath, key, value):
key_ = key.split(".")
key_length = len(key_)
try:
with open(filepath, 'rb') as f:
json_data = json.load(f)
i = 0
a = json_data
while i < key_length :
if i+1 == key_length :
#!/usr/bin/env bash
#
# Copyright 2018 (c) Yousong Zhou
#
# This script can be used to debug "no space left on device due to inotify
# "max_user_watches" limit". It will output processes using inotify methods
# for watching file system activities, along with HOW MANY directories each
# inotify fd watches
#
# A temporary method of working around the said issue above, tune up the limit.
post {
failure {
echo "邮件报警"
}
success {
echo "发送测试报告"
script{
emailext subject: "Unittest: Job '${env.JOB_NAME} - ${env.BUILD_NUMBER}'",
mimeType: "text/html",
body: '''
<!-- Robot Framework Results -->
<%
import java.text.DateFormat
import java.text.SimpleDateFormat
%>
<STYLE>
BODY, TABLE, TD, TH, P {
font-family:Verdana,Helvetica,sans serif;
font-size:11px;
color:black;