Skip to content

Instantly share code, notes, and snippets.

@node
Last active December 28, 2016 09:56
Show Gist options
  • Save node/1390819 to your computer and use it in GitHub Desktop.
Save node/1390819 to your computer and use it in GitHub Desktop.
utility
- 下载整站
> wget -r -p -np -k http://xxoo.com
注释: -r 递归, -p 下载网页关联的其他资源,-np 不搜索上层目录, -k 绝对链接转为相对链接
其他参数:
  ◆-b:后台下载,Wget默认的是把文件下载到当前目录。
  ◆-O:将文件下载到指定的目录中。
  ◆-P:保存文件之前先创建指定名称的目录。
  ◆-t:尝试连接次数,当Wget无法与服务器建立连接时,尝试连接多少次。
  ◆-c:断点续传,如果下载中断,那么连接恢复时会从上次断点开始下载。
- 查看版本相关
> uname -a
> lsb_release -a
> ls /proc/*info
/proc/buddyinfo /proc/cpuinfo /proc/meminfo /proc/slabinfo /proc/zoneinfo
> whoami
> whereis xxoo
> which xxoo
> id
> who
> write xxoo
> wall
更多常用命令: http://linux.chinaitlab.com/special/linuxcom/
jo - json output for shell https://github.com/jpmens/jo
jq is a lightweight and flexible command-line JSON processor. https://stedolan.github.io/jq/
@node
Copy link
Author

node commented Apr 24, 2012

Python 相关工具安装

easy_install

wget http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg#md5=fe1f997bc722265116870bc7919059ea
sh setuptools-0.6c11-py2.7.egg
which easy_install

pip

easy_install pip
which pip

install others

easy_install xxoo
pip instal xxoo

@node
Copy link
Author

node commented Apr 25, 2012

通过命令将临时内容分享到外网 http://dpaste.de/about/

API

#!/usr/bin/env python

import urllib
import urllib2
import sys

def paste_code():
    request = urllib2.Request(
        'http://dpaste.de/api/',
        urllib.urlencode([('content', ''.join(sys.stdin.readlines()))]),
    )
    response = urllib2.urlopen(request)
    print response.read()[1:-1]

if __name__ == '__main__':
    paste_code()

Save this script in /usr/local/bin/dpaste and chmod +x ..filepath.

Usage: cat foo.txt | dpaste

@node
Copy link
Author

node commented May 11, 2012

python 命令行直接处理JSON: curl http://xxxxx.com/xxx.json | python -m json.tool

python 调试 : python -m pdb myscript.py

@node
Copy link
Author

node commented Aug 6, 2015

跟有控制台输入的程序交互

!python.exe

import subprocess
halls = subprocess.Popen([r'D:\Workspace\TexturePacker\bin\TexturePacker.exe'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
result = halls.communicate(input=r'agree')[0]
print halls.returncode
print halls.communicate()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment