Tuesday 30 April 2013

Remove Hyperlinks from Excel 2010 Worksheet (Hint: Eraser Dropdown)

Select the cells with the offending hyperlinks. Click the Home tab in the Ribbon, and the Editing subsection $(or Editing "Group"). The Ribbon is made of groups e.g. Font, Alignment, Number, Editing. Click the "Eraser Dropdown"and select "Clear Formats" (NOTE: NOT Clear All as this will delete the hyperlink text as well).

Thursday 25 April 2013

Simply Snassie - The Story of Strong Named Assemblies in .NET

Quick Question: What is a strong-named assembly (Snassie, or SNA) and why do you need it?

Do you know the answer? Read the next section to find out more!

Strong named assembly (SNA) = Assembly SIGNED with a STRONG NAME

A Strong-named assembly is simply an assembly - SIGNED with a strong name (containing amongst other things, a digital signature). Perhaps a more apposite name might have been, Strong SIGNED assembly (SSA).  SNA in this context should not be confused with IBM's SNA (Systems Network Architecture, a protocol stack for networking, introduced in 1974).

STRONG NAME may contain Culture Information, and WILL contain PUBLIC KEY and DSig

The strong name is like the "unique id" for the assembly; comprised of its text name, version number, culture information (if applicable) plus public key and digital signature. Think of it as a STRONG character name in a movie, like Dr Hans Zarkov, or Ming the Merciless, in the Flash Gordon movie (1980), and the digital signature being a component of the strong name e.g. simply Hans, or Ming.

By the way, I generally don't sign my assemblies. Why do I need to understand strong-named assemblies?

As it turns out, reading MSDN articles on .NET Security won't make a load of sense if you don't know what strong-named assemblies are. Further, at some point, you are bound to encounter an exception somewhere or other that requires you to understand what Snassies are from A-Z.

What other things do I need to know about SNAs?

A strong-named assembly can only reference other strong-named assemblies.

Remind me how digital signatures work.

A digital signature verifies the integrity of data passed from generator to recipient (a.k.a. the "verifier"). The verifier has access to the sender's public key.

What's the underlying algorithm for generating signatures in this SN infrastructure.

Strong names require public key cryptography. This begs the question: Quelle Algorithme?  Currently, the SN implementation used the RSA public key algorithm and the SHA-1 hash algorithm (SHA=Secure Hash Algorithm).

Tuesday 16 April 2013

The Programmers Automation Cost-Benefit Decision

One of the daily decisions programmers confront is whether it is worth automating certain mundane tasks, particularly with regards to systems support. The upfront time expense in automation may bring long run benefits, but may delay short term projects. If the latter, then serious thought has to be given to whether automation should be attempted, with mindfulness not to put important deliverables "at risk". Oftentimes, many desirable automations must be put on the back-burner to achieve higher priority deliverables. These projects can then be picked up opportunistically during any "idle time" that may arise.

Keeping Pace with the New C++ and the Expanding Lexicon of Lvalues

Reading the "Standards committee" papers is one way (open-std.org) to keep in touch. The latest draft standard can be found in pdf format here.

One example of how things change is the new nomenclature of lvalues and rvalues.

In TCPL, an lvalue is simply "something on the left-hand-side of an assignment".

In C++0x, semantics change.

A glvalue is now a "generalised lvalue" denoted either an "lvalue" or an "xvalue".

An lvalue now means a function or an object, and an xvalue is an object near the end of its lifetime (short for "eXpiring Value").

An "rvalue" now means, more precisely, an xvalue, a temporary object (or sub-object of the same such) or a value not associated with an object.

A "prvalue" is an "rvalue" that is not an "xvalue".

The Sooner you Begin Coding the Later You Finish

Some managers pressure programmers to begin coding too early. This can result in the wrong thing being built and huge wastage in terms of wrong coding and rework. As Bjarne states: "the most important thing in software development is to be clear about what you are trying to build".

Sunday 14 April 2013

ISO 3166 Country Codes for Programmers

Two letter standard country codes are given by the ISO 3166-1 alpha-2 standard.

US - USA
GB - UK (taken from United Kingdom of Great Britain and Northern Ireland)
GG - Guernsey
JE - Jersey
GI - Gibraltar

66 is the 11th triangular number, 31 is prime. Alpha-2 standard is used in BICs (Bank Identifier Codes) and ISINs (International Securities Identifying Number).

The Castle Project

Castle is an umbrella for various open source projects in .NET, the most recognised one being Windsor. It's an IOC container. It also includes nVelocity, a .NET fork of the Velocity template engine.

Tuesday 9 April 2013

System.dll versus mscorlib.dll

The difference - mscorlib is tightly bound to the CLR whereas System.dll is not. The CLR and mscorlib must be versioned together.

You've got your basic data structures (such as Dictionaries) and threading constructs defined within mscorlib. It's an integral part of the CLR.

Getting Timings in C#: System.Diagnostics.Stopwatch

Use System.Diagnostics.Stopwatch to measure run times.

You can create a Stopwatch amazingly using the StartNew static method that actually returns a Stopwatch object. This also sets the elapsed time property to zero.

When you want to stop the Stopwatch, all you do is call Stop, which tells the Stopwatch to stop measuring elapsed time.

You can get the elapsed time by calling Elapsed which returns a TimeSpan object or ElapsedMilliseconds which returns the milliseconds elapsed as a long data type (which is just "syntactic sugar" for a System.Int64).