linux tips

  • 查看硬件信息:sudo lshw  #ls hardware
  • 查看CPU位数32/64:getconf LONG_BIT #longest integer bit.
  • 快速建立文件服务器并显示自已的IP:ifconfig |grep  -oP "(?<=inet addr:)[0-9.]+" |grep -v 127.0.0.1 | sed "s/\$/:8000/"  && python -m SimpleHTTPServer
  • resize image: convert source -resize '100x200' dest
     

一条命令下载整个Douban Album

主要是为了练习命令行。

Read more

auto vpn token

写了个 autoit 脚本,用来批量生成 token 。每次10个,之后放到剪贴板中。没找到如何使用 Autoit 发邮件。必须使用第三方的客户端?再查。

Read more

perl中的括号

 借此理解标量/数组上下文。

Read more

twitter同步到sina

下面的代码可将twitter同步到sina微博。不过,还不能移植到GAE.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
#to ensure the utf8 encoding environment
import sys
default_encoding = 'utf-8'
if sys.getdefaultencoding() != default_encoding:
    reload(sys)
    sys.setdefaultencoding(default_encoding)
 
import urllib
import urllib2,cookielib
 
class Twitter(db.Model):
    id=db.StringProperty()
 
def send_sina_msgs(username,password,msgs):
     
 
    cj = cookielib.CookieJar()
 
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
 
    urllib2.install_opener(opener)
 
 
 
 
 
    data = 'username=%s&password=%s&returntype=TEXT'%(username,password)
     
 
    request = urllib2.Request(
 
            url     = 'https://login.sina.com.cn/sso/login.php',
 
            data    = data)
 
 
 
    ret = opener.open(request)
 
    #content = ret.read()
 
 
    for msg in msgs:       
 
        data = 'content=%s'%(msg)
 
        request = urllib2.Request(
 
                url     = 'http://t.sina.com.cn/mblog/publish.php',
 
                headers = {'Referer':'http://t.sina.com.cn'},
 
                data    = data)
 
        ret = opener.open(request)
        #content = ret.read()
        #print content