Skip to content

Instantly share code, notes, and snippets.

#!/Users/yanxu/jython2.2.1/jython
# encoding: utf-8
"""
poi.py
Created by yanxu on 2008-04-09.
Copyright (c) 2008 sina. All rights reserved.
"""
from org.apache.poi.hssf.usermodel import *
@qingfeng
qingfeng / gist:3222
Created July 30, 2008 04:01
Django filter
'''
Django filter
/ 2026M 11%;/data0 107775M 0%;/tmp 2026M 3%;/usr 12186M 5%;/var 10154M 2%;/data1 138236M 0%;/data2 138236M 0%;/data3 138236M 0%
->
/ 2026M 11%
'''
@register.filte
def formatRootFSInfo(text):
if text==None:return ''
diskinfo=text.split(';')
@qingfeng
qingfeng / randomColors.java
Created July 30, 2008 05:12
My Processing code
float randShift=.2;
int quadW=15;
int quadH = quadW;
float[] q={-quadW/2,-quadH/2,quadW,quadH};
void setup() {
size(900,600);
background(255);
smooth();
noStroke();
@qingfeng
qingfeng / README
Created July 30, 2008 08:10
ROR link_to_remote clone. simple django ajax
django link_to_remote document:
ajax+param Example:
{% ajax %}
link_to_remote
url => /dashboard/serverstatus/
update => #server_status_body
data => maxcount=10
{% endajax %}
1.domid的部分可以写一个div的id
2.setInterval中的时间单位是毫秒
@qingfeng
qingfeng / admin.py
Created July 31, 2008 07:34
Django admin m2m management
from django.contrib import admin
from app1.models import *
class MembershipInline(admin.TabularInline):
model = Membership
extra = 1
class PersonAdmin(admin.ModelAdmin):
inlines = (MembershipInline,)
class GroupAdmin(admin.ModelAdmin):
inlines = (MembershipInline,)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
<title>China Python User Group</title>
<meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
<style type="text/css" media="screen">@import "http://iui.googlecode.com/svn/tags/REL-current/iui/iui.css";</style>
<script type="application/x-javascript" src="http://iui.googlecode.com/svn/tags/REL-current/iui/iui.js"></script>
@qingfeng
qingfeng / logtodb.py
Created August 4, 2008 06:07
Python Class
#!/usr/local/bin/python
from __future__ import with_statement
import sys
import MySQLdb
class Log2DB(object):
"""hadoop log result into database"""
def __init__(self):
self.DB_USER='root'
self.DB_PASS=''
@qingfeng
qingfeng / barmusic.py
Created August 4, 2008 06:58
获取贴吧和音乐用户的差异
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import re
import pickle
import urllib2
def getStar(url,regx):
'''根据url获取明星'''
@qingfeng
qingfeng / obmalloc.c
Created August 5, 2008 15:02
Python memory management
/*
* Python的内存分为
* Block
* Pool
* arena
* 内存池几个部分
*/
#undef PyObject_Malloc
void *