javahacker.com

The Java Hacker – Peter Jaric's Blog

Customize Saved Searches in Thunderbird

I use Mozilla Thunderbird exclusively as my email client. One feature Thunderbird offers is Saved Searchs. I use it to create a virtual folder “Unread Mail” that shows all my unread mail that is not junk. To do this I have selected the options “Status isn’t Read” AND “Junk Status isn’t Junk”.

My main use for this folder is to keep mail I haven’t handled yet in view. I mark these mails as unread and take care of them later. Now and then I mark some mails as unread by mistake and they disappear from my virtual folder, which isn’t very good. To fix this I decided to mark all mails I want to keep as starred. Then I wanted to change my virtual folder so that it displays mail that match (“Status isn’t Read” OR “Status is Flagged”) AND “Junk Status isn’t Junk”. This is not possible in Thunderbird’s interface, though. You can only select “Match any of the following” or “Match all of the following”.

I looked around a little in the configuration files (I found them in $HOME/.thunderbird) and found a file virtualFolders.dat! And by simply setting the terms property to the correct value solved my problem, like this:

terms=AND (junk status,isn’t,2) AND (status,isn’t,read) OR (status,is,flagged)

If you want to try something like this, remember to close Thunderbird before you edit the file. And make a backup of virtualFolders.dat first!

Update

When I tried to repeat this on my computer at work, I failed at first. The best way seems to be to create a saved search folder from within Thunderbird that matches the one you want to end up with as much as possible. In my case I made one that matched my desired terms with the exception that the OR was an AND (“Match all of the following”) and then I simply changed that AND to an OR in virtualFolders.dat.

Playing Swedish Scrabble? Boggle?

If you’re playing Scrabble in Swedish with your friends, you will get invaluable help from my friend Jonatan‘s new web application: ordlista.org. There you can check whether a word is valid when playing Scrabble, or just browse through words for fun. It has helped us in numerous Scrabble and Boggle games.

Good gaming!

“Connection problem or invalid MMI code” on Android phone


We have got a new cell phone operator at work and one of their features is that if you prefix a number with the code *150# the call will be charged to a separate bill that will be sent to the employee and not to the employer. This is quite common in Sweden and is of course a good thing, but it doesn’t work on Android (pre 2.1). I use an HTC Tattoo and get this message when calling for example *150#0123456789:

Connection problem or invalid MMI code

In the thread I linked to above, there is a workaround: put a plus sign (+) before the first digit, like so: *+150#0123456789. This gets rid of the error message and allows the call to go through. The number that is called according to the phone has no plus in it: *150#0123456789

Let’s hope this works. Otherwise I might get a call from my boss later on :)

Update:
I mailed Ventelo’s (the operator) support and received this positive answer (translated by me):

Yes, using *+150# will work as well.

Good news, in other words!

Update 2:
Here are some tips from the comments:

By me:
Hi everyone, looking for general help about MMI codes. I must admit that I do not know much about this more than what I have described in my post. If my solution doesn’t work out for you (and I suspect it doesn’t, as you have different problems), you’ll have to try to find an answer elsewhere, perhaps here: http://answers.yahoo.com/dir/index?sid=396545653

By Phoenics:
Hello, try calling your network carrier… they will give you a series of troubleshooting steps like some codes. Just provide them the serial no. of your phone (dial *#06# to get it from your phone)…

used to be a customer service representative and i have encountered concerns like this. :)

By Ismael:
Check this. It seems this the solution for your problems http://forum.xda-developers.com/showthread.php?t=1478608

just add an comma (,) at the end of the code.

for example,
if your code is *123*1#
then you should dial it as *123*1#,

By sam winston:
hai everyone.. this is a best solution from USSD code error… There are two ways
1 st one: Reboot your mobile ( if you have lot of time to wait)
2 nd one: Just turn on the Airplane mode for 30 second then turn off the Airplane mode( if you are in a urgent situation)..

The above two ways will help to get the balance reply using USSD code dialing in your android.

If you want more information aboutt this contact me Ph no : –redacted–

By Mohamed:
Hi Guys,
my phone is sky vega
i have came across the problem of not being able to execute the basic detail commands provided by the operators to check the details.

however i had the same problem and this is what worked for me

just add an comma (,) at the end of the code.

for example,
if your code is *123*1#
then you should dial it as *123*1#,

this way i think it blocks the rest of the codes going with it and works properly

this worked for me check for yours

If it helps please say “thanks”

Aardvark and answers that do not answer the question

Recently Google announced that they have acquired Aardvark, a service that finds the right person to answer any question you might have. I’ve used it frequently for a little while, and while I think it is a very cool idea and answering questions is quite addictive, I think there is a problem with the quality of the answers to my questions.

It is very common to get answers from people who really do not know the correct answer, but use Google to find something related to the question. I understand that, because it is very tempting to try to answer as many questions as possible, but it isn’t very helpful in the end, because there might be someone more qualified to answer out there.

To raise the quality of answers to my questions I will try to include something in my questions to make casual answerers avoid them. I am thinking of a good phrasing to not sound too arrogant but at the same time fulfill my goal. I think I’ll try something along the lines of “Please only answer if you really do know the answer to this specific question! I have already googled for answers myself. Thanks!!!”

I wonder if that will work or if I from now on will get no answers at all :)

Matching combined results in jQuery – ordered correctly

Today I used the “selector1, selector2, selectorN” selector in jQuery and was confused that, in some cases, when looping over the results I got them in the order of the selectors and not in the order of the elements in the page. I had expected it to work as an OR operator. My code looked like this:

var headers = $('h1,h2,h3', context);
headers.each(function(index) { ... });

First my function was called for all h1s, then for all h2s, etc, regardless of their ordering in the page. Some googling finally led me to this solution: first find all headers and then filter out the ones I need. My first try looked like this:

var headers = $(':header', context).filter('h1,h2,h3');
headers.each(function(index) { ... });

It didn’t work, unfortunately. There was no difference. After some reading I finally produced this less elegant but working solution:

var headers = $(':header', context).filter(function() {
	return $(this).is('h1,h2,h3');
});
headers.each(function(index) { ... });

This gave the desired result. The “:headers” selector was very useful for me this particular time, obviously. It needs to be replaced for the particular set of elements one is looking for of course, and if worst comes to worst, maybe ‘*’ is the only solution, even though it probably will have a bad effect on performance.

New InfoGlue Forum

I have been working with the CMS InfoGlue for a while now and one thing that has been seriously lacking is a large community. To help beginning to build the foundation of a community, I have been pushing for a central official InfoGlue forum and finally we have got it together.

Please visit the forum for a look at the result. There are very few posts at the moment, but hopefully InfoGlue users will be finding their way there soon!

EnBil.nu

My friend Jonatan and his friend Robert released their new site EnBil.nu yesterday! It aggregates most of Sweden’s car rental sites into one easy-to-use site. With their own words (in Swedish):

Vår förhoppning är att EnBil.nu ska vara den bästa sajten för att söka efter hyrbilar i Sverige, och vi vågar faktiskt påstå att så redan är fallet. För att göra en sökning anger man datum, tid och en uppskattning av antal mil man kommer köra. EnBil.nu söker sedan hos ett flertal olika biluthyrare, och presenterar resultatet, ordnat efter pris som även inkluderar milkostnader. Än så länge söker vi efter hyrbilar på Statoil, OKQ8 och Europcar.

I wish Jonatan and Robert good luck with the new site and I will use it the next time I will be renting a car, that’s for sure!

Edit: Updated the URL of EnBil.

Setting up CrunchBang Linux on an Acer Aspire One with SSD

I have had an Acer Aspire One netbook (AA1) for a while and recently I decided to throw out the bundled Linpus OS and install a more flexible Linux. Linpus has served me quite well, but it has some shortcomings that many other popular distributions do not share.

After some research I decided to try CrunchBang Linux, a Ubuntu based distro that has good reviews over at the Aspire One User forum. Correctly, I must say. It is running on my AA1 and it is so much better than Linpus was.

There is an installation guide for CrunchBang on the AA1 that I followed, but it’s for the hard drive version and I have an AA1 with a SSD which requires special consideration. I made a number of other changes too, and I thought I should share them. So this is my brief instruction on setting up CrunchBang on the AA1:

Instructions

  1. Follow the installation guide and be sure to use ext2 for the file system (thanks exwannabe). This requires manual partitioning (do not select guided partioning). Remember to create a swap partition if you have less than 1.5 GB memory (I’ve read that with 1.5 GB RAM it is possible to do without a swap partition, but don’t take my word for it).
  2. As mentioned at the end of the installation guide, follow the instructions to reduce wear and increase performance.
  3. The default logout dialog do not include suspend and hibernate options. This can easily be added with a package with a modified logout script.
  4. To make the AA1 suspend when the lid is closed, press Super-Space (hold the Home button and press space), select “Preferences->Screensaver & Power Management”, click “Power Management” and select “Suspend” in the drop down to the right of “When laptop lid is closed” in the tabs “On AC Power” and “On Battery Power”. Now is a good time to configure the other power options to your taste.
  5. The default fonts are a little big. To make them smaller, follow these instructions:
    1. For widget fonts (menu labels, button labes, etc), press Super-Space, select “Preferences->User Interface Settings” and choose a smaller font by pressing the “Font” button. I selected “Sans 6”.
    2. For window manager fonts, press Super-Space, select “Preferences->Openbox Config->GUI Config Tool”, Select the “Appearance” tab and configure your fonts by clicking the font buttons. I selected “Sans 6” for all fonts here also.
    3. For the terminator (the terminal program in CrunchBang), open $HOME/.config/terminator/config in your favorite text editor (I use emacs) and change the font size. Here I use “Mono 7”.
  6. One thing I liked with Linpus was an XFCE feature that let me maximize my windows totally with no decorations (like the window title area) by pressing Alt+F11. To add this feature to CrunchBang, open $HOME/.config/openbox/rc.xml and add this entry after the one with A-F3:
        
          
          
        
    

    This will not make the maximized windows cover the panel at the bottom of the screen. It is possible to make the maximized window use this area, but since I haven’t found out a way to disable the panel always being on top, there is no point in that.

    Another small problem with this key binding is that since it works by toggling the two states, a window which is maximized but decorated, will be unmaximized and undecorated by pressing Alt-F11. The solution here is to unmaximize it first and then press Alt-F11. A little clumsy, but it doesn’t happen all that often.

Surprise

I think that the default color scheme of CrunchBang looks very cool, but since I prefer black on white over white on black for everyday work, I changed the window manager theme to a light one. Later I was surprised to see that synaptic still used the default theme. It wasn’t until I ran another program with sudo that I understood. It seems like root uses this theme too and since I always run synaptic sudoed root’s theme is used.

Remaining issues

There is some stuff that I haven’t fixed yet:

  1. I get no on screen indication when I adjust the volume or mute it with the Fn-keys. Similarily I get no indication when I toggle the wifi switch. When changing the screen brightness I get an indication sometimes but not always.
  2. The wifi led is totally dead but I think there are guides for making it work.
  3. When resuming the AA1 after suspending it I get a password prompt. This feels almost totally useless since I use auto-login when starting the computer anyway. I haven’t found a setting to disable the password prompt yet.
  4. There are probably other programs that have their own font settings. But that’s mostly a question of configuring as the need arises.

Good luck!

Destination: University!

I’ve got a new job! From late May I will be working at Uppsala University in the central software development unit.

Uppsala University has launched a project aiming to bring most of the diverse university web sites into one platform. The platform will be an open source CMS called InfoGlue. I will mostly be working with implementing web components for InfoGlue.

I am looking forward very much to this, but at the same time it is kind of sad to leave my current colleagues. Since I live in Uppsala and will not have to commute by train to Kista, Stockholm, the decision was easy, though.

(Three virtual points to anyone who caught the SF reference…)

Get rid of a graphics problem in Ubuntu on Thinkpad A21P

Update 2:

David Rees has filed a bug report of this issue: https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-video-ati/+bug/799986 (see his comment further down).


Update:

I have updated this guide for Ubuntu 11.10 Oneiric Ocelot. These updates are marked with Ubuntu 11.10 where they occur.


I wanted to see if an old IBM Thinkpad A21P could be put to use and installed Ubuntu (9.10) on it. The installation went well, but when X started and displayed the login screen, the graphics were messed up.

Some googling finally solved this, but since I had to collect information from several sources, I thought I should sum it up in one post.

The problem is a known bug, and there even is a fix for the problem in the bug report, provided by Longwing. Add these lines to your xorg.conf file in the appropriate place (the Monitor section):

HorizSync 31-77
VertRefresh 50-77

Modeline "640x480" 27.96 640 656 720 864 480 480 485 501
Modeline "800x600" 43.68 800 816 928 1072 600 600 606 626
Modeline "1024x768" 71.39 1024 1040 1216 1400 768 768 776 802
Modeline "1152x864" 90.48 1152 1168 1384 1568 864 864 873 902
Modeline "1280x960" 111.82 1280 1296 1552 1736 960 960 970 1003
Modeline "1280x1024" 119.28 1280 1296 1552 1736 1024 1024 1035 1070
Modeline "1600x1200" 160.16 1600 1616 1968 2208 1200 1200 1212 1253
Modeline "1600x1200" 167.23 1600 1616 1968 2208 1200 1200 1212 1253

This is all very well if you know how to do that. I haven’t been editing the X configuration files for a while, so I actually had to look it up.

First off, we need an xorg.conf file. It’s probably located in /etc/X11, if it exists. It didn’t on my computer, but as I found out, it can be generated. In order to do that, X has to be shut down. Switch to a virtual console by pressing Alt+F1. Log in and stop gdm (the GNOME Display Manager, it manages the X displays) like this:

sudo /etc/init.d/gdm stop

In Ubuntu 11.10 it’s lightdm:

sudo service lightdm stop

Then generate the Xorg configuration file like this:

Xorg -configure

In Ubuntu 11.10 we get errors if we do not run with sudo:

sudo Xorg -configure

This generates a file called xorg.conf.new. Open it in your favourite text editor and add the configuration lines from above to the Monitor section. Save it and then try it out with:

Xorg -config xorg.conf.new

In Ubuntu 11.10 we get errors if we do not run with sudo:

sudo Xorg -config xorg.conf.new

This will present a running X session, but it will probably not show anything interesting. We only need to check that the graphics problem is gone. You can easily exit the session by pressing Ctrl+Alt+Backspace. X should run nice now, but you need to make this change permanent by copying the configuration file to the correct place:

sudo cp xorg.conf.new /etc/X11/xorg.conf

Now just start gdm again and everything should be fine:

sudo /etc/init.d/gdm start

Hopefully this can help someone :)

Edit: added some clarification.