2015 Apr 6, 8:51 2013 Aug 7, 7:14
When writing a JavaScript library that uses postMessage and the message event, I must be considerate of other JS code that will be
running along side my library. I shouldn't assume I'm the only sender and receiver on a caller provided MessagePort object. This means obviously I should use addEventListener("message" rather than
the onmessage property (see related
What if two programs did this?). But considering the actual messages traveling
over the message channel I have the issue of accidentally processing another libraries messages and having another library accidentally process my own message. I have a few options for playing nice
in this regard:
-
Require a caller provided unique MessagePort
-
This solves the problem but puts a lot of work on the caller who may not notice nor follow this requirement.
-
Uniquely mark my messages
-
To ensure I'm acting upon my own messages and not messages that happen to have similar properties as my own, I place a 'type' property on my postMessage data with a value of a URN unique to me
and my JS library. Usually because its easy I use a UUID URN. There's no way someone will coincidentally produce this same URN. With this I can
be sure I'm not processing someone else's messages. Of course there's no way to modify my postMessage data to prevent another library from accidentally processing my messages as their own. I
can only hope they take similar steps as this and see that my messages are not their own.
-
Use caller provided MessagePort only to upgrade to new unique MessagePort
-
I can also make my own unique MessagePort for which only my library will have the end points. This does still require the caller to provide an initial message channel over which I can
communicate my new unique MessagePort which means I still have the problems above. However it clearly reduces the surface area of the problem since I only need once message to communicate the
new MessagePort.
The best solution is likely all of the above.
Photo is
Sharing by
leezie5. Two squirrels sharing food hanging from a bird
feeder. Used under Creative Commons license Attribution-NonCommercial-NoDerivs 2.0 Generic.
DOM html javascript messagechannel postMessage programming technical 2013 Jul 4, 1:00
My second completed app for the Windows Store was Words with Hints a companion
to Words with Friends or other Scrabble like games that gives you *ahem* hints. You provide your tiles and optionally letters placed in a line on the board and Words with Hints gives you word
options.
I wrote this the first time by building a regular expression to check against my dictionary of words which made for a slow app on the Surface. In subsequent release of the app I now spawn four
web workers (one for each of the Surface's cores) each with its own fourth of my dictionary. Each fourth of the dictionary is a trie which makes
it easy for me to discard whole chunks of possible combinations of Scrabble letters as I walk the tree of possibilities.
The dictionaries are large and takes a noticeable amount of time to load on the Surface. The best performing mechanism I found to load them is as JavaScript source files that simply define
their portion of the dictionary on the global object and synchronously (only on the worker so not blocking the UI thread). Putting them into .js files means they take advantage of bytecode caching making them load faster. However because the data is mostly strings
and not code there is a dramatic size increase when the app is installed. The total size of the four dictionary .js files is about 44Mb. The bytecode cache for the dictionary files is about
double that 88Mb meaning the dictionary plus the bytecode cache is 132Mb.
To handle the bother of postMessage communication and web workers this was the first app in which I used my promise MessagePort project which I'll discuss more in the future.
This is the first app in which I used the Microsoft Ad SDK. It was difficult to find the install for the SDK and
difficult to use their website, but once setup, the Ad SDK was easy to import into VS and easy to use in my app.
development technical windows windows-store words-with-hints 2013 Jun 24, 1:00
Having worked on Windows 8 I'm not in a neutral position to review aspects of it, however I'll say from a high level I love taking the following various positives from smart phone apps and app
stores and applying it to the desktop:
- Independent developers can easily publish apps.
- One trusted place for a user to find apps.
- User can trust apps are limited to a declared set of capabilities.
- One common and easy way for users to buy and try apps.
- Easy mechanism for independent developers to collect revenue.
Relieving the independent developer of software development overhead, in this case Windows taking care of distribution and sales infrastructure is wonderful for me with my third party
developer hat on. This combined with my new found fun of developing in JavaScript and the new Windows Runtime APIs means I've been implementing and finishing various ideas I've had - some for fun
and some for productivity on my Surface. Development notes to follow.
store technical windows windows-store 2013 Jan 7, 11:44
How To Screen Capture on the Microsoft Surface RT - Surface Geeks Surface Geeks
tl;dr: hold windows logo on the surface (not keyboard) and press volume down button on the surface
technical surface windows 2012 Sep 27, 2:58space mars science nasa 2012 Jun 25, 12:59
But if Surface is aimed at the OEMs—telling them “we can do this just as well as you can, if we have to”—and setting them a challenge—”your tablets have to be at least this good”—then the
limited availability isn’t necessarily such a big deal. As long as the OEMs heed the warning and raise their game, so that Redmond can be assured that bad hardware won’t jeopardized Windows 8’s
success, Microsoft could safely keep Surface operating as a small-scale operation, playing the Nexus role without upsetting the PC market.
technical surface win8 windows windows8 business 2012 Jun 18, 1:07
The Verge has the best earliest coverage of the Microsoft Surface press conference and pretty photos.
Microsoft Surface event 2012: everything you need to know
technical windows win8 tablet surface laptop windows-8 2012 May 7, 3:30
I'm done playing Fez. The style is atmospheric retro nastalgia and on the surface the gameplay is standard 2D platformer with one
interesting Flatland style game mechanic but dig deeper to find Myst style puzzles. Despite the following I thoroughly enjoyed the game and would recommend it to anyone intrigued by the previous.
Five eighths through the game I ran into one of the game's infamous Fez save game breaking issues, but I enjoyed the game enough that I
started over before any patches were released and had no further issues.
While playing the game I created some tools to help keep track of my Fez notes (spoilers) including a Pixelated Image Creator that makes it easy to generate data URIs for large, black and white pixelated images, and
(spoilers) a Fez Transliteration Tool to help me translate the in-game writing system.
video-game fez game xbox 2009 Nov 20, 7:03Whiteboard paint. As in, turn a surface into a whiteboard by applying this paint.
product paint whiteboard wishlist 2009 Jul 31, 6:09An interactive touchable table to help you browse and select fonts.
art visualization design font typography surface table touchscreen video 2009 Jan 15, 6:02Projecting giant images onto buildings that appear to interact with their surface. Lovely video. "We have posted quite a few times now about using projectors in the city to beam images onto
Architecture and the screengrab above is one from one the best examples we have seen so far."
video graffiti cultural-disobediance art technology projector light 2008 Oct 23, 1:58"The table can sense the level of liquid inside a glass, making it possible to tip off a waiter that it's time for a refill."
microsoft surface research restaurant refill 2008 Apr 24, 12:32Throwies = LED + battery + magnet. Throw onto metal surface. Looks like fun.
art graffiti electronics geek howto streetart diy throwies cultural-disobediance 2007 Sep 14, 7:37I previously mentioned how much I enjoyed
my new office. Well my team has moved to a new building and although we get more offices total
meaning no one on the team has to share an office, this building has less windowed surface area which means less people get window offices. Since I received the window office recently I'm kicked out
now in FIFO order. Stacks are so sad.
microsoft work personal office nontechnical 2007 Jul 2, 9:51Microsoft Surface Parody - "The future is here and it's not an iPhone. It's a big-ass table."
video humor microsoft iphone surface table parody