Drupal 6: Change theme for maintenance page

To display your maintenance page in your chosen theme and not the Drupal minelli/garland style, you'll need to create a copy of your page.tpl.php file.

Save the copy as "maintenance-page.tpl.php" in your theme folder and rip out all the bits you don't need.

Now set the 'maintenance_theme' variable using variable_set() to whatever theme you wish. It should apply immediately.

variable_set('maintenance_theme', 'your_theme_name');

Tested on Drupal 6.

jQuery: Fade and slide at the same time

Chaining functions is really handy, but when it comes to animation, its a bit annoying because it'll perform them in order.

To get fade and slide at the same time, use animate().

$('#element').animate({ opacity: 'toggle', height: 'toggle' }, "slow", callback_function);

The speed and callback functions are optional.

[ Source ]

CSS (IE8/IE9/IE10): Meta tag to disable compatibility view

I had some trouble with CSS on Internet Explorer 8 the other day and wondered why the hell it wasn't working.
After hours of frustration, I disabled compatibility mode by clicking on "Tools" > "Compatibility View" and it just worked.

But I had to disable this for the whole site, without having to teach each user about it. Luckily, there is a meta tag for it!

Add the following tag into the head section of your page and IE will use the specified rendering mode.

<meta http-equiv="X-UA-Compatible" content="IE=8" />
Unsure which version of Internet Explorer supports this, but I know IE8 and IE9 honours this setting.

*update 12/8/2011*

OK, this caused a bit of confusion to me but I figured out why rounded corners (CSS border-radius) wasn't working on IE9.

I shot myself in the foot because I've set the "IE=8" compatibility mode, IE9 will not render rounded borders because IE8 doesn't actually support it.

After reading a post on StackOverflow, I looked up the docs for document compatibility and found a fix. Set the order of compatibility in this format:

<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE" />

Now it'll try IE9 mode first, IE8, then IE7. You can even set IE=EDGE so it'll use the highest mode possible.

*update 21/8/2013*

haha a little over 2 years since the last update, I ran into another issue with this.

IE9 dev tools was spitting out this error:

X-UA-Compatible META tag ignored because document mode is already finalized.

The hell does that mean?

Well apparently it only works if we have it as the VERY FIRST tag in the <head> element, with the exception of <title>. Moving your compatibility meta tag up will fix it.

[ Source ]

[ Fix: IE9 fieldset rounded corners, Defining Document Compatibility, HTML1115: X-UA-Compatible META tag ('IE=9, IE=8, chrome=1') ignored because document mode is already finalized ]

jQuery: Limiting Select to Direct Children

Given the example below...

<ul id="example_menu">
<li>Menu Item 1</li>
<li>Menu Item 2</li>
<li>Menu Item 3
<li>Dropdown 1</li>
<li>Dropdown 2</li>
<li>Dropdown 3</li>
<li>Menu Item 4</li>

This jQuery selector:

$('#example_menu li');

Will return all LI elements within the menu, including the dropdown ones.

To limit your selection to just the "Menu Item X" items and not the dropdowns, use the following selector to limit it to the direct children of #example_menu.

$('#example_menu > li');

That wonderful little > symbol will fix all your problems, as it limits the selector to direct LI elements of the #example_menu.

Eclipse: Save space and reduce history clutter

Eclipse is a pretty feature packed (and perhaps bloated) IDE, but its still pretty useful. However, it does do some stupid things like storing 900mb worth of crap from yesteryear.


In your Eclipse workspace folder, there is a ".metatags" directory that stores all project related information.

Every time you modify a file in Eclipse, a copy of the old contents is kept in the local history.

By default, it keeps up to 50 copies of each file (that is under 1mb) for 7 days. For some reason, my Eclipse wasn't always clearing out the files upon exit either.

If you have a large file intensive project, that's a helluva lot of files! This isn't exactly a bad feature, especially if you don't use version control of some sort, but if you do, its useless.

Under ".metadata\.plugins\org.eclipse.core.resources\.history", you'll be able to find the local history of all edited files. Delete all them. Don't worry, its ok!

Open up your Eclipse preferences dialog and change the following:


I changed mine to 1 day, 1 entry per file and 1mb limit (since I couldn't set anything lower). You may want to change it to something more suitable for your usage.

Remember to restart Eclipse to apply the settings. Your Eclipse should now purge files whenever it is closed, but it still seems to need cleaning once in a while as files are deleted but cache directories aren't.

There are more uncommon space saving tips here.

[ Source, StackOverflow ]

C#: ShowDialog() keeps returning DialogResult.Cancel

When you call a dialog with dlg.ShowDialog() and check the result, you may find it always returning DialogResult.Cancel.

private void AddItem()
FormAdd dlgAdd = new FormAdd();
DialogResult res = dlgAdd.ShowDialog(this);

if (res != DialogResult.OK)

// All good to go here

So with your dialog, ensure that the correct "AcceptButton" property has been set to the correct button.

A simple mistake to make is to forget setting the result when you click OK/Save/etc.

private void btnAdd_Click(object sender, EventArgs e)
// Do some validation here

this.DialogResult = DialogResult.OK;

That should set the correct value by the time the dialog is closed.

Visual C++: Add Version Number to Your Applications

While in your Resource View, right click and add a new "Version" resource.


There are two "file version" fields. Edit the very first one called "FILEVERSION" as the second one below seems to be ignored altogether.


[ Source ]

Python: Check if a String is an Integer

A handy way of checking if a string can be converted into an integer is to use isdigit(), which will will return a boolean value.

if self.something.isdigit():
id = int(self.something)
return ModelName.objects.get(id = id)
except ModelName.DoesNotExist:
return None;

[ Source ]

Synergy+: How to compile source

Synergy is a very useful utility which links your mouse and keyboard between multiple computers. Each computer still uses its own monitor and can run its own operating system.

Much like how a KVM links a keyboard/mouse between multiple computers, but without the need for wiring or sharing of a monitor.

Image taken from Synergy+ homepage

The original Synergy project has died down, and the original author Chris Schoeneman has not updated it since 2006. Up comes Nick Bolton and Sorin Sbarnea to continue the project in the name of SynergyPlus on GoogleCode.

If you want to help develop this software, just pull the source from http://synergy-plus.googlecode.com/svn/trunk using your favourite SVN client. If that link no longer works, see here and let me know that its changed!

It'll take some time to pull the files out of SVN as there are some executables included (like the Visual C++ redistributable setup).

Once its done:

  • Go to "tool\win\cmake\bin"
  • Run "cmake-gui.exe" (Why the hell is this nearly 8mb?)


  • For the field "Where is the source code", select the SVN folder you pulled the files to.
  • Create a folder in your SVN folder called "project".
  • Within "project", create another folder called "bin".
  • For "Where to build the binaries", select your new "project" folder.
  • Click "Configure" at the bottom.

This is where you select your preferred IDE. For me, I selected Visual Studio 2005/2008. It may differ for you if you choose something else.

Default native compilers seem to work fine for me!

  • Fill in both EXECUTABLE_OUTPUT_PATH and LIBRARY_OUTPUT_PATH as the "bin" folder.
  • Click "Configure" again to remove the red labels.
  • Now "Generate" should be enabled. Click it.

Now you should have the project files ready for development.


Once you compile the code, all the binary files will be spat out in the "project\bin" folder.


Flickr: Automatically remove spaceball.gif to save pictures

The easy way would be to add a custom filter on AdBlockPlus called "http://l.yimg.com/www.flickr.com/images/spaceball.gif" on the domain at "flickr.com".

Another way would be to use a GreaseMonkey script. Restart Firefox and then install this user script.

It should take effect immediately.

C++: Handle the Syslink click event

Once you have the SysLink control working, you can respond to link clicks by adding a notification listener to your parent window.

case WM_NOTIFY: {
LPNMHDR pnmh = (LPNMHDR) lParam;

// If the notification came from the syslink control
if (pnmh->idFrom == IDC_SYSLINK_WEBSITE) {
// NM_CLICK is the notification is normally used.
// NM_RETURN is the notification needed for return keypress, otherwise the control is not keyboard accessible.
if ((pnmh->code == NM_CLICK) || (pnmh->code == NM_RETURN)) {
// Recast lParam to an NMLINK item because it also contains NMHDR as part of its structure
PNMLINK link = (PNMLINK) lParam;

ShellExecute(NULL, L"open", link->item.szUrl, NULL, NULL, SW_SHOWNORMAL);



The link->item.szUrl field is the "href" given in the syslink control markup.

C++: Dialogs with SysLink control do not show up

For some strange reason, adding a SysLink control onto the dialog during design time would cause DialogBox() to fail with -1.

There are a whole bunch of advice online to get it working, but all of them involve some tinkering with project files and the inclusion of ridiculously cryptic manifest files.

The main reason the Syslink causes the DialogBox() command to fail is because it requires unicode text support, starting from ComCtl32.dll 6.

All the new functionality defined in ComCtl32.dll version 6 supports only Unicode. Therefore, you cannot create ANSI versions of SysLink controls, only Unicode versions.

To get it working (without messsing with project properties and manifest ugly files, include this line into a project header file.

#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' "\
"version='' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

Note: This only works with Visual Studio 2005 and onwards.

But don't get comfy with your success, you still have another major puzzle to solve...

Can you ever figure out... JAPAN? Seriously, wtf?

To handle the link click event, see this post.

[ Syslink Control Overview, Enabling Visual Styles ]

Win7: Show "All Programs" in Start Menu when Most Recently Used List is Empty

(Skip blurb for download link. Report issues on the Genscripts Redmine tracker.)


For alot of people, the start menu will display a list of recently used programs. Its a pretty handy feature to have, but its not for all of us.
image The default start menu, filled with recently used applications.
However you may have disabled application usage tracking for some reason such as privacy or to squeeze just a bit more performance out of your machine.
The configuration dialog for recently used applications.
Right click the taskbar and select "Properties" to display the "Taskbar and Start Menu Properties" dialog, and disable application tracking by unticking "Store and display recently opened programs in the Start Menu"
Note: This will also remove recently used files from your jumplists.
Now there is a horrible side effect to this option, theres nothing in the start menu when you first show it.
image Annoyingly, your start menu will now display an empty list.


You've probably noticed it already, which is why you're here.
I've written a small program that displays all your Start Menu items automatically. Nothing spectacular, it just removes a small annoyance.
The program is called Spasm (Show Programs Automatically in Start Menu). I'll upload the app once its been polished a bit and I find an icon for it.



  • Simply run the file for it to take effect.
  • Close Spasm to stop it.
  • Run with the argument "--no-icon" to disable the tray icon.

    WTF Why Bother?

    Some people may be wondering this and by all means its a good question! I've seen the issue being asked a few times on the forums so I suppose that's where I got the idea from.
    The empty menu does annoy me a small bit, but I normally type in what I'm after anyway.
    I guess it was also out of nerdy curiosity, a self set challenge to see if I could or not without any help. And I did :)
    So far:
    • It probably won't work in any language other than English.
    • Checks the recently used list to see if its empty before displaying the full Start Menu items.
    • Doesn't do much of anything else.


    v1.41 (05/06/2011)
    • Added argument "--no-icon" support to hide the tray icon.
    v1.4 (14/03/2011)
    • Added a timer to detect refreshed shell.
    • Added icon to "already running" message.
    v1.3 (06/02/2011)
    • Rewrote how system information is shared between EXE and DLL files.
    • Now detects if Spasm is already running.
    • Only unload hooks if the DLL is being unloaded from Explorer.
    • Hopefully prevented the issue with Spasm losing grip on Explorer's handle.
    • Adds icon back to taskbar when Explorer crashes.
    • Now works if used on startup!
    v1.2 (16/05/2010)
    • Fixed x86 version so it works (Thanks Andrey and Patrick Timms for the heads up)
    • Added double click to show about
    v1.1 (09/05/2010)
    • Now works with any language.
    • Fixed x86 DLL function name mangling.
    • Added build version to executable.
    v1.0 (07/03/2010)
    • Initial release.

    Other Small Tweaks

    PostgreSQL: Display results vertically

    Sometimes you just need to quickly skim sample data from the database, but reading long data horizontally is a bit of a mess.

    To read results vertically, toggle the expanded display mode using "\x".

    content=# \x

    Expanded display is on.
    content=# select * from table_name;
    -[ RECORD 1 ]-----------+-----------------------------
    id                      | 8
    when                    | 2010-03-02 13:37:33.64327+11
    salutation              | Mr
    first_name              | twig
    address_street_number   | 123
    address_street_name     | French Girl
    address_suburb          | Has A Reason
    address_state           | For Hurting Boyfriend
    address_postcode        | 1234
    address_country         | France
    no_promotional_material | t

    content=# \x
    Expanded display is off.

    In case you're wondering, the french girl reference is from a song called "The Presidents of USA - French Girl".

    Facebook: Disable Live Feeds on Events

    Introducing to you, Facebook's new way of selling you out!

    I really would of liked an option to disable this somewhere in the privacy settings. Really, I would. Because I have no interest in this crap.

    "Update your status about this event", "Share with everyone watching this event" and "This is a sample of what everyone watching is saying"? NO I DONT WANT TO!

    But alas, I could not find an option, so here comes a heavy handed tactic to do so. Click on the AdBlockPlus icon and a dialog should appear.


    Add a new custom rule clicking on "Add filter..." button in the bottom left corner and paste in:


    Click OK and refresh the page.

    Whalla! Victory!

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