This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import twitter | |
import pydot | |
api = twitter.Api(username='usename',password='password') | |
g=pydot.Dot(graph_type='graph',font='verdana',overlap='false') | |
[g.add_edge(pydot.Edge('username',i.name)) for i in api.GetFriends()] | |
g.write_svg('socialnet.svg',prog='neato') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/awk -f | |
#will fail with several case, still investigating | |
BEGIN{ | |
print "begin"; | |
} | |
{ | |
count=0; | |
for(f=1;f<=NF;f++){ | |
if($f==""){ | |
if(count==0){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Don't Do This, it will cause a runtime error, | |
d = {"a":1,"b":2,"c":3} | |
for i in d: | |
del d[i] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from haystack.forms import SearchForm | |
from django import forms | |
from haystack.query import SearchQuerySet | |
SEARCH_FILTER =[('all','all'),('name','name'),('business','sector'),('address','address')] | |
class FilterSearchForm(SearchForm): | |
def __init__(self,*args,**kwargs): | |
super(FilterSearchForm,self).__init__(*args,**kwargs) | |
self.fields['keys'] = forms.ChoiceField(choices=SEARCH_FILTER,required=True, | |
label='search in') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf.urls.defaults import * | |
from views import * | |
from haystack.views import SearchView | |
from haystack.forms import SearchForm | |
from forms import FilterSearchForm | |
urlpatterns = patterns('', | |
(r'^$',SearchView(form_class=FilterSearchForm, | |
load_all=False)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
import urllib2 | |
# here i use json, but the api also support xml | |
import json | |
# for url parameter, just to make it look nice | |
param = urllib.urlencode({'api':'your api key','format':'json'}) | |
# get population of malaysia | |
url = 'http://open.worldbank.org/countries/my/indicators/SP.POP.TOTL' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. | |
DATABASE_NAME = 'citizenwatch.db' # Or path to database file if using sqlite3. | |
DATABASE_USER = '' # Not used with sqlite3. | |
DATABASE_PASSWORD = '' # Not used with sqlite3. | |
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. | |
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from os.path import abspath,dirname | |
THIS_DIR = dirname(__file__) | |
TEMPLATE_DIRS = ( | |
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". | |
# Always use forward slashes, even on Windows. | |
# Don't forget to use absolute paths, not relative paths. | |
abspath(THIS_DIR+"/../template") | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
# Create your models here. | |
ISSUE_TYPE = ( | |
('Broken Streetlight','Broken Streetlight'), | |
('Pipe Leakage','Pipe Leakage'), | |
('Pot Hole','Pot Hole'), | |
('alien infestation','alien infestation'), | |
('stray dogs','stray dogs'), | |
('runaway velociraptor','runaways velociraptor') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSTALLED_APPS = ( | |
'django.contrib.auth', | |
'django.contrib.contenttypes', | |
'django.contrib.sessions', | |
'django.contrib.sites', | |
'django.contrib.admin', | |
'issue' | |
) |
OlderNewer