Skip to content

Instantly share code, notes, and snippets.

View Gunio's full-sized avatar

gundotio Gunio

View GitHub Profile
Gunio / gist:1536565
Created December 29, 2011 22:52
Siri CalDAV
<VirtualHost *:80>
WSGIScriptAlias /cal /srv/http/caldav-to-gtasks/
<Directory /srv/http/caldav-to-gtasks/>
AuthType Basic
AuthName "WSGI"
Gunio / Simple Django URLs
Created October 18, 2011 20:02
Simple Django URLs
from django.conf.urls.defaults import patterns, include, url
urlpatterns = patterns('',
url(r'^(?P<input>[^/]+)$', 'UppercaseMaker.upper.views.home'),
Gunio / Simple Django Template
Created October 18, 2011 19:30
Simple Django Template
Your output is: {{output}}.
Gunio / Django Relative Template Directory
Created October 18, 2011 19:25
Django Relative Template Directory
import os
os.path.join(os.path.dirname(__file__), 'templates'),
Gunio / Simple Django View Response
Created October 18, 2011 19:11
Simple Django View Response
from django.shortcuts import render_to_response
def home(request, input="No input supplied"):
output = input.upper()
return render_to_response('home.html', {'output': output})
Gunio / gist:1296354
Created October 18, 2011 19:02
Django Installed Apps
# Uncomment the next line to enable the admin:
# 'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
Gunio / Parsing HTML in Python
Created October 18, 2011 18:33
Parsing HTML in Python with LXML
import requests
import lxml
from lxml import html
r = requests.get('')
tree = lxml.html.fromstring(r.content)
elements = tree.get_element_by_id('frontsubtext')
for el in elements:
print el.text_content()
Gunio / Parsing JSON in python
Created October 18, 2011 05:25
Parsing JSON in python
import requests
import simplejson
r = requests.get('')
c = r.content
j = simplejson.loads(c)
for item in j:
print item['repository']['name']
Gunio / POSTing using Python Requests
Created October 18, 2011 05:14
POSTing using Python Requests
import requests
url = ''
data={'title': 'RoboCop', 'description': 'The best movie ever.'}
r =, data=data)
print r
Gunio / GET using Requests And Authentication
Created October 18, 2011 04:52
GET using Requests And Authentication
import requests
r = requests.get('', auth=('YOURUSERNAME', 'PASSWORD'))
print r