The scribble pad of doom

Month

May 2011

3 posts

Django - Setting up mod_wsgi with a relative rather than absolute path.

The configuration example both on the Django website and on the mod_wsgi site itself shows a configuration where you set up the wsgi script to refer to an absolute path. That seemed like unnecessary configuration to be done every time I’m going to setup a Django site. Instead I created one where the path names are relative to the file instead. In my case the file resides under /etc/myproject/mydjangoproject/apache/django.wsgi, so I ended up with this:

import os
import sys

""" For safetys sake we don't want to import just 'settings' so we add the
parent dir for safer a safer import."""

paths = [
    os.path.normpath( os.path.join( os.path.dirname(__file__), "../" ) ), 
    os.path.normpath( os.path.join( os.path.dirname(__file__), "../../" ) )
]

sys.path.extend( paths )

os.environ['DJANGO_SETTINGS_MODULE'] = 'deals.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
May 5, 20118 notes
#mod_wsgi #Django
Fixing the remote host identification has changed error.

Every once in a while I run into an issue where the remote host server identification has changed because of a re-install or other reasons. This comes with an error like:

$ ssh root@127.0.0.1
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
2c:af:ca:27:89:36:c0:03:c6:9f:43:74:1e:8e:3a:0d.
Please contact your system administrator.
Add correct host key in /home/kit/.ssh/known_hosts to get rid of this message.
Offending key in /home/kit/.ssh/known_hosts:44
RSA host key for 127.0.0.1 has changed and you have requested strict checking.
Host key verification failed.

In Ubuntu you can fix this by running ssh-keygen with the -R flag, removing the key causing the problem.

$ ssh-keygen -R 127.0.0.1
May 4, 20114 notes
#SSH #Security
How to change the title in IE7 and 8.

I had an issue where I was building fade transitions between pages for a client, so I needed to update the title. I was using jQuery for a bunch of things so naturally I would do something like:

$("title").text("Wooo. New title!");

This works great in Chrome, Firefox and IE9, but not in IE7 or 8. Thankfully IE9 has a debugger so it was easy switch the browser into compatibility mode and trace the exception.

Turns out in older versions of IE the title element is magical and wasn’t letting jQuery appendChild (I’m also a bit surprised they aren’t checking this condition.) Instead old DOM0 comes to the rescue, which lets you set a title like so:

document.title = "Woo. New title!";
May 3, 20113 notes
#Internet Explorer
Next page →
2011 2012
  • January 1
  • February
  • March 1
  • April
  • May
  • June 1
  • July
  • August
  • September 1
  • October
  • November
  • December
2010 2011 2012
  • January
  • February 1
  • March 2
  • April 3
  • May 3
  • June
  • July 2
  • August
  • September
  • October
  • November
  • December
2010 2011
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September 4
  • October 2
  • November 6
  • December 7