New domain and blog

New domain and blog
Please head over to my new domain to view my blog and current projects

Thursday, 28 June 2012

Adding source code to Blogger

I have been trying for quite some time to add source code to my blog. Just copying and pasting the code works fine, but there is no proper formatting or colours used in normal source code editors. After browsing the internet and reading many examples, I finally came across this website that helped me get it done.

I have used the SyntaxHighlighter script and from what I have seen, this seems to be the most used method. It supports a number of different programming languages and once set up, very easy to implement.

Please back up your blog before trying this as you need to edit the html template. From your Dashboard, navigate to Template, and then select Edit HTML. A warming will pop up so select Proceed. The HTML template will now be displayed.

Navigate down in the template to find </head>
Copy the code below and paste it above </head>

Preview your template to ensure that it still looks ok. If all is fine, then save the template and close the editor.

The next step is to make the script work. You do this by using the <pre> and </pre> HTML tag. In between these tags is where you add your code. You also need to specify which script to use depending on what language your source code is in. Here is the example I used to display C# source code.

private void UpdateCounter()
if (iCounter.Value < 50000)
{ iCounter.Value++;
} else iCounter.Value = 1; } }

You need to add the tags and code in the HTML editor. Once the source code has been added, then you can go back the the text editor to complete the post.

That's about it. Once the template has been edited and your set up is correct, adding source code it pretty easy.


Wednesday, 20 June 2012

Cycling: Making friends with Kloof Nek

A few years ago when I was training for IRONMAN South Africa I used to do this ride and some at least three times a week before work. Back then I was fit and was training with a good group of guys.

Now after a few years with not much cycling, I decided to give Kloof Nek a try. For those that don't know, Kloof Nek is the road between Cape Town and Camps Bay. It's a relatively short climb, but gets rather steep in places and if you not ready for it, it can be quite tough. According to Google Earth, it is 4km long with a maximum elevation of 13% and an elevation gain of 235m. 
The view from the top is magnificent. To make it a bit of a longer climb, you can either turn right at the top and cycle to the top of Signal Hill or turn left and cycle along the face of Table Mountain past the cable way.

The ride down into Camps Bay and back along the coast makes the tough climb well worth it. 

Give this route a go and if you feeling energetic, cycle Kloof Nek, carry on and go over Suikerbossie into Hout Bay and then climb to the top of Chapmans Peak. The views from along the road and the top of all the climbs are amazing. When I'm fitter I will be doing that route and will get it up here. 

To download the Google Earth file, use this link.


Monday, 18 June 2012

LabVIEW: Event Structure vs While Loop

When I started working with Event Structures in LabVIEW, I wondered what the difference was in terms of CPU usage. In a small program, managing efficiency might not be an issue but in a large testing environment where many processes need to be performed, the need for managing efficiency becomes quite important.

To test the difference in CPU usage between using the standard While Loop, which can get messy very quickly and the Event Structure, I wrote a simple program. The While Loop and Event Structure options are placed in different cases which is selected before the program is run. Both options monitor two buttons, display a message when either button is pressed and has a counter which shows how many times the loop is run.

The Event Structure monitors two buttons and displays a message for each. 

The While Loop also monitors two buttons but as it can be seen from the front panel above, it is quite a bit more messy than the Event Structure. If any more button or inputs need to be monitored, this method can quite easily get out of hand.

Here is the CPU monitor comparison of the two options being run. On the left is the Event Structure only using 5% and on the right is the While Loop which is using 30%. There are ways to slow the While Loop down like adding a loop delay but I wanted to show the extremes.

I hope this helps and can provide some display on the different ways to do a similar process.

To download the example VI, use this link.