Tuesday, January 5, 2010

How to restore Visual Studio .sln file icon

I merely tried to associate .sln file type with the IDE so Windows 7 taskbar will remember my recent projects and I could access them with right click. I ended up reinstalling Visual Studio. This was after I tried to fix it in registry, just to find out Windows 7 has a different mechanism for file types associations. The big frustration was I could not find the icons themselves to put them on the registry. Visual Studio has a "Restore File Associations" feature. It doesn't fix the icons! Reinstalling after deleting all related registry values didn't work either! After a couple of hours where I visited sites like Ways Bill Gates Should Die, and Googling a lot I found the solution:

  1. Right click a .sln file
  2. Click "Open with..."
  3. Click "Browse..."
  4. Go to "Program Files\Common Files\microsoft shared\MSEnv"
  5. Choose "VSLauncher.exe"
  6. Click "Open"
  7. Check "Always use the selected program to open this kind of file"
  8. Click "OK"

Tuesday, December 29, 2009

C# Clipboard in Console Application

In C# accessing the Clipboard suppose to be easy, but you'll find out it doesn't work in the normal way.
Here is a small note from MSDN that I missed at first:

The Clipboard class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your Main method is marked with the STAThreadAttribute attribute.
So, in a Console application, use this function:

Code:
public static object GetClipboardData()
{
    object ret = null;
    ThreadStart method = delegate()
    {
        System.Windows.Forms.IDataObject dataObject = Clipboard.GetDataObject();
        if (dataObject != null && dataObject.GetDataPresent(DataFormats.Text))
        {
            ret = dataObject.GetData(DataFormats.Text);
        }
    };
    if (Thread.CurrentThread.GetApartmentState() != ApartmentState.STA)
    {
        Thread thread = new Thread(method);
        thread.SetApartmentState(ApartmentState.STA);
        thread.Start();
        thread.Join();
    }
    else
    {
        method();
    }
    return ret;
}

Saturday, December 26, 2009

Step-by-Step Math

Have you ever given up working on a math problem because you couldn’t figure out the next step? Wolfram|Alpha can guide you step by step through the process of solving many mathematical problems, from solving a simple quadratic equation to taking the integral of a complex function.

From here:
http://blog.wolframalpha.com/2009/12/01/step-by-step-math/

Example:
http://www.wolframalpha.com/input/?i=integrate+x+Sqrt[1-Sqrt[x]]

Sunday, December 20, 2009

Windows 7 & HomeGroup: Sharing with Windows XP, Windows Vista, and other operating systems

http://www.microsoft.com/downloads/details.aspx?FamilyID=80b1aa5d-1b5a-4447-8036-acc918ba7af2&displaylang=en

Windows 7 - Remove User From Login Screen

The users on the log-in screen are all the users that belong to the "Users" group.

To remove a user invoke the following command:

  net localgroup users /delete <username>

Instead, on Windows 7 Ultimate and Professional, you can use the User Manager to do that:

Monday, December 7, 2009

How to grab Google autocomplete list

We all know this wonderful feature:

Automation of grabbing that list can be helpful for instance if you want to know what people are looking for.

While typing in the search box, somewhere there is a Javascript code that makes the following HTTP GET request:
http://www.google.com/complete/search?hl=en&q=QUERY&cp=LEN(QUERY)

For example, the following query gives the same results as in the picture:
http://www.google.com/complete/search?hl=en&q=how%20to%20be%20better%20at%20&cp=20

window.google.ac.h(["how to be better at ",[
["how to be better at halo 3","43,100,000 results","0"],
["how to be better at basketball","87,500,000 results","1"],
["how to be better at math","52,900,000 results","2"],
["how to be better at soccer","88,300,000 results","3"],
["how to be better at football","207,000,000 results","4"],
["how to be better at beer pong","2,760,000 results","5"],
["how to be better at call of duty 4","72,600,000 results","6"],
["how to be better at madden","25,900,000 results","7"],
["how to be better at volleyball","9,370,000 results","8"],
["how to be better at chess","15,300,000 results","9"]]])