Wednesday, December 30, 2009

Thunderbird 3: Changing the toolbar back to the old settings

So I've installed Thunderbird 3 (on my parent's computer as a test mule) to try out the new features. So far so good, migration was smooth and I haven't noticed anything that has been lost.

The new toolbar? Gotta say I'm not a fan. They've removed a bunch of stuff that I use (like err, Reply and Forward) from the main toolbar and moved it into the details pane.

image
Trusty old and useful toolbar.

image 
The new not-so-useful 3.0 toolbar.

image
The new details pane containing the email action buttons.

Making the search more prominent is great, but moving the other stuff isnt. Why? Because I've gotta use a touchpad and it really sucks moving the mouse cursor around so much (if I didn't feel like using the keyboard shortcuts I mean) especially with a widescreen resolution where folders would be on the left and reply button on the far right.

Luckily, Mozilla have included a little tab to help haters like me migrate from one version to another.

image 
The Migration Assistant tab.

The first time you open Thunderbird 3, it'll display a "Migration Assistant" tab to give you some options. If you've still got it open, then click on "Use original toolbar" under the "New toolbar" heading.

If you've already closed it, you can find the assistant under the "Help" menu.

Monday, December 21, 2009

CSS: Make floated elements to push down items below it

Floating is a nice way of positioning elements, but most of the time you dont want it to have no weight on the page that elements below it will try to take up its display space.

For example:

<div>
  <ul class="list_wrap">
    <li style="float: left;">FLOAT A </li>
    <li style="float: left;">FLOAT B </li>
    <li style="float: left;">FLOAT C </li>
  </ul>
  <p>Content thats pushed up</p>
</div>

Will give you:

  • FLOAT A
  • FLOAT B
  • FLOAT C
Content thats pushed up

Example of retarded floating.

To fix that, its really simple! Just add "overflow: auto; width: 100%;" to "ul.list_wrap" and you've got yourself a winner!

  • FLOAT A
  • FLOAT B
  • FLOAT C

Content thats pushed up

Not so retarded floating.

[ Source ]

Sunday, December 20, 2009

Disable Windows Live Messenger Web Bar" from Automatically Signing In

While viewing windowslive.ninemsn.com.au, I noticed a little notification showing me that I've signed in from somewhere else.

image

Thinking that I forgot to untick the "save my password" on another computer, I took a quick look to see where it was from.

image

OK, WTF? Since when do sites start logging me into MSN?

Scrolling down to the bottom of the page showed me this.

image

Despite being a small bar, I'd hate to have this load on EVERY PAGE that I viewed. It signed me in automatically on every news article page that I opened on that site, meaning if I viewed 3 articles in 3 tabs, I'd be signed into Messenger 4 times!

image

This is fucken stupid! Not to mention the bandwidth wasted when loading my contacts EVERY TIME I LOADED A PAGE!

So far, I have not been able to find an option to disable it. Although logging out does work, it also logs me out of my email (which I like to logged in at home).

I do hope that Microsoft add an option for disabling this web bar. It may be useful for some, but not me.

Using AdBlockPlus to Disable Messenger Web Bar

Viewing the dev site for the web API, I've found the file required to run this service.

http://www.wlmessenger.net/api/3.5/loader.js

Using AdBlockPlus on Firefox, block anything from "http://www.wlmessenger.net/*" and do not restrict it to the current domain.

image
Right click on the icon and select "Open blockable items".

image
Search for "loader" and it'll help you find this item.

image 
Select that filter and click "Add Filter".

That should do the trick fine.

[ Sources ]

Wednesday, December 16, 2009

Django: Automatically fill information into template context

Sometimes you need a variable in your templates thats required for every page in your site.

Inserting it into every return statement in every view is a bit too troublesome.

Its much easier to add it into a "Context Processor". This will automatically insert the data you specify into every template rendered.

So in your app, create a file called "context_processor.py" and define the processors you need.

def custom_info(request):  
  return { 'MY_CUSTOM_INFO' : 'blah blah blah', }

Now in your settings, include the preprocessor.

TEMPLATE_CONTEXT_PROCESSORS = (  
  'django.core.context_processors.request',  
  'myapp.context_processors.custom_info',  
)

In your template, use it like normal without needing to load anything.

<div>Data: {{ MY_CUSTOM_INFO }}</div>

Saturday, December 5, 2009

Postgres SQL: phpPgAdmin comes up with "Login disallowed for security reasons"

blah

Edit "conf/config.inc.php" and search through the file for:

$conf['extra_login_security'] = true;

Set the value to "false" and logins should now work.

PHP: Get the longest string (or length) in an array

To quickly get the longest string in an array, use the following function.

function longest_string_in_array($array) {
  $mapping = array_combine($array, array_map('strlen', $array));
  return array_keys($mapping, max($mapping));
}

If you need the length of the longest string, use this little snippet.

$maxlen = max(array_map('strlen', $array));

[ Sources ]

Eclipse: Hide *.svn-base in Open Resource dialog

If you're using SVN to version control the source you're working with, you may notice in Eclipse v3.5 that the Open Resource dialog now shows you LOTS of *.svn-base files.

This is due to the filtering configuration in the plugins system has changed and plugins need to be updated.

The easiest way to hide those SVN files is to install Subclipse 1.6.x, which has been updated to work with the right filter configuration.

Drupal: Highlight errors in fieldset with form_set_error()

Using form_set_error() to display error messages, the first argument is the name of a field.

$form['height'] = array(
  '#type' => 'textfield',
  '#title' => 'Height',
);

Along with:

form_set_error('height', 'Error with height.');

image

Normally this is simple to define, but when using nested form items within fieldsets, this doesn't highlight the right item.

If the form was changed to nest the items:

$form['new'] = array(
  '#type' => 'fieldset',
  '#title' => 'New Image Size',
  '#tree' => true,
);

$form['new']['height'] = array(
  '#type' => 'textfield',
  '#title' => 'Height',
);

Using:

form_set_error('height', 'Error with height.');

image

Notice the height is no longer highlighted?

The reason is that the field argument requires some formatting to make it work with nested forms.

Using a stupid '][' to tokenise the fieldname, we can specify which item to highlight.

form_set_error('new][height', 'Error with nested height.');

image

This gives us the proper feedback we wanted.

[ Source ]

Regex: Remove Double Spacing

Example given in PHP, but since its regex it could be applied to other languages too.

$cleaned = preg_replace('/\s+/', ' ', $input);

This changes any double (or triple, quadrupal, etc) spacing into a single space.

Sunday, November 29, 2009

Netgear DGN2000 Overheating Issues

Despite my dislike for Netgear routers (which have proven their unreliability and buggy-ness in the past with friends constantly having to restart their routers), I purchased the Netgear DGN2000.

Why? It was the only Wireless N-router with an ADSL modem that looked nice.

I purchased it in mid September and its currently been 2 months and 9 days since I've installed and used it. The device has been running every day and in a horizontal position.

Normally it runs very hot to the touch. So hot in fact that it heats up the wooden table that it sits upon. I've also seen some posts online that it browns the white sticker that is on the back of the device.

The issues started on a day where temperatures hit +35°C. The router would occasionally freeze up and require a reboot. Initially I thought it was my ISP, but then I realised it didn't happen when the air conditioning was on.

This wouldn't be so annoying if it happened every month or so, but it was starting to occur after every 5-10hrs of operation. Netgear peice of shit.

image 
Netgear, apparently featured in a movie called Dogma.

I've left it standing vertically, and it definitely runs alot cooler than it did while running horizontally. Now it looks like crap and takes up more space than it should. I cant even get the 2nd antenna to point upwards since the power/ethernet cables are in the way.

IMG_4945
The Netgear DGN2000 standing vertically and not able to fit in that gap.

Looking up this issue online returns quite a few number of posts which seem to display the same symptoms. The interesting ones are here:

Contacting support

I registered to Netgear to contact their support and let them know that their device is a hot pile of steaming shit. Upon their registration processed I was asked if I wanted to purchase one of their "service contracts".

image 
WTF @ the pricing!? Extortionists!

I'll wait for their reply, but I don't think that they'll send me out another device that doesn't overheat anytime soon.

Until then, Netgear, I salute to you this wonderfully appropriate icecream in the middle of the Australian summer.

image
In the words of a great prophet Eddie Murphy (Delirious):
I could drop my icecream in a pile of shit and eat it.
I would be like "It's just sprinkles"