Python: Print stack-trace

Surprisingly, this doesn't come as a standard function in the Exception class.

import traceback
raise Exception("print exception!")
print traceback.format_exc()

Short and simple, so good!



Windows: Find and delete files of a given pattern (also searching subdirectories)

I needed a quick way to clear out all the compiled Python ".pyc" and Java ".class" files on my drive, and searching via Windows Explorer is just slow.

  • Open up a command prompt.
  • Go to the folder to start from.
  • Type in:

del /S *.pyc

del /S *.class

It'll all be over after the wall of text has finished moving.

So simple, so effective.


CPanel: No Such User Here \ Sender verify failed

Well, this one had me baffled for a while. I thought that the user had to exist before I could send emails "from" that address.

But that makes no sense if I were to ignore all emails from

So, I did a little research and discovered that it's a CPanel setting!

Log into your CPanel and go to "Email" > "Set default address".

You can choose to forward the email to a valid address, but in the case of a "no-reply", just discard it by selecting "Discard (Not Recommended)".

Click "Change" to save.

This is what I felt like after putting up with error emails for so long...


Python: Get string value of a PIL Image without writing to a temporary file

It's often useful to fetch the raw image data without having to save it to a file first (eg. as serving images by HTTP or sending email attachments)

To do that, we make use of the class StringIO.

import StringIO

# Save the file to a temporary file because that's how email attachments work
output = StringIO.StringIO(), format = "PNG")
email.attach(filename = "whatever.png", mimetype = "image/png", content = output.getvalue())

And there you have it!



Linux: How to scroll back up in GNU screen

Screen is a handy little thing that lets you run an extra persistent console in the background which stays active after you disconnect.

However, scrolling back up the screen buffer is a tad more tricky.

After using it on and off for a few years, I've finally run into the need to scroll up to see what's in the buffer.

To do that:

  • Press Ctrl+A
  • then [
  • And use J or K to move up and down (or the arrow keys)



Python: Convert RFC 2822 string to datetime with timezone support

Since it's such a short snippet, I'll keep this post nice and simple.

from email.utils import parsedate_tz
print parsedate_tz('Fri, 15 May 2009 17:58:28 +0700')

That's it!


Eclipse: Install HTML editor plugin

This is a lightweight editor plug-in with syntax highlighting and folding.

My Eclipse didn't have it, probably because I downloaded the classic release without all the extra Java trinkets.

Firstly, find out which release you're on. It usually displays a name under the word "Eclipse" on the splash screen when loading.

Then go to:

  • Open the "Help" menu
  • Click "Install new software"
  • Select "<your release name> -<release name>" from the dropdown
  • The URL could be or, depending on what you've got installed.
  • Wait for it to load...
  • Go to the bottom of the list and expand "Web, XML, and Java EE Development"
  • Select ONLY "Web Page Editor"
  • Click "Next"
  • Next again.
  • Accept agreements and finish
  • It may ask for you to accept the certificates when it's finished downloading. Tick the checkbox next to the item in the list and then click Next to install.
  • When it's done, it'll ask you to restart Eclipse. Do it.

Once your back in Eclipse, try editing a HTML file.

If it's not highlighted, you'll have to:

  • Open the Window menu
  • Click "Preferences"
  • General > Editors > File Associations
  • Select *.html
  • Select "HTML Editor" (not web page editor)
  • Click "Default"
  • Click "OK" to save

You should now have a great HTML editor!


Windows Live Messenger: How to disable Smartscreen security page?

This thing was driving me NUTS!

After upgrading to the new Messenger, I contemplating going back because I often receive dev links from workmates.

Unfortunately, these dev links are marked as "low traffic sites" and "isn't well known" because, well. they're secret dev links...

An example of the annoying "Protect yourself" screen is here:


Seriously, I'm not protecting myself, YOU ARE. STOP IT!

It might just be an extra click, but it's annoying!

Firstly, disabling Internet Explorer's smart screen filter won't fix anything. This is coming straight from WLM 2011 into your default browser (Firefox/Chrome/etc).

Secondly, GreaseMonkey scripts are flakey at best.

To properly disable it:

  1. Click on "More info" to expand some text.
  2. "Don't show me this message again"
  3. "Continue anyway"

Now, back to being productive.

Sony Vaio Gate: How to uninstall?

Argh preinstalled software which cannot be uninstalled... the worst kind.

Usually you can just uninstall crap like this from the control panel or from the Vaio Care suite, but no not this one...

Open up a command prompt and paste these instructions.

regsvr32 /u "C:\Program Files\Sony\VAIO Gate\VAIOGateDesktopShellExt.dll"
regsvr32 /u "C:\Program Files\Sony\VAIO Gate\EN-US\VAIOGateShellExt.dll"
del /F "C:\Program Files\Sony\VAIO Gate"

And viola!

Anything else I can help you with?

Synaptics Scrybe: How to uninstall

When I downloaded the latest drivers for Synaptics touchpad, I didn't expect it to come with Scrybe (even though the package specifically says "with Scrybe")

Well, when I saw it appear on my taskbar my immediate instinct was to kill it. What foul heathen dare trespass on my grounds!?

Shamefully, there was no uninstaller provided. Strangely enough, it was easy to kill it, which I'm not complaining about.

  1. Delete it from your startup folder (Start menu > All Programs > Startup > Scrybe > Right click> Delete)
  2. Quit Scrybe (Right clickon Taskbar icon, exit)
  3. Run the following commands

net stop ScrybeUpdater
sc delete ScrybeUpdater
del /F "C:\Program Files (x86)\Synaptics\Scrybe"

Obviously replacing "Program Files (x86)" with "Program Files" if you've got 32bit Windows.


Eat that bundleware!

Blogger Blogspot: Template code/tag to identify a list or post detail page

Something that's been annoying me for a while is the lack of template tag definitions.

Today I gleamed the template code and found something that would help.

To identify between a listing page (a list of blog posts) and a detail page (a page dedicated to a particular post, where comments are shown), you need the following condition check.

<b:if cond='data:blog.pageType == "item"'>
  <p>This is the post item page. Put your code here</p>

Now, where was I again? Oh yeah, the sign-off image.


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