The Yahoo Sports site was in bad shape (tabs not working, bunch of javascript errors, UI quite messed up) when viewed with Firefox 3.0 for about a week. I was keeping a close eye on the situation simple because of amusement and trying to guess when they gonna fix it. I mean you would think they would run and view their site with beta releases of the browser so that there are no surprises, after all Yahoo Sports is a big site. But I guess they didn't.

I wish I knew what exactly changed that caused the site to be so crippled. And that's another good thing for open source software: they are free to innovate and change things without worrying much about breaking older stuff if the change is really worth it. I guess in short term the devs might suffer (as I am sure yahoo sports had to change their code), but probably all will benefit in the long run with taking advantage of a great browser like firefox.

6/24/2008 11:52:29 PM
Comments (0)
Tags: firefox
 


I decided to blog today about one of my favorite (and least talked about) Firebug feature: Javascript Profiling. This could be become very relevant with web apps increasing in client side complexity and functionality. Also browsers are starting to support various advanced concepts and controls that will invite even more javascript development. I personally don't do javascript profiling often. More likely I will use it to make sure that the rough numbers I see after profiling don't look anything out of ordinary. For instance, one of the web apps I was prototyping, I was using jquery to select various html dom elements in a very inefficient way. Since it was a prototype, I really didn't care as long as I got the functionality in and could see how things worked. Once time came for cleanup, I used profiling to see what places I am making incredible amount of calls needlessly. So to get started, with Firebug up and visible (F12), click on "Profile" tab.

start

Click on "Profile" again to stop it. If you were running this on an empty page, you will see "No activity to profile." text. But if there was some javascript running (something running periodically for instance), you would see some timing data coming in. This is a great way to see what the site is running on a periodic bases by the way. To illustrate time measurement I will use a silly example. Let me create a simple page that when clicked on a button will find all the spans with-in divs with attribute "doHide" set to true and hide them. To do this, I will use jquery for selecting:

  function hideThem() {
    $("div > span[@doHide=true]").hide();
  }
  

I will start profiler running, click on the Hide them button and click on "Profile" again to get the results. Here is how they look:


So, 216 calls to hide some spans. That won't do. How about we just assing a special class to the spans and use that in selecting the spans to hide:

    $(".hideSpan").hide();
  

Results:


Kind of better since total time now is really negligible (unless the number of spans being hidden increases a lot). 168 calls, less, but still a lot. Again, you do this only if you notice something is working slower than it should. Don't get bothered much with optimizing simple javascript, make it readable and cross-browser usable your first priority. But from time to time check your work if you feel that javascript is awefully slow and you are looking to speed it up. By using the profiler you will know where to speed it up.


6/18/2008 1:10:45 AM
Comments (0)
 


This is very simple trick and I am posting this solely for the purpose that it might help a beginner developer.

While in a process of learning asp.net mvc I am building a sample website where I needed to store user selected days. Imagine input area that looks like this:

Mon Tue Wed Thu Fri Sat Sun

A good way to store this in your model and storage (DB, files, etc) is in a Flags Enum:

[Flags]
public enum Days
{
    None = 0,
    Mon = 1,
    Tue = 2,
    Wed = 4,
    Thu = 8,
    Fri = 16,
    Sat = 32,
    Sun = 64
}

Only one field required and no need to do string manipulations, just OR or ANDs to get the value selections. Again, very simple stuff, but might be not so obvious to some.

5/21/2008 12:43:01 AM
Comments (0)
Tags: Programming
 


PostgreSQL database has this very neat free text search engine called tsearch2 that used to come as add-on, but now is part of the installation. When emitting a tsearch2 query you can specify which configuration to use (english, german, or something other special) which dictates how the words are parsed etc. Since the 8.3 release of postgresql which includes tsearch2 the 'default' configuration is gone and the existing code can break. I found a quick way to create a default one by duplicating any of the existing configurations (in my case english) by executing this:

CREATE TEXT SEARCH CONFIGURATION public.default (
    COPY = pg_catalog.english
);

5/12/2008 11:27:16 PM
Comments (0)
Tags: tsearch2, postgresql, database, Databases
 


So over the course of the last year I really got into podcasting. I recently reviewed my podcast subscriptions and was amazed to find out that I am subscribed to a total of 33 music podcasts! With the help of Mediafly I organized the subscriptions so that my music channel at all times has about 10-14 different episodes. Depending on what I feel like listening I can choose to go with a bit of rock, maybe sometimes with ambient, eclectic, of course Trance (dominating my subscription list), even classical music. I am almost reaching a point where I am thinking to do a review of the best of trance podcasts available with ratings in different areas. Let's see if I ever get around doing that. But I think it would be useful as right now if you are a new podcast listener you might choose shows that are not as well produced or get released very rarely.

Besides music the other big channel I have is Sports and then Comedy.

5/5/2008 10:59:02 PM
Comments (0)
Tags: General, Podcasting
 


Reading is one of my hobbies, but I couldn't remember the last time I went to the bookstore before I did so last weekend. I needed to do a more in-depth check on the book I was considering buying and it being a nice day and all I decided to go to the closest Borders. Well let me tell you, I was amazed at how much the computer book area had changed. That particular borders some years ago had one of the best Software book section volume and quality wise. Now it is much smaller but most importantly the selection is miserable. Nothing beyond basic fluff.
Oh well, it didn't upset me at all. On contrary it was good to see a business enterprise adjust to the market conditions and repositioning their business to the changing customer needs (I saw much more open space, more inviting seating areas, cafe, etc that all the bookstore customers now look for).

5/2/2008 12:41:35 AM
Comments (0)
Tags: General
 


After a long break of silence I am attempting yet again get back into blogging. I will start with sharing something I learned about two months ago related to the object serialization.

I imagine many intermediate to advanced programmers are well familiar with xml serialization. One of the areas where you can use this is in storing/retrieving configuration files. Take an instance of the class that represents some configuration settings and serialize it upon the save/exit of your application. The next time you run your app again you can deserialize from the hard drive to use in the appliation. However there are some gotchas to watch out for. One of the desktop apps I was working on from time to time was failing while running under Windows Vista. The exception stack trace gave the clues that the problem is with xml serialization, but the actual message was rather confusing, stating that the csc.exe process could not run from the default .net framework installation. I was puzzled thinking why is csc.exe process is being spawned here at all? Well it turns out that that's how XmlSerializer works. When you write the following:

  
    XmlSerializer s = new XmlSerializer(typeof(EmailConfig));
    s.Serialize(outputStream, config);

.NET Framework implementation will actually build a serializer at runtime for your class by inspecting the type's properties and will compile that serializer and run it. I never expected this behavior, but it makes sense. I just wasn't aware of it. If you have many places where you are de/serializing or if your app cannot spawn any other processes you could benefit from this little utility called sgen. It comes with the .net framework installation. Check more in the documentation on sgen options but in short you point sgen to a .net assembly and ask it to generate corresponding xml serialization assembly. Since your assembly might have a lot of types and you serialize only a few you can specify to generate serializers only for the specific type(s). Then, when you ship your application bits ship the serialization assemblies together. The XmlSerializer will first look for the XmlSerialization assemblies (named YOURASSEMBLYNAME.XmlSerializers.dll) and see if it contains the serializer for the type it needs. If it finds it, uses it, otherwise faults back to generating code at run-time with the C# compiler.

I ended up modifying the build to generate the required serialization assemblies with the needed types as a post-build step. And the mystery exception went away.

4/29/2008 10:47:45 AM
Comments (0)
Tags: sgen, .NET, xmlserialization
 


I just hooked up Lucene.net for running searches for this blog. I generate the search index offline and then uploaded it through FTP. The only thing I am missing is automating the generation and upload process. I shall add that soon as well.

If you want to learn more about Lucene.net, take a look at the documentation written for Java version of Lucene, since Lucene.net is a straight port of it. It might be not obvious at first and you will wonder where all the documentation is located. So just visit the Lucene java pages and you will find most of what you need there.

By the way, ever since I had the site down the last time the blog entries in the google reader are all out of order. Anyone has any ideas what I can do to force google reader to refresh the entries for this blog?

2/11/2008 1:14:27 AM
Comments (0)
Tags: lucene, search
 


So, yesterday I took this blog down, upgraded the DB, and updated the blog code which was rewritten to use NHibernate instead of my own "home grown" ORM written way back in '04. The move went smoothly (although I do have some minor issues editing entries) with one glitch: the google reader subscription went all nuts. This morning I went to the reader and it showed this blog as having 64 new entries and the order is all out of whack. Oh well ... nothing really changed in the RSS output as the entry ids and guids didn't change. Maybe while the blog was down reader did some update and then did another one when it came back.

2/5/2008 9:23:45 AM
Comments (1)
Tags: test
 


There is a great series of blog posts being released on OdeToCode.com blog starting with "Three Rules for Database Work" post. In my first workplace we were running under very similar rules and concepts for versioning a database. For a quite large projects and 15-20 developers, it worked rather well. Of course you had to be disciplined as hell and couple of in-house built tools made the job a bit easier and more automated.

The rules and techniques the blog author is talking about really applies to the systems that are very database intensive, meaning complex DB schema, rules, integrity checks, etc etc etc (basically any solid application that uses database :) ). I have used a different approach to database versioning with Migrator for .NET. It is the port of migrations concept used in rails. The original author had abandoned the project. But just recently I found out that someone else is taking over and right now the source code is on google's code repository. I blogged about using Migrations before. I guess the official repository for the source and other project information now is located at http://code.google.com/p/migratordotnet/ .

2/2/2008 11:03:50 AM
Comments (0)
Tags: Databases
 
<July>
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

RSS
ATOM

Search