2015 Nov 24, 12:13 2015 Apr 14, 8:08 2015 Apr 14, 8:08 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 May 17, 5:43
This might be the strangest release of classic Chicago label Trax yet! The clue’s in the title - it’s Daft Punk brassified. We get four classics by the world’s most famous Gallic robot duo:
“Harder, Better, Faster, Stronger” gets turned into a 1940s Dick Tracy-style riff-off with every form of trumpet imaginable, “Around The World” mixes wind instruments with that famous vocal
mantra, “Da Funk” features plenty of sassy brass and “One More Time” wraps things up on a swingin’, jazzy high.
SoundCloud Iamjasonalexander Brass Music music cover daft-punk 2011 Dec 1, 3:22
“including driver updates to enable Internet sharing on some models such as the HTC HD7” Just upgraded and saw this. Very cool.
technical cell-phone wifi router wp7 2011 Nov 17, 11:00
I had previously replaced my use of Delicious with Google Reader. Delicious had a number of issues during their switch over from Yahoo to the new owners and I was eventually fed up enough to
remove it from daily use. I used Delicious to do the following things:
- Create a list of things to read later
- Save things to read again in the future
- Search through things I read and enjoyed (esp via tags)
- Annotate and share things on my blog
I realized that since I did most of my web browsing in Google Reader now anyway I may as well make use of its features. I star things to note I want to read it later or save to read again
later. I can annotate with notes in Google Reader and I can share items to my web site by way of the shared items feed. Additionally for when I'm not in Google Reader there's a bookmarklet to add
an arbitrary web site as a shared item in Google Reader.
Of course I wrote this and switched over about 1 week before Google removed the sharing feature from Google Reader. I'm irritated but in practice it forced me to find a different option which has
worked out mostly better. New blog post coming soon about that...
blog delicious me technical google-reader google feed 2010 Jul 1, 3:33"By charting the production of new books, new music albums, and new feature films over the last decade, the authors tried to see whether creative output went up or down in correlation with
file-sharing." They find that creative output is going up while piracy also increases. But this is correlation not causation. They can't say there wouldn't be more creative output with less piracy.
Regardless, still an interesting statistic.
arstechnica copyright law economics ip piracy music technical 2010 Apr 21, 6:49"OAuth provides a method for clients to access server resources on behalf of a resource owner (such as a different client or an end-user). It also provides a process for end-users to authorize
third-party access to their server resources without sharing their credentials (typically, a username and password pair), using user-agent redirections."
oauth authorization security privacy internet web rfc standard technical 2009 Nov 12, 3:24That is one deep mattress.
humor photo flickr mattress philosophy 2009 Oct 19, 4:32"This was our Zombie Wedding cake made by Mike's Amazing Cakes in Seattle! They're awesome! They made the Bride and Groom on top look like us down to the tux and dress, and the zombies matched our
wedding party too!"
photo cake wedding zombie 2009 Aug 19, 10:39If I had a Tetris game I bet I'd like to use this music!
music tetris videogame 8bit 2009 Aug 13, 9:46An awesome health care protest sign. I've made a huge mistake.
humor photo obama politics television arrested-development sign protest 2009 Jun 15, 4:46"This was such a fun project - this is what users of Internet Explorer 6 see when they visit Momentile." Funny image. There's just two things I don't like about this: (a) it makes me feel sorry for
IE6 when the only thing anybody should feel in relation to IE6 is the urge to upgrade to IE8 and (b) I hate it when websites get all preachy and try to convert you to another browser.
humor webdesign ie6 ie browser comic 2009 May 6, 12:56Time lapse photography from the perspective of a large ship at night in Texas. "The camera was fastened to an outside rail and set to take a photo every six seconds. Quicktime then assembled the
photos into a .mov file that plays back at 12 frames per second. So, one minute of movie time represents 72 minutes of trip time on the channel. The first half begins just below the Port of Houston
Authority Turning Basin (the very end of the channel) and continues down to Green's Bayou."
flickr video photography travel camera texas ship boat 2009 Apr 20, 6:15Remotely set shows to record, watch recorded shows, etc etc for Windows Media Center. Lots of cool looking stuff I need to try it out. The old MSN Remote Record service is gone and in its place
Microsoft has struck some sort of deal with the author of WebGuide such that its free!
microsoft windows tv mce plugin pvr cellphone remote free 2009 Apr 3, 11:38Har har
humor free paper photo flickr