Pages

Twitter Updates

Wednesday, May 18, 2011

Custom metadata tags in Flex 4.5

After upgrading to Flex 4.5 recently, I have become annoyed with Flash Builder's new obsession with marking metadata tags as unknown.

Unknown to you, FB, maybe, but not to me or my friends....we make heavy use of custom metadata tags, especially since adopting the parsley framework almost two years ago.

So I was kinda happy to find this after some digging:

Turns out, hidden down in the flex 4.5 sdk frameworks dir is a little file called metadata.xml that provides metadata about the metadata tags. The FB tooling uses this file to configure the new auto-prompters for metadata.

Cribbing the syntax from the SDK file, I crafted a metadata.xml for parsley 2.4 which has helped to shut FB up. It just needs to be included as an asset copied into the SWC.

 

Monday, May 09, 2011

Samsung 2343BWX and MacBook Pro


I recently upgraded to a Samsung 2343BWX monito
r for work. Lovely 23" screen at a great price. Natur
ally, I wanted to exploit the full 2048 x 1152 native resolution with my (older) MacBook Pro.

Problem: the Mac wouldn't recognize the max res of the monitor. I was stuck in 1920 x 1080 !

No obvious answers anywhere on the 'net.

Long story short, the solution is software: grab a copy of SwitchRes X 4.x and then create a custom config as follows:



Saves changes, reboot and select the new resolution via the System Display preferences.

Voila!

UPDATE: Recently, my MacBook Pro simply refused to offer the 2048x1152 setting and SwitchResX reported it as "Invalid". After much mucking about, I finally stumbled over the "Overscan" option in the main Display prefs. It was turned off. Turned it on, and life is good again.



Monday, February 22, 2010

DevOps - about time!

The DevOps movement seems like a no-brainer to me: treat the management of operational systems as we treat the management of software development.

Version control everything, seek to automate every single process that changes anything and automatically test every change. And then, make the smallest number of changes necessary to deliver the benefit sought. Take as many human, error-prone activities *out* of the overall process as possible - or as I've been overheard to say on a particularly bad afternoon "eliminate the monkeys".

Not surprisingly, devops and agile are strongly related - indeed, some have described devops as extending agile the "last mile" beyond development and into operations. About time!

in reference to: http://blogs.rpath.com/wpmu/closing-the-gap/2010/02/22/devops-a-movement-emerges/ (view on Google Sidewiki)

Sunday, August 09, 2009

xobj hosted on bitbucket

This post should have be written a few months ago. xobj has been made available as open source on bitbucket

The xobj project provides an object reflector between various dynamic languages and XML. Currently, python and ActionScript 3 implementations are available.

Motivations

xobj was motivated by a few specific goals:

  • Make the use of XML for object model interchange between client and server tiers less painful
  • Allow your code to use real typed instances of classes rather than simple generic data structures
  • Treat your code as the definition of schema rather than forcing an XMLSchema driven approach on your code.
  • Read and write XML documents that will pass most XMLSchema structural validation requirements with relatively little effort on your part
It is not required to provide an XML schema to use xobj. Custom objects may be used for parts or all of the document, whether or not an XML schema is provided. Schema validation is optional. If new elements show up, they will be preserved across read/write; schema additions will not normally require code changes.

Implementation Notes

During XML decoding, xobj preserves namespaces, element ordering and tracks attributes vs elements so that re-encoded object graphs can comply with most of the common XMLSchema validation requirements. This observed metadata is attached to your object graph rather than hidden out of view.

For "whole cloth" generation of XML from object graphs that were not themselves decoded in the first place, you can provide the namespace, elements ordering and attribute metadata declaratively to facilitate XMLSchema conformance.

However, most casual-use applications don't need to worry about namespaces, so your instance graphs will encode just fine as a usable XML document leveraging as much runtime class introspective data as is available. (AS3 in particular)

During decoding, xobj uses both the runtime type information available from your classes as well as a typemap you specify to determine the target type for every decoded XML element.

During encoding, xobj uses this same runtime information plus additional observed (or provided) metadata to inform the output XML.

For ActionScript, xobj decodes XML documents directly into typed instance objects rather than generic Object or ObjectProxy wrappers. This avoids the double-handling of generic objects required by the default SimpleXMLDecoder provided by Adobe Flex.

We've made a lot of use of this library in recent Flex/Python RESTful services at rPath.

Wednesday, August 05, 2009

Loading local file content in Flashplayer 10 with Flex

Recently, I was asked to improve a text entry UI for submitting certificates in support of Amazon EC2 credentials. We'd received feedback that copy/paste was proving problematic for certificate entry due to the finicky line-ending rules involved. The desired solution was to add a "Read from file..." button that would load the cert from a local file and paste that content into the UI. Note that we didn't want to upload the file itself, simply extract the content in the local client.

Flashplayer 9 won't let you do this. Flashplayer 10 will.

The solution revolves around the enhancements made to the FileReference class in Flash 10.

I'm posting this mainly because the examples I found on the net were either out of date (Flashplayer 10 changed in the final release) or were flat out wrong.

Firstly, make sure your dev environment is configured to use the playerglobals.swc from the Flash 10 player. Instructions for doing this can be found here

Second, crucial point, is that you must hold onto a reference to the FileReference instance across the whole browse, select, load and extract cycle. Failure to do this results in the instance being GC'd out from under you and subsequent "missing events".

This should be enough code to get you going:


// we need to keep this ref to prevent the fileRef getting GC'd
// cause the docs say that if it goes out of scope, you' won't get the
// completion events

private var fileRef:FileReference;

// call this from a button click or other control
public function handleReadFileContent(event:Event):void
{
fileRef = new FileReference();
fileRef.addEventListener( Event.SELECT, onFileSelect );
fileRef.addEventListener( Event.COMPLETE, onFileComplete );
fileRef.browse();
}

private function onFileSelect( event:Event ):void
{
fileRef.load();
}

private function onFileComplete( event:Event ):void
{
var content:ByteArray = fileRef.data as ByteArray;

myTextField.text = content;
}

Friday, July 18, 2008

Charles Web Debugging Proxy

Wish I'd found Charles earlier. A richly featured yet easy to use HTTP proxy designed specifically for web developers to debug the interactions between the browser and the server.

It has made debugging the Flex client to Python service interactions much much easier. It's also helped me win arguments with the guy writing the backend as to why the problem was on his side and not mine. :-)

Wednesday, July 09, 2008

Code Coverage in Flex

If you're doing any kind of serious development in Flex, you need to be looking at your test cases and the code coverage you're getting.

One of the challenges for any kind of incremental development, especially the kind of rapid prototyping efforts that Flex and FlexBuilder are so naturally suited for, is keeping an eye on where you need better testing - both automated via unit tests but also manual.

Hence my delight at finding the flexcover tool recently.

Not only is it now dead-simple to install (since version 0.5 came out), but you can use it in a fully interactive mode where it shows *in real time* the coverage of your code during any kind of application usage.

I've been letting it run in the background while I manually test parts of my evolving application to give me an idea of what needs attention, what code paths are dead and ripe for pruning, and generally, how much confidence I can have in my manual testing vs. the automated units

Check it out.