IE’s Function.apply() doesn’t like null

Well, after trying to find what the problem was with my script (it was working well in Firefox, but not in IE, sounds familiar??) I realized that Internet Explorer doesn’t like null to be passed as the second parameter to Function.apply…

According to Mozilla’s documentation, the second parameter to Function.apply should be:

An argument array for the object, specifying the arguments with which fun should be called, or null or undefined if no arguments should be provided to the function.

Since I was using apply only to bind this I decided to pass null as the second parameter… apparently IE doesn’t like that… After a bit of searching I found out that with IE, if you want to use Function.apply and not pass any parameter, you should just omit the second parameter or else IE will throw a “TypeError” if your parameter is not an array. So basically just use:

myfunction.apply(this);

Instead of:

myfunction.apply(this, null);

It will work in Mozilla since, as they mention in their doc, the second argument can be null or undefined so… all is well, and everyone is happy!…

Programming Fonts

Well, I know it’s been done before, more than once, but why not do it again! Programming fonts… a topic worth revisiting.

So 2 days ago I decided it was time for a new font and, it seems that each time I do that, I waste a whole day trying out different ones, at different size, without ever being completely satisfied.

Finding a suitable font can really depend on what platform or even which editor your are using. Mac OS X’s font rendering looks quite different than Window’s ClearType, some think that OSĀ  X fonts are too blurry, and I gotta admit that before I had to spend some time on a Mac, I was of that opinion. After a while though, I got used to it, to the point that I can say that Monaco in Textmate is one of my favorite font/editor combo…Unfortunately, anyone who tried Monaco with Windows editors (E Text Editor or Intype) will quickly realize that, without the “blurry”, bolder OS X rendering, it really doesn’t have that same impact.

Monaco

That being said, I spend most of my time developing in Windows, and Monaco is different to the point that I don’t really like it with ClearType.

There are several options, depending on what is important to you… for some, the ultimate criteria for a programming font is to fit as much text as possible on the screen, while still being readable. For that purpose, bitmap fonts are the best option. There are a bunch of good, free ones out there and here is a brief list of the most popular one:

As I said, Bitmap fonts are particularly effective if you want to have as much text as possible on your screen since they look their best at small (sometimes tiny) points (9pt, 8pt… sometimes even 7pt) and are still easy to read.

Personally, I don’t really mind having a font that can display 50 lines instead of 72 if I like that font better. I don’t mind having to use the scrollbar or the incremental search, which is why I prefer traditional (i.e. non-bitmap) monospace fonts. Again, there are a bunch of options in this category and I’m only going to list a few (mostly those that I’ve tried). They are somehow in a preference order, the top ones being the ones I like the most…

  • Envy Code R I tried that one before and although I liked it, I thought the coma “,” and the dot “.” were too similar. Well this has been fixed in the latest release (Preview 7) and it is now my main programming font. It reminds me of Pragmata (which I LOVE) but it’s free! It looks good no matter the size but personally I think it looks its best at 10pt.
  • Consolas is a very popular choice and it’s easy to understand why. The font looks gorgeous, it’s very easy to read, it works well with ClearType and it has some style too!I really love the double-loop “g” (I know that most people prefer a single loop). I still switch to Consolas every once in a while.
  • Pragmata is also one of my favorite, but I can’t really say that I love to work with it since I never bought it, so I can only judge from what I see on the site.Unfortunately I find the price to be a bit steep (although I know that quality fonts usually come with a high price tag). I just think that with all the free options available, you really need to have something special to charge 90euro for a programming font.
  • Another great one is Anonymous, a free TrueType version of Anonymous 9 (a Mac font). I love the style and personality of Anonymous and I use it from time to time, however, it is a bit different than what I am used to.
  • A lot of people like Inconsolata, released under the Open Font License (OFL), it is inspired by Consolas and TheSans (both from genious type designer Luc(as) de Groot). Although I love Inconsolata and used it for a while on XP, I always found it to be kind of blurry with ClearType turned on. I think it has been fixed in the latest versions though and if that’s the case, Inconsolata would definitely be among my favorite fonts.
  • Of course it’s impossible to forget Bitstream Vera Sans Mono (or the extended version DejaVu Sans Mono). If I’m on Linux, it is my font of choice for programming. They are easy on the eye, they look good for a monospace font and they are both free and available on most linux distribution nowadays.
  • Another interesting free/open alternative is LuxiMono, originally designed as an X Window System, but I think it hasn’t been updated in a while (unless I’m mistaken..?)
  • Finally, it’s impossible to write about programming fonts without mentioning Courier/Courier New. It’s available on any windows installation and it will usually be the default monospace font in a lot of Windows editors. Personally I don’t like coding with a serif font so I usually avoid it but a lot of people still swear by it.

So, to sum it up. Right now I am switching between Envy Code R and Consolas when on Windows. On a Mac I use Monaco as I think it looks gorgeous with OS X’s font rendering. When on Linux, I use Vera Sans Mono or DejaVu Sans Mono. As for the size, I usually switch between 10pt and 11pt, depending on the editor/font/OS…

I’m sure there are a lot more great programming fonts and I would love to hear people’s opinion about that as I always love to try out new ones!

Mootools 1.2 Upgrade Reference

I started to put together a (long) list of changes between MooTools 1.1(1) and MooTools 1.2. Hopefully this will help people porting their script to the new MooTools version.

Personally I think that nothing beats spending an hour or two reading the new documentation but apparently some people don’t have the patience to do it! :P For those people, check it out, it’s still incomplete and it will probably take a while to cover everything but hey, it’s a start!

The list can be found here: http://silverscripting.wikidot.com/mootools-upgrade:from-1-1-to-1-2

It’s a wiki page so people can contribute to it too… (please do…)

MooSlides: Sliding panels for mootools 1.2

Well I just finished a first working versions of mooslides, a sliding panel widget for mootools. It was inspired by all those sites (gamespot, tv.com etc.) using flash sliding panel widgets. I’m pretty sure a similar widget already exists for mootools, haven’t looked actually, but eh it had been a while since I had some fun with mootools and I wanted to try out the new 1.2 version.

An example can be seen here:
http://www.silverscripting.com/mooslides/test.html

This one is using images but you can pretty much put anything you want in the panels (images, text, form etc.).

The full documentation, download and more info at:
http://silverscripting.wikidot.com/mooslides

NAWTE0.4: Finally! MooTools1.2 compatibility…

Well I’m pretty much done porting nawte to MooTools1.2… I still haven’t updated nawte’s main site, but the latest source can be grabbed at nawte’s git repository located at http://github.com/SilverTab/nawte/. If you are not familiar with git, you can just browse the source and grab it from there…

Besides 1.2 compatibility there’s also one small change. I merged the insertBefore and insertAfter functions to create the insert function which takes a where parameter (eighter before or after).

The site and the doc should get updated soon…

What The Song!? - Looking for a song?

Just a quick announcement for the new project I’ve put together. Basically the idea is simple; I always seem to have a song stuck in my head and I have no idea what the title or artist could be. With that site I wanted to help everyone who’s in the same situation by the help of… user contribution of course!

So basically, you post a request, include as much information as you can about the song (partial lyrics, chords if you can play it on a guitar, even a wav or mp3 attachment) and you wait for people to help you out!

Hopefully people will participate! Check it out:
http://www.whatthesong.com

SilverBBCode - Coming soon…

Well I’ve been working on porting MooBBCode to Ruby and Php, and it should be done soon enough. The Ruby version is 90% done and PHP should follow shortly after. Basically it’s just a matter of re-adapting all the regular expressions to the PCRE engine, and since most of the Regex for BBCode are simple (and Ruby’s regex class is closer to PCRE than to Javascript regexp), it should be pretty done pretty quickly. Having the dot match all (the m flag in ruby) option alone is making it easier… Anyway!

One this is done, SilverBBCode + MooBBCode + NAWTE will provide a nice BBCode platform for anyone who has a new php or ruby project and wants to implement BBCOde in it without having to re-invent the wheel. This will also provide, with the help of NAWTE+MooBBCode, a nice Post Editor (or text editor or whatever) with WYSIWYM features, and text previewing without having to perform a server request…

Now I’m leaving for Thailand, Laos and Cambodia in 4 days so…this might not get done before I leave (although the ruby version might be completed) but, worst case scenario, it’s going to be ready soon after I come back (which is..well pretty much a month later)…

Anyway.. stay tuned!

MooBBCode - A port of BBCode to Javascript

Yes, MooBBCode is a port of BBCode to javascript, with the help of mootools. The goal is to eventually plug it into NAWTE.

It features:

  • Smilies
  • Quotes
  • Links, email links
  • 2-way parsing (to html or to bbcode)
  • much more…

Just head out here to read more about it, or check out a demo here.

MooIPE - In Place Editor for MooTools

I wanted a simple In Place editor for MooTools so I’ve put one together. It’s similar to Script.aculo.us’ version but a bit simpler.

There are both a 1.11 and 1.2 versions up.

An example of it in action can be seen here.

Full details/source/goodness here.

Note: There is a bug in the 1.2 version that crashes safari (for me at least) if anyone can figure out what the problem is, please let me know!

NAWTE - A custom WYSIWYG editor for MooTools

New little mootools plugin I’m working on. Check it out! It is based on Control.Textarea for prototype, but re-coded from scratch (and modified a bit) for mootools.

Basically it allows you to put together your custom WYSIWYM (i.e. What You See Is What You Mean) editor with any text area.

Check it out here!