How to reset lost QNAP iscsi CHAP password

I wanted to change the password for one of my QNAP ISCSI luns, but there really is no way to do that with the current software.

Fortunately you can recover your password by using ssh to login to your qnap, and look in /etc/config/iscsi_trgt.conf. Search for CHAPPasswd. The CHAP user is stored there as well, in case you forgot that too.

Posted in QNAP | Comments Off on How to reset lost QNAP iscsi CHAP password

ImportError: cannot import name sanitizer when trying to run django

I hope this saves you a couple hours of headaches that I experienced recently.

If you get the dreaded error:

from html5lib import sanitizer, serializer, treebuilders, treewalkers
ImportError: cannot import name sanitizer

Never fear. The fix is easy once you know how. Add this exact line to your requirements file and redeploy:

html5lib<0.99999999

This will fix it.

Posted in django, python, Web Programming | Comments Off on ImportError: cannot import name sanitizer when trying to run django

KeyError: ‘en-us’ when doing a reverse() lookup in urls.py

If you’re getting an error like this:


... in reverse_dict
return self._reverse_dict[language_code]
KeyError: 'en-us'

If your urls.py file contains a reverse() call, that is the reason.  You’re calling reverse before all the urls are loaded and everything is ready.  You need to use reverse_lazy() instead.:


url(r'^password/reset/$',
password_reset,
{'post_reset_redirect': reverse('password_reset_done'),
'html_email_template_name': 'registration/html_password_reset_email.html'},
name="password_reset"),

Change the reverse() call into a reverse_lazy() call and the problem will go away!

Posted in django, python, Web Programming | Comments Off on KeyError: ‘en-us’ when doing a reverse() lookup in urls.py

How to get rid of winmail.dat attachments when using Office365 and Outlook 2016

Sometimes Outlook 2016 decides to send the body every email as a winmail.dat attachment. This works fine when the person you are sending the email to is using Outlook. But other mail users will get a blank message with a winmail.dat attachment that they can’t open.

This frustrating problem can be fixed by doing this:

  1. Login to office365 as an administrator
  2. Click the Admin Icon
    screen-shot-2016-09-30-at-12-43-23-pm
  3. Expand the Admin Centers Menu, and click Exchange
    screen-shot-2016-09-30-at-12-45-52-pm
  4. On the left, click “mail flow”, then click “remote domains”, make sure “Default, *” is selected, and click the Edit Pencil icon.
    screen-shot-2016-09-30-at-12-48-36-pm
  5. Edit the settings with arrows, and click Save.screen-shot-2016-09-30-at-12-51-12-pm
  6. Enjoy
Posted in Exchange, Office 365 | Comments Off on How to get rid of winmail.dat attachments when using Office365 and Outlook 2016

How to fix all postgres sequence numbers in a database

Create this stored procedure:

CREATE OR REPLACE FUNCTION "reset_sequence" (tablename text, columnname text, sequence_name text) RETURNS "pg_catalog"."void" AS
$body$
DECLARE
BEGIN

EXECUTE 'SELECT setval( ''' || sequence_name || ''', ' || '(SELECT MAX(' || columnname || ') FROM ' || tablename || ')' || ')';
END;
$body$ LANGUAGE 'plpgsql';

Then, run this query:

select table_name || '_' || column_name || '_seq', reset_sequence(table_name, column_name, table_name || '_' || column_name || '_seq') from information_schema.columns where column_default like 'nextval%';

Posted in Uncategorized | Comments Off on How to fix all postgres sequence numbers in a database