Promo

Preface

Oh, hello.  Here lie a collection of articles, narratives and ponderings of computery things; finely blended with my portfolio bestowing works and experiments in U.I. design, infographics, and software development.  Bon appétit.

Calendar

<<  September 2010  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

Categories

posts rss
Cynosura 0 rss
General 0 rss
Graphic Design 4 rss
Programming 6 rss
WWW Tech 2 rss

All posts by ray

10 entries

A mongst serveral additions I made to the BlogEngine platform (the ASP.NET blogging application which runs this weblog) was the archive metadata which details the active time of the blog; that is, the span of time from the first and last post publication dates.  This feature is achieved with the TimeSpanArticulator; a simple static class which converts a TimeSpan to simple english.  In the true spirit of openess, I’ve released this utility under the LGPL, and here’s how you use it.

read on...

Author
Ray
Published
Tue. 27 January, 2009 12:17
1 Comments
comments closed
Tags
,
filed under
Programming

A t the heart of the Semantic Web is the philosophy that the world’s information can be rationalized.  Such a noble proposition extends from our innate desire to make sense of the world around us, and isn't unique to just the narrow section of the Artificial Intelligence community which co-founded the Semantic Web.  With this worldview comes the assertion of a universal truth, an all-conquering, logical explanation for any particular domain of discourse; a formalized ontology of the world around us. [1]  

The vision of the Semantic Web is to create such digitized ontologies† of the world’s digitized information as a means to enable computers to work in an unprecedented automated and rational fashion.  With these ontologies, we will be able to dictate information (i.e. metadata) which is meaningful to computers.  Combining this data with computer-understandable semantics will provide the framework to stimulate a ‘revolution of new possibilities’ [2] and bring an unseen synergy across the chaotic landscape of the internet, where applications and services currently operate in explicitly defined boundaries of interoperability.  read on...

Author
Ray
Published
Tue. 30 December, 2008 14:20
18 Comments
comments open
filed under
WWW Tech
Author
Ray
Published
Mon. 29 December, 2008 11:20
6 Comments
comments open
Tags
filed under
Graphic Design

On December 15th, Korean manufacturer Cowon released its well-anticipated (and twice delayed) flagship Portable Media Player upon the UK high street.  After pre-ordering my own Cowon S9, reviews started to trickle in (through the wild conjecture and white noise of impassioned zealotry; that which generally accompanies the discourse of any one of Apple's competitors) that were painting a resounding picture of mediocrity regarding its rather flimsy, rather botched, user interface.

The S9 user interface falls short on several fronts, not least its general usability and intuitiveness.  The cover-flow implementation is a let-down to say the least (or to be more accurate, it’s completely useless), and the media-library navigation is merely adequate and otherwise completely lacking in innovation.  Considering the S9s hardware specifications, it’s unsurprising that most people were expecting it to accommodate an interface more along the lines of unparalleled beauty, rather than mere mediocrity.

Fortunately, as the user interface is implemented entirely in Flash, it’s quite easy for Cowon to accommodate the homebrew niche by distributing the UI.  As it has done for other PMPs in in the past, Cowon released a sub-section of the flash UI here and here.  The first is the Main menu, and the second is the ‘now playing’ interface for music media.  On inspection it seems the latter is either a development version (with debug panes) or an older prototype.  Together, this is about 10% of the entire S9 UI, and even this doesn’t seem to be the bits that were released to manufacturing.  I was disappointed.  Unassured by their history of rather pedestrian firmware updates, I was pessimistic that Cowon would be entertaining the idea of updating the UI in any compelling way.  Impatient, I decided to extract the UI from the newest firmware binaries (V.2.06).

Results

The UI is Split into a total of 19 version 7 SWFs.  Amongst these is the loader, which is mainly responsible for loading and containing the various parts of the UI as they are required.  Only one part of the UI is loaded at any one time (probably for simplicity, and to conserve memory) which explains why UI transitions are currently non-existent.  The following table details what each remaining SWF does.

Filename(s)Description
Browser_total.swf The file/bookmarks/favourites explorer
Calc.swf The calculator utility.
Dictionary.swf, dictionary2.swf, dictionaryMain.swf The Dictionary interfaces.  One seems to be a Korean to English dictionary, the other English to Korean, and dictionaryMain.swf is the dictionary’s main menu.
Dmb.swf The DMB viewer.  The S9’s main menu won’t display the DMB icon depending on the exact firmware version.  The DMB interface is only useful in areas which support it; namely Korea.
Init_country.swf Seems to be a means of setting regional information.  I have not seen this interface on my S9; either only certain versions support localisation, or the option is only available on factory default settings.
Keyboard.swf A means to enter text into the S9.  Probably for the dictionary.
Mainmenu1.swf, Mainmenu2.swf, Mainmenu3.swf The main menus for the S9.  The first two are the standard menus on UK/US S9s (one with monochrome menu icons, the other with colour icons). The third seems to be an alternative menu that I haven’t seen on my S9.
Movie.swf The ‘now playing’ interface for video media.
Music.swf The ‘now playing’ interface for music media.  Also includes the cover-flow user interface.
Picture.swf The picture viewer
Radio.swf The radio interface
Record.swf The microphone/line-in recording interface
Settings.swf The settings interface.  Also includes custom configuration panes for things such as the equalizer, Bluetooth, the timer and alarm.
Text.swf The text viewer

I am releasing these SWFs, along with their decompiled FLA (version 8/CS2) equivalents, for general consumption.  I will not be supporting these files in any way, shape, or form.  Use them at your own risk; I accept no responsibility for what you decide to do with them, even if that includes destroying your precious Cowon.  Happy hacking.

Download here

Author
Ray
Published
Sun. 28 December, 2008 21:35
18 Comments
comments open
Tags
filed under
Programming

The LineMappingStreamReader is a TextReader which can be used to map the line breaks along a given Stream.  Using this single class it is possible to calculate two-dimensional coordinates (line and column values) for a given offset within a stream, and vice-versa.

background

During a recent .NET project I was confronted with the common problem of manipulating large swaths of XML in a performance-constrained setting.  The details aren’t important, however in summary the system had to read (potentially quite large amounts of) in-memory XML mark-up at ~2000ms intervals, so the solution necessitated something fast and lightweight.  Such constraints typically rule out XmlDocument and XDocument, which are far too slow and heavy. Furthermore I only required read access to the XML.  XPathDocument was designed to be a fast, lightweight alternative to XmlDocument which provides read-only access to an in-memory XML document; however it still doesn’t cut the mustard performance wise.  Instead, I went with the trusty XmlTextReader.

The plug-in I was writing is responsible for parsing a volatile code-DOM which contained many snippets of XML, and sanitizing this XML to make it conform to a 3rd party schema to be used in a ‘live preview’ — again, a 3rd party component.  This basically involved removing certain elements and attributes which the schema didn’t support.  To achieve this, the exact position of each node had to be discovered so it could be removed.  To do this, we can use IXmlLineInfo; an interface which XmlTextReader implements.

As the XmlReader progresses along a given stream, IXmlLineInfo can be used to find the line and column of any node upon which the XmlReader is currently positioned (figure A).  This proves to be inadequate, however, because to perform a simple extraction and concatenation on a data stream–much like what String.Remove (...) does — you need to know the exact position within the stream at which the extraction is to take place.  IXmlLineInfo only provides us with a coordinate (x,y) in the two-dimensional space of a multi-line document, and not the offset within the stream at which the coordinate occurs.  Surly this fact was a design oversight on the .NET architects’ part?  Enter the LineMappingStreamReader.

Usage

The LineMappingStreamReader can be used on any stream (be it in-memory or from a file, for example) and on any type of textual data.  The following very simple example shows how it can be used to map the lines in a string.  Note that because LineMappingStreamReader extends from StreamReader and not the less versatile StringReader, we first have to convert the string into a MemoryStream so it can be read.

static string testStr =
	"The\r" + 
	"quick brown fox jumps\r\n" + 
	"over the lazy dog";

static void TestA()
{
	// Create a LineMappingStringReader
	// to read the test string

	MemoryStream ms = new MemoryStream(
		Encoding.ASCII.GetBytes(testStr));

	LineMappingStreamReader lmsr =
		new LineMappingStreamReader(
			ms, Encoding.ASCII, false, 0x256);

	// read the entire string
	lmsr.ReadToEnd();

	// print all the recorded lines, 
	// incluing the last logical line.

	for (int i = 0; i <= lmsr.LinesRead; i++)
	{
		Console.WriteLine(
			String.Format(
				"Line {0}: {1}", i.ToString(),
				lmsr.GetLengthAtLine(i)));
	}

	lmsr.Close();
}

Output

 
   Line 0: 4
   Line 1: 24
   Line 2: 18

Example 2

To demonstrate the LineMappingStreamReader in a more useful context, the following example shows a LineMappingStreamReader being used by an XmlReader to read xml from a file, whilst outputting the starting positions of each ‘plant’ element.

static void TestB()
{
	// open the file
	FileStream fs = new FileStream(
		"catalog.xml", FileMode.Open);
	
	// create a new reader for the file
	LineMappingStreamReader lmsr = 
		new LineMappingStreamReader(
			fs, Encoding.UTF8, false, 0x1000);
	
	// create an XmlReader to read
	// the file as XML
	XmlTextReader reader = new XmlTextReader(lmsr);
	
	// process each node
	while (reader.Read())
	{
		if(reader.NodeType == XmlNodeType.Element &&
		   String.Equals(
				reader.Name, 
				"plant", 
				StringComparison.IgnoreCase))
		{
			int offset = lmsr.PositionToOffset(
				new Point(reader.LinePosition - 1, 
						  reader.LineNumber - 1));

			Console.WriteLine(String.Format(
				"Plant element found at line:{0} column:{1} offset{2}",
				reader.LineNumber, reader.LinePosition, offset));
		}
	}

	reader.Close();
}

Remarks & Disclaimer

I’ve included two files for download here.  One is the LineMappingStreamReader class, and the other is a sample console project which includes the previous examples.  This version of the class has been updated with non-localised exception messages so it’s easy to distribute.  The class has also been fully implemented to extend all of StreamReader’s operations (originally only the Read(...) method was implemented because of time constraints), and consequentially some of these — ReadLine() and ReadToEnd() — haven’t been unit tested.

LineMappingStreamReader.zip
LineMappingStreamReader.txt

Author
Ray
Published
Fri. 26 December, 2008 19:42
3 Comments
comments open
Tags
,
filed under
Programming