Monday, December 29, 2008

MS Visual Studio.Net 2010 Experience 2

I feel like a kid with a new toy :-)
I finally got the VB.Net and C# console working by making over 2 GB avialable to the VM.
I also got the VS.Net 2010 Training Kit that have labs and samples for all the key technologies: C# 4.0, VB.Net 10.0, MEF etc.

Anyone that want a copy can contact me: 076 824 3560. I'm base in Fishhoek, Cape Town. If you can bring 2 empty DVDs (dude its over 7 GB!) or a portable hard drive.

Weekly Source Code: FTP Connection To A FTP Server 2008/12/29

Chris Pels published a video on how to create an FTP connection to an FTP server using the FtpWebRequest class in .Net.

View the video here

MS Visual Studio.Net 2010 CPT Experience 1

After shutting down all the Services I still find the VM being extreamly show! Looking around under the settings I find that the VM only allocate 256MB RAM (that memory get take from the host machine) !! No that doesn't work, Windows doesn't run within 256MB of RAM (unless your running Windows 98 or something really old) I increased the memory to 1.8GB (leaving +- 2GB from my host) and wow the speed is now normal! :-)

Update:

Ok now it crash everytime I want to create a new VB.Net or C# console application. The only one that work fine is C++ (but I don't program in C++ that much - mainly C# and alittle of VB.Net)

Sunday, December 28, 2008

Visual Studio.Net 2010 CPT Experience

I finally got to download MS Visual Studio.Net 2010 CPT - that is pre-beta (like 2 years) release of the next version of MS Visual Studio.Net scheduled for release sometime in 2010 (exact date unknown).

Yes bandwidth is expensive in SA but using Telkom ADSL, 4Mbps line, Openweb 10GB Local with Openbrowser and Opera web browser as my download manager I got to download all 7 GB on a Sunday afternoon/late evening!

The installation took awhile to un-compress all 11 files (700 MB each) and then to setup the VirtualPC (using Virtual PC 2007 SP1)

The installation went well but find that MS Visual Studio.Net IDE is very slow on my machine (Intel Core 2 Duo, 3GB RAM) - I guess the only way is to stop some of the services (like MS SQL Server etc) that get started by the VM.

Also note that you need to change the date on the VM else the CPT will expire on 1 Jan 2009.

For more information visit:

http://tinyurl.com/GetCTP
http://tinyurl.com/VSFeedback
http://tinyurl.com/CTPActivation

Something for me to play with while Im in Uganda (ok just alittle - I still got work!)

Have fun! :-)

Wednesday, December 24, 2008

GizmoCall.com

Call directly from your web browser without installing any software... can call to a regular phone number (using cheap VOIP rates), to another Gizmo user or to a SIP number.

Use the embed Gimzocall plugin below.

Sunday, December 21, 2008

Telkom doBroadband 384kbps vs Telkom 4Mbps

About a week ago we upgraded from Telkom do Broadband with a speed of 384kbps, cap of 1GB (yes ladies and gents bandwidth in SA get capped unless your willing to spend R1000-R2000 on uncapped) to 4Mbps with a cap of 3GB. The speed increase is incredible!

I reguraly watch Channel 9 to download a video normally took around 30+ minutes, it download in about 5 minutes.

Tomorrow I'm preparting for my Uganda trip, more about that in a future blog (yes I know, I told you that before but good things come to those who wait hey...)

Wednesday, December 17, 2008

Scott Hanselman Chat & Wikipedia Goes Mobile

I came back from Scott Hanselman's chat hosted by SA Developer .Net Group in South Africa, Cape Town.

The chat was held at Microsoft offices, Scott talked about the ASP.NET MVC framework
giving a very good demo on a new website: NerdDinner that you will notice still use the default ASP.NET MVC template. After lunch (good food like always!) there was a Q&A session and a discussion.

Next in the news: Wikipedia goes mobile! To try this later on my Samsung Omnia i900, Windows Mobile 6.1 Pro.

Sunday, December 14, 2008

Weekly Source Code: Using MySQL Database with Visual C# 2008 Express Edition 15/12/2008

David Bolton that manage the C/C++/C# About.com website post a tutorial on how to use mySQL from MS Visual C# 2008 Express Edition.... The Express Edition is a free version of the Visual C# IDE (not the whole MS Visual Studio.Net suite)

See the tutorial here

Wednesday, December 10, 2008

VOIPBuster vs Skype - Phone Calls

Looking into VOIPBuster vs Skype for cheap VOIP calls expecially when I goto Uganda (more about that in a later post) I find that:

If you buy VOIPBuster credit you get 120 days free period where you can make free calls to countries unfortunatly for us Uganda or South Africa isn't :-( So nothing is going to be free.

Comparing the prices:

VOIP Buster:

0.060 EUR = R0.797024 (Landline)
0.170 EUR = R2.25728 (Mobile)

Skype:

Landline: R1.612
Mobile: R1.612

So VOIPBuster is cheaper for landline but Skype is cheaper for mobile.

See VOIPBuster Rates
See Skype Rates
To Convert EUR To ZAR

Tuesday, December 9, 2008

Black: Playstation 2 Game!

Yesterday I received my Black Playstation 2 game that I bought online from Take2
Black is a first person shooter and OBOY the game got good graphics and action packed!

I will write a review soon and also provide some videos.

Meanwhile back to work and looking forward to playing again....

O btw I ordered Hitman PS2 game aswell - its also a first person shooter!

My 27th Birthday

Yesterday, 8 December 2008 was my 27th birthday... beside that I was at work having a normal day I also ate alot of cake!

Last night my beautiful wife (Jolene De Villiers) took me out for dinner and a movie... we watched the new 007 movie: Quantum of Solace Alot of action but the ending was disappointing.

Today my Black Playstation 2 game arrived so having some fun tonight :-)

Friday, December 5, 2008

Scott Hanselman In South Africa!

Yes our favoarite super hero Scott Hanselman is coming to South Africa.
You need to RSVP

I'm going to the 17 December 2008 event.

See you there :-)

Update:

For those that aren't geeks, Scott Hanselman is a big .Net developer working for Microsoft in the USA... His one of the key players in the Microsoft .Net techonology. You can click on his name to read his bio, blog etc.

Monday, December 1, 2008

Weekly Source Code: Get Cents

Part of making changes to the Java currency to words code I pass in a double value parameter to the convert method (not a long) and add support for cents e.g. : $5.20 to equal "Five USD and Twenty cents".

An interesting problem I had was how do I get the cents part? e.g. $5.20 to get 20.

Firstly I had to format the number to round off to the last 2 digits so something like $5.2555 will not work. To do this in Java you can use the DecimalFormat class.

To get the cents I wrote:

double cents = new Double(new Double(number).doubleValue() - new Double(number).intValue()).doubleValue();
int iCents = (int) Math.round(cents * 100d);

The first line of code take the double value and subtract the integer value e.g. 5.20 - 5.0 = 0.20
The second line format the remaining value 0.20 to be an integer e.g. 20

Like always there are many ways in programming how this could be done and yes the above code works 100% since I wrote a very detail Unit test.

Tuesday, November 25, 2008

Windows Mobile 6.1 SMTP Error

Ooops Microsoft did it again!! everytime when I try to send email from my Samsung Omnia i900 with any of my email accounts and the email got attachments it fails with the error "The message(s) could not be sent. Check that you have network coverage and that your account information is correct. Then try sending again" off course you then think its your service provider (MTN in my case) but if your on WiFi its actually using your ADSL so its not your provider. This is actual a bug in the OS that got a fixed here. Now I must apply this fix over lunch break and see if it actually does FIX the problem for real!

O well another day of Microsoft sucks!

Update:

I applied the patch and it seam to have fixed the problem... Happy Days! :-)
just until I find the next bug.

Update 2:

You can get the official fix.

LINQ Reference Documentation

See the LINQ Reference Documentation, very handy!

Its been awhile since I blogged, been crazy at work.

Tuesday, November 11, 2008

Video Chat In Gmail

Oboy! This is cool, see here!

Visual Studio 2010 and the .NET Framework 4.0 Week!

It is worth the watch if your into the next release of MS Visual Studio.Net 2010.

See it on Channel 9.

Sunday, November 9, 2008

Weekly Source Code: No SPAM Email Link In .Net

Web crawlers gather email addresses from your website that they then use to SPAM you. Web crawlers do this by reading the raw HTML to see if there are any email tags like a "mailto:".

I wrote a sample program that I published to MSDN Code Gallery where an email address get shown to a website visitor as an image in the HTML's image tag, you can see Facebook as an example.

The image tag then has an onclick event, when visitors click on the image an AJAX call fetches the email address (from a resource like a SOAP/RESTful web service) and then open the default email client.

With this method the email address isn't in the HTML so the web crawler can't capture it.

This show the power that AJAX bring.

Thursday, November 6, 2008

Google Docs Mobile

I use Google Docs alot to share my personal documents, share work documents or just to manage my daily TODO list (as complicated and endless as it is! ;-)

You can access Google Docs via your mobile Wow! I was happy when I saw this since I don't like always having the laptop open if I just want to check something BUT (there is always alittle BUT) this is read only :-( Well it makes sense since mobile AJAX isn't support on all phones but it would've been a nice functionality expecially when I finally gonna get my Samsung Omnia i900.

Anyway, enjoy and have a good weekend! :)

Tuesday, November 4, 2008

Internet Over Bluetooth

Testing an application last night on my wife's ex Nokia 2760 phone using my bluetooth dongle (a Bluesoleil Dongle) I found that it create a personal area network where I can access the Internet from the phone over bluetooth without GPRS. WOW this is cool!

Btw, this week there isn't a weekly source code since I've been on leave on Monday and its been a crazy week back at work.

Friday, October 31, 2008

New Gmail Mobile v2.0

The new Gmail mobile client is avialable, you can download it by visiting m.google.com/mail on your phone.

Monday, October 27, 2008

New .Net Logo

Following NotAtPDC
I heard there's a new .Net logo.

Weekly Source Code: ASP.Net AJAX UpdatePanel And UpdateProgress

On the VCC website that I wrote, there is a Sermons web page You will notice that when you select a month it displays a progress animation image at the bottom of the drop down box and within seconds the grid refreshs with the new sermons without reloading the entire web page... This is a good example of an AJAX call that happens when you select the drop down box but did you know that I didn't write any Javascript code to get it working?

To accomplish this I used ASP.Net AJAX in MS Visual Studio.Net 2008 with no Javascript or C# coding. ASP.Net AJAX is part of ASP.Net 3.5 but as a seprate download for ASP.Net 2.0 (MS Visual Studio.Net 2005).

The magic is done by the control with the drop down box and the grid getting wrapped inside the tag of ... the drop down box is a control and the grid is a control, so nothing special about the drop down box or the grid.

Also within the is the control that executes when the is busy updating the page, this gives feedback to the user that something is happening.

You must also add the control since all ASP.Net AJAX pages requires this control.

Thats it! Nothing else required, no JavaScript code... no coding at all!

When the drop down box fire an event when the user chooses a new item the update panel handles the event a-synchronously , fetching the new updated grid and displaying it all the while the update progress controls indicates to the user the busy image.

ASP.Net AJAX makes this easy for you, as a developer since it takes care of all the back-end stuff for you so it generates and handles the JavaScript code etc without you even knowing about it.

Friday, October 24, 2008

I'm On Twitter

Everybody thesedays are on Twitter so way not me?! Go visit http://twitter.com/lenniedv

Thursday, October 23, 2008

Next.... Windows 7

The next MS Windows version will be called Windows 7

I believe, we all hope that this time MS will do a proper job than what they did with Windows Vista or allow us to always downgrade back to Windows XP :-)

Tuesday, October 21, 2008

Weekly Source Code: My AJAX Library

Back when AJAX first came out there wasn't any libraries - no ASP.Net AJAX etc. I was mainly doing classic ASP with VBScript development (yes I know - that sucks!)

Most AJAX books and samples demonstrated using the XMLHttpRequest object are for making AJAX calls but the main problem was compatibility between the different web browsers - IE vs Firefox vs Safari vs Opera.

So I wrote my own AJAX library, I mainly used it for validation and later to pull customer information into a HTML form if the customer already placed an order.

To use it:

Setup 1: Include the JavaScript file into your HTML page.

Setup 2: Call AjaxValidate function, this function has 3 parameters:
  • psWebPage: The back-end server side page to call.
  • psCode: Code that identifies the request, if you send more than one request to a back-end server side pagethen this can be used to identify the request so that the page handles different request. You can leave this blank if your page handles only 1 request.
  • psValue: The request value.
Setup 3: When the result comes back it will call the setOutput JavaScript function that has 3 parameters:
  • sWebPage: The back-end server side page that was called.
  • sCode: The code sent to AjaxValidate function your JavaScript can process the request.
  • sResponseText: The response from the AJAX call. This can be HTML, plain text or even JSON.
With the AJAX frameworks of today my library don't have much of a meaning since you can do alot of advance AJAX functionality.

More about AJAX in the next Weekly Source Code.

C# From a Java Developer's Perspective

When I was moving from years of experience in Java to my first C# project with no knowledge of the framework or even the language I found this artical. It was very helpful to make the conversion from Java to the C# language especially since there's some differences that can bite you, when moving between them (like what I currently do on a daily basis).

Friday, October 17, 2008

What is Type Inference?

You might ask, "Lennie, in your previous blog about how bad variants are... what is type inference? Isn't it also a variant...?." The answer is yes and no, type inference comes from dynamic languages (remember Ruby, Python? yes those ladies!) and was added to the C# 3.0
language as part of the "var" keyword.

Basically what it does is that when you declare a variable with the "var" keyword its determined that the type of the variable from the data you assign to it, e.g.:

var firstName = "Lennie De Villiers"; // Hello, I'm a String type!
var age = 12; // yebo, I'm an int type!

but with type inference you can't change the type of the variable after its been assigned, e.g:

var firstName = 12; // Ooops, invalid!

With raw variants you can change the type of a variable all the time, like in the previous blog entry the MyNumber variable is a true variant since it is passed in as a number (probably a double) and then changed into a String type.

Microsoft added the "var" keyword since with LINQ queries the type of a variable is unknown but only know after execution.

Be careful of type inference since they're also bad and only should be used with LINQ queries when you execute them but afterwards (very important!) convert them to a proper known type else since you've the same problem where a developer looking at your code can't determine
the type of a variable - same problem with raw / true variants.

So to recap, type inference:
  • Infer the type from the value assigned to it;
  • Can't change the type after first assignment (its forever a string, int etc)
  • Bad coding practice since you still don't know the type of the variable.
True variants:
  • Bad coding practice since you still don't know the type of the variable.
  • Can change their type all the time, first a String then an int, then your PoolBoy class etc.
My golden run:
  • Type inference only when executing LINQ queries but afterwards convert to a proper type.
  • No variants, they're just bad!

Thursday, October 16, 2008

Variant Types Are Bad

I'm busy converting http://www.ozgrid.com/VBA/CurrencyToWords.htm to Java code but having problems since the original coder used variant type e.g. you don't know the type of the variables: MyNumber, DecimalPlace, Count etc looking at the variable declaration but only once you assign a value to it, it also doesn't use type inference (the var keyword in C#) meaning you can assign a string to the variable then later an integer... bad boy! So this makes conversions hard. Not just
that but what about maintenance?! If this code is used in a production environment what about the poor junior that must maintain it a year / decade from now (if VBA code is still running in 2020).

Tuesday, October 14, 2008

C++ 0x Compiler

C++ 0x is the next version of C++ with some added language features, libraries etc. The C++ standard committee is planning to have it released around the end of the decade. The "0x" is because the year of release is unknown.

The GCC 4.3+ compiler has support for some of the C++ 0x features, also some of the features was released as part of TR1 in MS Visual C++.Net 2008. I will blog about TR1 and C++ 0x features in the future.

Monday, October 13, 2008

Weekly Code: Find Duplicates in SQL

Sometimes you need to check if there's duplicated rows in a SQL table, for this you can use the query:

SELECT field, COUNT(field) AS NumOccurrences
FROM checkdup
GROUP BY field
HAVING (COUNT(field) > 1)
  • checkdup: This is the table name to check.
  • field: This is the field name to check.
This will return 2x columns, the first column is the duplicated data and second column is a count of how many times its duplicated.

Friday, October 10, 2008

RGB Color Calculator

If you require the hex (hexidecimal) value of a RGB (Red, Green, Blue) color combination then here is one you can use color calculator.

Thursday, October 9, 2008

Programming Language Wars

Normally I don’t agree or join language wars but: I programmed for 4 years in Java, VB (VB.net and VB 6), C++ and C#, PHP etc. The fact is that each language have advantages and disavandages, yes the .Net framework is more solid than the Java lib but Java is cross-platform to portable devices etc… VB is easy to code since it hide you from the details of the framework where with C# its more “C++ system style” of coding where its not so abstract like VB…. the point that i’m making is that anyone can go on how bad one language is over another etc but hey, be glad that we don’t live in the days of Assembler since that was bad! A language is a tool, use the tool that you prefer (its your own personal opnion) and have knowledge in, for example: I will not go write a complete website in a week using Ruby on Rails since I don’t know it but it doesn’t mean its a bad tool. Use the tool that suite the task at hand and what you prefer… damm if you want to write a website in Lisp then go for it!

When it come to language wars, I don't care... I will even use Fortran if I must / want too!

On the job market side you might want to consider your options since that is a total different story to use the language that your employer want etc.

Tuesday, October 7, 2008

Escaping Special Characters In C#

When you add records into a database you need to escape special characters like the single quote (') else your insert statement might fail.

After searching hard I found that C# does provide a method that does escaping by providing a string parameter and returning the escaped string, the surprise is that its not part of the String class but actually inside the SecurityElement class thats part of the System.Security namespace... find the Escape method!Now I wonder... why did Microsoft add it to that namespace? :-( grrr....

Monday, October 6, 2008

Mono 2.0 Released!

Mono 2.0 as been released! Get it here.

Saturday, October 4, 2008

Weekly Code: C# ForEach Method In C++

This week's source code is a C++ version of C#'s ForEach method available here The ForEach method isn't the foreach statement, C#'s ForEach method you pass a delegate to a method and it will execute the method for every element in the collection.

The C++ version works similar where you pass it the vector collection and a function pointer, it will then execute the function passing in the vector. The function can then perform any action on the vector, in this case sample it change the values to 1.

Function pointers are powerful in C++ but yes they've a very error-prone ugly syntax.

Friday, October 3, 2008

Cool Tool: Time Calculator

Ever need to add/substract or even devide time? Use Scott Severance's online Time Calculator

A good tool when your calculating your monthly time sheet :-)

Java Gotcha: mkdir vs mkdirs

In Java's File class there is the mkdir and mkdirs methods but note that both of them work very differently.
  • mkdir: Creates the directory named by this abstract pathname.
  • mkdirs: Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories
So if you want to create a directory like /reports/customer with mkdir method it will be unable to create the /reports directory if it doesn't already exist.

This is one of those Java Gotchas that can waste alot of debugging time.

Wednesday, October 1, 2008

Compile Objective C With MinGW

Objective C is a special dialect of C that allows you to code for the Mac OS X and the iPhone.

It's very interesting to know that MinGW contains the GCC compiler that can compile Objective C code.

Using MinGW with MSYS I got to compile and run the following sample Hello World program saved as Hello.m:

#import <stdio.h>

int main( int argc, const char *argv[] )
{
printf( "hello world\n" );
return 0;
}

All that you do is open MSYS and run the GCC compiler.

Tuesday, September 30, 2008

Java Puzzle In C++

The java.about.com website has a puzzle where you need to decode a string, so I wrote the decoder program in C++.

Monday, September 29, 2008

iPhone 3G Now In South Africa

Vodacom released the long awaiting iPhone 3G in South Africa.

For more information and deals, visit http://www.vodacom.co.za

Weekly Code: C++ Include Guards 29/09/2008

Include guards prevents you from including an header file multiple times, it's done by using compiler precessors:

#ifndef FileUtils_H
#define FileUtils_H
#include "FileUtils.h"
#endif

You can also put a #pragma once at the top of the file:

#pragma once

#include "FileUtils.h"

There is also a generator for include guards available.

Thursday, September 25, 2008

Regular Expression Search

Manipulating some data today to write Java code from the data, I found that Eclipse and EditPlus
both have support for regular expressions in the Search Find/Replace dialog! I wrote a simple "[0-9]" regular expression to remove all numbers from my data (leaving only plain text) WoW! Thats cool! :-)

Google's 10 Birthday

Yes the big girl is turning 10!

http://www.google.com/tenthbirthday/

Tuesday, September 23, 2008

beanstalkapp.com - Free Sub-Version

If your looking for a free/paid for online sub-version (SVN) provider then I suggest using beanstalkapp.com which offers a free sub-version account with 20 MB space and other plans that you can upgrade too.

Monday, September 22, 2008

Light Bot - Save/Load

My wife Jolene De Villiers found a version of Light Bot here that allow you to save/load a game so you can continue from where you last ended. :)

Sunday, September 21, 2008

Weekly Code: Predicates In C++/CLI (21/09/2008)

In C++/CLI every .Net generic List collection (List class) which is in the System.Collections.Generic namespace have methods like FindAll that takes in a Predicate as a parameter.

A Predicate is a delegate that to a method that return true if a match is find in the collection base on a condition in the delegate method. It make it easy to find a element match in a collection without writting a complicated for each loop for example.

C# make this easy by using anonymous methods in C# 2.0 and lamda expressions in C# 3.0 but C++ language doesn't have this feature (C++/CLI is base on C++ that doesn't have anonymous methods/lamda expressions)

In this example I demostrate using predicates in C++/CLI with Visual C++.Net 2008 to find items in a collection.

If your interested in C++/CLI then I suggest reading C++/CLI In Action.

Weekly Code List

Saturday, September 20, 2008

TIOBE Software - Java TOP 1!

On the TIOBE Software list for the popularity of programming languages for September 2008 Java is TOP 1 on the list. :-)

Go Go Java!!

Light Bot - Game For Programmers :)

I started to play Light Bot a game where the idea is to program a little robot to move/jump around blocks and light up all the blue blocks. You program the rebot using block (unfortunatly no coding :-( where you've 2 functions that you can execute.

Friday, September 19, 2008

Java URL vs URI

Goodday :)

You can get URL and a URI but remember that both of them work differently.

The URL encode the string where the URI is the actual resource.

I had a problem in a Java unit test (using jUnit) for PDFTable where my unit test failed since it was unable to load the fonts. The reason for this is that it was using the URL so trying to find the font files under an encoding path.

So the actual code fix is:

URI url = getClass().getClassLoader().getResource(fontResourceDir).toURI();
String path = url.getPath();

The toURI() method represents this abstract pathname.

PDFTable Open Source Project

Our employer allow Evan Summers and myself to release the Java code we wrote to generate PDF statements and invoices as a opensource project - PDFTable which is under the Apache License, Version 2.0

Im planning to make some modifications to it soon.

Welcome!

Hi!

Welcome to my blog. I'm Lennie De Villiers, I'm a software developer for Soliditech with 4 years software development experience using programming languages like Java, C#, C++, VB.Net, PHP, ASP.Net. My main focus in this blog is to share my experience.

Happy reading! :-)

cheers

Lennie