The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,861 other subscribers

Archive for 2010

TFS folder compare in Visual Studio 2005

Posted by jpluimers on 2010/06/04

Recently I had to do some work in Visual Studio 2005 and TFS 2005.

I missed the “Folder Compare” feature on one of my machines, and I was sure it was on one of my others.
This feature is standard in Visual Studio 2008. A very handy feature indeed :-)

Then this post reminded me to install the Team Foundation System Power Tools. Read the rest of this entry »

Posted in .NET, Development, Software Development, Visual Studio and tools | 1 Comment »

Delete and Remove to Unlock EISA Hidden Recovery or Diagnostic Partition in Vista » My Digital Life

Posted by jpluimers on 2010/06/03

When you try to delete an EISA Hidden Recovery or Diagnostic partion, some options fail:

  1. DiskMgmt.msc does not show the “delete” option
    (the link is for Windows XP, but the – usually very useful – tool has been almost the same for ages)
  2. DiskPart.exe fails with “Cannot delete a protected partition without the force protected parameter set
  3. The free partition managers I tried (Partition Assistant 2.0 Home Edition and EASEUS Partition Master) refuse to install on the x64 editions of Windows (x64 is used more and more at home these days)

Luckily, this thread discusses both problems, and points to this page for a solution with DiskPart.

Read the rest of this entry »

Posted in CommandLine, Development, Power User, Software Development | 6 Comments »

Bookmarklets: empower your webbrowser

Posted by jpluimers on 2010/06/02

Next to Greasemonkey – the script engine that empowers FireFox and Chrome, there is another very powerful way to enhance your browser:
Bookmarklets.

Bookmarklets are like shortcuts, but they don’t point to a static URL: they add action, usually by some JavaScript.

If the bookmarklet returns a string, then the browser will follow that as a URL.
But the since bookmarklet  has access to the current page, it can also perform just a local action.

The cool thing is that most bookmarklets work on almost any popular browser.

These are a few bookmarklets that I use on a regular base, most are from bookmarklets.com: Read the rest of this entry »

Posted in Bookmarklet, Conference Topics, Conferences, Development, Event, Power User, Software Development, Web Browsers, Web Development | Leave a Comment »

Example.[com|net|org] Web Page

Posted by jpluimers on 2010/06/01

After years of doing web-development, I just stumbled on example.com/example.net/example.org second level domain names.

Those are domains meant for documentation or example purposes.
And there is RFC 2606 that documents them.
There are even these first level domain names:
.test/.example/.invalid/.localhost

You’re never too old to learn something new :-)

–jeroen

Posted in Development, Software Development, Web Development | 1 Comment »

#fail: Facebook has changed their mail domain to facebookmail.com

Posted by jpluimers on 2010/05/28

Recently, facebook started to complain that my email is not valid any more:

Please update your email address
Our systems have detected that valid.email@example.com is no longer a valid email. Facebook requires all users to maintain an active contact email. Please enter and confirm a new contact email below:
New Email: XXXXXXXX
If you believe you have received this message in error, please reconfirm your current email.

Note I changed my facebook email address in the quote above and log below, but the unchanged one is valid, and accepts mail. Read the rest of this entry »

Posted in Opinions, Power User | 11 Comments »

.NET/C#: comparison is a 101, or isn’t it?

Posted by jpluimers on 2010/05/26

In C# (well, actually: .NET), there are a couple of ways to compare things:

  • the built-in equality operator (==) which translates to the IL instruction CEQ
  • an overloaded equality operator (operator ==) that a class or struct can introduce
  • the virtual Equals method that is introduced in System.Object and which you need to call explicitly

Sometimes, this leads to confusion, for instance, given

object one = 0;
object two = 0;
bool same = one == two;

what would you expect the value of same to be?

Actualy, the value is false.

Why?

The reason is that the operator == does not call the System.Object.Equals method.
So the System.Int32.Equals method is never called.

What happens in stead, is that the CEQ instruction is called.
Since both the integer zero values have been boxed into two objects (referred to by one and two), the CEQ will perform the comparison on the object references.
Even though both zero values are the same, both objects have a reference to a different spot in memory (the contents of both memory spots then are the same zero value).
Since one and two refer two different memory locations, the value of same becomes false.

Similar things hold for most types, unless they overload the operator ==.

System.String is a special type.
Even though it not a value type (it is derived from System.Object, not SystemValueType), it behaves like a value type.

One of the things that string does is overload the operator == (and overload the operator !=):

public static bool operator ==(string a, string b)
{
    return Equals(a, b);
}

So even though one and two are potentially* referring to different locations, their content is compared, and same becomes true.

string one = "Foo";
string two = "Foo";
bool same = one == two;

*Now lets see these memory locations:

object one = "Foo";
object two = "Foo";
bool same = one == two;

Surprise! Here too, same becomes true.

What happened here is that when the compiler compiles two identical strings into an assembly, they are interned and end up at the same memory location.

Conclusion:

Comparison in .NET is not always 101.
It depends on the types involved, value types versus reference types, boxing, interning and the overloaded operator ==.

–jeroen

via The Lounge – CodeProject.

PS:
Another special thing about strings is that they are immutable:

A String object is called immutable (read-only) because its value cannot be modified once it has been created. Methods that appear to modify a String object actually return a new String object that contains the modification. If it is necessary to modify the actual contents of a string-like object, use the System.Text.StringBuilder class.

via String Class (System).

PS2:

Some other interesting links on comparison, interning, etc:

Posted in .NET, C#, Development, Software Development | Leave a Comment »

Happy Towel Day

Posted by jpluimers on 2010/05/25

Don’t forget to bring your Towel today

–jeroen

Posted in .NET, About, Delphi, Development, Opinions, Personal, Software Development | 1 Comment »

“Yoda Conditions” (from: stackoverflow – New programming jargon you coined?)

Posted by jpluimers on 2010/05/25

Having done quite a bit of C and C++ work in the past, I often still use “Yoda Conditions”, especially in environments where you have both = and == as an operator.
So, in a boolean expression, I often put the constant to test in front of the test.

I recently learned at stackoverflow that quite a few people call these “Yoda Conditions”:

“Yoda Conditions”— the act of using if(constant == variable) instead of if(variable == constant), like if(4 == foo). Because it’s like saying “if blue is the sky” or “if tall is the man”.

Thanks to dreamlax for helping me find that.

This is a problem in languages that have both the = and == operators, and the result of an assignment itself is also a value (i.e. allowing a = b = true). Read the rest of this entry »

Posted in .NET, C#, Delphi, Development, Java, Ruby, Software Development, Web Development | 22 Comments »

Visual Studio 2010: macro to change Target Framework Version for solution (by Scott Dorman)

Posted by jpluimers on 2010/05/21

Scott Dorman udpated his macro to change the target framework version for all projects in a solution to Visual Studio 2010 and published the new macro on CodeProject.

His new macro now supports these target frameworks:

Notes:

  • The links are to the download pages of the frameworks; look for “Standalone version” or “Full installer” for non-bootstrap download.
    (version 1.1 can be downloaded here, but is not supported in VS2010)
  • The “Client Profile” versions are stripped down versions of their “Full” counterpart.

–jeroen

Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Delphi, Development, Prism, Software Development, Visual Studio and tools | 2 Comments »

Telnet for Windows Vista & Windows 7

Posted by jpluimers on 2010/05/20

I wrote about Telnet for Windows Vista & Windows 7.

These steps are even easier:

  1. Press the Windows key
  2. type “turn windows features on or off”
  3. choose “Telnet Client”
  4. press OK
  5. wait a few seconds for the install to complete

–jeroen

Posted in Power User, Windows, Windows 7, Windows Vista | 1 Comment »