Skip to content

Instantly share code, notes, and snippets.

View ustun's full-sized avatar

Ustun Ozgur ustun

View GitHub Profile
In [1]: u = User(username="foo")
In [2]: u.save()
In [3]: from myapp.models import *
In [4]: my_form = StudentProfileForm({"name": "Foo", "website": "http://foo.com"})
In [5]: my_form.is
my_form.is_bound my_form.is_multipart my_form.is_valid
function sendIdToPopupOpener(win, chosenId) {
var name = windowname_to_id(win.name);
var elem = window.opener.document.getElementById(name);
if (elem.className.indexOf('vManyToManyRawIdAdminField') != -1 && elem.value) {
elem.value += ',' + chosenId;
} else {
window.opener.document.getElementById(name).value = chosenId;
}
}
@ustun
ustun / gist:8805028
Created February 4, 2014 14:53
Upgrade Postgres.app's databases
export PGDATAOLD="/Users/ustun/Library/Application Support/Postgres/var"
export PGDATANEW="/Users/ustun/Library/Application Support/Postgres93/var"
export PGBINOLD="/Applications/Postgres.app/Contents/MacOS/bin"
export PGBINNEW="/Applications/Postgres93.app/Contents/MacOS/bin"
pg_upgrade
javascript:(function(){readStyle='style-novel';readSize='size-large';readMargin='margin-medium';_readability_script=document.createElement('SCRIPT');_readability_script.type='text/javascript';_readability_script.src='http://lab.arc90.com/experiments/readability/js/readability.js?x='+(Math.random());document.getElementsByTagName('head')[0].appendChild(_readability_script);_readability_css=document.createElement('LINK');_readability_css.rel='stylesheet';_readability_css.href='http://lab.arc90.com/experiments/readability/css/readability.css';_readability_css.type='text/css';_readability_css.media='all';document.getElementsByTagName('head')[0].appendChild(_readability_css);_readability_print_css=document.createElement('LINK');_readability_print_css.rel='stylesheet';_readability_print_css.href='http://lab.arc90.com/experiments/readability/css/readability-print.css';_readability_print_css.media='print';_readability_print_css.type='text/css';document.getElementsByTagName('head')[0].appendChild(_readability_print_css
@ustun
ustun / last changed date of a url to datetime object
Created March 15, 2010 15:55
How many days ago a web site was updated
#!/usr/bin/env python
import urllib
from datetime import datetime
response = urllib.urlopen("http://www.bilkent.edu.tr/~kafemud/monu_tr.html")
headers = response.info()
lastchangedDate = datetime.strptime(headers["date"],"%a, %d %b %Y %H:%M:%S %Z")
today = datetime.today()
dayDifference = abs((today-lastchangedDate).days)
if dayDifference > 2:
(global-set-key (kbd "S-M-<right>") 'other-frame)
(global-set-key (kbd "S-M-<left>") 'other-frame)