Are you a VB.NET Fanboy? Then come to ILoveVB.NET!#

I'm still a big fan of VB.NET even if I haven't touched a single VB.NET code in a year and one the biggest VB.NET fanboy I know has just started a website all about the good things you can do with VB.NET. Chris Williams (VB.NET MVP) has just started a website called ILoveVB.NET. The idea is to build a community that would champion the cause of VB.NET(which is to make the world known that VB.NET is a first class programming language and not a code kiddies toy anymore).

Here's the official message from Chris Williams:

This is the place where we show off all the amazingly cool stuff you can do with VB.NET.

If you're passionate about VB.NET, or you have an interesting project or maybe you're providing community support to a technology that doesn't currently have language parity, then you've come to the right place. We will gladly host your project and blog(s).

If you're looking for answers, you may find them here as well. If you're tired of looking everywhere for code samples and only finding C#, keep checking back here. We're making contact with the product teams and working towards getting the samples and SDKs you want.

Once again, thank you for stopping by. If you need anything, feel free to ask.

Chris Williams

Man, I bet you Paul, Carl, Bill and the VB.NET MVPs are going to be excited about this!

Wednesday, November 28, 2007 7:20:57 PM (GMT Standard Time, UTC+00:00) #    Comments [2]  | 

 

Generating random strings in C# and VB.NET revisited#

Somebody sent me an email today asking me about an article I wrote a few years ago detailing how to generate random strings and numbers in C# and VB.NET. He asked me if I could add function to the code that creates a random character set to be used as a base for the allowed characters in the random string. I went on and hammered the solution and this what I built for him. I don't have enough time to explain the whole thing but I hope the code comments I added would be good enough to understand what I did with the code.

[----------------- C# Version -----------------]

using System;
using System.Collections.Generic;
using System.Text;

namespace KeithRull.ConsoleCentral
{
   class RandomStrings
   {
      //our default string size
      private const int CONST_MaxStringLenght = 10;

      //our default character string set
      private const string CONST_AllowedCharacterLiterals 
         = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";

      //our randomizer
      Random randomNumber = new Random();

      /// <summary>
      /// Generate a random string using the default options
      /// </summary>
      /// <returns>the random string</returns>
      public string GenerateRandomString()
      {
         return GenerateRandomString(CONST_MaxStringLenght);
      }

      /// <summary>
      /// Create a random string based on a specified lenght
      /// </summary>
      /// <param name="lenght">the lenght of the desired lenght of the random string</param>
      /// <returns>the randomized string</returns>
      public string GenerateRandomString(int lenght)
      {
         return GenerateRandomString(lenght, CreateRandomStringSet());
      }

      /// <summary>
      /// Creates a random string based on a specific lenght and character set
      /// </summary>
      /// <param name="lenght">the lenght of the desired lenght of the random string</param>
      /// <param name="charsToUse">character set to use</param>
      /// <param name="randomizeSourceSet">defines whether the source set should be scrambled</param>
      /// <returns>the random string</returns>
      public string GenerateRandomString(int lenght, string charsToUse, bool randomizeSourceSet)
      {
         string randomString = String.Empty;

         if (randomizeSourceSet) {
            //scramble and jumble it
            randomString = GenerateRandomString(lenght, CreateRandomStringSet(charsToUse));
         }
         else {
            //use the default charset
            randomString = GenerateRandomString(lenght, charsToUse);
         }

         return randomString;
      }

      /// <summary>
      /// Creates a random string based on a specific lenght and character set
      /// </summary>
      /// <param name="lenght">the lenght of the desired lenght of the random string</param>
      /// <param name="charsToUse">character set to use</param>
      /// <returns>the random string</returns>
      public string GenerateRandomString(int lenght, string charsToUse)
      {
         //Create a new StringBuilder that would hold the random string.
         StringBuilder randomString = new StringBuilder();

         //Create a variable to hold the generated charater.
         char appendedChar;

         //Create a loop that would iterate from 0 to the specified value of intLenghtOfString
         for (int i = 0; i <= lenght; ++i)
         {
            int characterIndex = Convert.ToInt32(randomNumber.Next(i, charsToUse.Length - i));
            //Generate the char and assign it to appendedChar
            appendedChar = charsToUse[characterIndex];
            //Append appendedChar to randomString
            randomString.Append(appendedChar);
         }
         //Convert randomString to String and return the result.
         return randomString.ToString();
      }

      /// <summary>
      /// Returns a random set of characters based on the default literal set
      /// </summary>
      /// <returns>the random string</returns>
      private string CreateRandomStringSet()
      {
         //just use the default character set
         return CreateRandomStringSet(CONST_AllowedCharacterLiterals);
      }

      /// <summary>
      /// A function that returns a new set of characters based on an input set
      /// </summary>
      /// <param name="allowedCharacters">the source set</param>
      /// <returns>the new collection of characters</returns>
      private string CreateRandomStringSet(string allowedCharacters)
      {
         string randomizedString = String.Empty;

         //get a random string set size
         int randomSetLenght = allowedCharacters.Length * randomNumber.Next(1, CONST_MaxStringLenght);

         //while lenght of the random set is not the same as the source string lenght
         while (randomizedString.Length != randomSetLenght)
         {
            //add a new character
            randomizedString += GetRandomCharFromString(allowedCharacters);
         }

         //return our random string
         return randomizedString;
      }

      /// <summary>
      /// Gets a character from the the input string
      /// </summary>
      /// <param name="allowedCharacters">source string</param>
      /// <returns>a random character</returns>
      private char GetRandomCharFromString(string allowedCharacters)
      {
         return allowedCharacters[randomNumber.Next(allowedCharacters.Length - 1)];
      }
   }
}

[----------------- C# Usage -----------------]

using System;
using System.Collections.Generic;
using System.Text;

namespace KeithRull.ConsoleCentral
{
   class Program
   {
      static void Main(string[] args)
      {
         RandomStrings r = new RandomStrings();

         Console.WriteLine(r.GenerateRandomString());
         Console.WriteLine(r.GenerateRandomString(10));
         Console.WriteLine(r.GenerateRandomString(10, "qwerttyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKJHGFDSAZXCVBNM"));
         Console.WriteLine(r.GenerateRandomString(10, "[]{}<>!@#$%^&*()qwerttyuioplkjhgfdsazxcvbnm1234567890", true));
         Console.WriteLine(r.GenerateRandomString(10, "qwerttyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKJHGFDSAZXCVBNM", false));

         Console.ReadLine();
      }
   }
}

[----------------- VB.NET Version -----------------]

Imports System
Imports System.Collections.Generic
Imports System.Text

Namespace KeithRull.ConsoleCentral 
   Class RandomStrings 
      Private Const CONST_MaxStringLenght As Integer = 10 
      Private Const CONST_AllowedCharacterLiterals As String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" 

      Private randomNumber As New Random() 

      ''' <summary> 
      ''' Generate a random string using the default options 
      ''' </summary> 
      ''' <returns>the random string</returns> 
      Public Function GenerateRandomString() As String 
         Return GenerateRandomString(CONST_MaxStringLenght) 
      End Function 

      ''' <summary> 
      ''' Create a random string based on a specified lenght 
      ''' </summary> 
      ''' <param name="lenght">the lenght of the desired lenght of the random string</param> 
      ''' <returns>a random string</returns> 
      Public Function GenerateRandomString(ByVal lenght As Integer) As String 
         Return GenerateRandomString(lenght, CreateRandomStringSet()) 
      End Function 

      ''' <summary> 
      ''' Creates a random string based on a specific lenght and character set 
      ''' </summary> 
      ''' <param name="lenght">the lenght of the desired lenght of the random string</param> 
      ''' <param name="charsToUse">character set to use</param> 
      ''' <param name="randomizeSourceSet">defines whether the source set should be scrambled</param> 
      ''' <returns></returns> 
      Public Function GenerateRandomString(ByVal lenght As Integer, ByVal charsToUse As String, ByVal randomizeSourceSet As Boolean) As String 
         Dim randomString As String = [String].Empty 

         If randomizeSourceSet Then 
            'scramble and jumble it 
            randomString = GenerateRandomString(lenght, CreateRandomStringSet(charsToUse)) 
         Else 
            'use the default charset 
            randomString = GenerateRandomString(lenght, charsToUse) 
         End If 

         Return randomString 
      End Function 

      Public Function GenerateRandomString(ByVal lenght As Integer, ByVal charsToUse As String) As String 
         'Create a new StringBuilder that would hold the random string. 
         Dim randomString As New StringBuilder() 

         'Create a variable to hold the generated charater. 
         Dim appendedChar As Char 
         For i As Integer = 0 To lenght 

            'Create a loop that would iterate from 0 to the specified value of intLenghtOfString 
            Dim characterIndex As Integer = Convert.ToInt32(randomNumber.[Next](i, charsToUse.Length - i)) 
            'Generate the char and assign it to appendedChar 
            appendedChar = charsToUse(characterIndex) 
            'Append appendedChar to randomString 
            randomString.Append(appendedChar) 
         Next 
         'Convert randomString to String and return the result. 
         Return randomString.ToString() 
      End Function 

      ''' <summary> 
      ''' Returns a random set of characters based on the default literal set 
      ''' </summary> 
      ''' <returns></returns> 
      Private Function CreateRandomStringSet() As String 
         Return CreateRandomStringSet(CONST_AllowedCharacterLiterals) 
      End Function 

      ''' <summary> 
      ''' A function that returns a new set of characters based on an input set 
      ''' </summary> 
      ''' <param name="allowedCharacters">the source set</param> 
      ''' <returns>the new collection of characters</returns> 
      Private Function CreateRandomStringSet(ByVal allowedCharacters As String) As String 
         Dim randomizedString As String = [String].Empty 

         'get a random string set size 
         Dim randomSetLenght As Integer = allowedCharacters.Length * randomNumber.[Next](1, CONST_MaxStringLenght) 

         'while lenght of the random set is not the same as the source string lenght 
         While randomizedString.Length <> randomSetLenght 
            'add a new character 
            randomizedString += GetRandomCharFromString(allowedCharacters) 
         End While 

         'return our random string 
         Return randomizedString 
      End Function 

      ''' <summary> 
      ''' Gets a character from the the input string 
      ''' </summary> 
      ''' <param name="allowedCharacters">source string</param> 
      ''' <returns>a random character</returns> 
      Private Function GetRandomCharFromString(ByVal allowedCharacters As String) As Char 
         Return allowedCharacters(randomNumber.[Next](allowedCharacters.Length - 1)) 
      End Function 
   End Class
End Namespace

[----------------- VB.NET Usage -----------------]

Imports System
Imports System.Collections.Generic
Imports System.Text

Namespace KeithRull.ConsoleCentral 
   Class Program 
      Private Shared Sub Main(ByVal args As String()) 
      Dim r As RandomStrings = New RandomStrings() 

      Console.WriteLine(r.GenerateRandomString()) 
      Console.WriteLine(r.GenerateRandomString(10)) 
      Console.WriteLine(r.GenerateRandomString(10, "qwerttyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKJHGFDSAZXCVBNM")) 
      Console.WriteLine(r.GenerateRandomString(10, "[]{}<>!@#$%^&*()qwerttyuioplkjhgfdsazxcvbnm1234567890", True)) 
      Console.WriteLine(r.GenerateRandomString(10, "qwerttyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKJHGFDSAZXCVBNM", False)) 

      Console.ReadLine() 
      End Sub 
   End Class
End Namespace

[----------------- Screenshot -----------------]

And that's how you create random strings in C# and VB.NET. Interested in the source code? You can download them here. RandomStrings.cs (4.61 KB) | RandomStrings.vb (5 KB)

Wednesday, November 28, 2007 6:08:02 PM (GMT Standard Time, UTC+00:00) #    Comments [1]  | 

 

I'm getting ready to install Visual Studio 2008#

I've just finished downloading Microsoft Visual Studio 2008 bits last night and I think I'm about ready to install it on my VPC (yup, I don't want to install it yet on my real machine.).  I'm really excited about this new release since it looks really really promising. I've seen blogs giving it high praise and some not giving it a nod of acceptance(a few I should say) but for me it's the best Visual Studio to come out yet. I've been playing with the beta version since last year and really happy with this new release from the VS Team.

I know there are several things to consider before you install this version and I'm really glad that Jon made this list to keep as sane when installing/upgrading to Visual studio 2008. Great job Jon!

Now I'm ready to rock!

Wednesday, November 28, 2007 5:19:26 PM (GMT Standard Time, UTC+00:00) #    Comments [2]  | 

 

Are you ready for a Code Trip?#

Sounds like Woody, Lynn, Jason, Tim, Anand, Rob, Mithun and JD are going to hit the road with there Microsoft Truck this 2008.

What's a Code Trip?  Think of it like Cannonball Run. Only slower, and geekier.  We sat around on a campfire burning copies of Microsoft Bob a while back and decided we needed to hit the streets.  We want to get out to developers and hear some stories and have some fun (JD wants to blow stuff up, so we're trying to work that in).  Really, it is going to be what you tell us it is. One RV, bunch of geeks, lots o' code.  Join the trip!

This is going to be awesome.  I go to MS conferences alot and have met a couple of MS Developer Evangelist in the past (specially those who are in the SoCal area) and I think it's a great time for me to meet the other MS Developer Evangelist who cover the west coast.

Hey Woody! Can you reserve me one of those XBOX 360 :D I think that would look great in our living room :P Just kidding.

Monday, November 26, 2007 6:54:16 PM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

Microsoft MS-DOS 5 Advertisement#

"No PC should be without it! No PC should be without i!"

I saw this in YouTube today and it made me laugh really hard. I'm really surprised how far we have come along since the days of MS-DOS up to Vista and Longhorn.

Check the video here: http://www.youtube.com/watch?v=dmEvPZUdAVI

Wednesday, November 21, 2007 10:36:10 PM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

Outsourcing in the Philippines is still cheap#

I just saw this because Jojo Paderes had his status in GTalk pointing to this link.

According to Mercer, the Philippines is still one of the cheapest IT outsourcing destination in the world. The figures states that as of 2007 IT Managers in Manila only earn $22,280/year on an averaged ranking third compared to Switzerland, the highest paying country which has their IT managers average a whooping $140,960/year[link].

Figure 1*

IT Manager: 10 top-paying countries (various currencies)
 

 

Local USD EUR GBP
Switzerland 176,920 140,960 110,990 74,150
2 Denmark 722,310 123,080 96,890 64,750
3 Belgium 95,380 121,170 95,380 63,760
4 UK 62,180 118,190 93,090 62,180
5 Ireland 85,200 108,230 85,200 56,950
6 US 107,500 107,500 84,650 56,550
7 Germany 84,020  106,730  84,020  56,160 
8 Canada 106,000 93,860 73,870 49,370
9 Hong Kong (China) 702,720 90,340 71,120 47,530
10 Australia 115,480 88,850 69,950 46,740
Figure 2*

IT Manager: 10 lowest-paying countries (various currencies)
Local USD EUR GBP
Vietnam 15,470 15,470 12,180 8,140
2 Bulgaria 34,25o 22,240 17,510 11,700
3 Philippines 1,106,700 22,280 17,540 11,720
4 India 1,120,490 25,000 19,680 13,150
5 Indonesia 289,155,000 31,720 24,970 16,690
6 China (Shanghai) 265,810 33,770 26,580 17,770
7 Malaysia 129,930 35,260 28,040 18,740
8 Czech Republic 791,430 35,880 28,250 18,880
9 China (Beijing) 285,130 36,220 28,520 19,060
10 Argentina 133,040 43,180 33,990 22,720
 

Figure 3* Figure 4*
IT Manager: 5 highest paying positions in Asia
    Local USD
Hong Kong 1 702,723.00 90,344.03
2 Australia 2 115,483.00 88,846.75
3 Japan 3 10,347,000.00 87,638.17
4 South Korea  4 69,374,000.00 74,022.62
5 Singapore  5 104,127.00  66,615.70
IT Manager: 5 lowest paying positions in Asia
    Local USD
Vietnam 1 15,473.00 15,473.00
2 Philippines 2 1,106,700.00 22,281.05
3 India 3 1,120,486.00 24,996.90
4 Indonesia 4 289,155,000.00 31,721.24
5 China - Shanghai 5 265,814.00 33,768.74

*Note:

  • Average total cash compensation includes base pay and annual bonus.

  • Foreign exchange conversions were made as of November 2006.

  • Source: Mercer: 2007 IT Pay around the World. 

You can treat the numbers above in different ways... either Manila is not getting the big piece of the pie because we are undervalued (considering that we are the largest english speaking nation in Asia) or... That we can attract more companies to outsource to Manila because we are talented and cheap enough to do projects for other countries which means a larger economic growth for our country.

I think the numbers above would fluctuate specially knowing that the US Dollar is currently in a slow decline and Euro starting to dominate the markets. 

The Philippines has a great talent pool when it comes to IT and most of the them work hard to hone their skills even if they don't get paid that much. That's what I call responsibility and commitment to bringing ang building a world class application from a truely world class workforce.

Hayy, I hope Manila gets a bigger piece of the pie :( Till then, Mabuhay ka Filipino Developer!

Wednesday, November 21, 2007 6:12:59 PM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

Porting Quake II .NET to VS 2008 and .NET 3.5#

Microsoft realeased Visual Studio 2008 yesterday and it made my fingers play with the latest bits and I wanted to exercise my hands on something that I could play with and at the same time learn the cool new features of the latest VS2008. With 'Play' being the keyword I have decided that the best application I could work with(and play at the same time) is this demo program from Vertigo.

Man, they did a great job on this app. The solution is in Visual Studio .NET 2003 (.NET 1.1) but can easily be ported to .NET 2.0 or .NET 3.5(which is what i'm trying right now). Here's some bits about the application taken from Vertigo's website:

In 1997, the computer gaming company id Software released a watershed first-person shooter game called QUAKE II, which went on to sell over one million copies and earn industry accolades as Game of the Year. Later, in December 2001, id Software generously made the QUAKE II 3-D engine available to the public under the GNU General Public License ("GPL").

Now, in July 2003, Vertigo Software, Inc. is releasing Quake II .NET, a port of the C-language based engine to Visual C++ with a .NET managed heads-up display. We did this to illustrate a point: one can easily port a large amount of C code to C++, and then run the whole application as a managed .NET application using the Microsoft Common Language Runtime (CLR) without noticeable performance delays. Once running as a .NET managed application, adding new features is easy and fun.

Quake II .NET Features:

  •  Demonstrates how to port C to native and managed C++
  •  Shows how to extend Quake II using .NET
  •  Whitepaper with tips on porting to native and managed C++

I haven't program in C++ in years but it think this is going to be a great refresher for my rusty C skills. I wonder if Scott Stansfield and his minions are brewing up something like this for .NET 3.5 and XNA? Hmmm... I have to wait and see but in the mean time if you guys are interested you can download this great application from Vertigo's website(complete with source code, demo tips and a developer white paper) here.

Hey Jeff! Maybe you can give me tips on how to beat the bad guys on level 4.

Tuesday, November 20, 2007 6:57:58 PM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

It's not a bug! It's a...#

"FEATURE!"

Hehehe! I just saw this in my documents folder. I can't remember where I got it but it definetely made my developer flesh chuckle! Dedicated to all Software QA's out there(specially to my wonderful wife :*).

Later!

Tuesday, November 20, 2007 1:09:14 AM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

VisualSVN Server: Managing SubVersion repositories has never been this sweet!#

"Ayayay Caramba!" Another great app from the makers of VisualSVN.

Introducing VisualSVN Server. VisualSVN Server is a packaged that contains all you need to start(and managed) your own SVN repository. Think of it as your own mini toolbox of goodies for SVN. The package comes with SubVersion, Apache and sleak lookin' management console.

And best of all, it's 100% free.

Monday, November 19, 2007 10:02:05 PM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

VS2008 and .NET 3.5 ready for the picking#

Oh boy! Oh boy! Oh boy! Talk about geeky goodness! In case you miss the news, VS 2008 is ready for download for MSDN subscribers. Not an MSDN subscriber? Fear not! VS Express 2008 was also shipped today!

Want to learn whats on VS2008? Check out the video tutorials here or just read what ScottGu has to say.

Jeff also mentioned that Team Suite and TFS is also available and that the 90 day trial(in case you are not an MSDN subsriber) can be downloaded from the MSDN website.

Monday, November 19, 2007 8:19:50 PM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

My ASP.NET FileSystem Browser Revisited#

More than 2 years ago I wrote this article and submitted it in CodeProject detailing how you can build a FileSystem Browser in ASP.NET. The article talks about how newbie ASP developers moving to ASP.NET might code the solution and how somebody a little bit more familiar with ASP.NET would build the same application in lesser code.

Somebody emailed me about my article yesterday asking for some guidance. This lead me to inspect my old article. The first thing i said to myself after seeing my old code is 'Yikes! I did that?'. Yup, it was that horrible. The solution works, its functional based on the need but I knew i could clean it up and code it much better if i had the chance to do it a second time around. That chance happened today.

I haved changed the way i read folders(before it was using query strings). I have replaced that logic by placing the path inside my LinkButton CommandArgument property. How i pass the FileSystemInfo[] to the grid(it was using an intermediate datatable) and the type of control that displays the data(it was using a datagrid before now we are using a gridview). I've also added a breadcrumb like control to track the users location and made it a little bit prettier by adding icons instead of plain text descriptions.

I'll be updating this constantly based on the request I haved received from my original article. The most common request is sorting which I will add on the next release.

Hopefully this version is less crappier than the last.

*Update*

Thanks to Andreas Haydeck for pointing out a bug in the BuildNavigatorPath method that causes the navigator path not to show the proper folder location. This has been fixed and the code in this article has been updated.

Download the latest source here: KeithRull.FileSystemManagerRevisited.zip (6.57 KB)

Saturday, November 17, 2007 12:02:24 AM (GMT Standard Time, UTC+00:00) #    Comments [5]  | 

 

Even images should pass quality assurance#

I was explaining the benefits of outsourcing projects in Manila today to someone who has a huge project.. probably between 1 year to 2 years of development amounting to atleast $50K for the initial concept. He asked me to help him find a suitable outsourcing company preferrably in Asia. I then made a push to have him look at several company's in Manila which he agreed... what i did next was show him a website of a known development company. He read everything and browsed every page on their site to get more information about them. We were having a great conversation and I think he ha already decided that he is going to contact this one company but then he decided to look at their methodologies section... there he noticed something that he didn't like about the website...

"Some comment?" What? Nice coding standard there buddy.

I mean, come on! If you are posting a code snippet to an ad atleast make sure that the code looks good and follows your motto "Code of Discipline" because to tell you frankly it makes your company look bad when you don't QA what you push to visitors even if it's just an image.

In the end, he got turned off and asked me to show him a different outsourcing company.

Sad. Sad. Sad. A missed opportunity.

Wednesday, November 14, 2007 1:12:03 AM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

Android: Google's answer to the Windows Mobile platform#

Man, this is fast becoming an all out war. I think Mr. Gates and Mr. Jobs would be anxious on whats going to happen with this latest release from Google specially knowing that Google is giving away $10,000,000 to the best application built on top of the Android platform

Check out the video here:


 



 



 



 



 


 

Tuesday, November 13, 2007 9:58:43 PM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

Nobody should tell you what you should be. Nobody!#
"Nobody should tell you what you want to be in life. Stick with your dream and don't let anybody tell you that you can't make that dream happen."
 
I was browsing technorati today when I stumbled upon this blog entry from an aspiring developer in Manila. My heart shrunk after reading her dilemma.
 
"...I told my family that I want to be a Software Developer that's why I keep on reading and studying about new programming technologies. But my family objects, especially my mom. They don't want me to study. They just want me to pick  whatever job and stick to it. One day, they even kept my programming books in a locked shelf. Imagine, they don't want me to be a programmer..."
 
I had the same situation more than 3 years ago when i got here in the US. You see, I was a developer in Manila before my family decided to move to the US for a big outsourcing company doing VB6, VB.NET, C# and ASP. I was a Web Administrator for a real state firm before that(doing classic ASP and PHP) and a Analyst Programmer Trainee when I was in college. But almost everybody in my dads side of the family thinks that i should be a US Navy. They said that i can't find any developer job here in the US because "I graduated in the Philippines" and that i can't use my degree because the school that i can from has a curriculum that isn't recognized by the academe in America.
 
My heart was broken after hearing that from several people... it's hard to accept that what you have worked hard on for 4 long years wont amount to anything in another country. Alot of people told me to give up my dream and just "settle for what's on the table" which means that i just need to take what i can and not live up for my aspirations.
 
Hearing those kind of opinion specially coming from your family members is somewhat dishearthening.
 
At first, I was discouraged. I wasn't mad at them at all but i didn't believe what they told me. I knew that I can accomplish my dream if i work and pray hard for it. I worked doubly hard going to the library to read a book everytime I can. I would even borrow books and rigorously read them till i fall asleep. I didn't had the chance to bring my development tools at that time because i was advised not to bring my CDs so i ended up downloading everything all over again via a 56kbps line. I was lucky enough to find SharpDevelop and that's how i started honing my skills in C#(and VB.NET). Everyday I gain more and more confidence in myself knowing that every tear and pain is a step towards my goal to become a Software Developer in the US.
 
My first job interview was a disaster. I was sweating like a sheep and so nervous that i dabbled every word I spoke. I knew all the questions they asked me but i wasn't able to communicate well enough to merit me as a valid candidate for the position. I knew right there and then that I failed the job interview. I was sad but held my head up high knowing that I needed that stab so I can be better.
 
I became event more confident after that faithful event. Taking every piece of experience i learned from it as part of my comunication toolbox(and that is speak clearly, be yourself and don't sweat like you don't know what you are talking about).
 
I prayed harder too knowing that God has something prepared for me in my future and I was right!
 
After a month of applying and staying long hours sending my resume our home phone rang with someone on the other line bringing me a message... I was hired and they wanted me to start that week. After putting the phone down i started shouting like crazy. It was so sweet to let that out of my chest that finally, my dream is coming true.
 
It's been more than 3 years ago since that faithful day. I smile everytime I think of what I have accomplished even with almost everybody saying that I can't be who I want to be. I knew God has promise for me and that it would happen if i work hard and continue to believe Him.
 
And it did :)
 
I believe that nobody should tell you to stop dreaming. I believe that you can accomplish anything you want as long as you put your mind, body, heart and faith into it. Anything is possible as long as you work hard, believe and put your trust in God.
 
Through that battle I held a verse in my heart which I'd like to share to you:
"Have I not commanded you? Be strong and courageous. Do not be terrified; do not be discouraged, for the LORD your God will be with you wherever you go."
                                                   Joshua 1:9 - taken from the NIV Bible
 
So I say to you all "Dream on, don't loose hope and never let go!".
Friday, November 09, 2007 7:08:45 PM (GMT Standard Time, UTC+00:00) #    Comments [2]  | 

 

Some interesting statistics on Microsoft's internal network#

James McGovern has has posted this stat on how vast the network is inside the Big House in Redmond and i'm quite amazed in their IT infrastructure:

Microsoft internal IT:

600k connected devices
10,000 Servers
3 Datacenters 1 operations center
11% is virtualized in Microsoft Datacenters
330 of 385 servers run Windows Server 2008 (RC0) plus all 85 Microsoft.com servers
11 clustered systems
30,000 users in redmond domain (50,000 with vendors)
NAP reporting 140K clients, 90 clients deferred mode

The Redmond Active Directory domain is running in Windows Server 2008 mode since last thursday (Nov 1st)

Microsoft Email:

6 million internal emails per day
20 Million emails from Internet
97% rejected as spam
99,999 uptime

Want to read more? Go to James McGovern's website and check out this crazy stat.

Hmmm... I wonder how many geeks are running the show in such a huge network. Hmm.. Do you know?

Friday, November 09, 2007 12:12:11 AM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

I'm coming to MIX08!#

I know, i missed alot after i didn't go to MIX07. I told Jon that i'll be coming to MIX07 but something happened with my project and i was asked to tend the wounds. This time I won't let the chance to party with Miguel, Jeff, Phil and Scott pass me by!

MIX08 here I come!

Thursday, November 08, 2007 9:40:22 PM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

Want to earn money for your .NET Articles?#

My friend Mohammad Azam (Azamsharp) of GridViewGuy.com is looking for talented developers who also have extra-ordinary writing skills. He is looking for people who can contribute well-written articles to his website and in return he'll pay you $10/per article. So if you think you are up for the challenge and you have the skills and the motivation to write then send him a message at azamsharp@gmail.com.

Wednesday, November 07, 2007 8:34:49 PM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

How To: Add javascript code to a control inside your GridView#

Yesterday I wrote a post as about adding a mailto link to a GridViewColumn and was surprised with the amount of response i got via email regarding that topic. One person asked me a frequently asked question which i realized I haven't tackled on my blog yet. The question was:

Keith,

   Is it possible to add javascript code in a GridView Column? I'd like to attach a javascript function to a hyperlink that will show an alert that show's the selected Name whenever a user clicks that link.

Thanks,

XXXXX (Identity hidden)

The answer to the question is Yes you can add javascript code to a control inside your GridView and believe it or not there is two ways to do it. There's the easy way and there's the complicated but not hard to do way.

Let's start with the easy way. The easiest way to do this is by create a TemplateField in your GridView and add a HyperLink control inside the ItemTemplate of your TemplateField. Next, you need to modify the NavigateUrl property of the HyperLink control to something similar to this:

<asp:TemplateField>
   <ItemTemplate>
      <asp:HyperLink ID="selectionHyperLink" 
                     runat="server" 
                     NavigateUrl='<%# Eval("Name", "javascript:showMessage(&#039;{0}&#039;);") %>'
                     Text="Select" />
   </ItemTemplate>
</asp:TemplateField>

What the code on my NavigateUrl property does is that it attaches a javascript function called showMessage passing a parameter which in this case is a value from column taken from the binded datasource of the GridView. The javascript for the above code would like this:

<script language="javascript">
   function showMessage(personName)
   {
      alert("You clicked " + personName + "!");
   }
</script>

The second approach is adding a GridView_RowDataBound event to our GridView and add some control logic inside that event but first we need to modify our control attributes:

<asp:TemplateField>
   <ItemTemplate>
      <asp:HyperLink ID="selectionByCodeHyperLink" 
                     runat="server" 
                     Text="Select" />
   </ItemTemplate>
</asp:TemplateField>

As you can see i have removed the NavigateUrl attribute. The reason behind this is because i'll be feeding that information inside the GridViewDatabound event. To accomplish what we have accomplished on our first example we need to decide on two things: 1.) Do we want to use the same logic wherein we specify the javascript via the navigate url? or 2.) Do want to use the Control.Attribute.Add() method of the control to attach a onclick event to it.

Anyway, I'll leave that thinking to you and just show the code for both instead so that you can choose which approach is right for you:

Here's the code for the straight up NavigateUrl assignment of the javascript.

protected void peopleGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
   //determine if the row type is DataRow
   if (e.Row.RowType == DataControlRowType.DataRow)
   {
      //find the hyperlink control in the GridView
      HyperLink hyperLink = (HyperLink)e.Row.FindControl("selectionByCodeHyperLink");

      //check whether the the hyperlink exist on our GridView
      if (hyperLink != null)
      {
         //get the dataitem assigned to the row.
         //assume that the dataitem is of type Person
         Person person = (Person)e.Row.DataItem;

         //assign our javascript code
         hyperLink.NavigateUrl = String.Format("javascript:showMessage('{0}');", person.Name);
      }
   }
}

As you can see, all we did was assign the same string that we assigned on our first example. Below is the add attribute version of the above code.

protected void peopleGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
   //determine if the row type is DataRow
   if (e.Row.RowType == DataControlRowType.DataRow)
   {
      //find the hyperlink control in the GridView
      HyperLink hyperLink = (HyperLink)e.Row.FindControl("selectionByCodeHyperLink");

      //check whether the the hyperlink exist on our GridView
      if (hyperLink != null)
      {
         //get the dataitem assigned to the row.
         //assume that the dataitem is of type Person
         Person person = (Person)e.Row.DataItem;

         //add this code to make the text act as hyperlink
         hyperLink.NavigateUrl = "javascript:;";
         //add our javascript attribute
         hyperLink.Attributes.Add("onclick",String.Format("javascript:showMessage('{0}');", person.Name));
      }
   }
}

And that's it! That's how you add javascript code to controls inside a GridView. Hope that you learned something from this tutorial. 

Want to download the source for this project? Get it here: KeithRull.MappingLinksInGridViews.zip (3.28 KB)

Wednesday, November 07, 2007 7:41:23 PM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

How To: Add mailto to a column in a GridView control#

I was reading my site refferers today when I saw an interesting refferer query that came from Google. Three people got to my site after typing this phrase "hyperlink databind gridview mailto". I went to the the Google results page and immediately went to the page the was indexed by Google and upon futher review i found that my page wasn't really the answer to those persons question. Out of my curiousity i fired Visual Studio 2005 up and tried to add mailto link to a GridView using the HyperlinkField as my base.

<asp:HyperLinkField  DataNavigateUrlFields="Email" 
                     DataNavigateUrlFormatString="mailto:{0}"
                     DataTextField="Email" Text="Email me!" />

I ran the project thinking that this should work because this always works for me when i do same process for URLs. To my surprise, it didn't. For some unknown reason the column appears as plain text without any href attribute in sight. I went back to the HTML and checked it twice to see if maybe i missed something on the control attributes... hmmm, eveything looks ok. After a few minutes of playing around I resorted to the technique that never fails.. I converted the column to a TemplateField.

<asp:TemplateField HeaderText="Email">
   <ItemTemplate>
      <asp:HyperLink ID="emailHyperLink" 
                     runat="server" 
                     NavigateUrl='<%# Eval("Email", "mailto:{0}") %>'
                     Text='<%# Eval("Email") %>' />
   </ItemTemplate>
</asp:TemplateField>

Run the project again and sure enough, it worked. Huh! Weird! Anybody who knows what happened?

Wednesday, November 07, 2007 12:02:15 AM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

How To: Read a web page and get all the urls assigned to an HREF attribute via Regular Expression#

A fried of mine IM'ed me today asking for help about an specific task that was assigned to him by his project manager. He is currently working on a project that has the client getting furious alot because the client discovered that most of the links on their site were broken (the vicious 404 erros) or are not pointing to the right pages (misplaced links). His PM wasn't happy at all so he was asked me to help him create a program that would parse a website and get all URLs accessible inside a page and dump the result into a text file.

I had a little bit of free time so i decided to help him by building this small application to show him how he can accomplish the task in C#.

using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.IO;
using System.Net;

namespace KeithRull.GiveMeUrls
{
   class Program
   {
      static void Main(string[] args)
      {
         //the url to scrape
         Uri urlToScrape = new Uri("http://www.devpinoy.org");
         //the list that would contain the urls recovered from the specified uri
         List<string> listOfUrls = GetAllUrlsFromUri(urlToScrape);

         string fileName = SaveToFile(listOfUrls);

         Console.WriteLine("Parsing completed! Urls saved to file: {0}", fileName);

         Console.ReadLine();
      }

      public static List<string> GetAllUrlsFromUri(Uri urlToScrape)
      {
         //the list that would hold the urls
         List<string> listOfUrls = new List<string>();
         //the search pattern that we are going to use for our regular expression
         string searchPattern = "href\\s*=\\s*(?:(?:\\\"(?<url>[^\\\"]*)\\\")|(?<url>[^\\s]* ))";

         //get the contents of the page and put it to a string
         string pageContents = GetPageContents(urlToScrape);

         //our regular expression should ignore case
         Regex regEx = new Regex(searchPattern, RegexOptions.IgnoreCase);

         //get all the maching values generated by our regular expression
         Match match = regEx.Match(pageContents);

         //loop thru all the matching strings
         while (match.Success)
         {
            //assign the match value to a temporary placeholder
            string urlFound = match.Value;

            //check to see if the url does not include the full path(e.g: default.aspx)
            if (listOfUrls.IndexOf(urlFound) < 0)
            {
               string urlToAdd = urlFound;
               if (urlFound.StartsWith("href=\"javascript:"))
               {
                  //do nothing, we need to display it as is.
               }
               else if (urlFound.StartsWith("href=\"/") || !urlFound.StartsWith("href=\"http://"))
               {
                  //add the scrape url to the beginning of our found string
                  urlToAdd = urlFound.Insert(6, urlToScrape.OriginalString);
               }
               //add the url to our list
               listOfUrls.Add(urlToAdd);
            }
            //move to the next match result
            match = match.NextMatch();
         }

         //return the list of urls that we have recovered from the site
         return listOfUrls;
      }

      /// <summary>
      /// Reads a webpage and captures it html representation into a string
      /// </summary>
      /// <param name="urlToScrape">the website you want to read</param>
      /// <returns>the html representation of the site</returns>
      private static string GetPageContents(Uri urlToScrape)
      {
         HttpWebResponse httpWebResponse = null;
         StreamReader streamReader = null;
         string pageContents = String.Empty;

         try
         {
            //create a webrequest object for the url
            WebRequest webRequest = WebRequest.Create(urlToScrape);
            //convert the webrequest to an httpwebrequest
            HttpWebRequest httpWebRequest = (HttpWebRequest)webRequest;
            //assign a timeout value for the process
            httpWebRequest.Timeout = 100000;

            //create a webresponse object to hold the response generated for our request
            WebResponse webResponse = httpWebRequest.GetResponse();
            //convert the webresponse to httpwebresponse
            httpWebResponse = (HttpWebResponse)webResponse;

            //get the response stream and assign it to our streamreader
            streamReader = new StreamReader(httpWebResponse.GetResponseStream());

            //read the contents of the stream
            pageContents = streamReader.ReadToEnd();
         }
         catch (Exception ex)
         {
            //buble up the error
            throw ex;
         }
         finally
         {
            //close our webresponse object
            httpWebResponse.Close();
            //close our streamreader object
            streamReader.Close();
         }

         //return the page contents
         return pageContents;
      }

      /// <summary>
      /// Saves our list of urls to a text file
      /// </summary>
      /// <param name="listOfUrls">the list containing the urls</param>
      /// <returns>the filename created for the file</returns>
      public static string SaveToFile(List<string> listOfUrls)
      {
         //the file name
         string fileName = String.Format("{0}.{1}",Guid.NewGuid(), "txt");

         //create a streamwriter for our file
         StreamWriter sw = File.CreateText(fileName);

         //loop thru each string in our collection
         foreach (string url in listOfUrls)
         {
            //write the string to our file
            sw.WriteLine(url);
         }

         //close oour streamwriter
         sw.Close();

         //return our filename
         return fileName;
      }
   }
}

Basically, the code does is it accepts a url and then parses that page using a regular expression to check all the strings that matches our search pattern. Once it finishes the processing of the page, it would then dump all those urls into a text file.

I sent the code to him and he was very happy with the result. Sweet!

Tuesday, November 06, 2007 8:21:58 PM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

A Comparisson Of Open Source Bug Tracking Softwares in ASP.NET#
We are currently using Gemini here for our issue tracking and we love it eversince we had it installed in our server but this joy of Gemini has not stopped us from searching a better alternative because there are things that we don't like about it(specially that cost part of the software). That lead me to scour the web to find alternatives that we might consider in the future as a viable replacement for our long trusted Gemini. to my surprise I only found 4 open source ASP.NET bug tracking solution compared to the gargantuan list that I saw for PHP. Below are the 4 applications that I found and my comment about each project.
Friday, November 02, 2007 7:41:15 PM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

ASP.NET was originally written in Java. What?#

Sounds strange but it's true. Just ask Mark Anders and he'll tell you the complete story. ;)

Anders:
"... The original prototype was written in Java. I loved Java as a language and Scott(Guthrie) did too. So it was done in Java, and we took that around to lots of different groups. The first group that we took it to was the tools team. The VB and the InterDev teams were in a feud, and when they saw our demo they liked it. They said, 'If you build that, we will target it with our tools."

Thursday, November 01, 2007 10:07:10 PM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

How To: Read the values of a GridViewRow and assign them to a control#
A few days ago a forum question was posted in DevPinoy.org on how to read the values of a inside a GridViewRow and assigning them to a Label control(or TextBox) when that row is selected. I wasn't able to reply to that thread early due to time constraints with a project I had at that time but I told myself that I'm going to answer it as soon as my schedule frees up. This article is a bit late(about 3 days to be exact) but i still hope that this answers that persons question.
Thursday, November 01, 2007 9:33:42 PM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

All content © 2010, Keith Rull
On this page
This site
Calendar
<September 2010>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789
Archives
Sitemap
Blogroll OPML
Disclaimer

Powered by: newtelligence dasBlog 2.3.9074.18820

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts


Pick a theme: