A quick reference guide for using the Python Programming language.
text = "Some string, with some stuff."
text2 = "Yet, another string here."
import os | |
import requests | |
import shutil | |
import time | |
from bs4 import BeautifulSoup | |
from selenium import webdriver | |
url = "http://www.chrisburkard.com/" | |
# web_r = requests.get(url) | |
# web_soup = BeautifulSoup(web_r.content, "lxml") |
#!/bin/zsh | |
# pyenv install for CentOS 6.5 x86_64 | |
yum install -y gcc gcc-c++ make git patch openssl-devel zlib-devel readline-devel sqlite-devel bzip2-devel | |
git clone git://github.com/yyuu/pyenv.git ~/.pyenv | |
export PATH="$HOME/.pyenv/bin:$PATH" | |
eval "$(pyenv init -)" |
# 0 is too far from ` ;) | |
set -g base-index 1 | |
# Automatically set window title | |
set-window-option -g automatic-rename on | |
set-option -g set-titles on | |
#set -g default-terminal screen-256color | |
set -g status-keys vi | |
set -g history-limit 10000 |
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# Python 3 and compatibility with Python 2 | |
from __future__ import unicode_literals, print_function | |
import os | |
import sys | |
import re | |
import logging |
import logging | |
import pytz | |
TIMEZONE = 'Asia/Hong_Kong' | |
def posix2local(timestamp, tz=pytz.timezone(TIMEZONE)): | |
"""Seconds since the epoch -> local time as an aware datetime object.""" | |
return datetime.fromtimestamp(timestamp, tz) | |
class Formatter(logging.Formatter): | |
def converter(self, timestamp): |
To add en_US.UTF-8
to the list of usable locales:
dpkg-reconfigure locales
sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen && locale-gen
locale-gen en_US.UTF-8
When hosting our web applications, we often have one public IP
address (i.e., an IP address visible to the outside world)
using which we want to host multiple web apps. For example, one
may wants to host three different web apps respectively for
example1.com
, example2.com
, and example1.com/images
on
the same machine using a single IP address.
How can we do that? Well, the good news is Internet browsers
import requests | |
import asyncio | |
import time | |
urls = [ | |
"www.baidu.com", | |
"www.sina.com", | |
"www.google.com.hk", | |
"www.sohu.com" |