Skip to content

Instantly share code, notes, and snippets.

@ftao
ftao / gist:833555
Created February 18, 2011 11:22 — forked from anonymous/gist:156623
"""
This fabric file makes setting up and deploying a django application much
easier, but it does make a few assumptions. Namely that you're using Git,
Apache and mod_wsgi and your using Debian or Ubuntu. Also you should have
Django installed on your local machine and SSH installed on both the local
machine and any servers you want to deploy to.
_note that I've used the name project_name throughout this example. Replace
this with whatever your project is called._
@ftao
ftao / cn_cut.py
Created April 6, 2011 13:18
根据新浪微博的规则截断 的 Python 代码片段
def cn_cut(status, length):
l = 0
end = len(status)
for i,c in enumerate(status):
if ord(c) <= 0xff:
l += 1
else:
l += 2
if l > length * 2:
end = i
@ftao
ftao / install_pytho27.sh
Created July 7, 2011 10:00
install python 2.7 on debian 6
#!/bin/sh
mkdir ~/down/
cd ~/down/
sudo apt-get install build-essential
wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tgz
tar -xzf Python-2.7.2.tgz
cd Python-2.7.2
sudo apt-get install libsqlite3-dev zlib1g-dev libncurses5-dev
sudo apt-get install libgdbm-dev libbz2-dev libreadline5-dev
sudo apt-get install libssl-dev libdb-dev
# python ep2011_video.py | tee ep2011_video.txt
import httplib2
import urlparse
from BeautifulSoup import BeautifulSoup
BASE_URL = 'http://ep2011.europython.eu/'
SCHEDULE_URL = 'http://ep2011.europython.eu/p3/schedule/ep2011/'
headers = {
@ftao
ftao / download_video.sh
Created March 18, 2012 03:27
download pycon2012 videos
#!/bin/sh
wget https://github.com/rg3/youtube-dl/zipball/master -O youtube-dl.zip
unzip youtube-dl.zip
cd rg3-youtube-dl-ceba827/
python youtube-dl --batch-file ../pycon2012_video_urls.txt
@ftao
ftao / install-fabric-on-windows.rst
Created March 29, 2012 06:33
install fabric on windows

If you need to install fabric on a windows machine without a compiler . This gist may help (We are assuming your are using python27 , search for corresponding packages if you are not )

Install dependences

Install some dependence using pre-compiled package

Win 32

@ftao
ftao / test.html
Created September 11, 2012 08:46
django floatformat problem
f: {{ f|floatformat:9}}
<br/>
f2: {{ f2|floatformat:9}}
<br/>
d: {{ d|floatformat:9}}
<br/>
s: {{ s|floatformat:9}}
@ftao
ftao / install_pub_key
Created December 29, 2012 07:58
Install ssh pub key to remote server in one line
cat path/to/pub.key | ssh your.remote.server 'sh -c "mkdir -p ~/.ssh/; cat - >>~/.ssh/authorized_keys"'
@ftao
ftao / index.html
Last active December 15, 2015 12:39
生成四则运算的题目
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
#result{
width:900px;
line-height:25px;
@ftao
ftao / gist:7982948
Created December 16, 2013 06:06
my public key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC23tUdjQbKxLj0xeNgseWTwFy08C7rtWRSgbA1sTy1HzL25D+4Bl5+t0VQxdHyll29io9rbBafiBg3epBHMY3ziPdXT6Bk6PNteA6bLQwB/eKaxdyW8s4ZE8wh+WiXv4FAhyBB3GlVm6S1mb69JFe3d87M3E5mNIpxjm/Q4XmPtTO20TTA90D3Uw1H5XnPCkrOQD3xgDlN0IvsHq817eLC8QtStR4FY9apmB1xU0f9uCcqPh57hV9qZgguvx18L3KdJXjldpbYYZBL5jkyhR26TQBzRov4z4aPk9g45ETNf8u/3EhGPwmeNCHwz9rm3Kp5uJPrPvB5SgBr6ch9p223 vagrant@preci