2015 Sep 30, 5:53 2015 Apr 6, 6:26 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 2009 Oct 6, 3:24The map/reduce tutorial for Hadoop the Apache open source project. "Hadoop Map/Reduce is a software framework for easily writing applications which process vast amounts of data (multi-terabyte
data-sets) in-parallel on large clusters (thousands of nodes) of commodity hardware in a reliable, fault-tolerant manner."
hadoop mapreduce java software programming opensource database distributed google yahoo apache technical todo 2009 May 29, 2:50
I like the idea of QR codes, encoding URLs and placing them
on real world objects, but the QR codes themselves are kind of ugly. To make them less obvious I thought I could spray QR codes on to an object with an infrared reflective paint and shine infrared
light on the QR codes, since most cameras, for instance the camera in my G1 phone, pick up infrared that our eyes do not.
In my search for infrared paint I've found a seller of IR ink (via programming forum) and an Infrared Paint Recipe (via IR FAQ).
In looking for this paint I've found that it comes up a lot in relation to the military for things like paint markers that are visible at
night with proper equipment, and paint that absorbs IR light to make vehicles less obvious to night vision goggles. Even though the first
reflects infrared light and the second absorbs it websites end up refering to both as infrared paint which made it difficult to search.
Additionally I found links to some other geeky infrared projects:
ir paint technical ir infrared qr qr code 2008 Sep 22, 1:21Nathan Evans and Christian Grothoff, de-Tor-iorate Anonymity. The presentation notes for a DefCon talk about an attack on Tor in which the attacker may discover Tor nodes used in a session.
tor anonymity privacy security network defcon 2008 Sep 3, 9:49Notes on how COM classes are registered on 64bit versions of Windows. Whole swaths of the registry (among other things) are redirected to a subnode named Wow6432Node when you're a 32bit process
running on a 64bit Windows.
msdn registry development microsoft 64bit 2008 Jul 10, 4:43"The goal is to implement IP-transport encryption in a way that is transparent both to the IP-layer (including nodes in the network path) and to the applications that benefit from the encryption."
Seems like a good idea to me.
cryptography encryption internet privacy security ip wiki 2008 Feb 8, 3:26Google's Social Graph API's normalization method. This is no way to treat a URI...
uri google api normalize social social-graph graph reference 2007 Oct 12, 4:08As noted in the
XSL Transformations spec you can create the identity transform using the xsl:copy element. With the MSXML implementation of xsl:copy
the example the spec gives produces slightly ugly elements. For instance given it produces . In order to ensure empty elements turn out pretty I've modified the example as follows:
This got me thinking about inverting XSLTs. Clearly in general an XSLT isn't invertible since an XSLT can completely ignore the input XML and produce something else entirely but then the above is an
example of an XSLT that is invertible. So there is a subset of XSLTs that are invertible, how might you produce the inverse of an XSLT, and would this ever be useful?
xml msxml inverse xlst xsl 2007 May 13, 6:59Presentation on graph visualization.
data information design google video visualization graph 2007 May 11, 8:55Last time, I had written some resource tools to allow me to view and modify Windows module resources in my ultimate and noble quest to
implement the XML content-type fragment in IE7. Using the resource tools I found that MSXML3.DLL isn't signed and that I can replace the XSLT embedded resource with my own, which is great news and
means I could continue in my endevour. In the following I discuss how I came up with this
replacement for IE7's XML source view.
At first I thought I could just modify the existing XSLT but it turns out that it isn't exactly an
XSLT, rather its an
IE5 XSL. I tried using the
XSL to XSLT converter linked to on MSDN, however the resulting document still
requires manual modification. But I didn't want to muck about in their weird language and I figured I could write my own XSLT faster than I could figure out how theirs worked.
I began work on the new XSLT and found it relatively easy to produce. First I got indenting working with all the XML nodes represented appropriately and different CSS classes attached to them to make
it easy to do syntax highlighting. Next I added in some javascript to allow for closing and opening of elements. At this point my XSLT had the same features as the original XSL.
Next was the XML mimetype fragment which uses
XPointer, a framework around various different schemes for naming parts of an XML document. I focused on the
XPointer scheme which is an extended version of
XPath. So I named my first task as getting XPaths working.
Thankfully javascript running in the HTML document produced by running my XSLT on an XML document has access to the original XML document object via the
document.XMLDocument property. From this this I can execute XPaths, however there's no builtin way to map from the XML nodes selected by
the XPath to the HTML elements that I produced to represent them. So I created a recursive javascript function and XSLT named-template that both produce the same unique strings based on an XML node's
position in the document. For instance 'a3-e2-e' is the name produced for the 3rd attribute of the second element of the root element of the XML document. When producing the HTML for an XML node, I
add an 'id' attribute to the HTML with the unique string of the XML node. Then in javascript when I execute an XPath I can discover the unique string of each node in the selected set and map each of
them to their corresponding positions in the HTML.
With the hard part out of the way I changed the onload to get the fragment of the URI of the current document, interpret it as an XPath and highlight and navigate to the selected nodes. I also added
an interactive floating bar from which you can enter your own XPaths and do the same. On a related note, I found that when accessing XML files via the file URI scheme the fragment is stripped off and
not available to the javascript.
The next steps are of course to actually implement XPointer framework parsing as well as the limited number of schemes that the XPointer framework specifies.
xml xpointer msxml res xpath xslt resource ie7 technical browser ie xsl