Skip to content

Instantly share code, notes, and snippets.

View hdknr's full-sized avatar

hdknr hdknr

View GitHub Profile
@hdknr
hdknr / x
Created September 7, 2009 02:32
CmdUtils.makeSearchCommand({
name: "t",
url: "http://trac.hdknr.com/wiki/{QUERY}",
icon: "/favicon.ico",
description: "Wiki Entiy for trac.hdknr.com",
});
In .vimrc , specify g:github_user and g:github_token like this:
:let g:github_user="hdknr"
:let g:github_token="_your_token_"
>>> import virtualenv
>>> text=virtualenv.create_bootstrap_script('')
>>> len(text)
54329
>>> lines=text.split('\n')
>>> lines[0]
'#!/usr/bin/env python'
>>> lines[1]
'## WARNING: This file is generated'
$ python manage.py shell
Python 2.5.2 (r252:60911, Jan 4 2009, 17:40:26)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.db import connection
>>> connection.cursor()
<django.db.backends.util.CursorDebugWrapper object at 0x9e09b6c>
>>> type(connection.connection)
<class 'MySQLdb.connections.Connection'>
def _cursor(self, settings):
if not self._valid_connection():
kwargs = {
'conv': django_conversions,
'charset': 'utf8',
'use_unicode': True,
}
if settings.DATABASE_USER:
kwargs['user'] = settings.DATABASE_USER
if settings.DATABASE_NAME:
def _execSQL(self, sql_name, *args):
sql = self._getSQL(sql_name)
# Kludge because we have reports of postgresql not quoting
# arguments if they are passed in as unicode instead of str.
# Currently the strings in our tables just have ascii in them,
# so this ought to be safe.
def unicode_to_str(arg):
if isinstance(arg, unicode):
return str(arg)
else:
>>> type(con)
<class 'MySQLdb.connections.Connection'>
>>> c=con.cursor()
>>> c
<MySQLdb.cursors.Cursor object at 0xa1a2c6c>
>>> c.execute('show tables',None)
19L
(('auth_group',), ('auth_group_permissions',),....
>>> c.execute('select username from auth_user where username like %s',('hdknr'))
1L
Python 2.5.2 (r252:60911, Jan 4 2009, 17:40:26)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>> type(MySQLdb.connect)
<type 'function'>
>>> c=MySQLdb.connect(**{'user':'root','passwd':'hdknr','host':'localhost','db':'djopenid'})
>>> type(c)
<class 'MySQLdb.connections.Connection'>
def handleRequest(self, request):
""" openid.server.server.Server.handleRequest()"""
handler = getattr(self, 'openid_' + request.mode, None)
if handler is not None:
return handler(request)
else:
raise NotImplementedError(
"%s has no handler for a request of mode %r." %
(self, request.mode))
def get_object(self, action, params, cls, path='/', parent=None):
if not parent:
parent = self
response = self.make_request(action, params, path)
body = response.read()
boto.log.debug(body)
if response.status == 200:
obj = cls(parent)
h = handler.XmlHandler(obj, parent)
xml.sax.parseString(body, h)