Skip to content

Instantly share code, notes, and snippets.

View dongweiming's full-sized avatar
:octocat:
🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔

Weiming Dong dongweiming

:octocat:
🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔
View GitHub Profile
@dongweiming
dongweiming / Spider.py
Created October 23, 2012 03:23
A Spider
#!/usr/bin/env python
#coding=utf-8
import urllib2
import Queue
import sys
import traceback
import threading
import re
import datetime
(defun score (dice)
(reduce #'+ (mapcar #'(lambda (n)
(let ((coun (count n dice)))
(case n
(1 (cond ((= coun 3) 1000)
((< coun 3) (* 100 coun))
((> coun 3) (+ 1000 (* 100 (- coun 3))))))
(5 (cond ((= coun 3) 500)
((< coun 3) (* coun 50))
((> coun 3) (+ 500 (* (- coun 3) 50)))))
def __getattr__(self, name):
"""
According to invoke methods to obtain data
"""
base_type = ['Careful', 'Warning', 'Critical']
base_module = ['CPU', 'LOAD', 'Process', 'STD', 'MEM', 'SWAP', 'TEMP', 'HDDTEMP', 'FS']
get_type = ['get'+n for n in base_type]
get_module = ['get'+m+t for m in base_module\
for t in base_type]
def getCareful(self, stat):
return self.__limits_list[stat][0]
def getWarning(self, stat):
return self.__limits_list[stat][1]
def getCritical(self, stat):
return self.__limits_list[stat][2]
# TO BE DELETED AFTER THE HTML output refactoring
@dongweiming
dongweiming / t1.py
Created August 12, 2013 17:14
tornado-async-contrast
#!/bin/env python
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
import tornado.httpclient
import time
@dongweiming
dongweiming / gist:7526221
Created November 18, 2013 11:17
prelude-taglist
在.emacs.d/core/prelude-core.el最后添加函数
(defun prelude-py-taglist (arg)
"简易版taglist"
(interactive "P")
(let ((buffer-other
(if arg
"*py-taglist*"
(format "*py-taglist from %s*" (buffer-name)))))
(occur-1 "class \\|def " nil
@dongweiming
dongweiming / gist:7576058
Created November 21, 2013 04:22
发现问题
class ProcessStates:
STOPPED = 0
STARTING = 10
RUNNING = 20
BACKOFF = 30
STOPPING = 40
EXITED = 100
FATAL = 200
UNKNOWN = 1000
#!/usr/bin/expect
#使用expect登陆服务器脚本
#dongweiming 2013.04.02
set timeout 5
set server [lindex $argv 0]
set port [lindex $argv 1]
set password [lindex $argv 2]
set tbjpass XXX
import multiprocessing
import time
import pymongo
start = time.time()
db = pymongo.MongoClient()['test']
def mapper(i):
if i['a'] > 0.95:
@dongweiming
dongweiming / pli.el
Last active August 29, 2015 14:05
A Major mode for demo
;;; pli.el --- A Major mode for demo
;; Description: A Major mode for demo
;; Created: 2014-09-01 01:12
;; Author: dongweiming [email protected]
;; URL: http://github.com/dongweiming/pli-mode
;; Keywords: test, emacs
;; Version: 1.0