A1 to Column Index Calculator

When referencing a column with the ExcelApplication object, you can use either an A1 notation or a 0-based index. Code using the former is more human-readable, while the latter makes it easier to process multiple columns at once. It would be helpful to be able to quickly convert a column reference from one style to another.

Attached is the A1 Calculator, a simple Windows application that converts an A1-style column reference to a 0-based column index and vice versa. The application accepts input in either style. Current it supports the binary Excel format, which allows a maximum of 256 columns, from A to IV. It performs validation to ensure that the input is valid.

 

 

 

 

 

 

Numbers in Emacs

found this page: http://www.emacswiki.org/emacs/NumbersInRegisters

Registers are useful tools when writing KeyboardMacros. Notice how you can store numbers in registers, insert them again, and increment them in the register.

See the Node Keeping Numbers in Registers in the EmacsManual.

Example session:

‘C-u 1000 C-x r n x’
Store 1000 in register x
`C-x (‘
Start a keyboard macro
‘C-x r i x’
Insert the number in register x into the buffer
`C-x r + x’
Increment the number by one
`<end> <newline>
Do something else
`C-x )’
End keyboard macro definition

Now run ‘C-u 50 C-x e’ to run the macro 50 times.

See IncrementNumber, ReplaceRegexp, ReplaceCount or RenumberList for alternative that don’t involve registers. Continue reading Numbers in Emacs

Deploying a BlackBerry Application OTA in IIS

You can get an application to your BlackBerry in four different ways.

  1. (OTA -Over The Air) Host the application files on a web server and browse to them from the phone
  2. put the application files onto a SD card and load it on the device
  3. load the application onto the phone using the BlackBerry Desktop Manager
  4. push the application to the phone using the BES

There are three different types of files that you will use to install the application on your phone.

Manifest files.

You will need one or the other depending on the deployment metheod you are going with. These files hold the information on how to install the application on your phone what files are going to be needed to do that. Continue reading Deploying a BlackBerry Application OTA in IIS

Hyper-V, COM ports, and the StarTech NETRS2321E

As you may already know, Hyper-V does not allow you to connect physical COM ports to child virtual machines. This poses a problem for many people who want to virtualize servers with legacy devices connected via RS-232. There are different hardware and/or software solutions available, but ultimately they all require that you make your COM ports available over a network connection. Your main options are to share/redirect a COM port from a physical machine to a virtual machine, or to use a hardware adapter to connect the RS-232 device directly to the network.

For our legacy application, I chose to go with a hardware adapter. We purchased the StarTech 1 Port RS-232/422/485 Serial over IP adapter. I was very eager to get this adapter because it would allow us to virtualize an old server that was still relying on a directly connected serial device. I chose to go with an adapter so we could have flexibility and not need to rely on a single server to do some sort of sharing or redirecting of a COM port.

After we received the adapter I was a little disappointed. Continue reading Hyper-V, COM ports, and the StarTech NETRS2321E

Defining Managed Path When Creating New SharePoint Site

I needed to create a new sub-site underneath an existing SharePoint site, which is located at http://server/site1. The sub-site’s URL should be http://server/site1/site2. The simplest way to create a new site is to use an option normally exposed through the UI, such as the Create page under the Site Actions menu. However, in this case, I’m working with an existing site that’s customized so that the Site Actions menu isn’t available.

The first idea that occurred to me was to use Central Adminitration to add a new site collection. To do so, I selected Create Site Collection under the Application Management menu. In order to create the new site collection under the desired path, I decided to define site1 as a managed path. This worked well enough and allowed me to create a new site collection under http://server/site1/site2. However, to my horror I discovered that the site located at http://server/site1 had disappeared, replaced by the dreaded HTTP 404 screen! Continue reading Defining Managed Path When Creating New SharePoint Site

Removing Character from String in C Sharp

I need to process a string in order to remove certain unwanted characters. One such character has an ASCII value of Hex 01. I happen to be using a StringBuilder, which offers a Replace method similar to String.Replace.

I can’t simply do a Replace(Convert.ToString(0x1), "") which just removes all instances of the string “1”. To get the correct character, I can use Convert.ToChar(0x1) or simply ‘\x01’. However, I can’t remove a character with the Replace(char, char) overload because there is no such thing as an “empty” character literal that’s analogous to an empty string. Each value of char type is mapped to a code point and is therefore exactly one character long.

To remove the character, simply take an additional step and convert it to a string: Replace('\x01'.ToString(), "").

Modifying the “Action If Name Is in Use Field” for a Merge Replication Article

The “Action if name is in use” field controls what happens to an article’s contents, at the subscriber, when a snapshot is reinitialized. The default setting (with merge replication) is to drop the existing object and create a new one. The problem is that all permissions on that object are also dropped. Fortunately, we can choose another option that will truncate(delete) the data in the object without the removing the permissions. There are a few caveats to this solution. It doesn’t work with articles that are stored procedures (keep the object unchanged is the only other supported option), you have to use transact-SQL to preform the change, and it’s a one way trip (meaning you can’t change back to the previous setting) without recreating the publication.

An alternative solution is to leave the default setting and create a script to reapply the permissions on the object after it has been dropped. In our case, we use this alternative for articles that are stored procedures. Continue reading Modifying the “Action If Name Is in Use Field” for a Merge Replication Article

Amazingly Simple (and Fast) XML Formatting Trick

While pre-populating a SharePoint list instance with data, I find myself having to insert a large amount of unformatted data into an XML file in Visual Studio 2008. When formatted, the XML data consist of roughly 12000 lines. After I pasted the data into the file, Visual Studio took several agonizing minutes to format them into nicely human-readable form. Moreover, during this time, my computer’s CPU usage was also pegged at or near the maximum, rendering it practically unusable.

However, I found that if the XML data are already mostly formatted, then Visual Studio leaves them alone. So I tried to load the XML data into a text editor to see whether it could do the job faster. Unfortunately, my text editor isn’t capable of automatically formatting XML, and using regular expressions is too manual of a process.

Finally, I noticed that Internet Explorer loads and formats an XML file almost instantaneously. This suggests the simple trick of opening the XML file in IE, pasting the formatted XML content into a text editor to remove the extraneous hyphens, then pasting the results into Visual Studio. Doing so reduces the amount of time for the process from several minutes to just a few seconds.

Union Vs. Union All

The Union and Union All operators combine the results of two SQL queries. Union All merges every row, while Union throws out duplicate rows. It turns out that Union actually performs the equivalent of distinct sort behind the scene.

As a simple test, I ran 3 separate queries: (1) using Union All, (2) using Union, and (3) using Union All and distinct sort to generate the same results as query 2. For query 3, the order by clause is actually not necessary, as select distinct also automatically sorts in ascending order. Below is the SQL Server execution plan for each query.

Queries 2 and 3 are executed identically. As expected, both are much more expensive than query 1. So stick with Union All whenever possible.

Blogged