This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-*- coding: utf-8 -*- | |
import redis | |
REDIS_HOST = "localhost" | |
REDIS_PORT = 6379 | |
REDIS_DB1 = 0 | |
REDIS_DB2 = 1 | |
REDIS_DB3 = 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name {{ server_name }}; | |
access_log {{ access_log }} main; | |
error_log {{ error_log }}; | |
location / { | |
access_by_lua ' | |
local reqType = ngx.var.request_method | |
if reqType == "T" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
How to use it: | |
1. Just `kill -2 PROCESS_ID` or `kill -15 PROCESS_ID` , The Tornado Web Server Will shutdown after process all the request. | |
2. When you run it behind Nginx, it can graceful reboot your production server. | |
3. Nice Print in http://weibo.com/1682780325/zgkb7g8k7 | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import heapq | |
import random | |
class BtmkHeap(object): | |
def __init__(self, k): | |
self.k = k | |
self.data = [] | |
def Push(self, elem): | |
# Reverse elem to convert to max-heap |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-*- coding: utf-8 -*- | |
""" 封装成装饰器. | |
""" | |
import sys | |
import time | |
import threading | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"singleton" | |
) | |
func main() { | |
mSingleton, nSingleton := singleton.NewSingleton("hello"), singleton.NewSingleton("hi") | |
mSingleton.SaySomething() | |
nSingleton.SaySomething() | |
c := make(chan int) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" 基础镜像构建脚本. | |
会自动构建依赖的镜像, 比如构建基础镜像 centos6, 则以 centos6 开头的镜像都会构建, 比如: | |
centos6-java8 | |
centos6-java8-tomcat8 | |
根据镜像长度判断依赖关系. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env | |
import os | |
import sys | |
import re | |
import logging | |
import time | |
import argparse | |
import pexpect | |
import subprocess |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"log" | |
"net/rpc" | |
"os" | |
) | |
func main() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
import requests | |
def get_servicetag_from_sn(sn): | |
url = "http://www.dell.com/support/troubleshooting/cn/zh/cndhs1/ExpressService/ExpressService/GetSpecificExpressServiceTag" | |
data = { | |
"TagCode": sn | |
} |