Thursday, April 28, 2011

Enhanced Scrollbar in Productivity Power Tools

0 Comments

Visual Studio is one of the best IDE out there, though extensions were part of Visual Studio before, Visual Studio 2010 rocks with lot of cool extensionsProductivity Power Tool is one of my favorite with ton of features. You can find more info in the extension page. Though I have been using 2010 for a while, I haven't noticed Enhanced Scrollbar feature till today. It operates one three mode,

  1. Scrollbar mode
    • Scroll bar with some tiny color rectangles, each rectangle gives you info about cursor location, search term matching locations, break point and bookmark locations etc…. By clicking the tiny square you can navigate code faster.
  2. Map mode
    • Scrollbar mode plus instant preview. By hovering over the cursor, it displays the code in a preview window.

      image

  3. Full Mode
    • Map mode plus zoomed put page as scrollbar. Gives overview of the whole page with instant preview,

      image

It also comes with tons of options and you can switch modes just by right clicking the scroll bar.

image  image

Wednesday, April 27, 2011

UN publishes report on war crimes committed against Tamils, What can you do to stop it?

1 Comments

After long sleep and strong opposition from big powers like Russia, China and India[Yes same India, the country of Gandhi] and Sri Lanka, these big power’s loyal slave, UN publishes its report on war crimes committed against innocent Tamils. This report brings hidden truth about Sri Lanka and its masters India and China. How these big powerful countries ignored rights and lives of two hundred thousand Tamils and massacred them without any witness.

It finally tells the tale of why Sri Lanka government didn't and don't let any media including Red Cross into their country.

What you can do?

  1. Read this report. Truth may not be pretty but you have to know it. Strength of the Truth lies on our hands. Truth is like light, the more you know it, brighter it gets and tougher it becomes for the criminals.
  2. Share this report, Tweet it, blog it, Facebook it. Spread the truth. If we ignore this, then we encourage these murderers.
  3. Stop buying products from Sri Lanka, China and India[Yes same India, the country of Gandhi] . You may feel like, how can we stop buying thing made in China? At least stop buying one thing. Changes will happen if we all come together.

 Report Of The Secretary-General’S Panel Of Experts On Accountability In Sri Lanka.

BBC reports war crimes committed against Tamils

0 Comments

Yesterday BBC reported war crimes committed against Tamils in Sri Lanka quoting UN report on Sri Lanka’s war crime. You can read the full UN’s full report here, REPORT OF THE SECRETARY-GENERAL’S PANEL OF EXPERTS ON ACCOUNTABILITY IN SRI LANKA

You can read BBC’s report here

BBC News - Sri Lanka: UN says army shelling killed civilians - http://bbc.in/iaEZG8

BBC News - Sri Lanka 'war crimes': Main allegations - http://bbc.in/e8eSgB

UltraWinGrid default (active) row selection and bad exception handling

0 Comments

I have a UltraWinGrid bound to a BindingSource object data source .   This is how I display list of rows in the grid.

The only difference between the two methods is, last line in the second method, This is an classic bad example exceptions.

By default, UltraWinGrid selects a row if no row is selected, I was trying to disable this behavior, I couldn't find any straight property or method to do this. I found ActiveRow  returning the selected row and it has a setter. So I thought setting ActiveRow to null would disable the selection. But it doesn't. I have couple of problems with this line,

ultraWinListGrid.ActiveRow = null;
  1. It doesn't do what it looks like doing
  2. It doesn't tell me what happened and why it didn't do it.
  3. It doesn't prevent me doing things it can’t do.

So, How did I solve this, that's an another poor encapsulation story. Take a look here for a workaround.

Tuesday, April 26, 2011

Different ways to open application/programs in powershell

1 Comments
I wanted to test start-up speed of Firefox, IE and Chrome. So I wanted to write a small script to open all these browsers in same time and see which browser opens faster.
If I wanted to write it in batch file, it would be something like this.

You can do the same thing in Powershell like this,

By the way winner is Chrome, I love you Firefox, but you have to start up faster :(

Friday, April 22, 2011

Sync your blog with Twitter and Facebook using twitter feed

0 Comments

If you post something on your blog and you want it to be tweeted to your twitter account or facebook account, 

 

just does that. Super cool thing is they don't ask you your twitter user name and password and bank info, They use oAuth, it takes you to twitter site, you authorize twitterfeed to update your twitter feed, Bingo, You have it.

If you want your posts to be written on your facebook wall, You can do that with twitterfeed too.   But I have twitter synced with my facebook already, so now having twitterfeed to tweet my posts to my twitter account, I am hoping my post will be broadcasted to twitter and twitter will write it to my facebook wall.

Sri Lanka – evidence of ongoing repression and abuse.

0 Comments

Channel 4 publishes another story about Tamils who forced to live in camp controlled by army.  For full story go here

Tamils - victims of genocide and warcrime.

1 Comments
“You can bend it and twist it... You can misuse and abuse it... But even God cannot change the Truth.” - Michael Levy

Truth always brings itself out. One form or another. It is just matter of time. Some people see it right away and some never see it and some don't want to see it. Because it’s never pretty and hurts like hell. The longer you hide it, bigger its vengeance. This post is for the people who don't see the truth or don't want to see the truth.

This is video about Isai Priya, A Tamil girl found naked and dead during the Sri Lanka’s war against terrorism. Nobody deserves this. Nobody.

Video by Channel 4

Channel 4 obtains more video of war crime executed by SriLanka troops. And UN Investigator authenticates the video.

Kill everybody, Finish them all. Orders from the top Sri Lankans army.

CNN's Becky Anderson talks with a U.N. special investigator Prof. Philip Alston

Photos allege Sri Lanka war massacre - AJE - Al Jazeera English

Sri Lankan soldier pulls out a naked woman’s dead body in the battle ground and – Headlines Today

Al Jazeera questions the SriLankan army bombed on no fire zone.

Another video of Tamil victims of Sri Lanka armies brutal attack.

Thursday, April 21, 2011

var vs dynamic in C#

1 Comments

var is just another C# syntactic flavor. C# compiler infers the types for us.

Lets take a look at this code snippet,

    int intX = 10;
    var intY = 20;  

It may look different in the surface, but both are type of Int32 in IL.

image

var is static typing, this means that resolutions are verified at compile time. If we try to access a method or property that doesn't exist or beyond the access level, compiler stops the compilation. No more soup for you. Its like Soup Nazi.

    string testString = "Hello";
    testString.toString(); //Compile time error

In the other hand, dynamic uses dynamic typing. If you try to access the method or property that doesn't exist then compiler wont stop you from compiling the code. Compiler changes its role as a controller to helper. It assumes that we know what we are doing and move out of our way.

    dynamic testDynamic = "Hello Dynamic";
    testDynamic.toString(); //Run time error.  

Both var and dynamic have their purposes in the framework. Its all come down to using the right tool for the right job. var provides support for anonymous types.  It provides better readability, Imagine using LINQ chaining without anonymous methods.

    class Person
    {     public string Name { get; private set; }     public Person(string name)     {         Name = name;     }
    }  
    //Convert Person to SuperPerson without creating yet another class
    List<Person> persons = new List<Person>() { new Person("Ordinary Joe"), new Person("Regular Rick") };
    var superPersons = persons.ConvertAll(p => new { Name = p.Name, SuperPower = "Fly" });  

dynamic comes with its own set of features, It also provide better readability. Having dynamic objects in .NET, makes programming COM easy and readable. Code that is tough to read is tough to maintain and extend.

    // Before the introduction of dynamic.
    ((Excel.Range)excelApp.Cells[1, 1]).Value2 = "Name";
    Excel.Range range2008 = (Excel.Range)excelApp.Cells[1, 1];

    // After the introduction of dynamic, the access to the Value property and
    // the conversion to Excel.Range are handled by the run-time COM binder.
    excelApp.Cells[1, 1].Value = "Name";
    Excel.Range range2010 = excelApp.Cells[1, 1];  

You can change dynamic type from one to another with out casting or boxing/unboxing.

    dynamic value;
    value = 10; //Now it is Int32 
    value = DateTime.Now; //Now it is DateTime  

dynamic also adds another great feature, dynamic member. Any code that has access to a dynamic type can change its type or add new properties or add new method.

dynamic enables us doing reflection like coding without paying heavy performance penalty. Take a look at these micro ORMs like dapper-dot-net and Massive. They are so tiny and super fast. its like too good to be true.

References:

  1. Using Type dynamic - MSDN
  2. Access Office Interop Objects – MSDN
  3. Implicitly Typed Local Variables (C# Programming Guide)
  4. Dynamic Language Runtime Overview
  5. Massive: 400 Lines of Data Access Happiness
  6. StackOverflow dynamic vs var

My top 5 shows at MIX 11

0 Comments

Knockout JS: Helping you build dynamic JavaScript UIs with MVVM and ASP.NET (FRM08)

An Overview of the MS Web Stack of Love (FRM02)

NuGet In Depth:  Empowering Open Source on the .NET Platform

NuGet In Depth: Empowering Open Source on the .NET Platform

Scaffolding – ASP.NET, NuGet, Entity Framework Code First and More

Scaffolding – ASP.NET, NuGet, Entity Framework Code First and More

Mono: State of the Union

    Different ways to create threads in C#

    0 Comments

    Dual cores and Quad cores are long gone, Hexa and Octa are kicking the dusts. Its time to brush-up multi threading.

    First lets see different ways to create threads,

    Most of examples are taken from http://www.albahari.com/threading and C# 4.0 in Nutshell.

    Monday, April 4, 2011

    WPF Brushes are freezable

    0 Comments
    Brushes are freezable objects. Thus, you can make changes to Brush objects so long asthe Freeze method has not been called. After the Brush.Freeze method is called, the brushbecomes read-only and no further changes can be made.
    MCTS Self-Paced Training Kit (Exam 70-511): Windows Application Development with Microsoft .NET Framework 4

    Saturday, April 2, 2011

    How do I have code in my blog?

    0 Comments
    My brian is wired to syntax highlighted code. When I see some code and its not syntax highlighted, It takes me longer to parse and umderstand code. Lately I have been using few websites to display code in my blog. Unfortunately there is no magic bullet yet.
    • gist.github: Decent site, No private store and No AutoHotkey support :)

    • snipplr: Supports private code snippets and tags. Doesn't add background color to code snippet, if your site’s background is not white, you have to edit the embed script every time you paste.

    ;Auto type Master Password by sending AutoType command to KeePass

    1. ^+c::
    2. {
    3. KeyWait, LWin
    4. Send, ^c
    5. Sleep 50
    6. Run, http://www.google.com/search?q=%clipboard%
    7. }

    View this snippet on Snipplr

    • pastebin: Supports AutoHotKey :). Color theme is not my cup of tea. But I am going to give a try.