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 / 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 dongweiming@douban.com
;; URL: http://github.com/dongweiming/pli-mode
;; Keywords: test, emacs
;; Version: 1.0
@dongweiming
dongweiming / README.md
Last active August 29, 2015 14:09
settings

启动celery

celery -A app.celery worker

启动flask

python app.py

来个双层requests.get

@dongweiming
dongweiming / homebrew.mxcl.redis.plist
Created March 27, 2015 04:05
homebrew.mxcl.redis.plist
$cat /usr/local/Cellar/redis/2.8.8/homebrew.mxcl.redis.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
(defun get-repo-url (arg)
(let* ((remote (if arg "upstream" (nth 2 (s-split "/" (magit-get-tracked-ref)))))
(remote-url (magit-get "remote" remote "url"))
(fragments (s-split "[:/@]/?/?" (s-chop-suffix ".git" remote-url))))
(concat "http://" (s-join "/" (cdr fragments)))))
(defun open-in-repo (arg)
(interactive "P")
(let* ((url (get-repo-url arg))
(branch (if arg "master" (magit-get-current-branch)))
@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