Git, GitHub and an open source .NET project – Part 1

I have used the open source enterprise search platform Solr for a number of years now and on a recent project have been using the open source SolrNet .NET client library. The SolrNet library lacked a feature I required when used with the bundled Service Locator implementation. A number of people had been asking for the same feature so I decided to jump in and implement it.

This is part 1 of my journey into learning Git, using GitHub and contributing to an open source project.

What is Git ?

imageGit is a free and open source, distributed version control system initially designed and developed by Linus Torvalds of Linux fame. Even though there are fundamental differences from a revision control system such as Subversion, there are numerous books and documentation available to help you.

The major difference with Subversion is that every Git working directory is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server. This takes some time to get used to but once the light comes on it is pretty cool.

Install PuTTY

If you want to use GitHub you’ll need an SSH key. Even though Git comes with an SSH client, I highly recommended that you install PuTTY on Windows. This is a free Telnet/SSH client that has a number of utilities that make dealing with SSH keys and passphrases more pleasant.

I downloaded and installed the PuTTY 0.60 Windows Installer.image4

Make sure that you associate .PPK (PuTTY Private Key) files with Pageant (SSH authentication agent) and PuTTYgen (SSH key generation utility).

Install Git

To install Git on Windows you need to download Git for Windows and install it. I downloaded and installed the full installer for official Git 1.7.3.1.

image11

I was only interested in using the Git Bash shell via the Windows Explorer context menu and so selected the Git Bash Here option. Since I was installing TortoiseGit for GUI based Git interactions I did not want my context menu cluttered with the Git GUI Here option.

image13

I selected the Use Git Bash only option here since I wanted my Git environment to work smoothly and remain contained. I was also only ever going to use command line Git from the Git Bash shell.

image14

Since I have PuTTY and TortoiseSVN already installed the Git installer has picked up the various Plink.exe executables. Plink is a command line interface to the PuTTY libraries that tools such as Git or TortoiseSVN/TortoiseGit use to provide SSH capabilities.

I selected the Use (Tortoise)Plink option and made sure that the file path pointed to the Plink executable in my PuTTY install folder. Now Git will use PuTTY to manage its SSH requirements.

image15

Git can translate line endings between Windows and Unix style line endings. I selected the Checkout as-is, commit as-is option as this would not perform any conversions. I figured that if I was working on a Windows project it should have Windows line endings.

image

Confirm that Git for Windows has been successfully installed by firing up the Git Bash shell. I fired mine up in my projects folder.

Install TortoiseGit

TortoiseGit provides an extension to Windows Explorer that works with a Git repository. Some people feel more comfortable using graphical tools. I prefer to have both since I can use whichever one helps me get a specific task done faster or easier.

I downloaded and installed the Tortoise Git 1.5.8.0 Windows installer.

image20

Like Git, TortoiseGit also can be made to use the PuTTY Plink executable.

image21

I selected all the features and completed the installation. That was easy !

Git enabled !

I now had Git installed and was equipped with both the command line Git Bash shell and GUI based TortoiseGit options.

Next is setting up GitHub …

Git, GitHub and an open source .NET project – Introduction

I have used the open source enterprise search platform Solr for a number of years now and on a recent project have been using the open source SolrNet .NET client library. The SolrNet library lacked a feature I required when used with the bundled Service Locator implementation. A number of people had been asking for the same feature so I decided to jump in and implement it.

This is my journey into learning Git, using GitHub and contributing to an open source project. I highly recommend the experience – you learn a great deal from reading and contributing to code that is so highly visible.

I have split my journey into the following 5 parts:

Updating multiple iPhones with a single iOS 4.2 download

After a number of years of roughly 200MB upgrades for my iPhone 3G and then iPhone 4 I was shocked when the latest iOS 4.2 update weighed in at just over 600MB. Added to the gut punch was the fact that I had to upgrade 2 iPhones now – yes, my wife has joined the cult.

What is iTunes actually downloading ?

iTunes makes it really easy to upgrade your iPhone but I wanted to be able to download the update once and use it to upgrade both phones.

01 - New version available

iTunes hides all the details from you – so how was I going to get at the iOS 4.2 firmware update file (.ipsw) ?

Use the proxy luke !

An HTTP proxy is a tool every developer should know how to use. I use Charles on Mac OS X. Fire up Charles to force all the HTTP traffic through a proxy and then click on the Update button in iTunes to start the download.

02 - iTunes

The other major factor in downloading this update only once is clearly visible in the status column. My ADSL router was on its way out and I just couldn’t get decent download speeds at the time. Thank goodness those days of darkness are behind me now – I’m very happy with my new LinkSys Dual-Band Wireless-N ADSL2+ Modem Gigabit Router. But I digress …

03 - Charles HTTP Proxy

The iOS 4.2 firmware update file (.ipsw) that iTunes was downloading is clearly visible in Charles:

We now have the complete URL for the file and can download it outside of iTunes. Stop the iTunes download as its purpose had now been served.

Download

I use curl when downloading large files and since it is bundled in Mac OS X there is no extra download or installation required.

04 - Curl download file

The "-C –" switch combination tells curl to automatically calculate where to resume the transfer. This ensures that if the connection drops or is reset you can resume the download where you left off.

The "-O" switch tells curl to save the download to a local file with the same name as the remote file.

Install

Fire up iTunes and hold down the option key while clicking on the Update button.

 01 - New version available

05 - Option update

The file selection dialog will open. Select the iOS 4.2 firmware update file (.ipsw) you have just downloaded.

06 - Select file

All the next steps will be familiar since they are all part of the standard steps for iOS updates.

07 - Update

Confirm that your iPhone has been updated.

08 - Updated

Now repeat the Install steps for each of your iPhones that you want to update.

The case of the annoying Tomcat 6 Monitor

Ever since installing Tomcat 6 on my Windows 7 machine at home I’ve had an annoying message box pop up every time I restart my machine: Access is denied. Unable to open the service ‘Tomcat6′. Since it takes less time and effort to click on OK than to sort out the problem that is exactly what I have been doing … but enough is enough.

Access is denied

Tomcat IS running – so what is causing this error?

I confirmed that the Tomcat 6 service was running even though I got this message box – so what was causing it ? It turns out that Tomcat 6 Monitor Application was causing this error. Tomcat 6 Monitor Application is a GUI for monitoring and configuring the Tomcat 6 Service. It needs to be executed by the Administrator user and the UAC is getting in the way at start up time.

Are you feeling brave ?

The only solution I have found to work so far is to remove the Tomcat 6 Monitor Application from the Windows startup. And the only way to do this is to remove a registry entry …

Fire up regedit (Start Menu > Search programs and files > regedit.exe) and remove the following key:

  • Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

567

Now you should not see this annoying message box every time Windows starts up. But it also means that Tomcat 6 Monitor will not be started on Windows startup.

Running Tomcat 6 Monitor manually

You may still want to run the Tomcat 6 Monitor since it does provide nice shortcuts for configuring and monitoring the state of your Tomcat 6 service. You can execute the Tomcat 6 Monitor via Run as administrator or you can configure the shortcut in the Start Menu to always execute the application as administrator.

Find the shortcut to the Tomcat 6 Monitor in the Start Menu (Start Menu > Apache Tomcat 6.0 > Monitor Tomcat) and right-click on it. Select Properties.

2

Click on the Shortcut tab in the Monitor Tomcat Properties window. Click on the Advanced button and check the Run as administrator checkbox.

3

Click Continue on the Dialog that pops up and now you should be able to start the Tomcat 6 Monitor by simply clicking the shortcut in the Start Menu. Windows will still flash the UAC though since you are running this application as administrator.

4

Update: 05 December 2010

The comment by Scot shows once again that there is always more than one way to skin a cat. Thanks Scot.

If you would still like to have the Apache Tomcat Monitor fired up on startup then replace the steps in this post with the following:

  • Leave the registry key ApacheTomcatMonitor at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run untouched. This will ensure that Windows starts up the Tomcat Monitor.
  • Right click on the tomcat6w.exe executable found at %CATALINA_HOME%\bin. Click on the Properties menu item and then select the Compatibility tab. Check the Run this program as an administrator checkbox under the Privilege Level section. Click the OK button.

Run as administrator

When Windows starts up now you will no longer get the Access is denied. Unable to open the service ‘Tomcat6′ message. The UAC will pop up and ask you to confirm the starting of the Apache Tomcat Monitor.

Tech-Ed Africa 2010 sessions I’m attending

I’ll be attending the following Tech-Ed Africa 2010 sessions in Durban next week:

Monday, 18 October 2010

  • Understanding the Microsoft Application Server: AppFabric, WF, WCF, and More (APS201)
  • What’s New in Windows Communication Foundation in .NET Framework 4 (APS306)
  • Using the MVVM Design Pattern with the Microsoft Visual Studio 2010 XAML Designer (DTL323)
  • Code Contracts and Pex: Power Charge Your Assertions and Unit Tests (DTL207)
  • Why functional programming matters – A look at F#, C#, and more (DTL304)
  • Building RESTful Applications with the Open Data Protocol (DTL310)
  • My Favourite Windows Presentation Foundation 4 Features (WCL206)
  • 10 Ways to Protect Users of Your Web Applications (WUX303)

Tuesday, 19 October 2010

  • LINQ, take two – realizing the LINQ to Everything dream (DTL414)
  • WCF: The Unified Services Programming Model for SOAP, REST, Data, and RIA Communication (WTB327)
  • Behaviour-Driven Development: Taking Unit Testing to the next level (DPR303)
  • RIA & Rich Client Applications: There is life beyond HTML (WUX311)
  • The Windows API Code Pack: Add Windows 7 Features to Your Application (DTL316)
  • Rx: your prescription to cure asynchronous programming blues (WTB324)
  • Designing and Developing a Windows Phone 7 Silverlight Application End-to-End – (part 1 of 2) (WPH202)
  • Designing and Developing a Windows Phone 7 Silverlight Application End-to-End – (part 2 of 2) (WPH303)
  • Windows Server AppFabric Caching: What It Is and When You Should Use It (APS309)

Wednesday, 20 October 2010

  • Best Practices: Building a Real-World Microsoft Silverlight Line-of-Business Application (WUX407)
  • Task Parallel Library: Design Principles and Best Practices (DTL424)
  • WCF Made Easy with Microsoft .NET Framework 4 and Windows Server AppFabric (APS310)

Happiness and Sadness

I’m really looking forward to the AppFabric and Windows Phone 7 sessions and am excited about both sets of technologies. I am bitterly disappointed though that the following two Tech-Ed North America 2010 sessions are not being presented given that Udi Dahan is in South Africa this week delivering his Advanced Distributed System Design with SOA & DDD (5 days) course:

  • Command Query Responsibility Segregation (ARC302)
  • High Availability: A Contrarian View (ARC308)

Upgrading a MacBook (13” Aluminum, Late 2008) – Part 1 (RAM)

I love my MacBook. It was the first 13” aluminum unibody notebook from Apple and although it was launched as part of the MacBook range it has since migrated to the MacBook Pro range.

I run my MacBook through a 24” Samsung SyncMaster T240 and use the wired keyboard and wired mouse. This gives me a nice desktop setup and when I need to be mobile the 13” form factor is perfect.

Lately I have begun to feel the limits of the stock 2GB RAM and the 160GB HDD. So it is time for an upgrade. I will be embarking on a 2 part project to upgrade both the RAM and the HDD of my MacBook.

RAM Specifications

Clicking on Apple > About This Mac showed that 2GB of RAM was installed and clicking on More Info … > Hardware > Memory showed that each of the 2 available memory slots had 1GB DIMMs.

About This MacMemory Slot information

According to the memory specifications at Apple Support my MacBook can take a max of 4GB RAM with the following specifications:

  • Double Data Rate Small Outline Dual Inline Memory Module (DDR SO-DIMM) format
  • 30mm
  • 1 Gigabyte (GB) or 2 Gigabyte (GB)
  • 204-pin
  • PC3-8500 DDR3 1066 MHz Type RAM

After looking at the price of Apple RAM I decided to rather purchase 2 x 2GB modules from Kingston (KTA-MB1066/2G). These are reasonably priced and are compatible with my MacBook.

Upgrading the RAM

Apple provide detailed instructions via their support site on how to upgrade your RAM. I shut down my MacBook and disconnected it from the power adapter. I had my new RAM, some precision screwdrivers and was ready to begin.

DSC_0122

Opening up the MacBook

Turn the MacBook over and push down on the door latch to release the access door. Remove the access door and the battery. The battery has a handy tab on it to make lifting it out of the bay easier.

Remove access door and battery

Next remove the eight screws that secure the bottom case of the MacBook. The screws at the top of the picture have slightly larger heads than those at the bottom and are easier to get out. I used a 1.4mm flat screwdriver on the top screws. I tried a #00 philips precision screwdriver on the bottom screws but my precision screwdriver was obviously not good enough. I finally resorted to a 1.2mm flat screwdriver to get the bottom screws out. You may notice that I only have 7 out of the 8 screws out. I couldn’t manage to get the final screw out and eventually gave up after stripping the head.

Removing the screws

Thank goodness the screw I couldn’t get out was a corner screw. I carefully pivoted the bottom case open around the remaining screw. Finally ! I was in.

Making a plan ...

Removing the old RAM

Touch a metal surface inside the MacBook to discharge any static electricity from your body. Then push the ejection levers on the sides of the memory modules outwards to release the first memory module from the memory slot. The memory should pop up at an angle. The first image in the sequence below shows the first memory module popped up at an angle with the second memory module still clearly visible below it. Remove the memory module from the slot remembering to hold the module by its notches and not the gold connectors.

Repeat the steps to release the second memory module.

Removing the old RAM

Installing the new RAM

Touch a metal surface inside the MacBook to discharge any static electricity from your body.  Align the notch on the gold edge of the module with the notch in the lower memory slot. Tilt the memory module and push it into the bottom memory slot. Use two fingers and push down the memory module with firm even pressure until it is level. The first two images in the sequence below show the first memory module tilted and then pushed level under the second (top) memory module.

Repeat with the second memory module. The last two images in the sequence below show the second memory module tilted and then pushed level above the first (bottom) memory module.

Installing the new RAM

Closing up the MacBook

Reverse all the steps from Opening up the Macbook. Replace the bottom case making sure it is sitting flush. Then replace and tighten the screws. Place the battery back into the bay and then replace the access door. Press it down gently until the latch moves to the closed position.

Confirmation

Switch on the MacBook and make sure it boots. Clicking on Apple > About This Mac now shows that 4GB of RAM is installed and clicking on More Info … > Hardware > Memory shows that each of the 2 available memory slots has correctly installed 2GB DIMMs.

About This Mac Memory Slot information

Installing Tomcat 6 on Windows 7

Tomcat is an open source Java Servlet container developed by the Apache Software Foundation. It is bundled with a very capable Java based Web (HTTP) Server.

Which Java to install ?

Tomcat requires Java to be installed – it is afterall a Java Servlet container. Since Tomcat 5.5 the dependency on the JDK (Java Development Kit) for compilation of JSPs (Java Server Pages) has been removed. The Eclipse JDT Java compiler has been bundled with Tomcat to provide this capability. This means that we just need to install the JRE (Java Runtime Environment).

So its a simple decision then – or is it ?

Java Virtual Machines

From the Oracle Java SE Documentation:

The JDKTM provides one or more implementations of the JavaTM virtual machine (VM):

  • On platforms typically used for client applications, the JDK comes with a VM implementation called the Java HotSpotTM Client VM (client VM). The client VM is tuned for reducing start-up time and memory footprint. It can be invoked by using the -client command-line option when launching an application.

  • On all platforms, the JDK comes with an implementation of the Java virtual machine called the Java HotSpot Server VM (server VM). The server VM is designed for maximum program execution speed. It can be invoked by using the -server command-line option when launching an application.

The above documentation and information from other resources on the differences between the Client VM and Server VM suggest that we should be using the Server VM when running Tomcat on a server.

Unfortunately the Server VM is only bundled with the JDK. So we are back to our dependency on the JDK. If you are installing Tomcat on a server and require the optimisations around speed and for long lived processes install the JDK and use the Server VM.

Which Tomcat Binary Distribution ?

Just when you thought it was getting simpler … The Tomcat 6 Downloads page has 6 options for binary distributions.

Pick the 32-bit/64-bit Windows Service Installer option. This distribution is geared towards users planning to launch Tomcat through Windows services and also provides the compiled APR/native library.

Installing

Download and install the Java 6 SE JDK. Remember to install the 64-bit version if you are running on a 64-bit OS. The Tomcat installer will look for a 64-bit Java VM on a 64-bit OS.

Download and install the Tomcat 6.0.29 32-bit/64-bit Windows Service Installer.

Ensure that you select the Service and Native options under the Tomcat component. The Manager application component provides a web based management application.

 Tomcat 3

You will be asked to choose an HTTP connector port for Tomcat and if you chose to install the Manager component you will also be required to configure authentication details for the Manager.

Tomcat 5

When asked to provide the path to the java virtual machine to use, specify the JRE folder of the installed JDK.

Tomcat 6

When the install is complete, the Tomcat service will be automatically started if you chose Run Apache Tomcat in the final screen on the install wizard.

Tomcat 9

Confirm the install

Once the service has started, the Tomcat icon should appear in the taskbar. Right click the icon and select Configure from the menu.

Tomcat 10 Tomcat 11

 

Select the Java tab on the Apache Tomcat 6 Properties window. Confirm that the Server VM (jre6\bin\server\jvm.dll) is being used by Tomcat.

Tomcat 12

Open the Windows Services manager and confirm that the Tomcat service has been correctly installed.

Tomcat 14

Finally confirm that you can communicate with Tomcat on the configured HTTP port. Open http://localhost:8080 in your browser.

Tomcat 15