Playing With Wire » Mac OS X http://www.playingwithwire.com The Internet Startup Blog Wed, 20 Jul 2011 18:45:29 +0000 en-US hourly 1 How to recover from when Spaces/Expose stop working http://www.playingwithwire.com/2009/09/how-to-recover-from-a-spacesexpose-stop-working/ http://www.playingwithwire.com/2009/09/how-to-recover-from-a-spacesexpose-stop-working/#comments Wed, 16 Sep 2009 20:55:58 +0000 http://www.playingwithwire.com/?p=679 Did Expose/Spaces stop working all of the sudden? This happens to me almost every day. Most of this time this is when I resume my MacBook Pro at home. I assume this has something to do with the fact that I have an external monitor connected at the office, and that somehow messes with Expose/Spaces. Luckily there is a quite simple solution.

  • Fire up Activity Monitor (/Applications/Utilities/Activity Monitor)
  • Filter the results for ‘Dock’
  • Click on ‘Dock’ and ‘Quit Process’
Filter for 'Dock' in Activity Monitor

Filter for 'Dock' in Activity Monitor

Unfortunately this will collect all windows into a single ‘space,’ but you will be able to once again use Expose/Spaces. Enjoy!

]]>
http://www.playingwithwire.com/2009/09/how-to-recover-from-a-spacesexpose-stop-working/feed/ 0
Building the perfect networked media center with Plex and iLife. http://www.playingwithwire.com/2009/09/building-the-perfect-networked-media-center-with-plex-and-ilife/ http://www.playingwithwire.com/2009/09/building-the-perfect-networked-media-center-with-plex-and-ilife/#comments Tue, 01 Sep 2009 16:39:45 +0000 http://www.playingwithwire.com/?p=624 I know, I know, this topic has been covered a billion times before. Everyone has got their own idea of what the perfect multimedia system is. But hear me out, I think you’ll like what I have to say. Since you’re probably in the process of upgrading to Snow Leopard, perhaps now is a good time to reorganize your media.

When we’re done you will have the following:

  • Central iPhoto and iMovie libraries
  • Your central iPhoto library accessible in Front Row
  • All your music, movies and TV shows, organized and accessible directly from your remote control

Have all your media accessible with your remote control.

Have all your media accessible with your remote control.

The requirements

Like all solutions, there are some requirements. However, I would consider these requirements pretty basic. For most gadgeteers out there, these are things you already got in your possession:

  • A Network Attached Storage (eg. Drobo, ReadyNAS, or an old Linux box). Preferably something with some redundancy (RAID1, RAID5, RAID-Z etc.)
  • Two or more Macs with Leopard or later (perhaps a Mac Mini to the TV/Projector and an iMac as a desktop)
  • A lot of media (picture, music, movies, TV shows etc).
  • Sounds too good to be true? Well, it isn’t. Best of all, you won’t have to spend a single dime on software. So what’s the secret? Good ‘ol UNIX symlinks and a software called Plex. That’s it.

    Configuring the NAS

    Since I have no idea what kind of NAS you’ve got (and it doesn’t really matter), all I’ll say is that I recommend that you create the following shares:

    • ‘pictures’ – for the iPhoto library
    • ‘videos’ – for the iMovie library
    • ‘movies’ – for all your movies
    • ‘tvshows’ – for all your TV shows
    • ‘music’ – for all your music

    If your NAS supports AFP, that’s great, but SMB will do just fine too.

Copying the media to the NAS

While I’m not going to cover how you copy your movies, TV shows and music (as I assume you know that), I will however cover how you copy your iPhoto and iMovie libraries.

Start by connecting to your network shares ‘pictures’ and ‘videos’ (or equivalent). You can do that either by browsing to them in Finder, or use Finder’s ‘Connect to server’ feature (available under ‘Go’ -> ‘Connect to server’).

If you’re a power user, skip the next four paragraphs.

Let’s start with the iPhoto library. Open up your home directory and go into the ‘Pictures’ folder. Now copy the ‘iPhoto Library’ folder over to the share ‘pictures’. Depending on the size of your archive and the speed of your network, this can take a while. Once done, rename the folder ‘iPhoto Library’ on your local computer to ‘iPhoto Library.old’ or something similar.

Now, this is the important part. Go over to the ‘picture’ share on the NAS and drag the iPhoto Library back to the local folder while pressing Command and Option. An arrow will show up under the icon you are dragging. Release the mouse button. If the files start to copy, you did not successfully press Command and Option.

We’re now done with iPhoto. You should now be able to fire up iPhoto and it will access the photos directly from the NAS. To do the same for another computer, all you need to do is to rename the local ‘iPhoto Library’ into something else, and create a link as we just did above.

Next up is the iMovie library (if you use it). Start by opening up the two folders (‘videos’ on the NAS and Movies in your home directory). Now copy the ‘iMovie Projects’ from the local Movies folder onto ‘videos’ on the NAS. Next, rename ‘iMovie Projects’ on the local machine to ‘iMovie Projects.old’ and create a link to the NAS (by dragging it from the ‘videos’ folder to the local ‘Movies’ folder with Command and Option held down). Repeat the same thing with the folder ‘iMovie Events’.

For the power-users out there, there is an easier way to do all this. Simply fire up the Terminal and run the following commands:
$ rsync -aP "~/Pictures/iPhoto Library" /Volumes/pictures/
$ mv "~/Pictures/iPhoto Library" "~/Pictures/iPhoto Library.old"
$ ln -s "/Volumes/pictures/iPhoto Library" ~/Pictures/
$ rsync -aP ~/Movies/iMovie* /Volumes/videos/
$ mv "~/Movies/iMovie Events" "~/Movies/iMovie Events.old"
$ mv "~/Movies/iMovie Projects" "~/Movies/iMovie Projects.old"
$ ln -s "/Volumes/videos/iMovie Events" ~/Movies/
$ ln -s "/Volumes/videos/iMovie Projects" ~/Movies/

For additional computers, just run the same commands, but leave out the rsync.

Automounting the shares

While you would imagine this to be very easy on a UNIX based system, it’s surprisingly difficult on Mac OS. Perhaps there is a better way, but this is the most straight-forward solution I’ve found. If you know of a better way of doing this, please let me know!

Finder -> 'Go' -> 'Connect to Server'
From Finder, navigate to the ‘Go’ menu and select ‘Connect to Server’. Once it opens up, you need to enter the address to your NAS (complete with the names of the share). That is, if you NAS is named FOO, enter ‘smb://foo/pictures’ and press the plus icon. Repeat this for the share ‘videos’.

Next we need to open up the folder ‘Library/Favorites’ in your home directory. Within this folder, you will see the two shares you just created in the step above. Leave this Finder window open while you click on ‘Apple’ -> ‘System Preferences’ -> ‘Accounts.’ Then select ‘Login Items.’ Now drag the two shares from Favorites into the list of Login Items.

The Items list after dragging in the two shares.

The Items list after dragging in the two shares.

The two shares will now automatically mount upon login for the current user. As noted above, this is not a great way to automatically mount shares, but as far as I know, this is the most convenient way. Keep in mind that, if you do not automatically mount the shares, you will not be able to access your iPhoto/iMovie library until you’ve manually mounted the shares.

Moving on to the other media

With iPhoto and iMovie moved to the central storage, it’s time to move on to the other media. Luckily this is much easier.

The cornerstone in managing all the remaining media is a software called Plex. If you never heard of it, Plex is basically a Mac OS version of the popular media center solution XBMC for Xbox. In its look and feel, Plex is quite similar to Front Row, but it offers a plethora of features that is missing in Front Row. Not only are you able to watch your Movies and TV Shows, you will also be able to install apps within Plex which allow you to stream media directly from sources such as Hulu and BBC.

Plex ContentAssuming you’ve already downloaded and installed Plex, just launch it and head to ‘Watch your Videos’ -> ‘Add Source’ -> ‘Browse’ -> ‘Windows Network (SMB)’ -> Locate your NAS and select the share ‘movies’ and press ‘OK.’ Now go to ‘Set Content,’ select ‘Movies,’ ‘imdb,’ and then press ‘Select’. Plex will now scan through the folder and all its sub-folders and run it against imdb to try to figure out what it is. If the movies are properly named, Plex will fetch the description of the movie, the cover as well as the full name and year. It will then take all of that data and present them neatly organized under ‘Watch your Movies’

Now repeat the same thing for ‘tvshows’ and ‘music,’ but select the content accordingly.

The whole process is pretty straight forward, but since the Plex Wiki already does a great job of describing this process in greater detail, I will simply recommend that you read more about that there.

There you go, that’s it really. While there is a whole lot of things that can be added to this article, such as iPhoto integration etc., I’ve intentionally left that out to keep the article a bit briefer. You might also wonder why I didn’t move the iTunes library over to the NAS. The reason for this is that I think that it might get corrupted if multiple users access it simultaneously. That’s why I instead suggested that you simply move the music-files itself to the network, and play them directly in Plex.

One obvious expansion of this setup is to include Plex Media Server. Perhaps I will cover that in a ‘Part 2′

]]>
http://www.playingwithwire.com/2009/09/building-the-perfect-networked-media-center-with-plex-and-ilife/feed/ 3
Review of Safari 4’s Fresh Developer Tools http://www.playingwithwire.com/2009/06/safari-4-launches-new-developer-tools/ http://www.playingwithwire.com/2009/06/safari-4-launches-new-developer-tools/#comments Tue, 09 Jun 2009 17:07:53 +0000 http://www.playingwithwire.com/?p=479 Activate the Developer menu in Safari 4's preferences.

Activate the Developer menu in Safari 4's preferences.

Apple’s Safari web browser was upgraded to version 4 yesterday and with it came an update to the developers tools first introduced in Safari 3.1. The new version is set to give Firefox’s FireBug plugin some very serious competition. Not only does the Development environment look and perform very well, it’s also very full featured.

In the toolset we find inspection of HTML and CSS, JavaScript debugging, page load profiling tools and a Databases inspection tool presumably for HTML 5’s offline storage support. There are also tools to disable caching, spoof user agents and more from the handy Develop menu.

Inspecting Pages

When designing a new web page frequently plenty of time is spent making minor changes, updating the server and then checking the results in the web browser. This three stage process slows down the design process and hampers the creative flow. Page inspection tools allow you to review and edit your page live in the browser, allowing you to easily try out different CSS rules or HTML edits until you know what you want. And what you see is literally what you get – your preview is the actual web browser.

A line of HTML highlighted in the rendering.

A line of HTML highlighted in the rendering.

Safari 4’s “Web Inspector”, shown with Develop / Show Web Inspector, is Apple’s take on page inspection. Reminiscent of Firebug’s equivalent, the inspector area attaches to the bottom of the Safari window. On the left hand you get the HTML for the page and on the right hand you get the full hierarchy of CSS affecting the currently selected element. By choosing the magnifier icon you can click on any element in the page – a headline, an image, a paragraph – and bring it into focus in the HTML view. The same can be done by selecting tags in the HTML source code directly.

When an element is selected it is outlined in blue in the page. A light blue box shows the dimensions of the element itself and a darker blue box behind it outlines the element with margins included. This is helpful when an element is not positioned where you want it or it’s the wrong size. The blue boxes will let you know if the problem is with the margins or if there is something else going on.

Once you have a theory of what you’d like to change you can go in and edit the effective CSS directly using the Styles panel on the right hand side. For instance you could tweak the font-size by double clicking the font-size value and typing in a new number. A set of checkboxes also allow you to toggle individual CSS rules on or off to see how that affects the page as a whole. A great tool for hunting down what CSS rule is doing what. For each section in the Styles panel you also get the responsible selector and the CSS file it comes from, making it easy to copy your changes back to the original style sheet when you are done with your edits.

The CSS editor is well designed but it does not seem to allow adding new CSS rules live, a feature available in FireBug.

What’s Taking so Long?

Another important consideration when designing a website is the page load time. Safari 4 boosts a slick looking Resources inspector which gives the developer a breakdown not only of how long each JavaScript, CSS or image file took to load but also when each download started. All of this is shown in the context of the whole page load from the first millisecond to the last.

Timing the bits and pieces of a web page.

Timing the bits and pieces of a web page.

By laying the load time out in a timeline various sources of delay can be tracked. For example in the screenshot above the main document takes just short of half a second to load. We can also see that the CSS file request goes out even before the main HTML is finished loading, as Safari finds the CSS link in the header almost immediately. For each bar the semitransparent section is the latency – the time until the first byte of the response. So in the above case we can see that the latency makes up the majority of the load time. We can also see that the two images used on the page are loaded concurrently and that they start loading immediately when the CSS has been retrieved. Finally the colorful bar on top breaks the total load time down by type and lets us know the whole page finished loading in 1.2 seconds.

Individual resources can be inspected, allowing the developer to review the size and contents of each resource. In the same section the request and response headers can be reviewed. This is useful for the web server administrator in order to determine compression status and cache expiration headers. Strangely enough POST parameters don’t seem to show up which could be a serious problem for debugging.

This CSS file was gzipped and comes with a far future expires header. Great!

This CSS file was gzipped and comes with a far future expires header. Great!

Breaking Into the Source

Tracing the execution of JavaScript.

Tracing the execution of Javascript.

In the web 2.0 age, JavaScript is almost as important as the HTML and CSS that make up a page. Luckily Safari 4’s JavaScript debugging facilities give you a window into your code as it runs. You can set breakpoints, step through source code and inspect the call stack and variables as you go along.

When a page has been loaded the Scripts tab shows the various JavaScript resources available on the page, by source filename. When a file has been selected the JavaScript is displayed with syntax highlighting and line numbers. Clicking on a source line number sets a breakpoint. Once the targeted code executes Safari automatically launches into single step mode, allowing for the usual controls: Step Over, Step Into and return (called Step Out). At each step you can also inspect the values of the variables available in the scope.

There is also a Console feature which not only shows console messages and errors generated by your JavaScript during runtime but allows you to run commands live. Need to see what happens if a certain variable has a different value? Just set it using the console and watch the results unfold in the active web page.

Executing a JavaScript command in a live page.

Executing a JavaScript command in a live page.

Step Behind the Scenes

Safari 4's Develop Menu.

Safari 4's Develop Menu.

Safari 4’s Develop menu reveals additional tools and utilities useful for debugging and inspecting a web page. Enable or disable caches, images, CSS or JavaScript to see what the page looks like in a degraded state. This allows you to make sure the web page looks good even without images for instance, a great utility for making sure your website is accessible for persons with disabilities. Toggling JavaScript is also an obvious boon when you need to make sure your software runs in text browsers or where JavaScript has been disabled for security or performance reasons. There is also a “Snippet Editor” which seems to allow easy previewing of HTML snippets.

There are some flaws. Two were mentioned above: there does not seem to be a way to inspect POST data, important especially when debugging AJAX, and it does not seem possible to add new CSS rules dynamically as you could in FireBug.

There is also a selection bug: when the Web Inspector is revealed, selecting any text on the page causes the window to immediately scroll to the bottom. This subsequently selects all text on the page below where you started to select. Another bug is that if an element is selected such that the blue outline boxes show up, switching tabs sometimes left the outline hanging around in the other tabs too, now not highlighting anything in particular. Finally the JavaScript debugger seems to freeze up JavaScript in every Safari page – not just the one you are working with. This makes it hard to work with say an online reference in a different window.

A more minor flaw is a missing feature. There is no page optimization analysis tool such as Yahoo’s YSlow or Google’s Page Speed. These tools help analyze pages for performance problems. For example they check for additional compressibility in images and for correct headers.

These flaws aside the Development tools found in Safari leave little to be desired. All the features you expect are there and the package is polished far beyond what’s ordinary for web development. Apple has clearly been looking to FireBug when picking their features and that’s a good thing. FireBug has for a long time been setting the standard for these kinds of tools, but has been suffering from engineers’ syndrome: heaps of features but with little mind to UI design and detail polish. Safari 4’s development environment meets nearly all the same requirements and does it in style, bringing an excellent choice to the web developer’s toolbox.

Read more about the new developer tools at Apple’s What’s New page.

]]>
http://www.playingwithwire.com/2009/06/safari-4-launches-new-developer-tools/feed/ 8
Adding support for Postgresql on iReport 3.0.0 http://www.playingwithwire.com/2009/01/adding-support-for-postgresql-on-ireport-300/ http://www.playingwithwire.com/2009/01/adding-support-for-postgresql-on-ireport-300/#comments Tue, 13 Jan 2009 09:33:00 +0000 http://www.playingwithwire.com/2009/01/adding-support-for-postgresql-on-ireport-300/ Shortly after getting iReport running using the fix described in this article, we ran into a new problem — the Postgresql support. After some Googeling, it became clear that one had to add the the driver for Postgresql by hand from here. If not, you will encounter this error message:

Error: java.lang.ClassNotFoundException: org.postgresql.Driver

When adding the driver, beware of what version you’re selecting. After banging our heads in the wall for a while, we realized that we picked the wrong version. On Mac OS X 10.5.6 (with all latest updates installed) the version you’re looking for is the ‘JDBC3′ branch (assuming you’re using the java version that comes with OS X). Once we figured this out, the installation was easy. First, download this file. Then you need to move it into the ‘lib’ folder in iReport.

If you’re a console user like us, here are the steps:

cd iReport-3.0.0/lib
wget http://jdbc.postgresql.org/download/postgresql-8.3-604.jdbc3.jar

Easy as pie.

]]>
http://www.playingwithwire.com/2009/01/adding-support-for-postgresql-on-ireport-300/feed/ 0
Fixing the launcher for iReport on MacOS X (again) http://www.playingwithwire.com/2009/01/fixing-the-launcher-for-ireport-on-macos-x-again/ http://www.playingwithwire.com/2009/01/fixing-the-launcher-for-ireport-on-macos-x-again/#comments Mon, 12 Jan 2009 23:53:30 +0000 http://www.playingwithwire.com/2009/01/fixing-the-launcher-for-ireport-on-macos-x-again/ If you’ve never heard of iReport and Jasper before, you really ought to take a look at it. It’s a really impressive suite of reporting tools that can generate reports from pretty much any data source out there.

Almost exactly a year ago, we wrote a similar article on how to fix the launcher in version 2.0.x. While I’m sure Jasper improved iReport a lot during this time, they also managed to break the launcher in new ways with version 3.0.0.

This is how you can get it working (assuming you’ve downloaded it):

tar xvfz iReport-3.0.0.tar.gz
cd iReport-3.0.0/bin
awk ‘{ sub(“r$”, “”); print }’ startup.sh > startup2.sh
chmod +x startup2.sh
./startup2.sh

The commands above fixes two problems with the launcher. First we convert the line feed from DOS format to UNIX format (the awk-part). The second problem was that the launcher was not executable. If you just make the original launcher executable (chmod +x startup.sh), you will end up with this:

-bash: ./startup.sh: /bin/sh^M: bad interpreter: No such file or directory

Good luck, and have fun generating all those new cool reports.

]]>
http://www.playingwithwire.com/2009/01/fixing-the-launcher-for-ireport-on-macos-x-again/feed/ 0
Starting Jasper iReport on Mac OS X http://www.playingwithwire.com/2008/01/starting-jasper-ireport-on-mac-os-x/ http://www.playingwithwire.com/2008/01/starting-jasper-ireport-on-mac-os-x/#comments Sat, 12 Jan 2008 03:05:19 +0000 http://www.playingwithwire.com/2008/01/starting-jasper-ireport-on-mac-os-x/ Today I tried to start iReport for the first time on the Mac. There was a shell script distributed with the program, so I gave it a shot in the Terminal. Unfortunately I got an exception immediately.

Stryker:iReport-2.0.3 2 siker$ chmod a+x iReport.sh
Stryker:iReport-2.0.3 2 siker$ ./iReport.sh
Exception in thread "main" java.lang.NoClassDefFoundError: 2

I fooled around with the script for a while. Seeing that it was trying to generate its class path using creative uses of dirname on the first script argument, I figured that maybe it’d help to run the program with the full path specified like so:

Stryker:iReport-2.0.3 2 siker$ "`pwd`/iReport.sh"

That didn’t do it though. After looking at the script some more I realized they were pretty lax with quoting. That was it. Moving the software to a location without spaces in the path solved the problem and made iReport start up just fine.

Stryker:iReport-2.0.3 2 siker$ cd ..
Stryker:Downloads siker$ mv iReport-2.0.3 2 ~/iReport
Stryker:Downloads siker$ cd ~/iReport/
Stryker:iReport siker$ ./iReport.sh

Hope that helps someone running into the same problem. I would post a bug report but I saw someone was two steps ahead already and had created a clickable Mac application and submitted a build file. That’s clearly the preferable solution.

]]>
http://www.playingwithwire.com/2008/01/starting-jasper-ireport-on-mac-os-x/feed/ 0
SWT JFace TableViewer Checkbox http://www.playingwithwire.com/2007/12/swt-jface-tableviewer-checkbox/ http://www.playingwithwire.com/2007/12/swt-jface-tableviewer-checkbox/#comments Thu, 20 Dec 2007 00:15:54 +0000 http://www.playingwithwire.com/2007/12/swt-jface-tableviewer-checkbox/ Tom over at the eclipse-dev blog posted this useful snippet for putting native looking checkboxes in SWT JFace TableViewer tables. Unfortunately the checkboxes ended up with a gray background in OS X, as seen in the picture below.

Gray Checkbox Background
An unsightly gray checkbox background.

I came up with this hack to hack the hack to work.

private Image makeShot(Control control, boolean type)
{
	// Hopefully no platform uses exactly this color
	// because we'll make it transparent in the image.
	Color greenScreen = new Color(control.getDisplay(), 
		222, 223, 224);

	Shell shell = new Shell(control.getShell(), 
		SWT.NO_TRIM);

	// otherwise we have a default gray color
	shell.setBackground(greenScreen);

	Button button = new Button(shell, SWT.CHECK);
	button.setBackground(greenScreen);
	button.setSelection(type);

	// otherwise an image is located in a corner
	button.setLocation(1, 1);
	Point bsize = button.computeSize(SWT.DEFAULT, 
		SWT.DEFAULT);

	// otherwise an image is stretched by width
	bsize.x = Math.max(bsize.x - 1, bsize.y - 1);
	bsize.y = Math.max(bsize.x - 1, bsize.y - 1);
	button.setSize(bsize);
	shell.setSize(bsize);

	shell.open();
	GC gc = new GC(shell);
	Image image = new Image(control.getDisplay(), 
		bsize.x, bsize.y);
	gc.copyArea(image, 0, 0);
	gc.dispose();
	shell.close();

	ImageData imageData = image.getImageData();
	imageData.transparentPixel = imageData
		.palette.getPixel(greenScreen.getRGB());

	return new Image(control.getDisplay(), imageData);
}

The result now looks like the picture below.

Normal Checkbox
It’s not pixel perfect but closer.

It’s based on Florian Potschka’s version of makeShot as found in the comments to the original post. Replacing your makeShot method with the one above makes the background of the checkbox transparent. It’s not perfect: we use a random near white background color as our ‘green screen’ color in order to get the right antialias color in the edges. But this will also make any pixels with exactly this color inside of the widget shine through. Hopefully there won’t be many. Given enough time somebody will add checkbox support to arbitrary table cells in SWT and this hack will be made obsolete.

Here’s the complete snippet (untested):

package de.fhmracing.glasseye.canexplorer.gui.transmit;

import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ColumnViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;

public abstract class EmulatedNativeCheckBoxLabelProvider extends
    ColumnLabelProvider {
  private static final String CHECKED_KEY = "CHECKED";
  private static final String UNCHECK_KEY = "UNCHECKED";

  public EmulatedNativeCheckBoxLabelProvider(ColumnViewer viewer) {
    if (JFaceResources.getImageRegistry().getDescriptor(CHECKED_KEY) == null) {
      JFaceResources.getImageRegistry().put(UNCHECK_KEY,
          makeShot(viewer.getControl(), false));
      JFaceResources.getImageRegistry().put(CHECKED_KEY,
          makeShot(viewer.getControl(), true));
    }
  }

  private Image makeShot(Control control, boolean type)
  {
    // Hopefully no platform uses exactly this color because we'll make
    // it transparent in the image.
    Color greenScreen = new Color(control.getDisplay(), 222, 223, 224);

    Shell shell = new Shell(control.getShell(), SWT.NO_TRIM);

    // otherwise we have a default gray color
    shell.setBackground(greenScreen);

    Button button = new Button(shell, SWT.CHECK);
    button.setBackground(greenScreen);
    button.setSelection(type);

    // otherwise an image is located in a corner
    button.setLocation(1, 1);
    Point bsize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT);

    // otherwise an image is stretched by width
    bsize.x = Math.max(bsize.x - 1, bsize.y - 1);
    bsize.y = Math.max(bsize.x - 1, bsize.y - 1);
    button.setSize(bsize);
    shell.setSize(bsize);

    shell.open();
    GC gc = new GC(shell);
    Image image = new Image(control.getDisplay(), bsize.x, bsize.y);
    gc.copyArea(image, 0, 0);
    gc.dispose();
    shell.close();

    ImageData imageData = image.getImageData();
    imageData.transparentPixel = imageData.palette.getPixel(greenScreen
        .getRGB());

    return new Image(control.getDisplay(), imageData);
  }

  public Image getImage(Object element) {
    if (isChecked(element)) {
      return JFaceResources.getImageRegistry().get(CHECKED_KEY);
    } else {
      return JFaceResources.getImageRegistry().get(UNCHECK_KEY);
    }
  }

  protected abstract boolean isChecked(Object element);
}

Hope it’ll help somebody.

]]>
http://www.playingwithwire.com/2007/12/swt-jface-tableviewer-checkbox/feed/ 0
Installing symfony on OS X Leopard http://www.playingwithwire.com/2007/10/installing-symfony-on-os-x-leopard/ http://www.playingwithwire.com/2007/10/installing-symfony-on-os-x-leopard/#comments Thu, 01 Nov 2007 04:59:18 +0000 http://www.playingwithwire.com/2007/10/installing-symfony-on-os-x-leopard/ Just in case anyone runs into trouble with this, I just want to describe the steps for installing the symfony framework on an OS X 10.5 (Leopard) machine.

The good news is that Leopard comes with PHP 5 built in. The bad news is that PEAR is not included, which is needed to install symfony in the most convenient way.

My first attempt to remedy the situation was to run the darwin ports package manager to install pear:

# port install pear-base

Unfortunately there were two problems. First of all, the version of pear that comes with darwin ports does not use the OS X version of PHP by default, but rather looks for the PHP darwin port. This was easily remedied by adding export PHP_PEAR_PHP_BIN=`which php` to /etc/profile but unfortunately that’s not enough. The second problem is that a few files seems to be missing in the darwin port of PEAR and you’ll get the following error when you try to install symfony:


PEAR_Downloader::require_once(Structures/Graph.php): failed to open stream: No such file or directory in Downloader.php on line 1230

Indeed, even running pear install Structures_Graph results in this error message.

The Solution

This blog suggested go-pear.php as an alternative way to install PEAR on the Mac and it does work. So with no further ado, this is how to install symfony on Leopard:

sudo su -
curl http://pear.php.net/go-pear > go-pear.php
php -q go-pear.php

pear channel-discover pear.symfony-project.com
pear install symfony/symfony

Good luck with your Leopard powered symfony hacking.

]]>
http://www.playingwithwire.com/2007/10/installing-symfony-on-os-x-leopard/feed/ 6
Business Decisions: Selecting a Document-format http://www.playingwithwire.com/2007/10/business-decisions-selecting-a-document-format/ http://www.playingwithwire.com/2007/10/business-decisions-selecting-a-document-format/#comments Fri, 19 Oct 2007 21:27:57 +0000 http://www.playingwithwire.com/2007/10/business-decisions-selecting-a-document-format/ If you’ve been reading our blog before, you’ve probably already figured out one thing: we love Open Source and Apple products. Because of this, all our desktop machines run either Linux or Mac OS. Although our mixture of platforms might not be representative for all organizations, this article is still likely to apply to all start-ups and companies that are trying to create a company-wide policy for document-formats.

In our organization today we have three different office suites:

While all of these office suites have their pros and cons, they work just fine until the moment you try to move between suites. In the past in most organization it was often the case that everyone was forced to use Microsoft Office because some manager was bribed by Microsoft upper management said so. However, this is no longer a reasonable approach when we have a more diversified desktop environment than ever before. Today it’s no longer rare that we have Macs and PCs running both Windows, OS X and Linux in the same network. Because of this, forcing all users to use Microsoft Office is no longer reasonable.

First out: Microsoft’s .doc/.xls/.ppt

We’ve concluded that requiring all users to use the same software is unreasonable, but we still need to decide on one document-format that all users can both read and write. The first document format that comes to mind is the .doc-format for documents, and the .xls-format for spreadsheets. Let’s analyze this option a bit.

License: Microsoft’s own proprietary format.

Application .doc .xls .ppt
Open Office Yes (but layout problems) Yes Yes (but layout problems)
Apple iWork Yes (but layout problems) Yes (but uses a different structure natively) Yes (but layout problems)
Microsoft Office Yes (native) Yes (native) Yes (native)

Verdict: Ok, so all of the above editors support Microsoft’s proprietary file-formats. However, the drawback is that it is a proprietary format, which means that both iWork’s and Open Office’s implementation of these formats are most likely reverse-engineered. The real implication of this reverse-engineering is that the support is not really perfect. As you might have experienced, when using Open Office or Pages to export to .doc files, oftentimes the layout of the document is ruined. Since they layout tends to be quite important in business-documents, I would consider this a major drawback.

Next: Open Office’s .odt/.ods/.odp (Open Document Format)

You’ve probably already figured out that this would be our favorite, but let’s try to be unbiased. Similarly to the .doc/.xls/.ppt-combo, we’ll start out with a table of the support in the relevant applications.

Licensing: Creative Commons.

Application .odt .ods .odp
Open Office Yes (native) Yes (native) Yes (Native)
Apple iWork No No No
Microsoft Office Yes, with plug-in Yes, with plug-in Yes, with plug-in

Verdict: Unfortunately it seems like the Open Document Format won’t work. Here the biggest problem is iWork. It is really a shame that Apple chose to not include support for this format. However, there might be an answer for why this is. According to Apple’s list of features in Leopard, we can see that there’s support for Open Document Format in TextEdit. Without having any evidence at all for this claim, we would guess that Apple intentionally chose to not include the support for Open Document Format in iWork simply because they would add support for the format on OS-level in Leopard.

The decision

As you can see in the charts above, none of the two alternatives is perfect. What holds the .doc/.xls/.ppt-combo back is its proprietary nature. Because of this, all the other applications fail to read and write these files good enough for a corporate environment. What holds the Open Document Format back is the lack of implementation in iWork. Moreover, it might also be cumbersome to have to use a plug-in to read and write Open Document Files in Microsoft Office, even that that’s still better than no support at all.

The bottom line is that at this point, the only possible approach is to use the .doc/.xls/.ppt-combo. Although we don’t like it, we’re out of luck with Open Document Format due to the lack of support in iWork. However, because of the uncertainty of the support of Open Document Format in Leopard, we will actually wait and see until it’s launched to take a formal policy decision on our Document-format.

]]>
http://www.playingwithwire.com/2007/10/business-decisions-selecting-a-document-format/feed/ 6
Prisonbreak: iPhone Unlock Review http://www.playingwithwire.com/2007/09/prisonbreak-iphone-unlock-review/ http://www.playingwithwire.com/2007/09/prisonbreak-iphone-unlock-review/#comments Sat, 15 Sep 2007 02:07:18 +0000 http://www.playingwithwire.com/2007/09/prisonbreak-iphone-unlock-review/ Over the last few days, iPhone unlocking has seen a couple of sharp turns. First iPhoneSimFree promised to deliver a commercial solution to unlock your iPhone. Then they hesitated and decided to become a wholesale only company, further delaying their release. Ultimately, they missed the train and the hacking community stepped in (Free iPhone unlock supposedly pending (Updated x2)), and released a free hack: iUnlock by the iPhone Dev Team (no association with Apple).

The box for a 4GB iPhone.Since vendor lock-in is never a good thing for the customer, the release of this software is great news. And as fans of the free market may be aware, cell phone unlocking is legal. But does it work? Playing With Wire decided to find out. We picked up a 4GB Apple iPhone, headed out on the internet and soon found a great unlocking tutorial at modmyiPhone. The guide is Mac specific, but we also stumbled across unlock.no which appears to offer a guide for Windows users – we didn’t try it though.

The Unlock Process

The process is a little bit lengthy but everything is done using simple graphical tools. For starters, you need to make sure your iPhone is entirely up to date. iTunes does this for you after you trigger the ‘recovery mode’ of your iPhone, by pressing Sleep and Home for 25 seconds.

iPhone in recovery mode.
The iPhone in recovery mode.

Once you’re in recovery mode you can just connect the iPhone to your computer and iTunes will offer you the option of restoring the phone. Prepare yourself for the first of a couple of lengthy downloads – for us iTunes downloaded 96 MB of software updates (we used iTunes 7.4.0 and iPhone Firmware 1.0.2 for this article). When it’s all done, iTunes will tell you so and you can close down the application.

So now we had an updated but not yet activated iPhone. The Mac application “iNdependence” makes activation a breeze, but this is where the second lengthy download comes into the picture as you have to download the firmware a second time. We did run into a minor snag: when we followed the instructions on the page we couldn’t get the activation to work on our first attempt. Disconnecting the phone, restarting iNdependence and then reconnecting the phone took care of it though – iNdependence unlocked the phone without complaint. Voila, now we had an iPhone that was basically like Apple’s latest iPod, the iTouch: it could play music and video, but it couldn’t make phone calls.

iNdependence activating an iPhone.This is where the Unlock application comes into play. To actually get it onto the phone, you need SSH installed though. Just like the guide says, the AppTapp application allows you to install third party software on your iPhone. We ran into trouble here though: when we ran AppTapp we got an indefinite progress bar. We waited a good 15 minutes for the application to finish, but it never did. What’s worse, our iPhone locked up in ‘recovery mode’ and could no longer be started. We realized that we had left iNdependence running from the previous step, and perhaps this application conflicted with the AppTapp installer. Regardless of the reason, the iPhone was dead at this point.

AppTapp making no progress.
AppTapp never got any further than this for us.

We restarted the iPhone and connected it to iTunes to restore it to factory settings. We were horrified as iTunes crashed very early on in the process. We mentally readied ourselves for creating our own Will It Blend episode, thinking the phone was a goner. Luckily after a full reboot of both the computer and the phone, the software reset went through.

We were back to square one, and had to go ahead and again activate the phone with iNdependence and then go for a second attempt at installing AppTapp. To be on the safe side, we downloaded the most recent version of AppTapp from its homepage. We made sure iNdependence was turned off.

This time we got an error message instead – something about a boot strapping process failing and a reference to the console. So we pulled up Console.app (/Applications/Utilites/Console) and took a look. To our surprise, the iPhone installer software was still working despite the error message.

AppTapp is reporting stuff in the Console.
Look! Something is still installing.

A couple of minutes later the phone restarted and all was well. The Installer icon appeared on the iPhone desktop and we could install the required software as described in the guide.

Installer.app on the iPhone.
Some of the applications the AppTapp Installer can install.

An activated iPhone with it’s SIM card removed.In the final part of the guide, the actual Unlock software is installed using SFTP. The guide recommends transferring the application bundle using Cyberduck, but we figured any SFTP client would do it. We had Panic’s Transmit installed, which worked just fine. After copying the files as instructed, and restarting the phone one more time, we finally had the Unlock icon on the iPhone desktop. It was time to install our T-Mobile SIM card and hope for the best.

25 minutes later we were making T-Mobile phone calls.

Notes and Observations

During the above process SSH was installed on the iPhone. This allows anyone who knows the default root password to log into your iPhone and do anything they want, as long as the phone is on a wireless network. We strongly recommend that you change your password as soon as possible using the ‘passwd’ from an SSH session.

With the same IP as before, SSH in using Terminal and run ‘passwd’ to change the root password.
Using SSH to change the default password (dottie).

So far, our iPhone has worked very well with T-Mobile. Initially there was an artifact ‘missed call’ icon hanging around over the Phone icon – a red circle in the upper right corner of the phone. Obviously, visual voice mail isn’t enabled as that’s an Apple and AT&T special feature, but the voice mail indicator works. When you press the icon, the phone calls your voice mail like a regular cell phone would.

Verdict

The Unlock application works just as advertised. Including the time it took us to take photographs and the time we spent resolving our few problems, the whole unlocking process took no longer than 2 hours. At no point was a non graphical tool needed, which surely will come as a relief to some users.

Unfortunately, the process is not entirely simple even with the graphical tools, since there are several opportunities to brick the phone or otherwise get tripped up. Still, if you feel confident with your technical abilities, and you don’t feel confident in AT&T’s cell phone abilities, this is the tool you’ve been waiting for. The iPhone is free.

]]>
http://www.playingwithwire.com/2007/09/prisonbreak-iphone-unlock-review/feed/ 5