Monthly Archives: December 2010

How to open Control Panel as Administrator with runas

  1. Open a cmd window as Administrator
    runas /u:administrator cmd
  2. Keep a cmd window running as your non-Administrator user too
  3. Open task manager (Ctrl-Esc or with taskmgr command) and kill explorer.exe
  4. Run the command “control” in the Administrator cmd window
  5. Close task manager you opened previously, and run taskmgr in the Administrator cmd window (to open it as Administrator user)
  6. Kill explorer.exe (because it is still running as Administrator)
  7. Run explorer in the non-Administrator cmd window

How to set up Japanese input in Ubuntu

The authoritative documentation is here:
https://help.ubuntu.com/community/JapaneseInput

A couple of steps are missing though, this is how I did it in Ubuntu 10.10.

  1. sudo apt-get install anthy ibus-anthy
  2. Go to System / Preferences / Keyboard Input Methods
    1. It asked me twice if I want to start the ibus service. Probably some bug, just say yes.
  3. Go to Input Method tab
  4. Select Anthy from the Select an input method drop-down menu

After this you should be able to switch between Japanese/English input with Control + Space.

To make this permanent, you need to set one more thing.

  1. Go to System / Administration / Language Support
  2. Set Keyboard input method system to ibus

Django AuthenticationForm gotchas

If you initialize as AuthentictionForm(request.POST) like probably many of your forms, no validation will take place at all.

In my case I needed to initialize as AuthenticationForm(None, request.POST)

The gotcha here is that the first argument must be a request object if you want to validate cookie support in the browser (that is, check if the user has cookies enabled in the browser). I didn’t want cookie validation, but I did want field and user account validation.

Another gotcha was handling the ‘invalid username-password error’. Field validation errors are linked to a field, so a missing username error is stored in form.username.errors. But the invalid username-password error is not specific to one field. You can find these errors in form.non_field_errors, but this is hard to find in the documentation. Also, the error messages are already formatted. I don’t know why they did it that way. Instead of a list of error messages, they made this one a <ul> formatted html.