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
# 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}}
--- strongswan-5.2.1/debian/rules 2014-10-27 14:36:53.659872404 +0300
+++ strongswan-5.2.1/debian/rules 2014-10-27 15:10:07.003054721 +0300
@@ -15,7 +15,7 @@
--enable-ha \
--enable-led --enable-gcrypt \
--enable-test-vectors \
- --enable-xauth-eap --enable-xauth-pam \
+ --enable-xauth-eap --enable-xauth-pam --enable-xauth-noauth \
--enable-cmd \
--enable-certexpire \
@ftao
ftao / strongswan5.2.1-openvz.patch
Created December 9, 2015 16:09
strongswan debian package openvz patch
--- rules.origin 2015-12-09 06:13:45.756687865 -0500
+++ strongswan-5.2.1/debian/rules 2015-12-09 09:43:52.992183631 -0500
@@ -50,7 +50,7 @@
--with-capabilities=libcap \
--enable-farp \
--enable-dhcp \
- --enable-af-alg
+ --enable-kernel-libipsec
endif
@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 / make_nghttp2_deb.sh
Created December 14, 2015 11:19
make_nghttp2_deb.sh
#/bin/sh
FAKEROOT=/home/vagrant/workspace/nghttpx/dist
PYTHONPATH=$FAKEROOT/usr/local/lib/python2.7/site-packages
mkdir -p $PYTHONPATH
PYTHONPATH=$PYTHONPATH make DESTDIR=$FAKEROOT install
fpm -s dir -t deb -n nghttp2 -v 1.5.0 -C $FAKEROOT -p nghttp2_VERSION_ARCH.deb \
-d "libssl1.0.0 >= 1.0.1" \
-d "libev4 >= 4.15" \
-d "zlib1g >= 1.2.3" \