Mac Pro Wake from sleep, restarts instead

A couple of weeks ago my Mac Pro (Early 2008) started failing to wake properly from sleep – basically it would boot from scratch rather than awaken.

PRAM zapped and all the usual stuff you see written across various forum. Then at the point of installing a replacement backup battery, I noticed a bright red light on one of the RAM risers.

Cutting a long story short, one of the RAM modules has failed. Checking the system profile, 4Gb of installed RAM is missing. The mac has wisely ignored the failing bank of RAM, but it would have been nicer if it had also alerted me to the fact prior to looking inside.

End result: physically removed the modules on the failing bank and now sleep/wakeup works as normal again. Fingers crossed the memory supplier will replace the failing package on their lifetime warranty.

Flex4.6 mobile maxChars bug/problem and workaround

Bug-note to self, and workaround while waiting for the bug-base to migrate from Adobe to Apache.

I’m using in a Flex 4.6 mobile project and found that setting the maxChars property to 512 caused exeption:

Main Thread (Suspended: ArgumentError: Error #2006: The supplied index is out of bounds.)
flash.text::StageText/set viewPort [no source]
spark.components.supportClasses::StyleableStageText/updateViewPort
spark.components.supportClasses::StyleableStageText/commitProperties
mx.core::UIComponent/validateProperties
mx.managers::LayoutManager/validateProperties
mx.managers::LayoutManager/doPhasedInstantiation
mx.managers::LayoutManager/doPhasedInstantiationCallback

However setting maxChars to something much smaller (e.g. 10) was fine. From experimentation, seems that the biggest number to which maxChars could be set without causing the problem was 481. I have no idea what that number relates to. Anyway the database field my TextInput corresponds to is 512 chars max so that’s the number I need.

The workaround:

Setting maxWidth on the TextInput seems to solve the problem. But rather than insert a constant I want the TextInput to flex to the width of it’s container, so the following seems to avoid the problem:

 

<s:TextInput
id        ="textInputId"
maxWidth  ="{skinableContainerId.width}"
maxChars  ="512" />

 

The future of Flex :

Thanks for the Macs

The passing of Steve Jobs last week, like others, caused me to reflect on his impact on my life via Apple.

I was a child of the 70s and teen of the 80s. I wanted to fly aircraft and was into science (fiction and fact) and electronic music.

Science fiction was full of computers : from Star Wars, Space 1999, BattleStar Galactica, Buck Rogers and Blake’s 7 etc

As for science fact, the first significant event I remember well – being allowed out of lessons to watch the first Space Shuttle launch on tv. Around that time the school had 3 computers. Two Commodore PETs and a ZX81. I got into trouble for not doing my homework to write a program to tie a tie. It was only ever to be a series of print statements that had to read out for the teacher to type into the PET. I had a go at reading from my blank note-book, but he sussed me. Despite that fail, my interest in computing was sparked and my savings went into getting a ZX81 and a couple of years later a ZX Spectrum and input of many listings from the likes of Sinclair User and Your Computer.

I gradually became aware of Apple via occasional appearances of the Apple II on the likes of the BBC Computer Programme / Micro Live. It had an immediate reputation of being a cutting edge machine but massively expensive. Similarly the original Macintosh was far beyond anything I could afford, so my next machine was to be a Sinclair QL. Although the QL was still not a GUI machine, Mac was already an influence causing me to create my A-Level computer science project on the QL, a GUI music sequencer. Admittedly it was just a graphical menu system driven by cursor keys, but this was the start of my interest in UI programming.

In my first year at University I bought my next machine – an Atari ST 512. Finally something with a GUI. A decent machine for the budget, and useful for games and as a music sequencer. It had a WYSIWYG word processor, but output looked a bit rough by the time my Epson LX-80 had printed. It was no Mac.

My 3rd year at Uni was industrial placement. I spent my year with ICI programming VAX FORTRAN on a DEC VAX 6310 cluster running VMS. All the UI work was text menu based and occasionally command-line. I was then well prepared for a career of programming in an industrial environment. However I was saving up deciding on a new machine for my final academic year where I knew I’d need to write up my final year project. I bought a number of issues of MacUser – everything about Mac oozed quality and I longed for one.

So in 1991 I managed (strangely) to get a discount on my first Mac by trading in my Sinclair QL. I was sad to see the QL go, but very happy to welcome a Macintosh LC and StyleWriter with WordPerfect for Macintosh. A really good machine which I retain to this day. Although it hasn’t been out of it’s box for a while.

WordPerfect came with student discount and a competition. I entered and won. The prize : A new Macintosh LC! Once sold, the initial net cost of my first Mac turned out to be pretty small. Other than completely underestimating how long it would take to print out my final report at full quality on the StyleWriter this machine was a good choice. While others were messing tweaking PCs, the Mac just worked and the print quality was great.

Through MacUser I was once again a lucky competition winner. The Prize: Flight to San Francisco with tickets to attend MacWorld Expo 1993. I had only been abroad once before so this was the trip of my life to that point and the exhibition at the Moscone centre was the biggest I;d ever seen. My least expensive purchase during the trip, but the most valuable, was a copy of Macintosh Human Interface Guidelines (ATL). I haven’t read it in some time but while all the examples in the book are specific to the look and feel of Mac System 7, I recall it includes reasoning and many principles which remain useful today.

By the end of it’s useful life in about 1994/1995 the LC’s memory was increased from 2Mb to 6Mb, vRAM increased from 256K to 512K, hard disc increased from 40Mb to 500Mb, an accelerator replaced the 68020 cpu with 68030, a 17inch monitor replaced the tiny 12inch original, AppleCD 150 CD-ROM drive was added and I saw QuickTime running for the first time. Ok, the drive was single speed, discs loaded via a caddy, and the video was postage-stamp size – but it felt revolutionary. Also many hours were spent in the world of MYST – CD-ROM based game.

Back in 1993 being the owner of a Mac and having an interest and knowledge of user interface principles helped me win my first job in ‘interactive media‘. A startup company formed to develop applications teaching English as a second language. We started with an empty office, my Mac LC and PhotoShop, soon replaced by a Quadra 800 and we choose MacroMind Director with which to develop our educational games.

Since then and to date I have always had a Mac as my primary machine and usually a PC to target-test. My work programming interactive media has taken me from small town small company through to London multinational PLCs and now to working freelance. I used System 6 through System 9 and Mac OS X from 10.1 to 10.7 and loved it – every improvement every step of the way.

I am no Apple fanboy. I don’t buy everything Apple produces (no iPad no iPhone). I grumble when things don’t work. I didn’t agree with everything Steve Jobs said but Macintosh in particular has been good to me every day for the past 20 years. For that I thank Steve Jobs and the teams of people he brought together to make it happen. I hope we (Apple staff and customers) all learned enough from his example to keep up the momentum. His passing has given me a kick in the pants to go and get more stuff done.

Which width? (AIR on devices)

Within the Flash APIs is there there are many similarly named properties which provide subtly different results based on their spec and the state of the application. Width and height are such properties.

Having just read of Mike Jones’ recent article: 10 Tips When Developing For Multiple Devices, and tip #1: Check screen dimension on initialisation, it includes a couple of lines of code to get the landscape height and width of the device screen using a boolean expression to determine the longest dimension. For me this begs the question, why can’t I simply get the right values directly from the API? Especially if my app.xml properties state the app should only display landscape, full screen.

The properties examined here:

Although accurately described in the reference, it isn’t necessarily easy to visualise the differences in behaviour for these properties from the documentation alone. So herewith, a simple HelloWidthHeight app to trace out the values upon initialisation. Included in that app is a class implementing logic based on Mike’s as static methods. The results of debug sessions executed on my HTC Desire are detailed for comparison in the table below.

Key app.xml <initialWindow> properties used were:

  • <visible>true</visible>
  • <aspectRatio>landscape</aspectRatio>
  • <autoOrients>false</autoOrients>
  • <fullScreen>true</fullScreen>
A B C D
stage.orientation default rotatedRight rotatedRight rotatedRight
stage.width 0 0 0 0
stage.height 0 0 0 0
stage.stageWidth 480 800 800 800
stage.stageHeight 800 480 480 480
stage.fullScreenWidth 480 480 800 480
stage.fullScreenHeight 800 800 480 800
Oriented.landscapeScreenWidth 800 800 800 800
Oriented.landscapeScreenHeight 480 480 480 480
Oriented.portraitScreenWidth 480 480 480 480
Oriented.portraitScreenHeight 800 800 800 800
  1. Screen inactive, phone held in any orientation
  2. Screen active, phone lying flat on the desk
  3. Screen active, phone held landscape, mic to the right (this is the intended orientation for the app)
  4. Screen active, phone held portrait, mic to the bottom

In conclusion, unless the application is only ever launched while the screen is active (though that would be the norm), the safe way of determining an oriented width and height is to use a boolean expression along with the fullScreenWidth and fullScreenHeight properties.

UPDATE (20-July-2011): The following table runs the same code in the BlackBerry PlayBook Simulator:

A B
stage.orientation default default
stage.width 0 0
stage.height 0 0
stage.stageWidth 1024 1024
stage.stageHeight 600 600
stage.fullScreenWidth 1024 1024
stage.fullScreenHeight 600 600
Oriented.landscapeScreenWidth 1024 1024
Oriented.landscapeScreenHeight 600 600
Oriented.portraitScreenWidth 600 600
Oriented.portraitScreenHeight 1024 1024
  1. Simulator initially landscape
  2. Simulator initially portrait

Note: Behaviour is slightly different on the PlayBook simulator in that the orientation of the application is set before the initialisation code runs. Therefore unlike on the HTC Desire, fullScreenWidth and fullScreenHeight are correctly returned as the orientation of the application expects.

If anyone else cares to run the code, I’d be interested to hear how variable other devices are in their results, or if this is showing a bug when run on HTC Desire. Running AIR 2.7 here.

Apple Cinema HD 23inch dies, then resurrects

This morning I was greeted with a blank screen and the power light flashing short-long-short, and groaned at how expensive today was about to get.

The Apple support page states that this flash pattern indicates the wrong power adaptor is being used with the display. I’m using the original 90W adaptor supplied with the screen and keep it powered via an APC UPS.

Fortunately with a bit of googling I found the ‘paper w’ solution here and on the post by jakobeon on the Apple disscusions forum. Essentially by using a strip of paper to blank off the middle of the 5 output pins from the power brick, the display is back to life.

From reading through comments made by others in both forums, and scanning over the power adaptors page, I’m forming the following conclusions. (Note: these are my guesses based only on my interpretation of other’s anecdotal evidence rather than anything authoritative).

1. I suspect the middle pin is used only to allow the monitor to sense which of the 3 Apple power-bricks is attached. If so then it seems more concerned with protecting the monitor from a low power brick, rather than from being overloaded somehow.

2. A number of people have indicated that simply replacing the brick like for like or with the higher power version makes no difference. This suggests to me that the fault is within the electronics of the monitor, when detecting the power source at switch-on, rather than in the brick.

So while this is far from an ideal solution, it is cheap, simple and quick to implement compared with trucking everything back for repair. However if in doubt, get it repaired by Apple – don’t blame me if your house burns down.

Finally using a decent mouse-surface

I’ve been using Apple Magic Mouse for some time. I love it. I’ve used loads of optical mice before it. The one thing that annoys me, even with this mouse, is that it’s accuracy depends very much on finding a decent surface.

I tried loads and loads of surfaces. More or less any surface (except transparent) will do for short stints. But for my workstation, my most used have been the cover of a hard back note-book (such as the Black n’ Red Casebound Hardback A4 Book), glossy magazine covers, other cardboard rectangles (e.g. the back of a note pad) taped to the desk. All of these surfaces tend to suffer the following problems:

  • They wear out
  • They move across the desk unless taped down
  • They are abrasive t the mouse – the tracks on my magic mouse are looking a little worn
  • They get grubby
  • They they turn to mush if coffee is spilled on them
  • Eventually the only relationship of the screen pointer to the mouse is that it moved

Now I think I’ve finally found a surface that will not wear down my mouse rails any further, so far yields extremely accurate results and will stand up to a tea spillage. Unfortunately costs a few quid, but that’s better than trying to accommodate a pointer with a mind of it’s own when on a deadline. The Razer Vespula Gaming Mat.

cPanel and mail subject filtering

If you are using ‘User level filtering’ of email in cPanel (v11.28.83), applied to the Subject header of an email, you may encounter circumstances where sometimes the filter fails for no obvious reason. On investigation of the email headers, it turned out that a certain sender was folding email subject headers over multiple lines. If the phrase being searched for was split over two lines within the header, the filter would fail.

For example, with rule : Subject contains ‘testing 123′

1. this would work:
Subject: line 1 testing 123

2. this would work:
Subject: line 1
 line 2 testing 123

3. this would NOT work:
Subject: line 1 testing
 123 line 2

It turns out that this is because cPanel simply passes the filter information down to exim, and it is here that the behaviour manifests.

I have posted an entry to the feature requests forum of cPanel, for it to be configured to better tolerate multiline subject headers. If you are encountering this problem, it would be helpful if you would contribute to that thread.

In the meantime a workaround is to use the ‘matches regex’ filter, replacing spaces in your match-phrase with ‘\\\\s+’. For example the following rule works in each of the three samples above.

Rule: Subject matches regex testing\\\\s+123

switched to svn via https on mac os x

I finally decided it is time to switch to accessing subversion repositories via apache and the https scheme rather than ‘file://’ scheme. Search revealed many articles touching the subject, but none providing exactly what I need. So documenting:

  1. The problem and motivation
  2. Up to date?
  3. Getting apache to serve https
  4. Configuring apache to serve subversion
  5. Migrating existing working copies to the new scheme
  6. Reference links to articles that helped

Problem and motivation

My main development machine is a Mac Pro running 10.6.4. My development projects are all kept outside my home directory on a second disc, one project per folder. Each project folder contains a subversion repository folder named ‘svn’ along with one or more working copies.

For the last few years I have checked out working copies using the ‘file://’ protocol. This seemed the simplest and most efficient approach in this single-user environment. I use svn clients such as SvnX, and Subclipse and occasionally the command line (for which having the svnbook to hand is a must). I have groaned previously about DreamWeaver’s subversion integration ‘attempt’ failing to support the file protocal (remains unchanged in CS5).

There are a couple of things I want to solve:

Firstly, I occasionally use VisualStudio in Windows7 running in parallels on this machine to work with ASP.NET. In the past I’ve simply pointed it at the working copy via the network drive. Of course this means that I can’t undertake svn operations through Win7 since that working copy’s URL is alien to the Windows 7 instance. Not too much of an issue since it’s only a matter of switching back to a Mac window to do svn business. However there is an annoying problem with VisualStudio’s code completion where it is unable to correlate markup within an .aspx file with it’s .aspx.cs file when the site is on a parallels network drive. To solve this I need to check out a working copy to the Windows7 local disk.

Second, I have taken to getting out and about with my MacBook Pro. If I want to work on the move I need to check-out a working copy.

For both these situations using the ‘file’ protocol is inappropriate. Attempts to check work back in are bound to generate svn errors as multiple svn systems attempt to obtain exclusive locks on the repository.

If however we can get to a single user/process touching repository files we can solve this problem – enter apache.

Up to date?

First thing I did was get my subversion installation up to date. At time of writing 1.6.12. Installer available from CollabNet. Just run the installer and follow the instructions. Note: this version installs into a different location to that installed by Apple. You may need to tell your client tools the location of the subversion to use.

That said, this isn’t going to help with DreamWeaver all that much. DW’s Subversion functionality is tightly tied to specific versions. Should you dare  touch a working copy with a later version (which changes some of the meta data) DreamWeaver will cease to work with that working copy. More information at this Adobe technote. So for now as far as I am concerned, until Adobe start releasing ‘upgrader extensions‘,  DW’s subversion functionality remains useless and turned off with ‘.svn’ files cloaked and svnX used for commits.

Getting apache to serve https

In the short term I have no plans to open access to my repositories via the net. However it is a future possibility so I think it worth getting going with https from the outset is worth it.

Mac OS X of course uses Apache for web-sharing. However it’s default state is not configured to serve SSL. To do so, we need a secure certificate and some configuration changes. As I am the only person accessing this machine, and I trust myself, I have no need to obtain a certificate from a commercial authority.

Steps taken to create the certificate and configure apache to use it…

Create a certificate authority

mkdir /Library/Certs
cd /Library/Certs
perl /System/Library/OpenSSL/misc/CA.pl -newca
[ENTER](to create new certificate)

Generate private key

openssl genrsa -des3 -out webserver.key 1024

generate a non-password protected copy of the key

openssl rsa -in webserver.key -out webserver.nopass.key

Generate a certificate request

openssl req -config /System/Library/OpenSSL/openssl.cnf \
-new -key webserver.key -out newreq.pem -days 3650

Sign the certificate request

perl /System/Library/OpenSSL/misc/CA.pl -signreq

You should now have created…

/Library/Certs/demoCA/
/Library/Certs/newcert.pem
/Library/Certs/newreq.pem
/Library/Certs/webserver.key
/Library/Certs/webserver.nopass.key

Tell Apache to include SSL

We now need to edit apache’s httpd.conf. You need to ‘sudo’ to acquire sufficient privileges to do so, and need to take care. Optionally make a backup copy of httpd.conf.

cd /private/etc/apache2/
sudo cp httpd.conf httpd.conf.bak
sudo pico httpd.conf

Find the following line and uncomment it by removing it’s # prefix

Include /private/etc/apache2/extra/httpd-ssl.conf

Use CTRL-O then CTRL-X to exit pico and we now need to edit the file we just included…

cd extra
sudo pico httpd-ssl.conf

Go through the file finding the following attributes ensuring they are uncommented and point to the SSL files we just created…

SSLCertificateFile "/Library/Certs/newcert.pem"
SSLCertificateKeyFile "/Library/Certs/webserver.nopass.key"
SSLCACertificateFile "/Library/Certs/demoCA/cacert.pem"
SSLCARevocationPath "/Library/Certs/demoCA/crl"

You should now be able to restart apache either through System Preferences… > Sharing > Web sharing, or

sudo apachectl graceful

You can access any errors via the Console application. If all is well you should be able to enter https://localhost/ into your browser’s address bar and get a result.

Configuring apache to connect to and serve subversion

Firstly, we are going to require a login. In my case I am going to create 3 login IDs. One for my normal workstation. Others for access via Win7 and my MacBook pro. So although all the work in the repro is by me, I can see which environment was used.
To do this, we will create an authorisation file containing the three users and place it somewhere sensible. For me…

cd /Volumes/projectdisc/projects
mkdir subversion
cd subversion
mkdir authfile
cd authfile
sudo htpasswd -c svn_passwd mpuser
sudo htpasswd svn_passwd mbpuser
sudo htpasswd svn_passwd win7user

you should now have svn_passwd contianing 3 users and their password hash strings. Returning to apache configuration, you may have noticed that the last line of httpd.conf reads…

Include /private/etc/apache2/other/*.conf

This includes, in alphabetical order, any further files ending .conf in the subfolder ‘other’. We will use this to add a svn.conf file to that folder…

cd /private/etc/apache2/other
sudo pico svn.conf

Will open an editor with empty/new file svn.conf. The first line of which will be:

LoadModule dav_svn_module /usr/libexec/apache2/mod_dav_svn.so

After this, we will add configuration blocks, one per project repository…

<Location /svn0000-svntest>
DAV svn
SVNPath /Volumes/projectdisc/projects/0000-svntest/svn
AuthType Basic
AuthName "subversion"
AuthUserFile /Volumes/projectdisc/projects/subversion/authfile/svn_passwd
Require valid-user
SSLRequireSSL
</Location>

Using keys ctrl-o then ctrl-x will save the new file and exit pico.

This configuration block tells apache to redirect svn0000-svntest to the repository at path /Volumes/projectdisc/projects/0000-svntest/svn. It requires a valid user authenticated against the file at /Volumes/projectdisc/projects/subversion/authfile/svn_passwd. Since this location will only ever be served through SSL, basic AuthType is ok and secure.

For apache to pick up this change, we need to restart it:

sudo apachectl graceful

One further step we need to make is to ensure apache is the only user/process to have control of the repository files. This shouldn’t be an issue as we are migrating access to be always via https and don’t want the file protocol used any more…

cd Volumes/projectdisc/projects/0000-svntest/
sudo chown -R www:www svn

At this point you should be able to access the repository through your browser with url http://localhost/svn0000-svntest

You will receive an alert indicating that the certificate is not trusted. You can tell safari that it should always trust this certificate.

To add further repositories, we simply need to change ownership as above, then add the detail to the configuration by simply duplicating the code block above with the Location text and SVNPath modified accordingly. The rest can remain as is.

Migrating existing working copies to the new scheme

My existing working copies each use the file:// url scheme. We need to convert them to use the new https scheme. This is pretty easy assuming you already have the Location added to svn.conf. Just cd to the working copy folder, use svn info to reveal the working copy’s url and relocate…

cd Volumes/projectdisc/projects/0000-svntest/wc
svn info
svn switch --relocate file:///Volumes/projectdisc/projects/0000-svntest/svn/trunk/wc https://localhost/svn0000-svntest/trunk/wc

If you are prompted that the certificate is invalid, use option p to permanently trust the certificate.

Reference links to articles that helped

Reading the following, articles that helped me work out what I wanted to do…

Along with chapters 3 and 10 of Subversion Version Control: Using The Subversion Version Control System in Development Projects ISBN-10: 0-13-185518-2 also on Safari books online.

Adobe AIR 2 runtime s for Windows, Mac and Linux publicly available

Spreading the word based on Adobe’s notes…

The AIR 2 release includes many new features including:

  • Native Process API
  • Open documents with the user’s default application
  • Microphone data access
  • Mass storage device detection
  • Updated, faster WebKit with enhanced support for HTML5 and CSS3
  • Multi-touch
  • New networking support including UDP and server sockets
  • Screen reader support
  • Reduced CPU usage on idle
  • Up to 30% reduction in memory usage without recompiling an application
  • + more

Links:

This coincides with the final release of Flash Player 10.1…

hello desire

So, it’s good-bye to my trusty and slightly crumbling Nokia 3100 (recently a source of amusement and pity amongst my peers)…

Nokia 3100

Hello HTC Desire…

HTC Desire Unboxed

It could so easily have been hello iPhone. I do have iPod Touch which I enjoy using. But fundamentally as a Flash/ActionScript/Flex/AIR developer it made no sense at all to get a smartphone on which Flash has been nobbled.

(My own brief comment and observation on the iPhone/Flash debacle : It looks to me that both companies have incompatible business strategies with regard to delivery of RIAs on mobile devices. Discussion outside of the these strategies is in my opinion a deflection. It was disappointing to read Steven Job’s thoughts on Flash, which to my mind are ill-informed and based on half truths – out of character in those regards. It was also disappointing to watch Adobe CEO Shantanu Narayen’s response in interview with the Wall Street Journal where, in my humble opinion, he was far from convincing and by the end was sounding more like a parroting politician. Disappointing too that past quality and performance issues with Flash player gave Apple an easy ammunition to exaggerate and exploit. As an avid Apple Mac and Adobe Creative Suite user I hope the two companies can return to a professional relationship which doesn’t leave customers of both companies, like myself, out in the cold.)

So back to the HTC Desire, some first impressions…

The good

  1. It looks good, feels good
  2. Nice bright responsive screen
  3. Call quality is good
  4. Better quality camera than I expected
  5. The main reason for getting this device – Flash based apps are allowed!

The not so good (compared with my iPod Touch experience)

  1. There are too many buttons. I find myself pressing the wrong one most of the time. Sometimes a button press is required. Sometimes not. The whole thing is less intuitive than the iPod Touch with it’s single button.
  2. It seems all too easy to initiate a call at random while scrolling through the contact list.
  3. Text selection/cursor positioning is awful
  4. There is no out of the box easy way of syncing Address book, Calendar, tunes, photos etc with my Macs. Looks like I need to purchase Missing Sync. That said, I did previously purchase Mobile Me to keep my Mac / Mac Book Pro and iPod Touch all in sync.
  5. The Mail application is crap. I use a self-signed SSL certificate on my mail server, so I immediately hit the problem of a silent fail when trying to add connection details to the mail application. The hack in the forum thread worked in fixing it, i.e. turning off my router’s WAN connection, while inputting the connection details. Also it doesn’t list the mail folders on the server – all I get is the inbox. Apple’s Mail app by comparison is a doddle and reflects the structure of my mail account.

Fingers crossed for Android 2.2.

Anyway, looking forward to setting up some kind of tether to share the data connection with my MBP and more importantly getting something running in AIR for Android on there.