2011-12-13

How to get a route from Google Maps on to an iPad so you can follow it offline

I wanted to find a way to download a route from Google Maps onto my iPad 3G so that I could follow the route on a map offline.  I know that with the iPad 3G data plan turned on you can just use the Maps app to find and follow directions, but I am a frugalista and I like to keep the 3G data plan on my iPad turned off except when I am on long trips.

Here is the procedure I worked out, which requires that you own the $3.99 (as of Dec 2011) MotionX GPS HD app.

  • Go to Google Maps and look up directions to the place you want to go.
  • At the bottom of the directions click the Save to My Maps link.
  • Go to Google My Places (fka My Maps) and select the map with directions you just saved.
  • Click the KML link to download a KML file of the directions to your computer.
  • Go to http://www.gpsvisualizer.com/ select the KML file to upload and pick GPS format for the output and click Go.
  • Email the resulting GPX file to yourself.
  • In Mail on your iPad open the email, tap the attachment, and select open in MotionX GPS HD app.
  • This will open the MotionX GPS HD app where you can complete the import of the GPX track.
  • This will just import the track into the MotionX GPS HD app.  You need to separately download OpenStreetMaps for the relevant area in MotionX GPS HD in order to have the maps available offline.
This doesn't give you turn by turn directions, but it does give you a simple line on a map that you can follow while offline.


2011-11-10

How to manage iOS Newsstand subscriptions auto downloads

The screen where you manage automatic download settings for subscriptions in the new iOS  Newsstand is hard to find (at least it was for me!) Here is how to get to it on your iPad, iPod Touch, or iPhone.

  • Tap on the Settings app to get to the Settings screen
  • Scroll down list of settings until you see the icon for the Store and tap that
  • There will be a section of the Store settings called "Automatically download new content when on Wi-Fi" and all of your Newsstand subscriptions should be listed there with an on/off slider for each one.
Incidentally, the wording of this screen seems to imply that automatic downloads of subscriptions only happen when on Wi-Fi (i.e. not on cellular), which I hope is true because one issue of the New Yorker would blow more than half my cheapskate 250 MB cellular plan.


2011-11-02

Save money using Google Voice plus a prepaid cellphone

A lot of prepaid mobile phone plans charge you only for the minutes you actually use, and if you don't use a lot of minutes each month it can save you a lot of money (I spend on average less than $10 a month on my T-Mobile prepaid service).  If you get a Google Voice account, and set it up to ring not only your prepaid cell phone but also your home and office phones, then you can give everyone your Google Voice number as your mobile phone number, but answer calls to it on your house or work phone when you are not on the road.

2011-10-11

How to prevent sessions from expiring too quickly on PHP applications


When I started using sessions for authentication in a PHP web application I discovered that users were being logged out after a very short time.  After some research I discovered how sessions work in PHP.
A unique session ID is stored on a cookie on the users computer.  When the user connects to the server the server looks for a file with that unique session ID in its temp folder, and if one exists it pulls variable values from that file.  Every time any user connects to the server and starts a session the server generates a random number and then looks at some settings in php.ini to determine whether or not to clean out the temp folder. When it cleans out the temp folder it throws out session files older than the session.gc_maxlifetime setting in php.ini (set in seconds).  In order to enable keeping users logged in for long periods I set session.gc_maxlifetime = 1814400 in the php.ini.

This works on MAMP installations also. Just edit to /Applications/MAMP/conf/php5.3/php.ini

How to configure Apache in MAMP to only be accessible from the machine it is installed on

For a number of reasons I wanted to run a web application locally on my MacBook.  After some research I decided that the path of least resistance was to install the free MAMP app, which runs an Apache-MySQL-PHP stack on a Max OS X machine without having to do a complex install process.   I got my web app working on MAMP pretty easily, but then I discovered that other machines on my local network could also access the web app if they connected to the right port of the IP address of my MacBook.  That isn't a problem when I am at home or work, but I didn't want the web app exposed when I was on public networks like at a coffee house or the library.  After some research I discovered the solution was to edit the /Applications/MAMP/conf/apache/httpd.conf file to change:

Listen 8888

to

Listen 127.0.0.1:80

This did two things. It changed the port that MAMP uses from the MAMP default of 8888 to 80 (the normal web server port) and specified that only traffic from the local machine would be accepted.  After I made this change and restarted the Apache server I was no longer able to access the web app from other machines on the same network.

2011-01-25

How to automatically mount external hard drive at boot in Ubuntu Lucid Lynx

I have an external USB hard drive connected to my Ubuntu laptop home server that I used to store MythTV recordings and videos.  Ubuntu would mount this USB drive to the mount point I had created when I logged in as my regular user, but not at boot.  I wanted the drive to automatically mount at boot so that after a power failure, or a reboot, I wouldn't have to log in as a user in order to have MythTV work.  After doing some research using Google I tried the following:

  • After logging in as my regular user to make the USB drive mount, I ran mount in a terminal which gave me a listing of all the mounted disks and their mount settings.  I copied down the mount settings for the USB drive and noted which device the USB drive was mounted as (sdb1 in my case).
  • Then I ran ls -l /dev/disk/by-uuid which gave me a listing of the UUID of each mounted partition and I copied down the UUID for the sdb1.  This is the unique identifier for the USB drive.
  • Then I made a backup copy of the fstab file: sudo cp /etc/fstab /etc/fstab.bak
  • Then I opened the fstab file in an editor: sudo nano /etc/fstab
  • Then I added a line to the bottom of the fstab file like this, putting a tab between each value, and using the UUID I noted, the filesystem type I noted, and the mount options I noted:
  • UUID=07955830-0d54-443c-bdba-f111121f6bd3   /media/myth_data    ext4    rw,nosuid,nodev,uhelper=udisks 
  • Then I rebooted and the disk was automatically mounted without me having to log in.

2011-01-03

A Mac OS X app to wake a Mac and then open screen sharing

I have a Mac Mini hooked up to our TV and stereo as a HTPC which has a hard-wired Ethernet connection. To save a bit of energy I have it set to go to sleep when it isn't used. My wife wanted to be able to play internet radio stations over the stereo, but she didn't want to have to turn on the TV, get a keyboard, etc. just to start one playing. I showed her how to use one program to wake the Mac Mini, and then how to launch screen sharing through Finder, but it was a lot of clicking. So I started googling for a way to set up a one-click icon that would (1) wake the Mac Mini, and (2) then connect to it by screen sharing.

As to waking the Mac Mini, I found this page that gives an Automator workflow to send the wake on lan magic packet (which will only work if the target computer has a hard wired Ethernet connection) and also open screen sharing:

Wake sleeping Mac with AppleScript and Automator

The guts of this is a PHP script written by Mark Muir to send the magic packet that wakes the sleeping computer. The version of this PHP script at the link has comments explaining how it works. Since I have zero experience with Automator I decided to adapt this to be an AppleScript. Here is what I ended up with:

on run
set command to "/usr/bin/php -r " & quoted form of ("$mac = \"a4:6a:19:d8:d2:24\";
$ip = \"10.10.10.255\";
$mac_bytes = explode(\":\", $mac);
$mac_addr = \"\";
for ($i=0; $i<6; $i++)
$mac_addr .= chr(hexdec($mac_bytes[$i]));
$packet = \"\";
for ($i=0; $i<6; $i++) /*6x 0xFF*/
$packet .= chr(255);
for ($i=0; $i<16; $i++) /*16x MAC address*/
$packet .= $mac_addr;

$port = 9;
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_set_option($sock, SOL_SOCKET, SO_BROADCAST, TRUE);
socket_sendto($sock, $packet, strlen($packet), 0, $ip, $port);
socket_close($sock);
")
do shell script command
delay 3
tell application "Screen Sharing"
open location "vnc://MyComputersBonjourName.local"
end tell
end run


To use this yourself do the following:

  • Make sure screen sharing is configured on the target computer and verify it works when you manually connect from the source computer.
  • Go to the target computer and open Network Utility and look up the Hardware Address of the target computers Ethernet network interface. Change the $mac value in the Applescript to be this value.
  • Look up the Bonjour name of the target computer (System Preferences -> Sharing : Computer Name) and substitute it for MyComputersBonjourName in the Applescript.
  • Change the $ip value in the Applescript to be the IP address of your router with 255 substituted for the last digits. For many people this would be 192.168.1.255. Also, 255.255.255.255 should work.
  • Open AppleScript Editor on the source computer (the one you want to connect from) and paste the script in it and then click Compile and then click Run to test it. It should wake the target computer and open screen sharing for it.
  • Save the AppleScript as an app by selecting File -> Save As and then picking application as the file type in the dialog box.
  • Double click on the app to verify it works.
  • Drag the app to the Dock or wherever you want it to live.