Skip to content

Instantly share code, notes, and snippets.

View venkatesh22's full-sized avatar

Venkatesh venkatesh22

View GitHub Profile
@venkatesh22
venkatesh22 / githookwithdjango.md
Last active August 12, 2019 08:21
Git pre-commit hook with django for checking debugging lines and run tests and jenkins

Keep your hook script in source control

Commit your hook script (say pre-commit.sh) at the root of your project and include the installation instructions in your README/documentation to encourage all developers use it.

Installation is nothing more than:

ln -s ../../pre-commit.sh .git/hooks/pre-commit

chmod a+x .git/hooks/pre-commit

@venkatesh22
venkatesh22 / gist:5973400
Created July 11, 2013 07:48
(1267, "Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='")
$ manage.py shell
>>> from django.db import connection
>>> cursor = connection.cursor()
>>> cursor.execute('SHOW TABLES')
>>> results=[]
>>> for row in cursor.fetchall(): results.append(row)
>>> for row in results: cursor.execute('ALTER TABLE %s CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;' % (row[0]))
'''
templatetags module
'''
from django import template
register = template.Library()
@register.simple_tag
def go_to_url(url):
return "window.location='" + url +"'; return false;"
@venkatesh22
venkatesh22 / gist:6145572
Created August 3, 2013 07:23
OperationalError (1267, "Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='")
$ manage.py shell
>>> from django.db import connection
>>> cursor = connection.cursor()
>>> cursor.execute('SHOW TABLES')
>>> results=[]
>>> for row in cursor.fetchall(): results.append(row)
>>> for row in results: cursor.execute('ALTER TABLE %s CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;' % (row[0]))
@venkatesh22
venkatesh22 / gist:6145594
Created August 3, 2013 07:29
fix for UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 1451: ordinal not in range(128) in httplib python2.7 lib
msg += message_body.encode('utf-8')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 1451: ordinal not in range(128)
httplib python2.7 library
r = urllib2.Request(str(url), body, headers)
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
},
'null': {
'level':'DEBUG',
#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.

Google+ Domains API - Quick Start

introduction

Google+ Domains API are meant to interact with your G+ accounts in the domain. With these APIs you can manage circles, read and write posts, shares, and comments etc.. more informations here

This tutorial is for creating an application that uses the Domains API, running on Google App Engine with python.

create GAE (Google App Engine) app

from threading import Timer
def debounce(wait):
""" Decorator that will postpone a functions
execution until after wait seconds
have elapsed since the last time it was invoked. """
def decorator(fn):
def debounced(*args, **kwargs):
def call_it():