This file contains hidden or 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
| function demo(num){ | |
| if(num<=1){ | |
| return 1; | |
| } | |
| return num*demo(num-1); | |
| } | |
| alert(demo(5)) //stdout:120 | |
This file contains hidden or 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 threading | |
| import time | |
| class Mythreading(threading.Thread): | |
| def __init__(self): | |
| threading.Thread.__init__(self) | |
| #self.daemon=True |
This file contains hidden or 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 -*- | |
| #Function: python yield demo | |
| Queue=[1, 2, 3, 4, 5, 6] | |
| def foo(regex): | |
| print "start..." | |
| while True: |
This file contains hidden or 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
| I. open a tar file | |
| import tarfile | |
| import glob | |
| t = tarfile.open("foo.tar", 'w') | |
| t.add("README") | |
| for pyfile in glob.glob('*.py'): | |
| t.add(pyfile) | |
| t.close() | |
| II. |
This file contains hidden or 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
| I.Example of how to read a compressed file: | |
| import gzip | |
| f = gzip.open('file.tar.gz', 'rb') | |
| file_content = f.read() | |
| f.close() | |
| II.Example of how to create a compressed GZIP file: | |
| import gzip |
This file contains hidden or 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
| I.pickle exmaple | |
| """object save to file.""" | |
| import pickle | |
| obj = Someobject() | |
| f = open(filename, 'wb') | |
| pickle.dump(obj, f) | |
| f.close() |
This file contains hidden or 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
| 1.rpm install puppetlabs-release | |
| rpm -ivh http://yum.puppetlabs.com/el/6.4/products/i386/puppetlabs-release-6-6.noarch.rpm | |
| sudo yum clean all | |
| 2.Install puppet-server and puppet-agent | |
| sudo yum install puppet-server puppet |
This file contains hidden or 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
| 1. yum install inxi for Centos | |
| yum install inxi | |
| 2.View help information | |
| inxi --help |
This file contains hidden or 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
| I. change yum source | |
| vim /etc/yum.repos.d/nginx.repo | |
| [nginx] | |
| name=nginx repo | |
| baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ | |
| gpgcheck=0 | |
| enabled=1 | |
| II. yum install nginx | |
| yum install nginx -y |
This file contains hidden or 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 os | |
| impost sys | |
| def walk(path): | |
| isdir, isfile, join = os.paht.isdir, os.path.isfile, os.path.join | |
| lsdir = os.listdir(path) | |
| dirs = [i for i in lsdir if isdir(join(path, i))] |