<Python Web开发实战>
This file contains 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 re | |
from collections import defaultdict | |
from datetime import datetime | |
import requests | |
# https://github.com/livid/v2ex/blob/master/api.py#L247 | |
url = 'https://www.v2ex.com/api/replies/show.json' | |
rs = requests.get(url, params={'topic_id': 313225, 'page': 11}) |
This file contains 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 | |
import random | |
import re | |
def color(messages): | |
color = '\x1B[%d;%dm' % (1,random.randint(30,37)) | |
return '%s %s\x1B[0m' % (color,messages) |
This file contains 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 threading | |
count = 0 | |
def incre(): | |
global count | |
count += 1 | |
This file contains 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 | |
from mapreduce import SimpleMapReduce | |
from simple import FILES, file_parser | |
def count_err_log(item): | |
word, occurances = item | |
return (word, sum(occurances)) | |
This file contains 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 | |
# Note: | |
# 1. 使用Redis缓存用户信息,减少重复调用 | |
# 2. 只通过用户的location字段看是否包含beijing、shanghai、guangzhou、 | |
# shenzhen、china这几个关键词判断是否是国人 | |
from collections import defaultdict | |
import redis | |
import requests | |
USENAME = '<YOUR USERNSME>' |
This file contains 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
❯ ps -ef | grep openvpn | |
0 35727 1 0 1:48PM ?? 0:00.07 /Applications/Tunnelblick.app/Contents/Resources/openvpn/openvpn-2.2.1/openvpn --daemon --log /Library/Application Support/Tunnelblick/Logs/-SLibrary-SApplication Support-STunnelblick-SShared-Sdouban.tblk-SContents-SResources-Sconfig.ovpn.9_0_3_1_305.1337.openvpn.log --cd /Library/Application Support/Tunnelblick/Shared/douban.tblk/Contents/Resources --config /Library/Application Support/Tunnelblick/Shared/douban.tblk/Contents/Resources/config.ovpn --cd /Library/Application Support/Tunnelblick/Shared/douban.tblk/Contents/Resources --management 127.0.0.1 1337 --management-query-passwords --management-hold --script-security 2 --up /Applications/Tunnelblick.app/Contents/Resources/client.2.up.tunnelblick.sh -w -d -f -ptADGNWradsgnw --down /Applications/Tunnelblick.app/Contents/Resources/client.2.down.tunnelblick.sh -w -d -f -ptADGNWradsgnw | |
501 35772 92964 0 1:49PM ttys007 0:00.00 grep openvpn | |
❯ ping 10.8.0.1 | |
PING 10.8.0.1 (10.8.0.1): |
This file contains 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
(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))) |
This file contains 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
$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> |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.