Archive for the ‘Python’ Category

Google Python Class Day 2-4

Monday, August 9th, 2010

Google Python Class Day 2-4

下载地址:
http://www.douhua.im/downloads/google.python.class/Google.Python.Class.Day.2.Part.4.flv

Google Python Class Day 2-3

Monday, August 9th, 2010

Google Python Class Day 2-3

下载地址:
http://www.douhua.im/downloads/google.python.class/Google.Python.Class.Day.2.Part.3.flv

Google Python Class Day 2-2

Monday, August 9th, 2010

Google Python Class Day 2-2

下载地址:
http://www.douhua.im/downloads/google.python.class/Google.Python.Class.Day.2.Part.2.flv

Google Python Class Day 2-1

Monday, August 9th, 2010

Google Python Class Day 2-1

下载地址:
http://www.douhua.im/downloads/google.python.class/Google.Python.Class.Day.2.Part.1.flv

Google Python Class Day 1-3

Monday, August 9th, 2010

Google Python Class Day 1-3

下载地址:
http://www.douhua.im/downloads/google.python.class/Google.Python.Class.Day.1.Part.3.flv

Google Python Class Day 1-2

Monday, August 9th, 2010

Google Python Class Day 1-2:

下载地址:http://www.douhua.im/downloads/google.python.class/Google.Python.Class.Day.1.Part.2.flv

Google Python Class Day 1-1

Monday, August 9th, 2010

Google Python Class Day 1-1

下载地址:
http://www.douhua.im/downloads/google.python.class/Google.Python.Class.Day.1.Part.1.flv

Gentoo下Nginx使用GeoIP模块为Django提供GEO信息

Tuesday, July 27th, 2010

首先要在Gentoo下安装编译Nginx,需要加入GeoIP模块,请参考另一篇文章《Gentoo 安装编译Nginx》。在安装的过程中应该是会自动安装dev-libs/geoip这个包,如果没有的话使用emerge安装:

emerge -avt dev-libs/geoip

下载MaxMind的GEO数据,解压缩放在/etc/nginx目录下:

#Get the free database of geo_city
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoLiteCity.dat.gz
mv GeoLiteCity.dat /etc/nginx
#Get the free database of geo_coundty
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gunzip GeoIP.dat.gz
mv GeoIP.dat /etc/nginx

编辑/etc/nginx/nginx.con文件,加入GeoIP的支持:

http {
    geoip_country  /etc/nginx/GeoIP.dat;
    geoip_city     /etc/nginx/GeoLiteCity.dat;
}

编辑django的fastcgi_param:

fastcgi_param GEOIP_COUNTRY_CODE $geoip_city_country_code;
fastcgi_param GEOIP_COUNTRY_CODE3 $geoip_country_code3;
fastcgi_param GEOIP_COUNTRY_NAME $geoip_country_name;
fastcgi_param GEOIP_CITY_COUNTRY_CODE $geoip_city_country_code;
fastcgi_param GEOIP_CITY_COUNTRY_CODE3 $geoip_city_country_code3;
fastcgi_param GEOIP_CITY_COUNTRY_NAME $geoip_city_country_name;
fastcgi_param GEOIP_REGION $geoip_region;
fastcgi_param GEOIP_CITY $geoip_city;
fastcgi_param GEOIP_POSTAL_CODE $geoip_postal_code;
fastcgi_param GEOIP_CITY_CONTINENT_CODE $geoip_city_continent_code;
fastcgi_param GEOIP_LAT $geoip_latitude;
fastcgi_param GEOIP_LNG $geoip_longitude;

在Django的使用方法:

def index(request):
    return HttpResponse(request.META['GEOIP_COUNTRY_CODE'])

Google Python Class

Tuesday, March 23rd, 2010

Google Python Class是Google组织的一系列学习Python的教程,包括很多视频和编程的练习,学习和使用Python的人一定不要错过。

PyAMF的Subversion 地址更换

Thursday, March 4th, 2010

在更新PyAMF的时候发现总是出现bug:

svn: Target path does not exist

到pyamf.org上去发现首页改版了,Subverion的地址也改了,新地址是:

svn co http://svn.pyamf.org/trunk pyamf