Categories
programming

WinJS landing page Windows dev center

JavaScript is winning the race.

WinJS landing page Windows dev center.

Categories
programming

“Easter egg” on Mozilla Developer website

Not sure if it qualifies as an easter egg, but visiting Mozilla developer website like this with your console open and you’ll get the following message:

             _.-~-.
           7''  Q..\
        _7         (_
      _7  _/    _q.  /
    _7 . ___  /VVvv-'_                                            .
   7/ / /~- \_\\      '-._     .-'                      /       //
  ./ ( /-~-/||'=.__  '::. '-~'' {             ___   /  //     ./{
 V   V-~-~| ||   __''_   ':::.   ''~-~.___.-'' _/  // / {_   /  {  /
  VV/-~-~-|/ \ .'__'. '.    '::                     _ _ _        ''.
  / /~~~~||VVV/ /  \ )  \        _ __ ___   ___ ___(_) | | __ _   .::'
 / (~-~-~\\.-' /    \'   \::::. | '_ ` _ \ / _ \_  / | | |/ _` | :::'
/..\    /..\__/      '     '::: | | | | | | (_) / /| | | | (_| | ::'
vVVv    vVVv                 ': |_| |_| |_|\___/___|_|_|_|\__,_| ''

Hi there, nice to meet you!

Interested in having a direct impact on hundreds of millions of users? Join
Mozilla, and become part of a global community that’s helping to build a
brighter future for the Web.

Visit https://careers.mozilla.org to learn about our current job openings.
Visit https://www.mozilla.org/contribute for more ways to get involved and
help support Mozilla.

Nice.

Categories
programming sysadmin

Splitting Thunderbird mailbox

Mozilla Thunderbird uses the mbox format, which makes it incredibly portable and easy to process. Unfortunately, it also means that all of your messages within a Thunderbird folder is in single file*. This can cause problems if you keep using a folder for many years. For instance I have a mbox file that is >1GB and it’s mounted in a network share. Opening, modifying, backing up takes quite a while. I finally gave up and decided to do something about it.

I wanted to organize my mailbox by year, while preserving its folder organization. A quick online search did not find anything I can use. So I whipped up my trusty PHP and wrote this.

https://github.com/boviner/splitmbox

Usual disclaimer applies.

* I’m simplifying here. If your folder contains subfolders, each subfolder actually has it’s own file

Categories
programming

All software have bugs. Period.

I’m recently reminded of this old article by Josh Bloch when dealing with some of our clients. Some people can’t seem to accept that software can have bugs and software can crash (note: in this case it’s not our software). For those of them, I leave them with the following quote from the article I mention:

We programmers need all the help we can get, and we should never assume otherwise. Careful design is great. Testing is great. Formal methods are great. Code reviews are great. Static analysis is great. But none of these things alone are sufficient to eliminate bugs: They will always be with us. A bug can exist for half a century despite our best efforts to exterminate it. We must program carefully, defensively, and remain ever vigilant.

via Extra, Extra – Read All About It: Nearly All Binary Searches and Mergesorts are Broken.

If we can’t even get a “simple” binary search working bug-free – by someone with such distinguished credentials – what hope is there for the rest of us for getting complex software to work correctly 100% of the time?

Categories
programming

Alexander Brevig : The //* /*/ //*/ comment toggle trick

Just saw this on HN. Alexander Brevig : The //* /*/ //*/ comment toggle trick.

I’ve been using something very similar – the only difference between the last comment //*/ vs /**/

//*
someFunction();
/*/
someOtherFunction();
/**/

This technique is surprisingly “portable” – works in C++, Javascript, PHP, amongst others. And it works better than if (0) { someFunction(); } else { someOtherFunction(); } ‘cos syntax-highlighting works.

Another trick that I’ve used by abusing comments is to produce output that are both valid Javascript as well as HTML – at least to most browsers:

//<!--
alert("hello");
//-->
//<html><body>some text</body></html>

In Javascript context it’ll show a “hello” prompt, whereas in HTML context it’ll show “// //some text”. This can be used when say you’re returning a Javascript API and someone is misinterpreting it as HTML. You can of course be creative about the “some text” part. 🙂