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
| sudo aptitude -y install nginx | |
| cd /etc/nginx/sites-available | |
| sudo rm default | |
| sudo cat << EOF > jenkins | |
| upstream app_server { | |
| server 127.0.0.1:8080 fail_timeout=0; | |
| } | |
| server { | |
| listen 80; |
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
| apt-get install xvfb | |
| apt-get install firefox |
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
| deb http://mirrors.163.com/ubuntu/ trusty main multiverse restricted universe | |
| deb http://mirrors.163.com/ubuntu/ trusty-security main multiverse restricted universe | |
| deb http://mirrors.163.com/ubuntu/ trusty-updates main multiverse restricted universe | |
| deb http://mirrors.163.com/ubuntu/ trusty-proposed universe restricted multiverse main | |
| deb http://mirrors.163.com/ubuntu/ trusty-backports main multiverse restricted universe |
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
| # coding = utf-8 | |
| from pyvirtualdisplay import Display | |
| from selenium import webdriver | |
| from selenium.webdriver.common.keys import Keys | |
| display = Display(visible=0, size=(800, 600)) | |
| display.start() | |
| browser = webdriver.Firefox() |
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 | |
| import pika | |
| credentials = pika.PlainCredentials("guest", "guest") | |
| params = pika.ConnectionParameters(host="127.0.0.1", port=5672, | |
| virtual_host="/", credentials=credentials) | |
| connection = pika.BlockingConnection(params) | |
| channel = connection.channel() |
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
| # coding: utf-8 | |
| import string | |
| def checkio(text): | |
| return sorted( | |
| dict( | |
| [(w, text.count(w)) for w in "-".join(text.encode('utf-8').translate( | |
| None, string.punctuation | |
| ).translate( |
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
| #Your optional code here | |
| #You can import some modules or create additional functions | |
| checkio = lambda d: [x for x in d if d.count(x) > 1] | |
| #Some hints | |
| #You can use list.count(element) method for counting. | |
| #Create new list with non-unique elements | |
| #or remove elements from original list (but it's bad practice for many real cases) | |
| #Loop over original list |
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
| # coding: utf-8 | |
| import datetime | |
| def timediffer(dt1, dt2): | |
| """ | |
| 计算两个时间点之间的时间差: | |
| 当时间差大于1秒,切小于一分钟时,返回dt1和dt2之间相差的秒数 | |
| 当时间差大于一分钟,且小宇一小时时,返回dt1和dt2之间相差的分钟数 | |
| 当时间差大于一小时并且小于一天时,返回dt1和dt2之间相差的小时数 |
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
| # coding: utf-8 | |
| import urllib2 | |
| import re | |
| import argparse | |
| from BeautifulSoup import BeautifulSoup | |
| __author__ = 'zheng' | |
| class Tumblr(object): |
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
| import ctypes | |
| import unittest | |
| import time | |
| import os.path | |
| from sdl2 import * | |
| from sdl2.sdlmixer import * | |
| class MixerTests(unittest.TestCase): |