April 2010 - Posts

This post was long overdue. I always wanted to thank the guys who put extraordinary effort and passion for making our lives easier everyday, without requiring anything at all in return. Here’s a list of 10 Firefox addons I cannot live without. I would like to thank the developers, testers and whoever is behind these free tools. You have done a really good job and literally managed to change our lives.

 

1. Screengrab

Capture full webpage even though you cannot see it. You can also select from visible portion before you save as image. That way, image editors are optional to do just that.

 

2. GreaseMonkey

Execute your JavaScript on external site. You can customize sites as per your need by manipulating the DOM elements, redirecting to other sites, refreshing page to keep alive the session. You can find wealth of such scripts at: http://userscripts.org/

 

3. View Source Chart

This addon lets you view source exceptionally better than Firefox’s default viewer. See the difference below. Right click on a page and View Source Chart.

ViewSourceChart

 

4. Measure It

Ruler for your produced HTML to help you make it pixel-perfect.

MeasureIt

 

5. ColorZilla

Get that color code. You do not have to capture, save, open with Photoshop and pick colors. You can do it all using this addon.

ColorZilla

 

6. Web Developer

Amazing *powerful* addon for Web Development. Just install it now if you haven’t already!!

WebDeveloper

 

7. ScrapBook

Anontate webpages, save and share using ScrapBook. You can use sticky notes, highlight text and add comment. Handy tool for QA, and often good for change requests.

ScrapBook

 

8. Firebug

Finally the legend. No words can appreciate as much as they deserve. This is the world’s most powerful web development tool. This stunning tool you can use for looking into the web transactions, headers, responses, cookies. You can also profile them. Using its amazing powerful HTML selector, you can manipulate DOM elements, styles, and see them reflected on the fly. Set breakpoints, and debug JavaScript.

Firebug

Firebug2

Firebug3

 

9. FireCookie

An extension of Firebug, allows you to see the cookies. You can also export them.

FireCookie

 

10. YSlow

This is an excellent extension of Firebug from Yahoo. It points out the rooms for improvement in your webpage by verifying and suggesting the best practices. Excellent reporting and elaborate guidelines, help you to score “A”s from many obvious “F” grades you are going to see your webpage is scoring.

YSlow 

Happy Web Development!

AspectF is an open source utility which offers separation of concerns in fluent way. I am personally a big fan as well as contributor of this project. It is very simple, easy to implement, and an excellent way to incorporate regular everyday logics into your business code from one single class, AspectF. I have added couple of new features to it, which are yet to be committed to the source control. However, here’s one feature that I have introduced today is to be able to write VB-like with keyword in C#.

The following is a sample code Omar mentioned in his blog post. Unlike VB, in C# you have to mention the instance variable like every time whenever you intend to modify its properties:

StatusProgressBar.IsIndeterminate = false; 
StatusProgressBar.Visibility = Visibility.Visible; 
StatusProgressBar.Minimum = 0; 
StatusProgressBar.Maximum = 100; 
StatusProgressBar.Value = percentage;

 

Now that I have added that feature, in AspectF you can write like the following:

AspectF.Define
.Use<ProgressBar>(progressBar1, p =>
{
    p.Style = ProgressBarStyle.Blocks;
    p.Minimum = 0;
    p.Maximum = 10;
    p.Value = 1;
});

 

As always the benefit of tying this up with AspectF is, you can use other aspects with it, too:

AspectF.Define
.Delay(1000)
.MustBeNonNull(progressBar1)
.Use<ProgressBar>(progressBar1, p =>
{
    p.Style = ProgressBarStyle.Blocks;
    p.Minimum = 0;
    p.Maximum = 10;
    p.Value = 1;
});

 

I have also added an unit test case to verify its functionality:

[Fact]
public void Use_Should_ReflectTheChangesMadeInsideTheScope()
{
    var textBox = new TextBox();
    var contents = "AspectF rocks!";
 
    AspectF.Define
    .Use<TextBox>(textBox, c =>
    {
        c.CausesValidation = false;
        c.MaxLength = 200;
        c.TextMode = TextBoxMode.Password;
        c.Text = contents;
    });
 
    Assert.Equal<bool>(textBox.CausesValidation, false);
    Assert.Equal<int>(textBox.MaxLength, 200);
    Assert.Equal<TextBoxMode>(textBox.TextMode, TextBoxMode.Password);
    Assert.Equal<string>(textBox.Text, contents);
}

 

Use AspectF. It is very handy, indeed!

IsNullOrWhiteSpace is a new method introduced in string class in .NET 4.0. While this is a very useful method in string based processing, I attempted to implement it in .NET 3.5 using char.IsWhiteSpace(). I have found significant performance penalty using this method which I replaced later on, with my version.

The following code takes about 20.6074219 seconds in my machine whereas my implementation of char.IsWhiteSpace takes about 1/4 less time 15.8271485 seconds only. In many scenarios ex. string parsers, this level of performance gain makes a huge huge difference. While I was building a CMS Framework lately, I noticed this difference in string parsing.

static void Main(string[] args)
{
    var test1 = "          ";
    var test2 = "    test  ";
 
    var start = DateTime.Now;
 
    for (var i = 0; i < 99999999; ++i)
    {
        var result1 = test1.IsNullOrWhiteSpace();
        var result2 = test2.IsNullOrWhiteSpace();
    }
 
    var diff = DateTime.Now.Subtract(start);
    Console.WriteLine(diff);
    Console.ReadLine();
}

 

Not all applications require Unicode support. If your application expects complete ASCII inputs, the following works way better than the native .NET 3.5 one:

public static class Extensions
{
    public static bool IsNullOrWhiteSpaceASCII(this string value)
    {
        if (value != null)
        {
            char c;
            var len = value.Length;
 
            for (var i = 0; i < len; ++i)
            {
                c = value[i];         // Instead of char.IsWhiteSpace
                if (!(((c != ' ') && 
                    ((c < '\t') || 
                    (c > '\r'))) && 
                    ((c != '\x00a0') && 
                    (c != '\x0085'))))
                    continue;
 
                return false;
            }
        }
 
        return true;
    }
}

Fortunately .NET 4.0 introduces a method, string.IsNullOrWhiteSpace to do just that, in smaller footprint as less as 8 seconds.

 

Technorati Tags: ,,

Just wanted to share a good news with you. For my valuable contribution to the ASP.NET community worldwide, Microsoft recognizes me as an exceptional technology community leader by awarding “Most Valuable Professional” (MVP) in ASP.NET.

MVP-Logo-2

I am honored to serve the community. I will continue to blog, write articles, speak in the seminars and stay active in the open source projects. This award is going to be the source of immense inspiration for rest of my life for what I do for the community. :)

Here’s my profile: https://mvp.support.microsoft.com/profile/Saqib

 

Technorati Tags: ,

More Posts