Django: "AssertionError - No exception supplied" on "assert salt and '$' not in salt"

After upgrading from Django 1.2.7 to Django 1.4.3, we had a problem where users were unable to log in.

This was due to an upgrade in the crypto algorithms used to store passwords.

When a user attempts to log in, the authentication process checks the "password" field in the User table.

The password field contains 3 components: algorithm$salt$hash

The algorithm is used to determine which crypto to use. The salt is a randomly generated salt upon setting of password, which in this case is an empty string "".

For now, you can temporarily fix this error by adding a new file "working_unsalted\".

from django.contrib.auth.hashers import UnsaltedMD5PasswordHasher
from django.utils.crypto import constant_time_compare

class WorkingUnsaltedMD5PasswordHasher(UnsaltedMD5PasswordHasher):
The default UnsaltedMD5PasswordHasher uses constant_time_compare(), but passes it the wrong values.
algorithm = "working_unsalted_md5"

def verify(self, password, encoded):
encoded_2 = self.encode(password, '')
return constant_time_compare(encoded[22:], encoded_2)

In your settings file, be sure to define the new hasher.



Lastly, change the algorithm in the database by changing auth_user.password values from "md5$..." to "working_unsalted_md5$...". When the user tries to log in, the new hasher will take effect.

I've made a ticket and pull request for this issue, so hopefully it'll be fixed in Django 1.4.4.

For now, enjoy your copy-pasta fix.

Photoshop CS5/CS6: How to center align text or image

This didn't really come as intuitive to me at first, but once I figured it out I realised it made a lot more sense than "center to board".

When you select the "Move" tool, you've got the options for alignment greyed out in the tool options.


To enable the alignment option buttons, you must first use the Marquee tool to select the region it should align to.

Once you've got a region defined, you can now align the layer according to the selected region.


Got the sauce? Let the photochopping commence!


Android: Override the default WebView error page with your own.

I've finally had some time to update my Diablo II Runewords app a little, and was thinking of ways to hide my URL from the WebView error.
Surprisingly, it was very easy to do that. Just a quick look through the WebView/WebViewClient docs and you've quickly got your answer.
Set up your WebView with a new WebViewClient by calling:
webView.setWebViewClient(new NoErrorWebViewClient());
And here is the subclassed WebViewClient which handles errors:
class NoErrorWebViewClient extends WebViewClient {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Log.e(String.valueOf(errorCode), description);

// API level 5: WebViewClient.ERROR_HOST_LOOKUP
if (errorCode == -2) {
String summary = "<html><body style='background: black;'><p style='color: red;'>Unable to load information. Please check if your network connection is working properly or try again later.</p></body></html>"; view.loadData(summary, "text/html", null);

// Default behaviour
super.onReceivedError(view, errorCode, description, failingUrl);

And the result is...
Just a reminder that within the error handler you can also load a local resource/asset rather than building the HTML string.
Now, go back to doing more magic!

Update 24/01/2013: Moved super.onReceivedError() to the end of the call to prevent flickering.

Android: Make your TextView look like a hyperlink

There's no shortage of posts regarding Linkify and automatically making part of the TextView clickable. Just search for "android textview hyperlink" and you'll get a fair idea.

TextView tvMessage = (TextView) findViewById(;

And the result would be something like...


But when you don't want the text to include http:// is when you'll have to look elsewhere.


To get this, it's really simple. You can even make a quick TextView subclass out of it.

* Sets a hyperlink style to the textview.
public static void makeTextViewHyperlink(TextView tv) {
SpannableStringBuilder ssb = new SpannableStringBuilder();
ssb.setSpan(new URLSpan("#"), 0, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
tv.setText(ssb, TextView.BufferType.SPANNABLE);

And to set up the click handler, just use an ordinary OnClickListener so you can handle the click any way you want.

TextView tv = (TextView) findViewById(;
tv.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), RecipeActivity.class);

Done, like a BOSS!

While you're at it, check out my Diablo II Runewords app!


uTorrent: Enabling or upgrading webUI

uTorrent has been a great program from the get-go, but I feel they were a little lacking when it came to the Web UI remote control feature.

This lets you access your uTorrent interface from your browser, on any computer and works pretty well!

Only problem is activating it.

Scroll past the blurb & license, then click on the link below "Download". Save it as "".

Most likely the zip file was omitted from the uTorrent download as most people won't use it or it would increase their filesize, something the uTorrent guys take with great pride.

  • Second step is to open up Windows Explorer and move into %APPDATA%/uTorrent/
  • Now open up uTorrent and click on: Preferences > Web UI


  • Enable Web UI
  • Set a username and password
  • Set your port and save the settings.

Initially I left it on the default port, but didn't actually know what that was so I had to give it a specific number.

Once you're ready, open up your browser and type in http://localhost:8080/gui/ (assuming your port is 8080)

Now make sure you've got that /gui/ part, it's important! Because if you leave it out, you'll only get a page saying "invalid request".

Other than that, you should see a popup asking for your username/password. Once you enter it in you should see something very familiar.

Gangnam cowboy, elevator thrusting! Familiar enough?


XBMC: Automatically play the next episode/video

I couldn't believe something this simple took so long to implement.

For some time I thought my XBMC configuration was broken, but it was actually "working as intended". The wife approval factor rating really drops when it comes to little things like this.


Fortunately, a clever chap called ScudLee made a patch for it and it's been integrated into XBMC v12 (Frodo).

At time of writing, v12 is current on RC3, so grab it and check it out!

It's in:

  • Settings
  • Videos
  • Playback
  • Play next video automatically (tick it)

Definitely taking the opportunity to upgrade to Frodo when it's finally finished.


Command Prompt/DOS: How to batch rename files

Surprisingly, the RENAME (aka REN) command in DOS supports wildcards.

If you had a stack of files called:

  • DSC_0001.JPG
  • DSC_0002.JPG
  • DSC_0003.JPG
  • DSC_0004.JPG

You could call:

REN DSC_*.JPG Photo_*.jpg

And it'll replace the text accordingly like:

  • Photo_0001.jpg
  • Photo_0002.jpg
  • Photo_0003.jpg
  • Photo_0004.jpg

What's even more surprising is that this solution came from Yahoo answers!

Hit me outta nowhere!


Python: Resize an image and keep aspect ratio

A handy little snippet that saves you a lot of work is the ability to quickly generate thumbnails from a source image.

from PIL import Image

filename = "/tmp/thumbnail_file.jpg"

# Read the image, resize and save as a temporary file
image =

image.thumbnail([max_width, max_height], Image.ANTIALIAS), "JPEG")

Image.ANTIALIAS option is the best for sizing down. See the docs for other resize filters.

One thing to keep in mind is that Image.resize() actually resizes the whole image to fit the given size exactly, without preserving the aspect ratio.

Proceed to bust a move!


Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog