Blog of a Filipino Developer about C#, VB.NET, ASP.NET, Java, PHP, SQL Server, MySql and Oracle RSS 2.0
 Thursday, January 03, 2008
I've seen weird searches before in my refferal logs but i've never seen someone do a search like this...
Thursday, January 03, 2008 11:39:25 PM (GMT Standard Time, UTC+00:00)  #    Comments [2] -
Weird Wide Web
 Wednesday, December 26, 2007

I was working on a .NET application that integrates with Gravatar today because I needed a quickway to fetch someone's photo based on their email address. One requirement when doing this type of integration with Gravatar is that the email should be encrypted into an MD5 hash. Luckily, .NET already has a library that can do this for me by just calling a few methods:

[C# Version]

public static string ToMD5(string stringToConvert)
{
   //create an instance of the MD5CryptoServiceProvider
   MD5CryptoServiceProvider md5Provider = new MD5CryptoServiceProvider();

   //convert our string into byte array
   byte[] byteArray = Encoding.UTF8.GetBytes(stringToConvert);

   //get the hashed values created by our MD5CryptoServiceProvider
   byte[] hashedByteArray = md5Provider.ComputeHash(byteArray);

   //create a StringBuilder object
   StringBuilder stringBuilder = new StringBuilder();

   //loop to each each byte
   foreach (byte b in hashedByteArray)
   {
      //append it to our StringBuilder
      stringBuilder.Append(b.ToString("x2").ToLower());
   }

   //return the hashed value
   return stringBuilder.ToString();
}

[VB.NET Version]

Public Shared Function ToMD5(ByVal stringToConvert As String) As String 
   'create an instance of the MD5CryptoServiceProvider 
   Dim md5Provider As New MD5CryptoServiceProvider() 

   'convert our string into byte array 
   Dim byteArray As Byte() = Encoding.UTF8.GetBytes(stringToConvert) 

   'get the hashed values created by our MD5CryptoServiceProvider 
   Dim hashedByteArray As Byte() = md5Provider.ComputeHash(byteArray) 

   'create a StringBuilder object 
   Dim stringBuilder As New StringBuilder() 

   'loop to each each byte 
   For Each b As Byte In hashedByteArray 
      'append it to our StringBuilder 
      stringBuilder.Append(b.ToString("x2").ToLower()) 
   Next 

   'return the hashed value 
   Return stringBuilder.ToString()
End Function

Now all I need to do is get the result of my function and pass it to the avatar page in the Gravatar website and it should return me my Gravatar image.

[C# Version]

string gravatarUrl = "http://www.gravatar.com/avatar.php?gravatar_id";
string gravatarID = Utilities.Strings.ToMD5("keith.rull@gmail.com");
Image1.ImageUrl = String.Format("{0}={1}",gravatarUrl,gravatarID);

[VB.NET Version]

Dim gravatarUrl As String = "http://www.gravatar.com/avatar.php?gravatar_id"
Dim gravatarID As String = Utilities.Strings.ToMD5("keith.rull@gmail.com")
Image1.ImageUrl = [String].Format("{0}={1}", gravatarUrl, gravatarID)

http://www.gravatar.com/avatar.php?gravatar_id=d7ae6b890f16ad7541732e0f38adcbf2

Awesome!

Wednesday, December 26, 2007 7:26:04 PM (GMT Standard Time, UTC+00:00)  #    Comments [1] -
.NET | Fun Stuff
 Friday, December 21, 2007

Have you ever thought about doing a Celebrity Deathmatch for developers? Well CodeSqueeze has just started one and in its first edition they have put two of the most popular .NET bloggers face-to-face. Scott "The Man" Hanselman vs. Phil "You will get" Haack.

Scott Hansleman has been on the forefront of technology and blogging for many years. Before recently joining Microsoft, Scott is most famous for his blog Computer Zen, where he releases famed “Ultimate Tool” lists, and primary driving force behind the Das Blog project. His recent adventure is trying his hand at podcasting which can be found at Hanselminutes.

Phil Haack is most known for his blog Haacked. Rarely off-topic, he flexes his mature .NET development skills with in-depth examples and anecdotes. By day, he is a Sr. Program Manager at Microsoft - by night, he is the lead of Subtext an open source blog engine.

Checkout the blow by blow breakdown and see who is the winner of the first ever Celebrity Deathmatch for developers ;)

Friday, December 21, 2007 6:16:43 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Tech News and Issues
 Monday, December 17, 2007

I've been banging .NET 3.5 lately and this rendezvouz with LINQ (Language Integrated Query) has been making my brain smile alot. I mean, how can you not like something so easy and well defined and makes your life as developer alot easier.

Anyhow, I just wanted to post my LINQ cheat sheet. It's not much and it's not even complete yet (I call this part 1.1). It consist of a few snippets that you might commonly do when doing LINQ processing. I'm planning to update this and hopefully I could find time this week to add some more piece of code that would demonstrate the other LINQ topics that I missed.

Anyway, here's some LINQ snippets:

//create our PersonService object
PersonService ps = new PersonService();

//get the list of person
PersonList listOfPerson = ps.GetPersonList();

//get a list of people with Gender set to Male
var maleOnlyList =
from l
in listOfPerson
where l.Gender == Gender.Male
select l;

//get a list of people with Gender set to female
//and declaring the returned fields
var femaleOnlyList =
from l
in listOfPerson
where l.Gender == Gender.Female
select new {
l.PersonID,
l.FirstName,
l.MiddleName,
l.LastName,
l.Email,
l.BirthDate,
l.Gender,
l.DateCreated };

//specify age
int selectedAge = 25;
//get a list of people with age greater than 25
var ageIsGreaterThan25 =
from l
in listOfPerson
where l.BirthDate >= DateTime.Now.AddYears(-selectedAge)
select l;

//get a list of people with a birthdate between a specified range
var birthdateBetweenRange =
from l
in listOfPerson
where
l.BirthDate >= DateTime.Parse("1/1/1980")
&& l.BirthDate <= DateTime.Parse("1/1/1981")
select l;


//order the result by lastname
var orderByLastNameSimple =
from l
in listOfPerson
orderby l.LastName
select l;

//order the list by birthdate and lastname
var orderByMultiple =
from l
in listOfPerson
orderby l.BirthDate descending, l.LastName ascending
select l;

//take three records
var takeThree = listOfPerson.Take(3);

//go to the 10th record and then take 3 records from there
var skipTenTakeThree = listOfPerson.Skip(10).Take(3);

//skip up until the Lastname is not equal to Thornton
var skipWhile = listOfPerson.SkipWhile(n => n.LastName != "Thornton");

P.S: There's more LINQ examples at the MSDN website.

 

Monday, December 17, 2007 8:36:31 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
.NET
 Wednesday, December 12, 2007

Wow, NBA.com is now joining the silverlight bandwagon.

NEW YORK — Dec. 10, 2007 — The National Basketball Association (NBA) will employ Microsoft Silverlight on NBA.com to further enhance the online video experience for NBA fans around the world. Microsoft Silverlight, a cross-browser, multiplatform plug-in for delivering the next generation of media experiences and rich interactive applications for the Web, will also be utilized on WNBA.com and NBADevelopmentLeague.com.

NBA.com will feature a full-screen NBA photo gallery, offer video highlights and deliver additional interactive applications throughout the site using Microsoft Silverlight. Through the use of Microsoft Corp.’s new application, the NBA will be able to provide further access to its extensive digital video library, integrate the video experience seamlessly into the site, and ultimately provide fans with access to more online video features.

Read the full article here...

I'm a big NBA fan and i frequently visit the site (atleast 4 times a day). Basketball is one of the most popular sports in the world and this partnership I think would greatly boost the adoption of Silverlight in the mainstream.

One more reason why i should kick my gears up another notch with silverlight.

Wednesday, December 12, 2007 10:36:34 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
.NET | Tech News and Issues
 Tuesday, December 11, 2007
I saw this on MSN today...

Surrogate Mothers: Womb for Rent

Customer service, tech support...these days we outsource everything to India. So why not pregnancy? Here is a report on the growing number of Indian women willing to carry an American child.

Woah...
Tuesday, December 11, 2007 10:47:23 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Life

I just saw this from my URL reffer list and it made me laugh.

Heheheh! How do you expect to get a result from this? Does the person expect to automatically get a list of all the people who attended the wedding?

Tuesday, December 11, 2007 8:31:25 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Fun Stuff
I wrote an article a few years ago using SQL SMO and just realized today that I can also list SQL Severs without importing an additional assembly to my project(Microsoft.SqlServer.Management.Smo) by using the SqlDataSourceEnumerator class. SqlDataSourceEnumerator is a class that provides a mechanism for enumerating all intances of SQL Server in a given network. SqlDataSourceEnumerator exposes a method called GetDataSources() that returns a DataTable containing the list of SQL Servers and some basic information about the server
Tuesday, December 11, 2007 7:39:31 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
.NET | Fun Stuff | SQL
 Friday, December 07, 2007

A few days ago in Twitterland, Tim Heuer had a contest. He said that whoever twitts him first would get a Microsoft Vista and Ofiice 2007 Ultimate... I quickly sent him a twit but sadly me efforts fell short. My friend Jon Galloway beat me by a second and he officially won... Jon feeling the pain of my defeat sent me a message saying that I can have the prize because he already have an MSDN subscription. Sweet!

Oh boy! That made my day!

Just today I got an email from Tim telling me that he already sent me the package and my eyes got big because it has some extras include in it.

   "package en route: DHL Tracking #248211XXXXX Sent 12/07/07 to Keith Rull
includes: Vista Ultimate, Office Ultimate, Expression Studio and VS2008 Pro as well as some stickers."

Wooohoooh! That's what I call Microsoft Lovin'! Thanks Tim and Jon! Now my Christmas list is almost complete... hmmm.. I wonder who's going to give me a Zune and an XBOX. :)

Now, onwards to SilverLight!

*update* [20071211]: I got the package from Tim yesterday :) Awesome! Now I don't have any excuse to neglect WPF. Thanks Tim!

Friday, December 07, 2007 10:50:23 PM (GMT Standard Time, UTC+00:00)  #    Comments [4] -
Tech News and Issues
 Tuesday, December 04, 2007

...and it has pure Ruby goodness tied into it! I think I'm going to wash my .NET hands today with Neatbens SOAp enhancements. Congratulations to the great folks from NetBeans! You definetely nailed it this time.

From their official press release:

The focus of NetBeans IDE 6.0 is superior developer productivity with a smarter, faster editor, and the integration of all NetBeans products into one IDE. NetBeans IDE 6.0 features Ruby/JRuby/Ruby on Rails support, enhancements for improved Swing development, a new Visual Game Designer, updated Data Binding support, integrated Profiling, and more. The new installer lets you customize your download preferences--use it to choose the features and runtimes you need.
Highlights of NetBeans IDE 6.0 are:

Java
* Swing GUI Builder
* Intelligent Editor
* Profiler
* Debugger
* Updated Platform APIs

C/C++
* C/C++ Projects and Templates
* Source Code Editor
* Multiple Configurations
* Class Hierarchy Browser
* File Navigation
Ruby
* Ruby on Rails Support
* JRuby Runtime
* Code Completion
* Debugger
* Refactoring
Mobility
* Game Builder
* Device Fragmentation
* SVG Graphics
* Web Services
* Handheld Device / Set Top Box
Web & Java EE
* Visual JSF Design
* Enhanced JavaScript
* AJAX Enabled Components
* CSS Editor
* Web Services & SOA
SOA
* XML Schema Editor, XSLT Designer
* WSDL Designer
* BPEL Designer
* Service Assembly Editor
* Deploy to JBI compliant runtime

Awesome! Really awesome! I've been using Netbeans on the side(due to my obedience with .NET) and it has been a great experience for me. I have used Java IDEs in the past(Visual Cafe 4 anyone?) and i must say that Netbeans has come along way since the days of old when Eclipse elitist call Netbeans a "a tool for non-serious java developers". I think this release has proven that NetBeans is valid alternative against the big boys(Eclipse & IntelliJ among others).

Now,  onwards to a cup of Java. ;)

Tuesday, December 04, 2007 11:37:22 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Java | Tech News and Issues

I was working on a report today when I opened my Excel 2007 and this is all i got:

To my surprise there was no toolbar. No menu. No spreadsheet tab. Nothing. All i got was a window with the manification option showing on top of the form. I right-clicked on the bar and this is what i got:

What in the world happened? This was working fine a few days ago! Arrrgh! :( Good thing there is Google Spreadsheet handy!

Tuesday, December 04, 2007 5:56:45 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
All about Keith | Tech News and Issues
Archive
<January 2008>
SunMonTueWedThuFriSat
303112345
6789101112
13141516171819
20212223242526
272829303112
3456789
About the author/Disclaimer

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

© Copyright 2008
Keith Rull
Sign In
Statistics
Total Posts: 254
This Year: 51
This Month: 0
This Week: 0
Comments: 111
Themes
Pick a theme:
Ads
All Content © 2008, Keith Rull
DasBlog theme 'Business' created by Christoph De Baene (delarou)