2010年8月27日金曜日

django filter登録

スタンドアロンでdjangoのテンプレートを使うときにフィルタを設定する方法。
register = template.Library()

@register.filter
def texEscape(value):
   return value.replace("&", "\\&")

django.template.builtins.append(register)
組み込みとして登録してしまうアラワザ。これでいいのか?

2010年8月13日金曜日

google map apiにurlアクセス

簡単だー。
 curl "http://maps.google.com/maps/api/directions/json?origin=越谷,&destination=草加,埼玉&sensor=false"

2010年8月12日木曜日

mac os で vlan

Mac OS X でのvlan 設定。linuxとちがって、vconfig はなくifconfigで直接やるようだ。
# ifconfig vlan0 create
# ifconfig vlan0 vlan TAG vlandev IFNAME
# ifconfig vlan0 ADDR netmask MASK