TeX is Still Around!

Once upon a time, I was really into TeX: I used to spend all my free time (and more…) visiting newsgroups, testing, writing and translating documents, and now, I have totally left all that behind – unfortunately.

And now I am so out of touch that it is by reading Simon Willison’s Weblog that I learn that Wikipedia runs TeX for formulae. Simon is a WikiLover, and I guess there are hundreds of thousands other out there, including myself: you can spend so much time on this site when you have nothing to do at work! But, I didn’t know that…

Unfortunately, the rendering as PNGs is almost as dodgy as it was when using latex2html, partly because the figures are made so big. The way of writing systems of equations (alternative way) is also messy, mixing TeX and <math> markup. And the use of mbox is recommanded whereas it would make more sense to find a way to insert HTML right there – even though positioning could be a nightmare. Good news is that they have included packages such as those provided by the AMS: thanks to that, almost any formula can be written. That’s so WikiCool!

Building Letters: Tsunami Edition

I received my Building Letters package last week (or maybe the week before). I didn’t have the time to have a proper look to it, but actually, it is not really about the fonts…

Building Letters are calling for entries in order to create a special edition “to get funds to help survivors, the fishermen in North Tamil and Southern Sinhala get back on there feet, and able to make a living again to support their families, and provide food for their communities”. This action, in association with SOTA, is called Font Aid III. No matter what they get by January 14th, I guess it’s worth getting ready to purchase it.

Coaches to Beauvais Airport

33% fare increase on coach from Beauvais to Paris: the ticket costs now 13€ instead of 10€ (in cash, please). You also have to show up 3h15 before take off, instead of 3h. That’s beginning to be ridiculous considering that more and more people use this service – not to mention that I have been yelled at once: I had handed my ticket to the driver who tore it and then tried to enter the bus with a bag (first yell), and I finally presented a torn ticket after putting by bag in the boot (second yell). And imagine it’s the first contact that tourists have with France when arriving…

The website allows you to buy a ticket online, but you have to add an extra 2€ to the price (it used to be for Credit Card costs but it is now for « file costs »; you are aware of that extra 2€ only when submitting your form and it is non-refundable) and it doesn’t seem to be working very well (my Firefox keeps telling me that POSTDATA has expired from cache, blabla) when you click from the link above. Some HTML code is apparent. I really don’t feel confident about buying tickets from their site…

As a customer (I have been using these coaches for 5 years, now!), I don’t feel treated with any respect at all (33% increase, with cash; the website is not even updated properly everywhere and shows obvious flaws that no one cares to fix). The feeling I have is that some company (I couldn’t find who operates that service) just take customers for idiots who just have to pay because there is no other way to get there. That is a real shame.

TextMining.org

Ryan Ackley, whose name appears in Word-related POI classes, has written a library to extract text from Word documents. According to him, textmining.org has several advantages compared to POI:

  • The textmining.org library is optimized for extracting text. POI is not.
  • The textmining.org libraries supports extracting text from Word 6/95. POI does not.
  • The textmining.org libraries do not extract deleted text that is still in the document for the purposes of revision marking. POI does not handle this.

The question is, now: did he document textmining.org as well as the POI classes?

Update: POI stands for Poor Obfuscation Implementation. Certainly didn’t find it on the site.

“Pious Words are not Enough”

Don’t go to the sales; dig deep into your pockets to prove that you really care about the world’s poor #+endquote

Alice Miles’ article in today’s Times Online deserves to be read again and again. And her words, I hope, won’t be dead letters.

She also writes:

And what to do about the horror in South Asia? In the end that disaster, too, will be about poverty. Once the bodies have been buried and the grieving can lift their heads from their children’s graves, these people will need money, and lots of it. Money could not have prevented the tragedy, but it can certainly help to heal it.

The West will get bored first – yes, even of this. By the end of January, nobody will be talking much about the earthquake (with the exception of those forced to cancel winter holidays in Thailand and Sri Lanka)

Today’s Rule-of-Thumb

You may have understood it: this morning’s comment was somehow related to an earlier comment I made. Tonight’s post is therefore going to illustrate what I was going to say this morning…

Here is the I received from web designers. Well, not really, this is a highly-simplified sample:

  • I used the “original” MM function which had been modified in the original code to take into accounts timeouts;
  • I rewrote the menus with lists rather than tables;
  • I removed timeouts as well as sub(sub)menus;
  • I changed design and colours for the sake of the designers’ anonymity.

In that example, the appearance of submenus is triggered by moving the mouse onto the corresponding menu item. Two problems arise immediately by looking (a) at the JavaScript code and (b) at the CSS code. Every menu item has a onmouseover event which hides the other submenus and opens the current submenu. It means that, for everything single menu item I am going to add (for example the item number 3 on the sample), I will have to add such an event to the newly-created item, and modify all the other so that the new submenu is hidden when going onto another menu item. In that example, there is also a style associated to every submenu which, amongst other things, place it in an absolute manner.

Now, think dynamic. Before starting, I don’t know whether I am dealing with 3 or with 50 items in my menu. I only know I am dealing with a collection which might (or might not) have submenus. It means that I will have to code on the server-side (a) the client-side which is going to deal with the menus and (b) the relevant CSS style. It is always been something awful to me, and not only because it is ugly but also because the resulting code is just a nightmare to maintain. And that’s a real pain in the arse to code such a thing, to be honnest.

The first obvious thing to do is to replace the =id=s used in the submenus by =class=es – which will then be used to close the whole lot.


<ul class=“nav2”>

<li class=“menu” id=“menu1”>My Sweet Home</li>

<li class=“menu” id=“menu2”>My Ugly Kids</li>

<li class=“menu” id=“menu3”>Linux Rulez</li>

</ul>

   <div id=“submenu1” class=“submenu”
      style=“position: absolute; top: 120px; left: 20px;”>

<ul>

<li>Lots of things</li>

<li>Some more</li>

</ul>

</div>

  <div id=“submenu2” class=“submenu”
      style=“position: absolute; top: 120px; left: 191px;”>

<ul>

<li>Beetle Juice</li>

<li>The Gimp</li>

</ul>

</div>


Why did I put the position as in-line styles? Simply because this will be very simple to compute server-side. Then, you have to add a getElementsByClass function to be able to find all the elements bearing the same class name – and hide them. I found the getElementsByClass function on Daniel Glazman’s blog (just think of removing the parenthesis after the getElementByClass in his code).


document.getElementsByClass = function (needle)

{
  var         my_array = document.getElementsByTagName(”*”);
  var         retvalue = new Array();
  var        i = 0;
  var        j = 0;

  for (i = 0, j= 0; i < my_array.length; i++)
  {
    var c = “ “ + my_array[i].className + “ “;
    if (c.indexOf(” “ + needle + “ “) != -1)
      retvalue[j++] = my_array[i];
  }
  return retvalue;
}

This function must be called in a function which hides every element of a particular class:


function hideClass(className) {
    var listeEle = document.getElementsByClass(className);
    for (i = 0; i &lt; listeEle.length; i++) {
        var ele = listeEle[i];
        if (ele.style) ele = ele.style;
       ele.visibility = "hidden";
  }
}

Now, the aim is to hide everything and to show the proper submenu; for that, yet another function:


function hideAndShow(idToShow, classToHide) {
 hideClass(classToHide);
   // And for the fun of reusing code:
   MM_showHideLayers(idToShow, ’’, ’show’);
}

For the moment, nothing too tough. Now, the real big deal is to handle the events without linking to the elements. That way, it is going to be much easier to integrate with dynamic code: the JavaScript on one side, the loops to display the menus on another one. For that purpose, I just referred to my favourite article on the matter on Sitepoint.

function attachObjectEvent(objet, fonction, event) {
  //setup initialisation function
   if(typeof objet.addEventListener != ‘undefined’) {
        objet.addEventListener(event, fonction, false);
   }
 //.. win/ie
   else if(typeof window.attachEvent != ‘undefined’) {
       objet.attachEvent(‘on’ + event, fonction);
    }

}

  function initMenus() {
 var menuList = getElementsByClass(“menu”);
    for (i = 0; i < menuList.length; i++) {
        var ele = menuList[i];
        attachObjectEvent(ele, new Function(“evt”,
                         “hideAndShow(‘sub” + ele.id + “,‘submenu’);”), “mouseover”);
  }

}

  attachObjectEvent(window, initMenus, “load”);


The HTML code can be simplified as follows:


<ul class=“nav”>

<li class=“menu” id=“menu1”>My Sweet Home</li>

<li class=“menu” id=“menu2”>My Ugly Kids</li>

<li class=“menu” id=“menu3”>Linux Rulez</li>

</ul>

    <div id=“submenu1” class=“submenu” style=“position: absolute; top: 52px; left: 20px;”>

<ul>

<li>Lots of things</li>

<li>Some more</li>

</ul>

</div>

   <div id=“submenu2” class=“submenu” style=“position: absolute; top: 52px; left: 191px;”>

<ul>

<li>Beetle Juice</li>

<li>The Gimp</li>

</ul>

</div>


Developer, just imagine how easy your task has become! You insert your loop (with a foreach or a &lt;logic:iterate&gt; or whatever) and that’s it. You can have a look at the “final” code .

Now, I know there are lots of improvements to be made to this example – I am not even sure (cough) this works properly on every browser since I kind of quickly modified Aaron’s code, not taking into account the test window vs. document – but that is a start.

You must also have realised that this method requires many more lines of code. It is partly due to the fact that the example is pretty straightforward. In a much more complicated (real-life) one, the number of JavaScript lines added is counter-balanced by the amount of styles removed. It also looks very expensive time-wise; it is, but imbricating client and server code often ends up in massive time loss, both in development and maintenance. And once the key functions have been defined, such as getElementsByClass and attachObjectEvent, it all goes much faster…

Feel free to comment, improve, etc. I am a developer who does not want to think too much when it comes to integrating HTML.

The Beeb How-To on Secure Communication

David Blunkett was forced to resign after several comprimising emails were uncovered by an inquiry set up by himself. This Beeb article tries to analyse other ways to send sensitive information to someone.

  • emails: too dangerous. Everybody knows now that sending an email is like sending a postcard to a friend. “[People] know that their corporate e-mail systems trap all of the information they send”, according to an expert. Well, apparently, they are not quite aware yet since people still get caught from time to time.
  • instant messaging: mouarf. They “allow users to have “real-time” conversations with no record”. But it is not that great, apparently, because “There is software available which stores instant messenger conversations”. Yes, indeed. That would be the instant messaging systems themselves, wouldn’t it?
  • encryption systems: “You can get software that allows you to encrypt e-mails by passing specific keys between yourself and whoever you’re communicating with”. Okay, let’s imagine that we’re talking about a public key, here. your recipient can share with whoever he or she wants. The problem? “Generally there are quite a few restrictions on what people can download and install on their PCs. I doubt whether Mr Blunkett, for example, would simply be able to install encryption software on his desktop computer”. Bizarre. You would think that someone with a position as critical as Home Secretary should be allowed to make use of encryption systems: terrorists (I am thinking about the IRA, for instance, which had the gathering of intelligence on potential targets down to an art) would be somewhat happy to gather private information about ministers. Maybe Santa should bring him another laptop and a USB key.
  • Webmail, such as Yahoo! or Hotmail: mouarf. By checking the connection logs, the account would be very easy to trace and the webmail hosting company could have been asked to hand the content of the inbox to justice.
  • Phone and SMS: how many burglars, terrorists, etc. have been arrested because they had foolishly used their own cell-phones?

So the only sensible way of protecting communication (encryption) has been dismissed as being awkward or impossible. And as long as people think so, people like Mr Blunkett will get caught…