gsxcl

Just wanted to give a quick shoutout to gsxcl. It started out as a simple test tool for gsxlib, but has now evolved into a pretty useful replacement for GSX's web UI. Currently it supports the following operations:

  • Warranty status
  • Part lookups
  • Checking repair details and status
  • Downloading part return labels

That's right - you can even use this to quickly download the return label of a part as a PDF:

./gsxcl -u username -p password -s sold-to -m label -q return-order:part-number > test.pdf
file ./test.pdf
test.pdf: PDF document, version 1.4

The operating principle is that -m defines the "mode" of operation and then everything after -q should supply the necessary arguments. Multiple arguments are separated with a colon, as for example in the label download command - we must supply both the return order number (starting with 7...) and the part number being returned.

usage: gsxcl -s sold-to -u username -p password [-r region] [-e environment] [-f format] [-m mode] [-q query]
-s  sold-to           your GSX Sold-To account
-u  username    the Apple ID with GSX WS API access
-p  password    the password for the Apple ID
-r  region           either "am" (America), "emea" (default, Europe, Middle-East, Africa) "apac" (Asia-Pacific) or "la" (Latin America)
-e  environment the GSX environment. Either empty (production), "it" or "ut" Defaults to production
-f  format          the output format. Either print_r (default), json, xml or csv
-m  mode          what to search for. Currently one of: warranty, parts, pending, repair, lookup, status, label.
              Defaults to "warranty"
-q  query           a query string (serial number, order confirmation, repair number, EEE code, etc
              Defaults to this machine's serial number

One of the most recent changes I added was the format option, allowing you to get data out of it in CSV, XML or just a PHP print_r(). The CSV option is probably the most useful one, the header row is constructed from all the property names of the GSX WS response.

Running it with just the required arguments will perform a warranty status check for the current machine.

gsxlib

I've started a new project on github called gsxlib. It's a helper library for dealing with Apple's GSX web service API. I just noticed I have several web apps all using their own GSX code, so the idea is to refactor them all under this one library.

Very simple to use, you don't even have to know the WSDL URL:

<?php

  include 'gsxlib/gsxlib.php';
  $gsx = new GsxLib('your sold-to account', 'gsx user', 'password');
  $info = $gsx->warrantyStatus('serialnumber');
  echo $info->productDescription;

?>

MacBook Pro (15-inch 2.4/2.2GHz)

Currently it only has a shortcut for warranty status checks, more to come soon. Check the readme for more details.

On a totally unrelated note - imapsync is awesome.

phpshell 0.1

This is kind of weird, but maybe somewhat useful some day. Looking for a quick way to test out PHP code, I ended up writing a small PHP "shell" (i.e. like IRB):

It comes with some useful shortcuts:

  • e() print's anything to the screen, including arrays (through print_r())
  • man() prints the entire manual page of a function. This requires that you have PHP Function Index installed.
  • fi() opens a command in PHP Function Index
  • d() reads stuff from the defaults database
  • Entering a function name without the paranthesis gives a short 20 line explanation of the command from the manual

There are some limitations - it requires PHP with readline support (which MAMP doesn't have, not to mention Apple's stock PHP) and links to render the HTML pages. Both can be installed through MacPorts (PHP would just need the +readline variant).

If nothing else, it's pretty interesting little experiment. Normal people would probably be better off using PHP Console instead. ;-)

Something for people who use PHP for Mac OS stuff - a class wrapper for Theo Hultberg's nice PLIST parsing implementation. Usage example:

include "plist.php";
$plist = new PropertyList("/Users/filipp/Music/iTunes/iTunes Music Library.xml");
$array = $plist->toArray();
echo count($array['Tracks']);
6670

Great for building reports from System Profiler dumps and all sorts of cool stuff. Download here.

The otherwise excellent Zend Framework manual unfortunately doesn't mention how to get the auto-incremented ID of a Zend_Db_Table. Luckily this is pretty simple when we know that ZendDbTable uses the same Zend_Db adapter mechanism.

In your Zend_Db_Table_Abstract subclass, just override the insert method:

public function create(array $data)
{
  parent::insert($data);
  return parent::getDefaultAdapter()->lastInsertId();
}

Not sure if that's the best way of doing it, but it works and makes sense.