As simple as:
tr '\r' '\n' < file-with-dos-newline.txt > file-with-mac-newline.txt
As simple as:
tr '\r' '\n' < file-with-dos-newline.txt > file-with-mac-newline.txt
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.
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:
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:
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.
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>
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
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.
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