Category Archives: Tech

Category for technical information

Useful Mac Shortcuts

Taking screenshots

Command-Shift-3:                    Take a screenshot of the screen, and save it as a file on the desktop
Command-Shift-4,                    then select an area: Take a screenshot of an area and save it as a file on the desktop
Command-Shift-4,                    then space, then click a window: Take a screenshot of a window and save it as a file on the desktop
Command-Control-Shift-3:    Take a screenshot of the screen, and save it to the clipboard
Command-Control-Shift-4,    then select an area: Take a screenshot of an area and save it to the clipboard
Command-Control-Shift-4,    then space, then click a window: Take a screenshot of a window and save it to the clipboard

Will add more as I discover them 😉

Viewing HSQLDB In Grails App

I have been looking over the net for a simple way to visualise the in memory data “hsqldb” of a grails app without moving to a real db to solve it. It turns out that grails has always had a built in visualizer/manager that can easily be started when you run up the dev environment. All you have to do is add these lines to the init function in your bootstrap.groovy file:

import org.codehaus.groovy.grails.commons.GrailsApplication
import grails.util.GrailsUtil
import grails.util.Environment

class BootStrap {

    def fixtureLoader

    def init = { servletContext ->

        String[] databaseManagerOptions = ['--url', 'jdbc:hsqldb:mem:devDB'];

        if (GrailsUtil.environment == GrailsApplication.ENV_DEVELOPMENT) {

        if (GrailsUtil.environment == GrailsApplication.ENV_TEST) {

     def destroy = {

The difference is only really the import or environment and the two lines for the database manager swing component. After you do this you app will then load up the manager tool every time you run your app in development mode.

Changing Safari’s Default Search Option

I have recently brought a new mac and am loving if so far 😉 . However, there is already something that has suprised me?? It is the fact that there is only the one option for searching in the safari browser and it is not changable :O . The reason it surprises me, is because so much junk criticism is thrown the way of Microsoft for making the default search their own and yet here I am looking at the coolest OS and wondering what is so different with this “unchangeable” google search? At least with Microsoft’s Internet Explorer you could change the search within a few clicks.

Well, enough with the winging 😉 because it only took me a few mins to find a solution called Inquisitor . This is a pretty cool app considering it adds functionality like Opera where you get the auto complete search popup as you type. It also gives you the ability to edit the default search engine in the advanced preferences of safari, and you will notice the difference.

Problems Mounting Drives Under Linux

Lately I have not being having much luck with mounting external usb drives in my Ubuntu 8.04 install. All that seems to happen, is that the drive will appear under “computer” but that is about as far as it goes. When I click on the external drive it just errors and does not open. So a solution that I discovered on the net uncovered part of the solution but I will attempt to put it together for you 😉 .

First of all you have to work out where you drive is mounted and what it is called. Under the Ubuntu distro, they are located under eg. /dev/sdb or something similar to that. The only thing that will change is the letter on the end. If you are not sure of which one you external drive is, you can unplug the drive then run this command :

ls -la | grep sd

Then plug the drive back in and run that same command to see what drive appears. This will tell you what the drive identifier is. Another way you might be able to find this information is by running the command :

dmesg | tail -n 50

This command will show you the tail end of the error message log, so from this you may also be able to determine what the drive identifier is from the message :

[ 2159.443365] FAT: bogus number of reserved sectors
[ 2159.443371] VFS: Can't find a valid FAT filesystem on dev sdb1.
[ 2159.488509] FAT: bogus number of reserved sectors
[ 2159.488515] VFS: Can't find a valid FAT filesystem on dev sdb1.
[ 2159.661736] FAT: bogus number of reserved sectors
[ 2159.661742] VFS: Can't find a valid FAT filesystem on dev sdb1.

As you can see from this message, it is telling me that it is trying to mount my drive as a VFAT system which is incorrect as it is actually NTFS. Now that this has identified my problem I can run a few commands to see if I can get it mounted. First I will make sure it is unmounted before I try to remount the file system:

sudo umount /dev/sdb1
umount: /dev/sdb: not mounted

That was just telling me that is was not already mounted, now I will create a directory for the file system to be mounted into. This can be anywhere you like but the standard spot in ubuntu is “/media/”. So next I run the command :

sudo mkdir -p /media/external_drive

Then if I am lucky all I have to do is mount the drive using :

sudo mount -t ntfs /dev/sdb1 /media/external_drive

Now you should be able to navigate to the folder you just created and view/edit the contents of the drive. If this still failed, try running the original dmesg command and see if you can track down what the problem is.

Normalizing Your Music

Listening to un-normalized music can be a painfull thing, considering one second it will be a normal volume and the next you will be deaf :omg . Anyway, I had a bit of a look on the net for a solution and by using Mp3Gain this is actually a pretty simple solution to fix.

Basically, Mp3Gain has the ability to normalize the volumes of all music without actually editing the mp3 files. It does this by analysing the levels and applying tags to the files which lets the player know how much to increase/decrease the volumes. The good thing is that it can do this over albums, to make the files pretty generic in their levels. Another good thing is that this can be done with a one liner 😉 . First install then run:

sudo apt-get install mp3gain
find . -iname '*.mp3' -execdir mp3gain -a -k "{}" + &

What that command is doing :

    find . -iname ‘*.mp3′
  • searches for all mp3 files.
  • -execdir
  • executes the command on a directory basis.
  • "-a"
  • tells mp3gain to use Album gain instead of Track gain (very important!)
  • "-k"
  • tells mp3gain not to increase the volume with no distortion.

For windows users this is a lot simples considering all you have to do is open the gui and tell it to run! 😛 .

Using Oracle Regular Expressions

Something a little more simple this time, or so i thought 😉 . Anyway, what I was trying to do was convert the first letter of every word into uppercase and the rest into lowercase. Immediatly I thought this would be a job for Oracle Regex. I started to have a look at some of the documentation and slowly noticed that this might not even be possible by directly using regular expressions, or more specifically, Oracle’s implementation of them.

Basically, the problem was that there are only 4 types that can be used and they are seperated info functions:


More info on this from the earlier link!!

To cut a long story short, oracle has not implemented all of the functionality of regular expressions, that is available to os’s like linux/unix. So my thought of just using regex_replace and doing an uppercase on the first letter group could not be done. However, there is a function provided by oracle which will do that automatically with no regex :

SELECT INITCAP('don talbert jones') FROM DUAL;

This solved my initial problem of uppercasing the names, but I was thinking what if you wanted to do something more complicated like initcap the names and re-arange as well:

                 (INITCAP (str),
                  '5, 1 3'
  FROM (SELECT 'first middle last' str FROM DUAL)

This will work for strings that are names only and no special characters eg “hyphen”. A more robust approach would be :

SELECT REGEXP_REPLACE( INITCAP (str), '([^a-zA-Z]*)([a-zA-Z]{1})([a-zA-Z]*)([^a-zA-Z]*)', '1' || '2' || '3' || '4' )  RESULT
FROM (SELECT '-,riyaz ahm:ad khan' AS str FROM DUAL)

This is the breakdown of what this version will be doing:

  • Search for anything that is not a character and any number of them: ([^a-zA-Z]*)
  • Followed by a single character: ([a-zA-Z]{1})
  • Then any character and any number of them: ([a-zA-Z]*)
  • Finally, anything other than a character and any number of them: ([^a-zA-Z]*)

These groupings represent the groupings in order from 1-4, so if you wanted to change the order of the characters or even remove the non characters then you would just manipulate  the numbers.

Overall, I am a little disappointed that the functions like U “convert uppercase” was not included in the original implementation but all I can do is winge 😉 .

Convert Video for Xbox 360

This is just a walk through on how I have managed to convert video for playback on the 360 from my Ubuntu Hardy install. Basically, I could not be bothered setting up the whole media center and all of that type of stuff. I did gave uShare a “very” quick go but could not get the xbox to connect so I gave up. Pretty soft of me wasnt it 😛 .

Anyway, after that effort I went searching for what the xbox will actualy support in the way of codecs and found some usefull information on the support site. This had me thinking “sweet” considering most of my shows are already in avi. But, as usual it was not going to be this simple. I spent ages trying all of the different codecs and kept getting nothing. The xbox would either show the red cross of death, play audio and no video or the other way round. I spent ages trying all of the different converstion, including video codecs and audio codec combinations. However, after all that stuffing about I noticed on the support site that the video/audio and extenstion information had to match, as well as the container. Now, I am not sure if this is something that everyone knows but I personally had no idea about the container??

Armed with this new information I tried the H.264 codec with the AAC audio and MPEG4 container  but to no avail. So, I just went straight for the wmv+wma+asf combination and omg it worked. Now I know I should have tried the other combinations, as they are better. But after hours of frustration I was totally over the whole process and not even remotely interested in watching the show that this was all in aid of :( . Ok, so I will show you the command that I came up with and it “should” convert any format over to the required xbox format:

mencoder "BBC-Planets_9.avi" -o "BBC-Planets_9.wmv" -of lavf -lavfopts format=asf -ovc lavc -lavcopts vcodec=wmv2 -oac lavc -lavcopts acodec=wmav2

You should already have mencoder installed but if not just :

sudo apt-get update
sudo apt-get install mencoder

Well just a brief description of the code is :

mencoder "BBC-Planets_9.avi" -o "BBC-Planets_9.wmv"

This section will take the input file of type avi and output to file type wmv. However, just remember this is only a name and does not have any smarts based on the extension. The next section is to do with the container that I was talking about earlier :

-of lavf -lavfopts format=asf
  • The “-of” stands for output format
  • The “lavf” is the codec you have chosen to do the conversion for you
  • “-lavfopts” is the options command specific to that codec “lavf”
  • “format=asf” and this is creating the video using the container asf

Next is the output video codec information :

-ovc lavc -lavcopts vcodec=wmv2
  • “-ovc” stands for output video codec
  • “lavc” is the library you have chosen to transcode you video, This is chosen based on the format you need.
  • “-lavcopts” the options command specific to lavc
  • “vcodec=wmv2” use lavc’s wmv2 library to convert the video to wmv

The final part is the audio codec information :

-oac lavc -lavcopts acodec=wmav2
  • “-oac” stands for output audio codec
  • “lavc” is the library used for transcoding to this audio type
  • “-lavcopts” is the options param for lavc
  • “acodec=wmav2” tells the transcoder to convert the audio to the type wma

Now that is pretty much it. I did spend a lot of time looking though the forums but most of the solutions did not work. All of the information needed was from using the man page of mencoder and the xbox format requirements on the page listed earlier. At some stage I would like to have a go at getting some of the other formats to work as well as having a look at vpass=2 which should make the video a lot better. When I do I will list the new command on the page for you guys.


Hey Again, this is just an update that might be useful for getting a little better resolution on the files

For first pass run this one:

mencoder -noskip "BBC-Planets_7.avi" -o "BBC-Planets_7_1.wmv" -of lavf -lavfopts format=asf -ovc lavc -lavcopts vcodec=wmv2:vbitrate=5000:vpass=1 -passlogfile "libvcodecstats.txt" -oac lavc -lavcopts acodec=wmav2

For second pass run this one:

mencoder -noskip "BBC-Planets_7.avi" -o "BBC-Planets_7_1.wmv" -of lavf -lavfopts format=asf -ovc lavc -lavcopts vcodec=wmv2:vpass=2 -passlogfile "libvcodecstats.txt" -oac lavc -lavcopts acodec=wmav2

Note, you might also want to check out different vbitrate settings?

Adobe Air in Ubuntu Hardy Herron

I had recently started using Twitter as suggested by a friend and it seems pretty cool. But, because of its fast and lite nature I needed some “pretty” way of posting and tracking my friends on it. I did the usual thing of searching the net for gnome packages and some were ok, but most were lacking and average. Anyway, I had a look for a similar thing on my windows machine, and came across spaz. This is a “widget” type install for the new Adobe Air . The adobe air suite allows widgets like spaz and analytics reporting suite to sit on the desktop, similar to the new vista style widgets.

Anyway, enough crapping on… The cool part is that, Adobe has released a package for linux :) . This is sweet news that they have taken the time to develop for linux, it is only in the Alpha atm but should be in beta very shortly. Here is a pic that shows the Analytics plugin and the Spaz one :

The install is pretty straightforward:

  • Download the deb package from adobe
  • Run these commands on the downloaded file :
  • chmod +x adobeair_linux_a1_033108.bin
    sudo ./adobeair_linux_a1_033108.bin

The package management system should take over from here, and .air packages should be installed with a double click from then on.

The plugins that I think are pretty sweet are here :

Ubuntu and Wireless Dropout

It had been a while since I had messed with wireless. But since I just brought a fancy new antenna, it was time to investigate some exciting new stuff. Well, as with most things I find exciting they usually end up costing me heaps of time :( .

Once I had setup the new antenna I wanted to have a look at the performance difference, which is a bit flaky from the network manager. But I noticed as I started messing with some commands something happened which was unexpected. I started getting the dreaded “wireless dropout” that occurs infrequently at about 20 second intervals just to piss me off. I tried to retrace my steps to find out what I had changed and ended up spending a whole day looking for the solution. It turns out that with the “cool” new commands that I had learned to do things like:

  • restart the network interfaces
  • lift the interfaces up and down
  • list other networks in my area and
  • finally, one to show the status of my own network

Even though it was nice to be able to type a few words and have the interfaces restart afresh I was leaning toward this being the problem. Then, I remembered that orignally when I was having these sorts of problems in the begining, I downloaded an app called Wicd! This was the solution for my problems orignally and funnily enough did the same again 😉 .

Well, there were some good things to come from this “journey”?? Not sure what they were, but here is a list of the commands that I found and are pretty handy! Also, remember Wicd might also be a simple solution for you?

Show status of “my” wireless interface: ‘iwconfig ath0

xxxxxxxx@HAL:~$ iwconfig ath0
ath0    IEEE 802.11g  ESSID:"xxxxx"  Nickname:""
          Mode:Managed  Frequency:2.442 GHz  Access Point: 00:xx:xx:xx:xx:8B
          Bit Rate:36 Mb/s   Tx-Power:18 dBm   Sensitivity=1/1
          Retry:off   RTS thr:off   Fragment thr:off
          Power Management:off
          Link Quality=58/70  Signal level=-36 dBm  Noise level=-94 dBm
          Rx invalid nwid:52311  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

Show list of all wireless broadcasts within range: ‘iwlist ath0 scan

xxxxxxxx@HAL:~$ iwlist ath0 scan
ath0      Scan completed :
          Cell 01 - Address: 00:xx:xx:xx:xx:8B
                    Frequency:2.442 GHz (Channel 7)
                    Quality=59/70  Signal level=-36 dBm  Noise level=-95 dBm
                    Encryption key:on
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
                              9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
                              48 Mb/s; 54 Mb/s
                    IE: IEEE 802.11i/Encryption here :)
                        Group Cipher : TKIP
                        Pairwise Ciphers (1) : TKIP
                        Authentication Suites (1) : PSK
          Cell 02 - Address: 00:xx:xx:xx:xx:78
                    Frequency:2.442 GHz (Channel 7)
                    Quality=28/70  Signal level=-67 dBm  Noise level=-95 dBm
                    Encryption key:on
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
                              9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
                              48 Mb/s; 54 Mb/s
                    IE: IEEE 802.11i/Encryption here :)
                        Group Cipher : TKIP
                        Pairwise Ciphers (1) : TKIP
                        Authentication Suites (1) : PSK

Restart all network interfaces

xxxxxxxx@HAL:~$ sudo /etc/init.d/networking restart

Vpn setup using PPTP

A client I have been working on recently asked me to setup a Vpn for them to work remotely and still maintain security. Now I knew the definition of Vpn connections but had never needed to implement one. What I did know was that there are two main configurations: Microsofts PPTP and IpSec but that was about as far as it went 😛 . So I did some reading and it turns out that the fastest and most used is PPTP for remote connections. However, IpSec seems to be the obvious choice for bridging locations such as office_1 to office_2. The security features of PPTP are not that strong, due to the high level of abstraction before the encryption takes place. IpSec is a much lower and “raw” layer which has much stronger security features, but suffers on speed because of this.

In this case I will be only using remote connections, so PPTP “seems” the way to go?? Anyway, it seemed a sinch to setup the user connections on the “Billion 7404 Vgp(M)” having only to select username, pass and some default configuration settings like: Encryption type; session mode and timeout. At this stage I was thinking how easy 😉 . To my suprise it was not this easy!

In this case I was not connecting to the vpn using Win pc’s but Mac’s instead. Mac’s have a built in Vpn client that supports PPTP and IpSec connections under “Internet Connections”. This made it a lot easier since I did not have to install a client. So I opened the vpn client and tried to connect to the network and found that it would not connect?? This is due to a bug in the mac vpn client which does not support “statefull” connections ( Bug ID# 4581573).

So with this new info i went back to the configuration settings for the vpn and made sure the settings were :

  • Encryption Enabled
  • Force 128bit
  • Force Stateless

When I tried the connection again all was good and I was connected. However, there still remains some strange behavior. Once connected I cannot access the internet using the Vpn and I also cannot connect to the servers using names, but only IP’s. This is not a show stopper but it is a little annoying as the clients will only be able to do work without accessing the internet. To me this looks like a simple dns problem but I have no idea how to correct it. I have submitted a post to the billion forum and hope they will resolve the problem for me, but I will keep playing in the meantime to see what is going on.

I am also wondering if this is the same problem that I am having with my linux box? I can make the connection to the vpn network and ping/connect to the server, but I have no access to anything else on the network. I cannot ping any machines and connect to the smb shares. So basically I can do nothing when connected unless i use a mac. I have not had a chance to try a pc but will see if i can have a go next week to see what happens?

So my current status is: I got the vpn setup relativly easy and can connect using my mac but not my linux box; when connected I can access the shares using the mac but cannot access the internet and the linux box cannot do anything. So, hopefully billion lends a hand and tells me what I need to do to get this working sweet?