Skip to content

Instantly share code, notes, and snippets.

View tmpbook's full-sized avatar
😇
aha

临书 tmpbook

😇
aha
View GitHub Profile
print 'test'
@tmpbook
tmpbook / check_image.py
Last active January 17, 2024 06:12
Pull 4254 docker images and delete them by python | 并发拉取镜像,记录拉取成功、失败、超时的情况
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import os
import sys
import datetime
import subprocess
import time
import gevent.pool
import gevent.monkey
@tmpbook
tmpbook / diff.py
Last active January 10, 2018 07:02
Find the different lines between two files | 接受两个参数,第一个是大文件,第二个是小文件,将小文件没有的行输出到 diff.txt 文件中
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import sys
def file_to_list(file):
with open(file) as f:
content = f.readlines()
return content
if __name__ == '__main__':
@tmpbook
tmpbook / delete_from_redis.py
Last active January 11, 2018 16:07
Delete keys which in a very big file from redis | 从非常大的文件读取 key 然后在 redis 中删除
import redis
import time
pool=redis.ConnectionPool(host='redis_hostname', port=6379, db=0)
r = redis.StrictRedis(connection_pool=pool)
start_time = time.time()
SUCCESS_DELETED = 0
with open("/data/rediskeys") as kf:
@tmpbook
tmpbook / redis_scan.py
Created January 12, 2018 11:11
scan redis by python.
import redis
pool=redis.ConnectionPool(host='redis_hostname', port=6379, max_connections=100)
r = redis.StrictRedis(connection_pool=pool)
cursor_number, keys = r.execute_command('scan', 0, "count", 200000)
while True:
if cursor_number == 0:
# 结束一次完整的比遍历
@tmpbook
tmpbook / matingare.py
Last active April 22, 2022 07:38
马丁格尔策略模拟 1.0
#coding:utf8
import random
import math
WIN = 1
LOSE = 0
def gambling_50_percent(pocket, pay):
result = random.randint(0, 1)
if result == WIN:
@tmpbook
tmpbook / blockchain.py
Created January 14, 2018 19:45
Learn blockchain by python | 使用 Python 理解区块链
import hashlib
import json
from time import time
from urllib.parse import urlparse
from uuid import uuid4
import requests
from flask import Flask, jsonify, request
@tmpbook
tmpbook / proxy.go
Created January 24, 2018 03:46 — forked from ericflo/proxy.go
Golang TCP Proxy
package proxy
import (
"io"
"net"
"sync"
log "github.com/Sirupsen/logrus"
)
@tmpbook
tmpbook / .block
Created June 25, 2018 03:00
Grouped Bar Chart with Crossfilter
license: mit
@tmpbook
tmpbook / build.sh
Created July 25, 2018 03:42
Jenkins build setup for Go Projects.
# You need install jenkins go plugin first -> https://wiki.jenkins.io/display/JENKINS/Go+Plugin
#!/usr/bin/bash
export GOPATH=$WORKSPACE
mkdir -p $GOPATH/src
project_name=$(echo $GIT_URL | awk -F/ '{print $NF}' | sed 's/.git//g')
echo ${project_name}
ln -f -s $WORKSPACE $GOPATH/src/$project_name
go get $project_name