May 01, 2016

Geotagging like it's 2016

Last time I dabbled in the art of geotagging was back in 2008 when I wrote about it here. It was quite a laborious task back then with having to manually specify on a map where a photo was taken #nothanks

Thankfully things have moved on slightly since then and smartphones and some digital cameras (the rugged/outdoorsy type) automatically add locale information into each shot utilizing built-in GPS devices. However more often than not, high-end cameras do not have this capability.

Hiking anyone?
I have this thing whereby I do something, like it and go all out and buy the kit. Thankfully eBay is at hand so I don’t need to pay full price for some of my techno geek gadgets that I "need" (helps settle that internal struggle of wanting all things beepy and squeaky versus the do I really need it question).

Anyway bought a mint condition Garmin eTrex 10 on eBay for around 60 bucks. These are very capable GPS units creating accurate track logs in GPX format.

So off on my hike I went, a track log being created as I walked (think Hansel and Gretel and those bread crumbs), taking random snaps with my camera along the way. At the end of it I was left with a bunch of photos and a GPX track file.

Off-topic but I toyed with the idea of getting a GPS device with maps built in but you really don’t need to; learn how to navigate using a grid reference system. Many GPS units like the eTrex 10 can be switched to display grid units compatible with a physical map instead of longitude and latitude coordinates.

It’s all about the metadata 
It’s certainly not all about you! That selfie you just took doesn't just contain your ugly mugshot beautiful you! A modern camera/smartphone will also capture a bunch of other stuff and include it in the image including when the photo was taken, make/model of camera used, whether or not the the flash was on, image orientation, etc. and if it is a GPS-enabled device (and has a signal), where the photo was taken #scary

That "stuff" (technical term for metadata) is stored in a standard format known Exchangeable image file format or Exif within the image file itself and can be manipulated without interfering with the actual image.

Hello Exiftool!
There’s a bunch of software out there that can manipulate an image’s metadata including where the photo was taken. Exiftool is one of them and it’s free and open source. In fact some of the paid software I’ve seen such as HoudahGeo bolt onto this tool so if you already have a GPX track, why do you need to pay for such tools (yep, you don’t!)

Exiftool can read in a GPX track file and based on the time and date of a photo, it can determine where on the track it was taken and update the image's metadata with its locale information accordingly.

With Exiftool installed on my Mac and the GPX track file (named mytrack.gpx) and photos in the same folder, I can execute the following to geotag my photos:
exiftool -P -geotag mytrack.gpx .
If the camera’s clock was set to a different timezone, use the geotime tag to specify that. I took my camera to the UK and had the camera time set to GMT (UTC+0). The following worked for me to geotag my photos once I returned:
exiftool -P -geotag mytrack.gpx '-geotime<${DateTimeOriginal}+00:00' .
For more information on geotagging with Exiftool see http://cpansearch.perl.org/src/EXIFTOOL/Image-ExifTool-9.90/html/geotag.html

Top Tip #1: Yep it’s therefore imperative ideal that the camera’s date and time is up to date. If this is not the case, then you probably want to fix this first. Good luck with that! Ha. Seriously, you can use Exiftool for that too. By the same token, the date and time on your GPS device should also have been set correctly when the track was recorded.

Top Tip #2: While Exiftool won't overwrite your original photos (at least by default), it will append _original to the filename and it’s rather annoying in case you need to do a quick restore. I therefore suggest you make a quick copy the entire set of images/image folder first.

January 28, 2014

CentOS 6.4 Install Issues

I've always liked to build things (especially when there's no real purpose) and that's why I knew my life would be once again more complete with a dedicated Linux box. You think I'm joking right?? Wanting a box that consumes less power, small but still with enough horse power to actually do something useful, I found a cheap Dell Optiplex FX160 on eBay.

After a bit of research, it seems the distro of choice for Linux pro wanna-bes these days is CentOS. With no CD drive on the FX160, I downloaded the Live CD version (CentOS-6.4-x86_64-LiveCD.iso) and used the provided livecd-iso-to-disk script on another Linux system to create a bootable USB install disk.

Unwanted X Window System: My first issue was how to not install X. It seems it's not possible using the LiveCD version of CentOS 6.4. So I tired the Minimal version (CentOS-6.4-x86_64-minimal.iso) which allowed me to avoid X however the equivalent livecd-iso-to-disk script isn't contained within the image so you'll have to download both images anyway.

Bad drive assignment: The next annoyance was that my newly created "Minimal" USB install disk was being assigned sda and that is kinda bad. This didn't happen with the LiveCD version. With the system disk being assigned sdb, I was greeted with a kernel panic once I tried to boot the new system without the USB install disk plugged in.
Resolution came when I swapped the USB install disk for one of those 4-in-one card readers with the Minimal image now installed on an SD card. The installer assigned the card reader something other than sda (in fact it had several drives assigned--none of which were sda) and so the system booted flawlessly after installation. Incidentally it also booted flawlessly once I plugged in the old USB install disk as it was no longer being assigned sda.

January 21, 2014

A Verizon iPhone 5S on Vodafone UK

My last rant blog post was about how my new iPhone 5S A1533 Verizon model (ME344LL/A) worked on AT&T out-of-the-box (i.e. no unlocking required). Here it is with a Vodafone UK SIM card in it connected to their 3G network. It looks like it would work on their 4G network too but I couldn't test as I'm a pay as you go customer and Vodafone do not yet support 4G for cheap bastards non-pay monthly customers.

iPhone A1533/CDMA (ME344LL/A) model on Vodafone UK
Note about Vodafone 4G: Vodafone UK operate their 4G network at the 800 MHz frequency or LTE band 20. Like the iPhone A1457 model sold in the UK, my iPhone A1533 model supports that same LTE band. Again, with Vodafone not supporting 4G for pay as you go customers, I couldn't test it out.

http://blog.vodafone.co.uk/2013/11/05/vodafone-4g-signal-and-frequencies-explained/

http://en.wikipedia.org/wiki/List_of_LTE_networks

http://www.apple.com/iphone/LTE/

Note about Vodafone Pay as you go: If you plan an iPhone on this Vodafone Pay as you go then you'll have to update the APN settings each time you insert that Vodafone SIM (it doesn't save the settings). Within the iPhone Settings screen, select Mobile (or Cellular if your phone is set to US English), and then Mobile Data Network. Within each APN field (there are three of them), change it from wap.vodafone.co.uk to pp.vodafone.co.uk

December 10, 2013

One iPhone for the Price of Two

One iPhone for the price of two. That’s the price it can cost you when you leave your iPhone at a bar. I am still waiting for that honest guy/gal who found it to return it to me.

Now iPhone-less and having the need to buy a replacement device at full cost, I decided to buy an unlocked device as I travel to the UK occasionally and have a prepaid Vodafone UK SIM card.

Buying an unlocked iPhone was easier said than done. Here in New York City they disappear almost the day they arrive as all the tourists snap them up to take home. Ordering online also wasn’t possible as the delivery date was after I would have crossed the pond already for the Christmas holidays.

With it being a Sunday, a day when Apple Stores do not receive new stock and not wanting to wait, I consulted an in-store employee. She said that I should buy the Verizon model. After further discussion and a brief in-store Google search, I did just that. I now have an iPhone A1533/CDMA (ME344LL/A) model (i.e. designed for the Verizon network) connected to AT&T with LTE reception:

iPhone A1533/CDMA (ME344LL/A) model on AT&T LTE

In layman's terms I bought a full priced iPhone 5S Verizon model, went home and simply swapped out the SIM card. No unlocking required.

Essentially there are two reasons why this is possible: The first is that the A1533/CDMA model supports both CDMA and GSM networks as well as the required AT&T LTE bands:

Model A1533 (CDMA)*: CDMA EV-DO Rev. A and Rev. B (800, 1700/2100, 1900, 2100 MHz); UMTS/HSPA+/DC-HSDPA (850, 900, 1700/2100, 1900, 2100 MHz); GSM/EDGE (850, 900, 1800, 1900 MHz); LTE (Bands 1, 2, 3, 4, 5, 8, 13, 17, 19, 20, 25)
Source: http://www.apple.com/iphone-5s/specs/

The second is that the device is unlocked out of the box. This is due to the FCC mandating all LTE devices for a specific band that Verizon are now licenced, have to be unlocked:

No licensee may disable features on handsets it provides to customers, to the extent such features are compliant with the licensee's standards pursuant to paragraph (b) of this section, nor configure handsets it provides to prohibit use of such handsets on other providers' networks.
Source: http://www.law.cornell.edu/cfr/text/47/27.16

LTE reception on AT&T: As long as you are in an LTE area, the iPhone Verizon model supports the required AT&T LTE bands. Your AT&T account only needs to be provisioned for an iPhone 5S (or actually maybe just an LTE capable device).

My AT&T account wasn’t as a few days earlier I had reported my phone as stolen and provided them with the IMEI of a replacement phone I was using at the time (a Nokia Lumia 520, a non-LTE capable device).

With my Verizon iPhone showing 4G in the corner and not LTE, I called AT&T and provided them with the IMEI number. Several moments passed while he searched for the correct data plan for my iPhone. He then asked if it was a Verizon model to which I reluctantly replied with yes. I presume they could tell from the IMEI number (my new Verizon iPhone starts with 35 whereas my old AT&T iPhone started with 01). He said that he wasn’t sure if I would be able to receive LTE reception as my phone wasn’t designed for the AT&T network however just as he said that my iPhone switched from showing 4G in the corner to LTE. I didn’t even have to power cycle.

LTE abroad: If you’re thinking of buying the same Verizon A1533/CDMA model here in the US for use abroad and wanting to get LTE reception, you should first review http://www.apple.com/iphone/LTE/ together with http://en.wikipedia.org/wiki/List_of_LTE_networks. I plan on using it on Vodafone in the UK in a few weeks and it seems that it may be compatible. Hopefully I can soon report positively on this.

More information: There's plenty of this kind of stuff on the web however I personally found these two links pretty helpful:
http://apple.stackexchange.com/questions/104166/can-a-verizon-iphone-5s-use-t-mobile-lte
http://forums.macrumors.com/showthread.php?t=1637205

September 07, 2010

Botched iPod Touch Repair

I guess I should keep this blog entry short as I essentially botched the repair (i.e. it’s literally now a brick not even good for a door stop). So what’s the point of me even writing this? Well I think it’s worth warning the world of what can happen when you try and play MacGyver.

So what was wrong with your iPod Touch? Well basically a great big grey blob on the screen:


How did that happen? I don’t know. I looked after it quite well I thought.

What did the Apple guys say? Well first it was a 1st generation so it being out of warranty, I didn’t expect much. Anyway I took it along to my local Apple Store on Zurich's Bahnhofstrasse and was told it couldn’t be repaired as the screen wasn’t removable. Not sure why as I later replaced it myself (albeit it's now a brick). They did however offer me 10% off a new one but at the time I thought nah, not paying 300 and odd francs for what is in effect going to be the cost of repair. To their defence, I later tought that's quite good of them. One thing I remember was how the guys Apple were quite bewildered about how big and perfectly round the blob was. Apparently they’d never seen anything like that before!


So what did you do next? Got back home and found DirectFix.com - a site offering replacement iPod components. They shipped me a replacement LCD screen for around $30 including postage. Great I thought. Should be easy enough. Apart from getting the cover off it was. There’s plenty of videos on YouTube. Photo below shows old and new side by side. Notice the funny coloured blob on the top (original) screen:


My conclusion: Don’t try it at home kids. One thing I liked about the 1st generation was its ability to charge over Firewire (using my Blaupunkt iPod adaptor in the car for example). It also looks like I won’t be watching any iTunes rented movies for a while on my television set. I used the Touch with an older, what’s labelled 'iPod' Universal Dock/model A1153 which has an S-Video connector. It worked well as I have an older CRT television and the Apple TV is no use with its HDMI and component outputs. Oh well. I enjoyed it.

Above: My iPod with the grey spot before I attempted a screen exchange.

June 06, 2010

Using Solaris 10/09 Virtual Appliance with VMWare ESXi

Sun have released Solaris 10/09 as Virtual Appliance. However it's not readily usable with VMWare ESXi Server 4.0 without a bit of tweaking. So in a nutshell, here's how to get it working:
  1. Use the VMWare vSphere client to create a Solaris 10 VM and export it as an OVF appliance. Modify the config file within this new appliance and replace the disk file with the one downloaded as part of the Solaris OVF appliance download from Sun's website here.
  2. Use the VMWare OVF Tool (available here) to convert the now modified OVF appliance to VMWare.
  3. Start the VM and modify some boot config files so that the VM can start correctly.
It was these two articles that got me going with this:
http://communities.vmware.com/message/907527
http://www.mail-archive.com/opensolaris-discuss@opensolaris.org/msg35493.html

Step 1 in detail

The OVF config that comes as part of the Solaris Virtual Appliance download throws up a bunch of errors when using VMWare OVF Tool:
- Line 8: Unsupported value 'http://www.vmware.com/specifications/vmdk.html#sparse' for attribute 'format' on element 'Disk'.
Give up trying to fix it. Within the VMWare vSphere Client tool, create a new Solaris 10 VM (with a tiny disk) and export it as an OVF appliance. Modify the OVF config file as part of this new appliance and replace the disk file with the one downloaded as part of the Solaris OVF appliance download. The config file is an XML file and it's not that difficult to work out what should be where.

I guess you could either move the Solaris disk file (downloaded as part of the Solaris OVF downloaded) to the directory containing newly create 'template' OVF, or replace the existing OVF config file with the 'template' OVF. I think I did the later. 

Step 2 in detail
Once you have a compatible OVF appliance ready you should be able to run the VMWare OVF Tool and have that migrate the appliance to your ESXi server. Something like the following should do it:
C:\Program Files\VMware\VMware OVF Tool>ovftool.exe --datastore="external_storage" --network="VM Network" "c:\TEMP\Solaris10_1009_virtual_image\solaris.ovf" "vi://root:password@myesxiserver"
If it worked then you should see the following:
Opening OVF source: c:\TEMP\Solaris10_1009_virtual_image\solaris.ovf
Warning: No manifest file
Opening VI target: vi://root@myesxiserver/
Target: vi://myesxiserver/
Disk Transfer Completed
Completed successfully
Step 3 in detail
Unfortunately starting the VMWare as is will produce the following:
The issue is that the boot device has changed and both /boot/solaris/bootenv.rc and /etc/vfstab need updating aswell as performing a reconfiguration boot.

1. Start the VM and at the grub prompt, enter fail-safe mode and allow the root file system to be mounted as read/write under /a.

2. Identify the new device name using the format command and get ready to use vi. You can brush up your vi skills here. Mine was /pci@0,0/pci15ad,1976@10/sd@0,0--so replace where necessary from now on. Also vi may not display correctly so fix the terminal type with the following command:
# TERM=sun-color; export TERM
3. Now edit /a/boot/solaris/bootenv.rc and update the line that starts with setprob boothpath so that it reads:
setprop bootpath '/pci@0,0/pci15ad,1976@10/sd@0,0:a'
4. Once you've done that update the boot archive:
# bootadm update-archive -R /a
5. Then edit /a/etc/vfstab (making a copy first) and modify the line mounting the root file system so instead of /dev/dsk/c0d0s0 and /dev/rdsk/c0d0s0 it reads the following absolute paths. Do not forget to suffix a: and ,raw respectively.
/devices/pci@0,0/pci15ad,1976@10/sd@0,0:a /devices/pci@0,0/pci15ad,1976@10/sd@0,0:a,raw / ufs 1 no -
6. Now we need to force a reconfiguration boot so that the system recreates the /etc/path_to_inst file that contains physical device to logical instance mappings.
# touch /a/reconfigure
# reboot
7. The system should now reboot and selecting the default grub option (i.e. non fail-safe) should perform a reconfiguration boot before bringing you to the graphical X login. If it doesn't then something went wrong :-(. Trace-back your steps.

8. Login and edit /etc/vfstab again so that you can replace those absolute paths. If you made a backup of this file before the last update, it would be easier to start with this. Before you do this use ls -l /dev/dsk to determine the new disks and update this file as appropriate. For example mine now reads:
/dev/dsk/c3t0d0s1 - - swap - no -
/dev/dsk/c3t0d0s0 /dev/rdsk/c3t0d0s0 / ufs 1 no -
/dev/dsk/c3t0d0s7 /dev/rdsk/c3t0d0s7 /export/home ufs 2 yes -
9. Reboot again and that should be it. System is now ready for use.

March 19, 2010

Use gawk to convert fixed width files to delimited

I had a bunch of fixed-width text files that I needed to be convert to CSV. Each file was different and determining the start and end of each field would be time consuming so this needed to be done dynamically. Fortunately the second line of each file could be used to do exactly that and I was able to run the script unmodified against each file.

An example of the input file:
empno ,ename    ,job        ,hiredate  ,sal
------,---------,-----------,----------,---------
7782  ,CLARK    ,MANAGER    ,09-JUN-81 ,2450.00
7839  ,KING     ,PRESIDENT  ,17-NOV-81 ,5000.00
7934  ,MILLER   ,CLERK      ,23-JAN-82 ,1300.00

The script looks at the second line of each file (i.e. the hyphenated line) to dynamically determine the start and end of each field:
#!/usr/local/bin/gawk -f
BEGIN {
 FS=","
 RS="\n"
 OFS=","
}

# Determine fixed length positions of each field by
# looking at second record (i.e. header row) and output
# each field separated by chosen delimiter.
NR==1{
 widthstring = (length($1)+1)
 for(i=2; i < NF; i++) {
    widthstring = widthstring " " (length($i)+1)
    if(i!=(NF-1))
     printf("%s",OFS ltrim(rtrim(rmlastcomma($i))))
 }
 i=NF-1
 print(OFS ltrim(rtrim(rmlastcomma($i))))
 FIELDWIDTHS = widthstring
}

# Now read from line 3 (skipping first two rows) using newly
# determined field lengths and remove whitespaces. Output
# each field separated by chosen delimiter.
NR>2{
 for(i=2; i < NF; i++)
    printf("%s",OFS ltrim(rtrim(rmlastcomma($i))))
 print(OFS ltrim(rtrim(rmlastcomma($NF))))
}

function ltrim(v) { gsub(/^[ ]+/, "", v); return v}
function rtrim(v) { gsub(/[ ]+$/, "", v); return v}
function rmlastcomma(v) { sub(/[,]+$/, "", v); return v}

The resulting output will be a regular CSV file:
7782,CLARK,MANAGER,09-JUN-81,2450.00
7839,KING,PRESIDENT,17-NOV-81,5000.00
7934,MILLER,CLERK,23-JAN-82,1300.00

Example command  to start gawk in Windows (reading in all files):
for %n in (*.txt) do gawk -f fixed2csv.awk %n >%n.csv

Yes, I did this in Windows!

December 02, 2009

MacBook Pro iSight camera fixed!

So I decided to sell in my Mac Mini and get a MacBook instead. I intended to buy a 17" MacBook Pro on my visit to Florida later this year. However about a week ago $2,500 + tax seemed steep for a machine I just wanted to use to browse the web and use iTunes on.... now I think I should have just bought a new one in Florida. Ah well, it's too late.

Anyway so I bought a second hand 17" MacBook Pro, model A1212 or MA611*/A. It's the one with a 2.33 GHz CPU, 2 GB RAM and a 160 GB HDD. It was in really good condition so I thought it was a good deal until I realised the iSight camera didn't work. At this point, I probably should have just given it back to the seller, but for various reasons I decided to keep hold of it.

I checked out the How to Troubleshoot iSight page on Apple's website to no avail. I thought it could be the connection between the iSight camera and the computer itself and so searching around the Internet brought me to a blog reporting a fix to my suspicion and a how-to on opening a MacBook Pro screen. They were both for different MacBooks, but gave me the inclining to have a go myself.

In the end it worked, so here's what I did. Essentially it involves the following three 'simple' steps:

  1. Unscrew MacBook Pro and remove screen.
  2. Open screen and re-connect iSight cable.
  3. Put everything back together and hope for the best.

Overall it took me about an hour.

Step 1

Basically unscrew every screw you can see. That includes all screws around the sides and underneath including the two screws that require a Torx T6 screwdriver under the memory compartment. So not to scratch my laptop I did this all on my bed. I would recommend doing this on an anti-static surface.

Once all the screws are out, the part with the keyboard and trackpad just pops off. Do it slowly though. The ribbon cable connecting the two pieces is easily removed by lifting the connector vertically off the motherboard. For better instructions on how to get this far, check-out the numerous hard disk upgrade how-tos elsewhere.

Second part of this step is removing the screen. For me, this is when my heart rate increased like I was disarming a bomb. Carefully unclip the cables between the motherboard and the screen by removing the tape holding them in place and using common sense on how these cables come out of the connectors. You may want to take the tape off in a way that you can re-use it later. Using the Torx screwdriver, remove the screws on each pair of hinge holds. On one of the pairs of hinge holds, remark the different screw used--i.e. the left most screw on the right pair of hinges is different, vice versa on the left pair of hinges, the right most screw is different.

Once you're complete you'll end up with a disaster like this:

Step 2

Opening the screen or actually the shell of the screen was the hardest part. I thought it couldn't be done at first and was ready for giving up until I really used to brute force. Check out the how-to I mentioned before on removing the shell. To quote them:

Once you get the two screws removed from the front of the bezel, you must remove the back plastic bezel. To do this, start from one of the bottom corners and slowly pry the back of the bezel off.

Once you get one corner free, move the other bottom corner and free that side from the laptop as well. Using your fingers, carefully pry the remaining bezel from the laptop.

The back plastic bezel is the aluminium backing plus the what seems to be plastic inner lip. Check out what part is coming away from what here:

Once you've got the bezel off, turn the screen so that it is face down and remove the black plastic cover over the PCB of the iSight camera.

I simply removed the cable the and re-inserted it and then held it into position with a little bit of tape. It really needs to be tidy as the bezel needs to fit well.

See that little black bit in the top circle to the the left of the connector? That simply dropped off so it couldn't have been important!

Step 3

Once ye done, sew 'er back up. Remember what I said about the two different screws on one of the the two pairs of hinges and make sure that all cables are connected and are tidy like they were before--you don't want to trap any wires!

Insert the battery/connect up the mains and switch her on. I'm not joking but the Apple start up chime was great to hear. Before trying PhotoBooth, I went to System Profiler and under USB High-Speed Bus, there it was, Built-in iSight!