Too Cool for Internet Explorer

Monday, October 25, 2010

The Windows Definitive Guide to NoSQL

First of all let’s correctly define NoSQL.

Currently, it is a RDBMs anti-pattern, some people are trying to use the old “not only SQL” definition, but I prefer the “non relational” instead.

There are of course more detailed definitions. For an easy understanding, any modern, non-relational, schema-free, web-scalable, with easy replication support, that don’t use SQL language to interface with it, will fit in the NoSQL field.

There are quite a few categories of NoSQL databases, grouped by characteristics like: Columns, Documents, Tuples, Key Values, Graphs, and others.

I have been working with relational databases associated with ECMs in applications almost all my professional life. When I hear from NoSQL databases a few years ago, the Documents category sparks my imagination.

Two of them have become trends in the field: CouchDB and MongoDB.

Being strictly honest, I have a predilection for MongoDB.

Here are a few reasons:
  • It is Powerful and Flexible
  • It has Collections (slightly similar to tables)
  • It is Easy Scaling (automatic Sharding)
  • It uses TCPIP (amazing performance) and finally 
  • It full supports Windows from the very beginning

In the “Ultimate Guide to NoSQL in Windows”, I will show how to get them both working easily.

Tuesday, October 19, 2010

HTML Colors and the Shadows of Gray

Do you remember of the old monochromatic times?

In another recently experienced situation, I feel like in a "back to the past" movie.

Let me show you how that feeling arises:

Working for the Enterprise, there is always a chosen hardware and of course a chosen development environment. I have already posted about customer's decision around being IE6 the standard browser to be considered when developing applications in the previous post.

Considering the hardware, I have recently involved in a situation where the chosen hardware simply didn't support the chosen software options.

We have basically two models of PCs coming from a big enterprise supplier. One of them have an on board video controller (let's call it the X320 model), and the other an off board more specialized video controller (this one could be the X330 model).

Our principal customer site consists mainly of shades of red and gray, but the problem appears more easily with a variety of different tones of gray.

The question is: using the customer's standard CSS plenty of gray tones, many of those tones are simply ignored by X320's video controller, but appear fine when using the X330's one.

This situation brings me back to the old "safe web color" time, and proves me that in the "safe way"; there are no many safe gray options.

If you have any question or need more information, I have compiled information about HTML Colors in general and specifically about gray scale here.

The final word is "Be careful about Gray Shades".

Saturday, October 2, 2010

Who cares about Javascript, Jquery and Prototype?

Well, I care about them all of course.

But I have recently experienced a situation where if I was in a more up to date development environment, none of them will surpass simple HTML and CSS.

Let me show how that application should work:

  • First of all, unfortunately, we need to use tables in these apps.
  • We have a set of images in a Thumbnail.
  • When one of the Thumbnail images is clicked a corresponding centered larger image will be displayed at the bottom of the page.
  • I have defined a fixed width of this larger image in 750px.
  • I was counting with the height being automatically and proportionally set considering that width.

Everything works fine in all browsers, except when images are narrow then that preset limit.

In that case the centered larger image becomes distorted. The narrow the image compared with the preset width the more obvious becomes the distortion.

You can see an example of how it not properly works here.

On the other hand the solution to that was amazingly simple. Simple as 2 lines of CSS code!

You can see that working option here.

But there is a problem… As always that simple amazing solution doesn’t work on IE6 (in fact it doesn’t work in IE at all). If you are testing the above example in IE, try the last image and see what happens.

Believe it or not, many customers around (at least here in Brazil) are using that infamous browser as the “official” one, and developers should base their web applications on it.

That is only one of the many situations where you should care about Javascript, Jquery and Prototype. They will help you a lot.

Since this is not so complicated, Jquery and Prototype are not necessary. Just a couple of Javascript functions have solved the problem.

Here is a working solution tested against IE6, IE8 and some real modern Browsers like Firefox, Safari, Opera and Chrome.

I would like to see some Jquery and Prototype alternatives to get the same, on an even simpler solution.

Tuesday, June 15, 2010

Peek-a-Boo (Pik a Ruby)

I have seen so many people around talking about testing different Ruby versions in Linux and OS/X.

What about using different Ruby versions in Windows?

I have been doing the job manually since the beginning, but there is a cool alternative.

It is a Multi-Ruby Manager for Windows.

A clever solution and there is extremely simple to get it working.

Let’s see:

Saturday, May 8, 2010

Diving into HTML5

I have chosen XHTML since I will apply some effort on Web development stuff.

Last Year W3C have decided to stop the XHTML development.

So, it is time to give XHTML a break, and start learning HTML 5 and CSS 3.

Of course we have many other HTML5 references on web; here is my first attempt into HTML5.

First things first: the Doc Type declaration.

Compared with my previous one:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

It couldn’t be more appropriate, simple and easy:
<!DOCTYPE html>

What we have been doing using the div tag, could now be done more semantically with, article, section, header, footer, nav and aside tags.

A few phrasing elements can help when including complementary information like: time meter and progress tags.

And a lot of new resources to be explored in the near future, like: video, audio, data attributes, microdata, native drag and drop, canvas, DOM storage, Client side SQL, new form controls, and some more.

At this point I need to do something practical, so, why not turning my own personal page into HTML5. Good chance to change its outdated design and a few concepts.

Hands on!

Here are the steps I have followed:

First, take the former page and a few ideas on what to change.

And here is the altered page:

It was an intermediary version, a cleaner one, but still using XHTML.

The tool I have used most in this phase was the ColorZilla Firefox Plug-in.

Since I was trying to keep the color scheme close to the one I have used in the previous version, this plug-in really helps.

Now, the big change!

I was looking for a different approach. My web page would show a more intimist profile, giving me a chance to explore HTML5 basics.

And here it is:

I have made a self-explaining layout from this new version of my page, where each new tag could be easily found.

I have also provided a full HTML5 page wireframe, so anyone could start working on it right now.

What to do next? I think a little work using the canvas tag will be.

Saturday, April 10, 2010

Who cares about a nanosecond?

Things are going faster and faster, so, why still measuring times in a second precision?

Could you think about how many files are uploaded from users in a specific city within a second?

Let’s say, any country capital with a high speed broadband service.

Try to put them all in order. Which arrives first?

Most of the current relational databases support Timestamp data:

Oracle ........ '2007-08-08 09:00:00.123456789'
DB2 ........... '2002-10-20-'
PostgreSQL .... '2003-07-29 13:19:30.532'
MySQL ......... '1970-01-01 00:00:00'

But most of it doesn’t consider nanoseconds properly.

People tend to consider that only Real Time Systems have better precision of time measurement needs, but that is not true.

I have recently developed a business application where users can upload files.

Files are uploaded in groups (fifteen maximum). It was important to know the order on which files have been upload.

Depending on the size of the files and users’ internet broadband capacity, some files could be uploaded in the same second.

So, that is the reason to store the uploaded date in the table as a Timestamp column.

The problem starts when trying to feed the required data using the language resources only. I know we can provide current timestamp from the database itself, but if you are not using a relational database and needs to store the timestamp?

Java and Python for instance, have nanoseconds support, but deal with them separately from the date and time. And about Ruby?

The Good new is that Ruby 1.9 does the job nice this way:'%Y-%m-%d-%H:%M:%S.%6N')

Where you can specify the desired precision in %3N, %6N or %9N, but will need a superfast machine to test them all.

Here is a working sample:

Another consideration you must take into account: the O.S. used:

  • Solaris and Linux already support nanosecond precision.
  • The situation on Mac OSX is not that good, since only microseconds are available.
  • Windows, on the other hand, supports nanoseconds, but have a 10ms granularity limit.

So, depending on O.S. running your code, you may need some extras to get the timestamp in the complete form.

The Bad new is that Ruby 1.8 doesn’t support nanoseconds.

Back to the real World, we must admit that most of people out there are using Ruby 1.8.6 under Windows.

So, I have made a working snippet for Ruby 1.8.6 on Windows that could at least, provide data to the PostgreSQL centisecond format.

Saturday, March 13, 2010

Ruby TransParenTheses

First thing first, the definition:

Parentheses (singular, Parenthesis)—sometimes called Round Brackets, Curved Brackets, Oval Brackets, or just Brackets, or, colloquially, Parens.

Contain material that could be omitted without destroying or altering the meaning of a sentence.

I think the above definition, must be considered when discussing about the non mandatory Parentheses use in Ruby.

On many discussion groups, people are questioning Matz’s option to not make the use of parentheses mandatory in Ruby Language, mostly around Ruby methods parameters.

Apparently this decision is becoming stronger.

If you run the following piece of code in Ruby 1.8.6, you will get a warning:

p 31

ptest01.rb:1: warning: parenthesize argument(s) for future version

The same occurs with this one:

p (3+1), 1

ptest02.rb:1: warning: don't put space before argument parentheses

But if you run them in Ruby 1.9.1 they will pass with no warnings.

Do you really think it would be better this way?

p(, 1))

When developing an application I like to put myself in the user’s shoes.

As a user of a reading text (program), I would like to read it easily.

Some times the absence of a rule is not that good.

But the strict use of a rule could be bad as well.

I have this little example:

I can say Matz is right to keep parentheses optional in Ruby, leaving to users the final decision on its usage.

Saturday, February 13, 2010

Ruby Symbols Ultimate Guide

In Ruby, a Symbol is a special class used to define a constant named label.

A symbol is defined using a colon ":" in the beginning.


A symbol is not a string, but it has a string representation and an object identifier.

Ruby newbies ask about advantages on using constants over variables, or symbols over both, very often.

First of all, you must know there are no really Constants in Ruby. They are just a convention on variable names (starting with uppercase letters).

You can in fact, change the "constant" values along your ruby program.

That way, it is your responsibility to keep your Ruby "constants" with the same value almost all the time.

Strings, even with the same content are different objects, so, are identified differently.

So, strictly technically speaking, Symbols are pointers to memory objects containing the symbol name.

Differently from Ruby variables or even Ruby "constants", Symbol values could not be changed.

In fact you couldn’t even access the Symbol content unless through a Symbol#to_s method.

Remarkable points here are:
  • When Symbols are better then Strings?
  • Which are the advantages and drawbacks from one over the other?

If you have a few unique string values, and will use them the way they are (no concatenation, upper or lower case, no nothing), Symbols are the right tool for the job.

In any other circumstance, stick with strings. They are not that much slower then Symbols, and much more flexible.

Symbol scope is a bit different and need to be considered.

About performance, you need to have a few points in mind when dealing with a great amount of strings and Symbols:

About memory:

Strings are Garbage collected, Symbols are not.

So, Symbols will be there while your program is running, which can be a great memory consumer.

Have you ever considered how many objects you will have when you set a variable inside a loop?

When creating a great amount of Strings and Symbol, how did the operation compares in performance?

About CPU Time:

When you make Strings comparison rather then Symbols comparison, it could be a great CPU time consumer, since the comparison must be done for each character in the string.

Symbol "values" can be retrieved in many different ways:


Symbols should be used whenever referring to a name (identifier or keyword), even if that name doesn’t exist in actual code yet.

  • Naming keyword options in a method argument list
  • Naming enumerated values.
  • Naming options in an option hash table.

That is it about Ruby Symbols

Sunday, January 3, 2010

Test on color code II