iSync and Nokia 5310 XpressMusic

September 23, 2009

Just got one of these syncing for a colleague. Found nothing on the nokia site, tried their plugin for the 5320 – which didn’t work.
Then I tried this third party plugin, http://pyxx.org/nokia-5310-xpressmusic-isync-plugin/

Worked first time (had to close and restart iSync). Great job folks!


Dos2Unix type conversion on Mac OS

August 23, 2009

As simple as:

tr '\r' '\n' < file-with-dos-newline.txt > file-with-mac-newline.txt


Getting longtitude and latitude coordinates from the centre of a google map

August 20, 2009

Googles long/lat is degrees only and a fractional component.

This script
javascript:coord = [gApplication.getMap().getCenter().lat(),gApplication.getMap().getCenter().lng()];
output = '';
for (x in [0,1]) {
neg = (coord[x] < 0);
if (neg) coord[x] *= -1;
deg = Math.floor(coord[x]);
minr = (coord[x] - deg) * 60;
min = Math.floor(minr);
sec = Math.floor((minr - min) * 60 * 100000)/100000;
output += (x==0?'Lat':', Long') + ': ' + deg + "° " + (min < 10?'0':'') + min + "' " + (sec < 10?'0':'') + sec + '" ' + (x==0?(neg?'S':'N'):(neg?'W':'E'));
};
void(prompt('', output));

decomposed that into degrees, minutes and seconds. The output was like the bellow.

Lat: 51° 40' 23.49798" N, Long: 8° 30' 06.43386" W

I wanted it to output degrees, minutes, and then a fractional component like the below, as was required by my Garmin mapping software (I was pulling location coordinates from google maps and inserting them as waypoints/route-vias in my Garmin app for uploading to my GPS device).

N51 40.39163302364358 W8 30.10723114013672

I tweaked it to return same.

I created a bookmark on the Bookmark Toolbar of my browser, and set the code below as the target/URL.

To use it I simply click the bookmark button for it when looking at a google map, and the coordinates for the location at map centre are given in a pop-up box.

Here is my ammended version of script.

javascript:coord=[gApplication.getMap().getCenter().lat(),gApplication.getMap().getCenter().lng()];
output='';
for(x in [0,1]){
neg=(coord[x]<0);
coord[x]=Math.abs(coord[x]);
deg=Math.floor(coord[x]);
minr=(coord[x]-deg)*60;
//min=Math.floor(minr);
//sec=Math.floor((minr - min)*60*100000)/100000;
min = minr;
output+=(x==0?(neg?'S':'N'):(neg?'W':'E'))+deg+" "+(min<10?'0':'')+min+" ";
};
void(prompt('Coordinates',output));

Update: http://netsharc.wordpress.com/2007/06/11/google-maps-latitude-and-longitude/ has the original and a few tweaks.


Mac : Open Terminal/iTerm here

August 19, 2009

Using Mac OS X and browsing the file system with ‘Finder’, I often want to open Terminal or iTerm and have the default path set to the current Finder folder.

Firstly Terminal. I found a script called ‘Open Terminal Here’ at http://jo.irisson.free.fr/?p=59

This seems to suffer from an issue where two windows are opened if Terminal was not already running.

Then I started using iTerm, it has a few more/different options than Terminal. For it I found a script ‘Open iTerm Here’ at http://snippets.dzone.com/posts/show/961

This seems to suffer from a similiar issue to above, where two tabs in a new iTerm window are opened if iTerm was not already running. I tried to modify it (my first apple script attempt) but managed only to get two windows open instead of a single window with two tabs.

Then I found an update to the Open iTerm Here script at http://www.danns.co.uk/node/226

This version successfully solves the issue of the two tabs. If you are a Terminal user, I imagine it should be easy to apply the patch to the Terminal Here script, or just use this script and have it invoke Terminal instead of iTerm.

Finally, to use the script  you then need to save it as an executable app. This is fairly straightforward:

  1. Open the Script Editor application
  2. Past in the source
  3. Save it
  4. Then chose save as
  5. Selected File Format of “Application”
  6. Save it again

You can now use QuickSilver or Silverlight to invoke the script.

However, I wanted to find out if I could add a button to Finder that could be clicked to run it. I eventually found out how to do this and here is how. You can simply drag the script .app file onto the top of the Finder application, and a button is created for it there.

So, when looking at a folder, just click the new button you created and a new iTerm is opened at the current path.

Lastly, I wanted to change the icon from the default. I wanted to use the iTerm icon. To do this, follow these steps to copy and paste the icon from the iTerm application:

  1. Go to Applications
  2. Navigate to iTerm
  3. Select the More Info… button
  4. Find your iTermHere.app and do the same
  5. Click the small icon at the top of the iTerm more info window and click cmd-c (apple-c, the shortcut to copy text)
  6. Click the small icon at the top of the iTermHere.app more info window and paste! (apple-v)

That’s it, you now have the script as an app, with a button in the Finder windows, and a nice iTerm icon.

Many thanks to all the folks involved in creating and refining these scripts I found, as linked to above.

Enjoy.


Clearing the MySql Logs

August 19, 2009

mysql> show master logs;

+------------------+------------+
| Log_name         | File_size  |
+------------------+------------+
| mysql-bin.000023 | 1074039776 |
| mysql-bin.000024 | 1023334365 |
| mysql-bin.000025 | 1073742100 |
| mysql-bin.000026 | 4254255    |
| mysql-bin.000027 | 117        |
| mysql-bin.000028 | 98         |
+------------------+------------+
6 rows in set (0.00 sec)

mysql> purge master logs to 'mysql-bin.000028';
Query OK, 0 rows affected (10.35 sec)

mysql> show master logs;
+------------------+-----------+
| Log_name         | File_size |
+------------------+-----------+
| mysql-bin.000028 | 98        |
+------------------+-----------+
1 row in set (0.00 sec)

mysql>


On demand “Tailing” of a database log table: select the last x records

August 19, 2009

Recently I had to monitor some data being output to a log table while an application was running.

The log table was quite large, and being written to constantly and also by portions of that system I wasn’t interested in.

So I only wanted to see the 10 or 20 most recent rows / records written.

There are quite a few ways to do this, but this is what I threw together. It assumes the ordering is based on an incrementing unique record id.

select count(*) into @rowcount from prodlog; select id, source_id, created_on, message from prodlog where id > (@rowcount-20) order by id;

I put the latest count of records in the table into a temporary variable. I then use that figure, minus the number of rows I want to see, to offset into the data.

Note that if the count of rows and row ids don’t match (e.g. because you used truncate) the above method will fail.

In this case you may use:

select id into @last_id from prodlog order by id desc limit 1; select id, source_id, created_on, message from prodlog where id > (@last_id-20) order by id;

This is still potential issues with this, for instance you may get less than you expected if there are gaps in the id sequence.

But it sufficed for my needs at the time :)


Hash/Pound/# character and links that don’t change the URL

August 18, 2009

An interesting alternative to href="#thisgoesnowhere", which causes the insertion of the “#” character and any following characters (“thisgoesnowhere” in this silly example) to the end of the URL, is to use a null javascript link target.

href="javascript:void(0);"

In this case, your onclick or other events are treated as before, but your page URL hasn’t needlessly changed.


VNC server : Fatal server error: could not open default font ‘fixed’

August 18, 2009

Trying to run vnc-server recently on a debian system, I ran into the following issue:

cat .vnc/debian-dev\:1.log
14/08/09 14:40:01 Xvnc version 3.3.7 - built Dec 30 2006 12:50:35
14/08/09 14:40:01 Copyright (C) 2002-2003 RealVNC Ltd.
14/08/09 14:40:01 Copyright (C) 1994-2000 AT&T Laboratories Cambridge.
14/08/09 14:40:01 All Rights Reserved.
14/08/09 14:40:01 See http://www.realvnc.com for information on VNC
14/08/09 14:40:01 Desktop name 'X' (debian-dev:1)
14/08/09 14:40:01 Protocol version supported 3.3
14/08/09 14:40:01 Listening for VNC connections on TCP port 5901
Font directory '/usr/share/fonts/truetype/' not found - ignoring

Fatal server error:
could not open default font 'fixed'

I solved the issue with some apt-get for dependancies as per below

apt-get install xutils xbase-clients xfonts-base xfonts-75dpi xfonts-100dpi

Ref:  http://www.debianhelp.org/node/5720


QuickSilver-esque shortcuts application on Ubuntu Debian GNU/Linux

October 6, 2008

Some of my colleagues have Apple Macs and use an application called ‘Quick Silver’ for managing frequently use application/scripts/text files/notes/ims/etc.

I was impressed with what one could do with it and began looking for something similar on Ubuntu.

There is a clone for Gnome called Gnome-Do [ http://www.gnomedo.com ] that lives up to the task pretty well from what I can gather so-far. There are some good updates in the ‘Intrepid Ibex’ release (8.10) that are not in the ‘Hardy Heron’ release (8.04), such as a more complete and useful preferences menu, more plugins and managing them individually through the applications preferences.

Try it out, after installing gnome-do, you need to set it up to launch at gnome login (easily done via the preferences in the intrepid version). Then you can invoke it with the SUPER+SPACEBAR short-cut.


Using MySql with Jahia on Debian GNU/Linux

October 6, 2008

After installing Jahia today, I wanted to use the MySql database instead of the default HyperSonic. I am currently using MySql for other purposes and want to have a look at accessing the Jahia database to re-use content.

Initially when I created the ‘jahia’ database in mysql and granted permissions to the Jahia user, Jahia reported:

"This database doesn't seem to support extended charsets."

Dropping the database and recreating it with a unicode dataset sorts this little niggle out.

mysql> create database jahia character set = utf8;