Archive for the ‘Mac OSX’ Category

Recovering ride data from Garmin Edge 500

Wednesday, November 19th, 2014

For the second time now I lost a ride from my Garmin Edge 500. But this time, thanks to this great blog post I was able to recover the data and upload to strava

I followed the steps in that blog post pretty closely, so this is largely a re-hash of that post for my own reference. But here’s what I did on OSX:

  1. Make a copy of the garmin device using dd
    dd if=/dev/disk2 of=~/temp/garmin.img bs=1m

    You can (but don’t need to) mount the device using Finder:

    open ~/temp/garmin.img
  2. Get sleuthkit
    • Download latest from http://www.sleuthkit.org/sleuthkit/download.php
    • Fix the junit path in bindings/java/nbproject/project.xml . Change from:
      <classpath mode="compile">lib;lib/diffutils-1.2.1.jar;lib/junit-4.8.2.jar;lib/sqlite-jdbc-3.8.0-SNAPSHOT.jar</classpath>

      to

      <classpath mode="compile">lib;lib/diffutils-1.2.1.jar;lib/junit-4.8.2.jar;lib/sqlite-jdbc-3.8.7.jar</classpath>
    • Fix the junit version in bindings/java/ivy.xml . Change from:
      <dependency org="org.xerial" name="sqlite-jdbc" rev="3.8.0-SNAPSHOT" >

      to

      <dependency org="org.xerial" name="sqlite-jdbc" rev="3.8.7" >
    • Build
      ./configure && make
  3. Get scalpel:
    git clone https://github.com/machn1k/Scalpel-2.0.git .
    ./configure && make && sudo make install
  4. Create a scalpel.conf:
    #fit file definition from http://www.thice.nl/recovering-data-from-garmin-edge500
    #fit y 1000000 \x0E\x10\x98\x00??????\x00\x2E\x46\x49\x54\x00\x00\x40\x00 \x01\x00\x00\x1A\x01??# updated fit definition as per data on my Garmin
    fit y 1000000 \x0E\x10\x98\x00???\x00\x2E\x46\x49\x54\x00\x00\x40\x00 \x01\x00\x00\x1A\x01??

    It’s worth noting that the first definition does find some files on the device (perhaps from an earlier version of the firmware), but the second definition finds a lot more files (including the recent file I was missing). I found the common header and footer by using hexdump on some known good .fit files on the device, e.g.

    for f in $(ls -1 2014-1*.fit); do hexdump -n16 $f; done
  5. Run scalpel on the copy of the garmin device:
    scalpel -c scalpel.conf -o garmin.out garmin.img

    There will now be a bunch of files in the garmin.out directory

  6. Get FitDump and GarminFit perl scripts:
    mkdir fitdump; cd fitdump
    curl http://pub.ks-and-ks.ne.jp/cycling/pub/fitdump-0.04.tar.gz > fitddump/fitdump.tar.gz
    curl http://pub.ks-and-ks.ne.jp/cycling/pub/GarminFIT-0.12.tar.gz > garminfit.tar.gz
    tar -xzvf fitdump.tar.gz
    tar -xzvf garminfit.tar.gz
    
  7. Do something like this to find the file you're looking for
    for f in $(ls -1 ../../garmin.out/fit-0-0/*.fit); do echo $f; ./fitdump $f | grep time_created; done > ~/temp/garmin.out/time_created.out

    Then you can look through the time_created.out file to find the file containing the ride you're missing based on the date. You can then directly upload this file to Strava

Installing ssh2 PHP extension under OSX

Tuesday, November 3rd, 2009

After migrating to my new mac, I found I needed to reinstall the ssh2 PHP extension:

Fatal error: Call to undefined function ssh2_connect() in /Users/ethan/Sites/myfile.php on line 40

Since this is the second time I’ve had to do this now, and it took a bit of head scratching both times, I figured I’d document how to install this extension under Mac OS 10.6… (more…)

Update: TPG Usage Widget

Thursday, August 20th, 2009

A very minor update to make the widget work with the recent change to the TPG site (seems someone decided they should refer to Downloads instead of Download).

Download TPG Widget version 1.11

Note that previous versions of the widget are no longer functional

Enabling Diagnostics in TPG Widget

Thursday, November 6th, 2008

To enable diagnostics for the TPG widget:

  1. Open ~/Library/Widgets/TPG.wdgt/TPG.js in a text editor
  2. Change the first line of code (past the documentation and revision historyFrom:
    // global debug variable
    var _debug = false;

    To:

    // global debug variable
    var _debug = true;
  3. Save and quit
  4. On the dashboard, close the TPG widget and then add it again
  5. Check /var/log/system.log (via the terminal, or the console app) for entries marked with 3thirty.

    Example of logfile entries in console app

    This will show the username that has been recorded, and the values that are used to calculate the usage meters

simple bc widget

Wednesday, October 22nd, 2008

I’ve knocked up a simple calculator dashboard widget for OS X. It doesn’t look that pretty, but it utilises the power of bc, and provides a quick and easy front end for it.

simple bc screenshot

The release notes:

/*
 * Simple bc Widget * URL: http://www.3thirty.net/simple-bc
 * Author: Ethan Smith
 * Created: 22/10/08
 *
 * Simple dashborad calculator utilising the baisc calculator, bc. This is really just an interface that
 * passes exactly what you enter to the bc command and prints out the result. The idea behind this widget
 * is to make it really quick and easy to perform simple calculations.
 *
 * Some of the things that this widget does (aka why this is better than the commandline):
 *	- Typing anywhere on the widget will start typing in the sum box
 *	- Pressing enter will perform the calculation
 *	- Pressing escape will clear the textfield
 *	- Starting a calculation with an arithmetic operator (+-/*) will perform the calculation against
 *	  the previous result
 *	- The "previous result variable" allows you to substitute the previous result at any point in
 *	  the current calculation (note that this can be a single letter or a longer word, but you'll have
 *	  all sorts of problems if you try to use a number!)
 *
 * Some of the bc features that are known to work:
 *	- Enter almost anything and bc will do it's best to make a calculation out of it
 *			Example "xyz + 14 - ff * 2 - (v + c)" = 14
 *	- multiline calculations are supported, with a semicolon between each calculation. The results
 *	  will also be separated by semicolons.
 *			Example: "10+4; 10+5;" = 14;15
 *	- variable assignment works. Just be careful that variable names don't get trodden on by the
 *	  "previous result variable".
 *			Example: "x=12; x=x+48; x-10" = 50
 *
 * Notes on the implementation of bc:
 *	- this widget really just passes through the calculation almost exactly as entered. Try running
 *	  bc from the commandline, see "man bc" or http://en.wikipedia.org/wiki/Bc_(Unix) for more
 *	- the scale (number of decimal places) is set to 3 by the widget
 */

Download simple-bc widget for OS X (zip, 48kb)

Update: TPG Usage Widget

Wednesday, August 6th, 2008

Download TPG Widget for OSX (version 1.10, 92kb)

  • Fixed major bug in percentage calculations that was causing us to always use the 10% warning, 20% critical limits
  • Modified horizontalIndicator behaviour – don’t show critical unless we are over the critical limit. Basically, this has the effect of “rounding down” from critical to warning, which is useful, given the granularity of the indicator I’m using
  • Removed target percentage, it’s unnecessary
  • Fixed minor bug with clicking on the two targets in quick succession

I think it’s time to update this page with product info and revision history, instead of having separate posts for each update….

Update: TPG Usage Widget

Sunday, August 3rd, 2008

This version introduces two new features:

  • Click on the current usage value to see the current target
  • Notification if there’s a new version available on the back of the widget

Download TPG Usage Widget for OSX (version 1.8, 92kb)

It’s also now available from the Apple Dashboard Widgets site

3 updates in one week! Maybe I should stay off the booze more often ;)

That said, this version clears out all the todos I had on my list for this widget. So unless there’s any bugs, I don’t anticipate any new versions for a while, but let me know if there are any problems.

Update: TPG Usage Widget

Friday, August 1st, 2008

Update: Make sure you get the latest version of the widget!

Another minor update to fix some display issues that may show up at the very end and start of the billing cycles.

What’s changed this time:

  • Fixed bug in calculating offpeak usage (typo). Previously, offpeak was always green
  • If you’re over your total limit for the month, default to 75% warning and 90% critical for color coding. Otherwise, the entire bar is green
  • Fixed display bug: the short horizontal usage bars don’t have the granularity to show really small percentages (eg at the start of the billing period). So, we overwrite them with some friendlier values (10% of total for warning, 15% for critical). It’s less accurate, but clearer than showing a single red light
  • Don’t save empty values for settings (ensure the widget won’t forget your username or password)
  • Removed unnecessary saveSettings call
  • Converted all ints to floats, so we keep fractions of gb/mb

Download TPG Usage Widget for OSX (version 1.6, 96kb)

And if anyone was wondering, yes, you can use subversion to manage a Dashcode widget project…

(more…)

Update: TPG Usage Widget

Sunday, July 27th, 2008

Update: Make sure you get the latest version of the widget!

Another update to the TPG Usage Widget for Mac OS X.

This fixes a pretty major bug with the calculation of red and yellow sections on the indicators; I assumed that everyone’s TPG billing cycles were monthly, like mine so was calculating usage to the end of the current month, rather than looking at the actual expiry date. This caused some pretty confusing indicators showing usage in the red when they should have been in the green.

This should be fixed now, but since I’ve only tested this for my account, please let me know if you notice any weirdness.

Version 1.4 changes:

  • Fixed bug in calculating “target usage” – not everyone has a billing cycle that coincides with the end of the month!
  • Now displays < 1 day as “today” (I saw 0, and maybe a negative on my installation last month)
  • Added option to click on the expiry date (or days) and change mode. Note that once this option is set, the widget will not override it (unless the mac is restarted or the widget is reinstalled)

Download TPG Usage Widget (version 1.4, 96kb)

Confused? Maybe this fineprint from Apple will help: “Mac OS X 10.4 Tiger is required. If you’re using Safari, click the download link. When the widget download is complete, Show Dashboard, click the Plus sign to display the Widget Bar and click the widget’s icon in the Widget Bar to open it. If you’re using a browser other than Safari, click the download link. When the widget download is complete, unarchive it and place it in /Library/Widgets/ in your home folder. Show Dashboard, click the Plus sign to display the Widget Bar and click the widget’s icon in the Widget Bar to open it.”

No? Didn’t think so. Just leave a comment and I’ll help you out

Update: TPG Usage Widget

Saturday, June 21st, 2008

Update: Make sure you get the latest version of the widget!

As requested by a few users, I’ve updated the TPG Usage Widget to be a bit smarter about setting the yellow and red levels in on the indicators.

Previously, yellow was at 75% of maximum, and red at 90%.

The widget now considers the level your usage should be at, given your monthly limit and how much of the month is left. If you’re beyond this point, the indicator bar will be red. If you’re within a day of hitting this limit then the indicator bar is yellow.

Try it out… it makes a lot more sense when you see this in action. Any feedback on this is welcome!

(Also fixed a bug in the days countdown)

Download TPG Usage Widget (version 1.2, 88kb)

Update 27/07/08: Update 1.4 to fix a major bug