1. Create font dict like this
- font = { 'fontname':'Tahoma', 'fontsize':16 }
2. When you want to change font for example in title use like this
- matplotlib.pylab.title(u'some text', **font)
2007-11-01
Install Webmin on Ubuntu
1. Add
2. sudo apt-get update
3. sudo apt-get install webmin
deb http://download.webmin.com/download/repository sarge contrib to /etc/apt/sources.list file. (make sure that you have uncommented all universe repository)2. sudo apt-get update
3. sudo apt-get install webmin
2007-10-25
How to integrate reCAPTCHA with Django
1. Sign up with reCAPTCHA for get public and private key.
2. Download reCAPTCHA for Python.
3. Copy captcha.py to location in your PYTHON_PATH so that you can import it. (e.g /usr/local/python2.5/Lib/site/packages)
4. Now your Django site can use reCAPTCHA.
in your view use reCAPTCHA like this.
import capcha
2. Download reCAPTCHA for Python.
3. Copy captcha.py to location in your PYTHON_PATH so that you can import it. (e.g /usr/local/python2.5/Lib/site/packages)
4. Now your Django site can use reCAPTCHA.
in your view use reCAPTCHA like this.
import capcha
def captcha_view(request):
captcha.displayhtml(RECAPTCHA_PUB_KEY) # use for display reCAPTCHA in template.
captcha_obj = captcha.submit( request.POST['recaptcha_challenge_field'],
captcha.displayhtml(RECAPTCHA_PUB_KEY) # use for display reCAPTCHA in template.
captcha_obj = captcha.submit( request.POST['recaptcha_challenge_field'],
request.POST['recaptcha_response_field'],
RECAPTCHA_PRIVATE_KEY,
request.META['REMOTE_ADDR'] ) # use for create captcha object for check result.
if captcha_obj.is_valid:
return success
else:
return error
RECAPTCHA_PRIVATE_KEY,
request.META['REMOTE_ADDR'] ) # use for create captcha object for check result.
if captcha_obj.is_valid:
return success
else:
return error
2007-10-06
How to use MySQL RegExp
You can use RegExp in MySQL like this.
- SELECT column_name FROM table_name WHERE column_name COLLATE utf8_bin REGEXP '^.* [a-zI]$'
Note: COLLATE is use for use case sensitive in SQL.
2007-09-29
Java jar file.
1. You can extract it and edit "manifest.mf" for edit class path.
2. You can use class inside jar file after extract it to include in one project (you may want to build project in one jar file).
2. You can use class inside jar file after extract it to include in one project (you may want to build project in one jar file).
2007-09-17
Using User info outside request in Django
1. Create "middleware" directory in project directory.
2. Create python file name "__init__.py and "threadlocals.py" in "middleware" directory.
3. in side "threadlocals.py" copy this code
2. Create python file name "__init__.py and "threadlocals.py" in "middleware" directory.
3. in side "threadlocals.py" copy this code
# threadlocals middleware
try:
from threading import local
except ImportError:
from django.utils._threading_local import local
_thread_locals = local()
def get_current_user():
return getattr(_thread_locals, 'user', None)
class ThreadLocals(object):
"""Middleware that gets various objects from the
request object and saves them in thread local storage."""
def process_request(self, request):
_thread_locals.user = getattr(request, 'user', None)
4. in "settings.py" add "project_name.middleware.threadlocals.ThreadLocals" to the MIDDLEWARE_CLASSES variable.
5. using like this
from project_name.middleware import threadlocals
user = threadlocals.get_current_user()
For more information >> Go to CookBookThreadlocalsAndUser
2007-09-05
Problem BIGINT in Jython
You must convert Python Long object to Java Long object before execute sql command.
Example: id = Long(data[0])
difficulty = utils.calc_sentence_diff(data[1])
cursor.execute(update_sql, (difficulty, id))
Example: id = Long(data[0])
difficulty = utils.calc_sentence_diff(data[1])
cursor.execute(update_sql, (difficulty, id))
Subscribe to:
Posts (Atom)