0%

16.04

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse

deb-src http://archive.canonical.com/ubuntu xenial partner
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
阅读全文 »

下载Pycharm

官方网站下载

安装java SDK(已安装可以忽略)

1
2
3
4
5
# 网络不是很好的这一步可能会慢一下
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default
阅读全文 »

Install

1
sudo pip install TermRecord

Usage

1
TermRecord -o /tmp/test.html

exit 停止录制

打开test.html查看

grinning all the time

😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄
阅读全文 »

.screenrc

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
# GNU Screen - main configuration file 
# All other .screenrc files will source this file to inherit settings.
# Author: Christian Wills - cwills.sys@gmail.com

# Allow bold colors - necessary for some reason
attrcolor b ".I"

# Tell screen how to set colors. AB = background, AF=foreground
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'

# Enables use of shift-PgUp and shift-PgDn
termcapinfo xterm|xterms|xs|rxvt ti@:te@

# Erase background with current bg color
defbce "on"

# Enable 256 color term
term xterm-256color

# Cache 30000 lines for scroll back
defscrollback 30000

hardstatus alwayslastline
# Very nice tabbed colored hardstatus line
hardstatus string '%{= Kd} %{= Kd}%-w%{= Kr}[%{= KW}%n %t%{= Kr}]%{= Kd}%+w %-= %{KG} %H%{KW}|%{KY}%101`%{KW}|%D %M %d %Y%{= Kc} %C%A%{-}'

# change command character from ctrl-a to ctrl-b (emacs users may want this)
#escape ^Bb

# Hide hardstatus: ctrl-a f
bind f eval "hardstatus ignore"
# Show hardstatus: ctrl-a F
bind F eval "hardstatus alwayslastline"
阅读全文 »

正常情况下

1
2
ssh test@example.com -p 30001
password:******

每次都要输入好麻烦。

使用密钥对(ssh-copy-id)

1
2
3
$ ssh-copy-id test@example.com -p 30001
password:******
$ ssh test@example.com -p 30001
阅读全文 »

grinning all the time

😄 😄 😄 😄 😄 😄 😄 😄 😄 😄 😄 😄 😄 😄 😄 😄 😄 😄 😄 😄 😄

Example

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
#!/usr/local/bin/python
#-*-coding:utf-8-*-

class A:
def __init__(self):
self.value = '1'
self._value = '2'
self.__value = '3'

def method(self):
try:
print self.value, self._value, self.__value
except Exception, error:
print str(error)

def _method(self):
try:
print self.value, self._value, self.__value
except Exception, error:
print str(error)

def __method(self):
try:
print self.value, self._value, self.__value
except Exception, error:
print str(error)


class B(A):
pass

if __name__ == '__main__':
a = A()
b = B()
try:
print a.value,a._value,a.__value
except Exception,error:
print str(error)

a.method()
a._method()
try:
a.__method()
except Exception, error:
print str(error)

print dir(b)
阅读全文 »

setup.py example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from setuptools import setup


setup(name='VMAgent',
version='0.1.7',
description='Openstack instance monitor agent',
url='http://github.com/zouyapeng/instance_monitor_agent',
author='Zouyapeng',
author_email='zyp19901009@163.com',
keywords='VMAgent OpenStack Instance Monitor',
license='Apache',

packages=['VMAgent'],
install_requires=[
'pymongo >= 3.2',
'oslo.config >= 1.4.0'
],
scripts=['bin/VMAgent', 'bin/VMAgent-stop'],
data_files=[('/etc/VMAgent/', ['etc/VMAgent.conf'])],
zip_safe=False
)
阅读全文 »

常用方法

1
2
for f, b in zip(foo, bar):
print(f, b)
  • 这种方法只能适用于foo和bar都不是很大的情况下,如果量比较大的使用zip将会产生大量的临时变量。
  • 不过在python3里面zip返回就是一个迭代器。

更好的方法(迭代)

1
2
3
4
5
6
import itertools

for f,b in itertools.izip(foo,bar):
print(f,b)
for f,b in itertools.izip_longest(foo,bar):
print(f,b)
阅读全文 »