Harvey Darvey's Blog

February 15, 2012

The year Valentine Flowers became vegetables in 2012

Filed under: Uncategorized — harveydarvey @ 4:20 am

Valentine day’s is about flowers, dinner, love and presents. Things have apparently taken a creative (and rather funny) turn in 2012 when the flower part slightly took a detour from it’s usual course of history.

Here we have :

Valentine Durians!


Valentine Broccoli Flowers!

* they come in cauliflower variety too. After receiving them, you can apparently remove the packaging and decoration and cook your favourite broccoli dish with it. Maybe the hidden message is to tell your girlfriend “Here! Learn how to cook with these. They’re good training for you till the day you become my wife, coz I ain’t like ordering take-out food”



Valentine Ringgit! (My favourite)

* yep, they’re made of RM10 ringgit notes.


Vegetable flower! … with tomatos, carrot, and mushrooms! They must have gotten them from the night market.



August 24, 2011

Setting Div width to 0px causes problem when setting it back to normal in Ipad safari

Filed under: How-to,Tablets — harveydarvey @ 3:04 am
Tags: , ,

Interesting behaviour.

As of 24/Aug/2011, if you are using Ipad safari to set a div to 0px, and trying to set it back to whatever normal width it was, the content of the div will disappear and can not be seen. Even though the div resized itself back to normal width, it just leaves a black empty white space.


One of the solution is to set the div to only 1px. You would be able to see the contents back again when you reset the width.

July 16, 2011

Pros and Cons of Ipad versus Android Tablet (my experience)

Filed under: Tablets — harveydarvey @ 5:32 am

Well, I ain’t gonna mislead anyone into thinking that this is a fair and unbiased article about the pros and cons of ipad versus the android tablet (to be specific, Asus transformer).

Nope, the argument here is not weighted carefully (although it does apply true to my personal experience). This article does not cover everything into the universe of all things for both tablets. I mean, I will not include everything from A to Z for every type of user there is out there or all features offered by both tablets.

You would want to read this because … let’s get back to that someday.

About me? Let me tell you that the argument points here is coming from someone who :

  • have used (and still using) the Ipad2 (non-3g version) and Android Asus Transformer (version 1)
  • does software development work (web based)
  • both devices have access to internet via an internet access point (YES 4g Dongle)
  • pretty advance level in IT (better than the average Joe or Jane out there)


So let me begin with my pros and cons without further delay.

Why Android is better?

The Native Keyboard We’re not talking about the bluetooth or external keyboard here. This is the native keyboard. Tablet wins here because you can just customize the keyboard as much as you like. Try typing a password like “cF8TZ1Qx1d” into the ipad. You’ll go crazy switching between the numeric keypad and pressing shifts a lot!

Android keyboards are very much cool, just look up the market and you can find tons of customizable keyboard for your need.

Heck, in ipad, you can “split” the keyboard… but what the heck about the part where you cannot decide how big the size should be? The design is bad.

image(Seriously it’s so tiny even for small Asian fingers. What’s the matter with not able to resize it abit bigger?)

Docking keyboard and extra battery life (16 hours) Granted, not all android tablet have this feature, but the Asus Transformer does have a cool keyboard dock which extends battery life another additional 8 hours. Yea, you could get a bluetooth keyboard for the Ipad, but it does not extend the battery life or is attached notebook-style onto it.

The docking keyboard also gives me better email composing experience.

File transfer wirelessly (not using internet, just home network) Get a ftp application and your android tablet becomes a ftp server, or ftp client!
Transfer files via ftp!
Downloading Files or Torrents “Ipad can’t download any type of files” vs. “my tablet can download torrents” … hmmm let’s see… yep, android wins here. I don’t want to pay money for having the “file-download” feature in ipad.
Getting dodgy apps Unless you jail break your ipad (which I’m not so keen on doing), you have to pay for apps.
But with your android, you can get dodgy apps from “reputable” sites.
Using it as a internet CCTV Download IP Camera from the market and your android tablet can become a CCTV (with voice!)
Set up your home router to do port forwarding and you can even access this CCTV via the internet. This means I can view my internet CCTV outside my house anywhere as long as I have internet (and the home internet is not turned off)
Remote Access experience is better Remote accessing to my laptop from the tablet is a much better user experience. With the dockable keyboard, and track mouse, I find it pleasant to remote access my pc for software development work.
Storage Expansion Usb thumbdrive, external hardisk, USB mouse and keyboard, or SD card anyone?

Ipad wins when :

When it comes to “reading” experience The ipad does have a better reading experience admittedly. Digital magazines look much more smoother and nicer compared to the tablet. I’m talking about when using Zinio.
Safari To Go This service has given us a very good app to read books from the Ipad (offline mode wins!)
I use it for reference often during development and for learning new IT stuff
Smoothness in UI The user experience UI is better here from Apple. The screen renders much smoother (like flipping stuff). Clap clap clap. But I can live with a “suckkier” UI on the tablet.
Certain Apps Some of the apps looks better in the iPad. A number of them have a better user experience and graphics wise looks better.

So you see… having used both, and I’m not so much of a content consumer (like news reading, tweeter freak, or facebook addict), I prefer the android tablet. It is much more flexible in terms of what it can do compared to the ipad.

If I have to choose to either give up my ipad or android today, I’m all for keeping my android. For me, Ipad = play. Android = work + play

(out of 5 star) Android Ipad
Work imageimageimageimageimage imageimage
Play imageimageimage imageimageimageimage

May 8, 2011

How to use Google Mail as a free SMTP server for sending email in asp.net

Filed under: How-to,Programming — harveydarvey @ 5:59 pm
Tags: , , , ,

Hello, when you are doing codes related to sending email, getting a workable SMTP for testing may be difficult during development. So here’s how you can use google mail (yes, a google mail where you own that account) to send out emails. This is working as at May 9, 2011.

Firstly, add this to your web config file as shown : (use your own email account and your email account password)


April 29, 2011

Configuring SmtpClient

Filed under: Programming — harveydarvey @ 7:02 pm

Configuring SmtpClient

This example uses .NET’s SmtpClient API to send e-mail. By default, it takes mail server settings from your Web.config file. To configure it to send e-mail through a particular SMTP server, add the following to your Web.config file:

      <smtp deliveryMethod="Network"> 
        <network host=" 


April 28, 2011

GROUP BY a CASE statement in SQL

Filed under: SQL — harveydarvey @ 6:06 pm

Supposing I have a table similar to this :

And I want a results like this, where I group by a CASE statement:

Here’s how it’s done :

 select count (*) as Total,  
 when [Month] = 'January' or [Month] = 'February' or [Month] = 'March' then '1st Quarter'  
 when [Month] = 'April' or [Month] = 'May' or [Month] = 'June' then '2nd Quarter'  
 else '3rd and 4th Quarter' end as Quarter  
 from [US.LLW.QNA]   
 group by   
 when [Month] = 'January' or [Month] = 'February' or [Month] = 'March' then '1st Quarter'  
 when [Month] = 'April' or [Month] = 'May' or [Month] = 'June' then '2nd Quarter'  
 else '3rd and 4th Quarter' end   

April 27, 2011

Use custom SQL statements with LINQ ExecuteQuery to populate your custom classes

Filed under: How-to,LINQ,Programming,SQL,VB.NET — harveydarvey @ 4:48 pm
(classes not created by the LINQ ORM Designer)

Supposing you want to return results as a list of custom classes. You can use the executeQuery here with custom sql statements.

Example : (this example is in VB.net, for c#, head over to ScottGu’s comprehensive linq page HERE)

This is how your custom class (you can also think of it as your entity class) may look like : In my example, my custom class : RiskLoadingSummary is a scaled down version of the RiskLoading table mapped in the data context designer. (Lets say RiskLoading is a class that maps all the fields in the table called RiskLoading, and RiskLoadingSummary, only maps 3 fields from the table)

(LINQ to SQL ORM generated class table in data context designer view) :


My Custom class : 3 properties mapped to 3 fields in the table.


Steps :

Extend your DataContext with a partial-class code behind file : (executequery will autopopulate all the properties based on your sql statement)

Let’s say your datacontext name is NorthWindDataContext (name auto generated and you’re using the NorthWind database). You’ll create a new separate class file in the same project as where your datacontext resides. This class file will extends the NorthwindDataContext by using the “Partial” statement. You may name it something like NorthWindDataContext_Extender.cs (or .vb, depending on your language). Then just enter the line of function code below:

Partial Public Class NorthWindDataContext
    Public Function GetSummary(ByVal intVersion As Integer) As List(Of RiskLoadingSummary)
        Return ExecuteQuery(Of RiskLoadingSummary)("Select Version, Score, SystemId from RiskLoading where Version={0}", intVersion).ToList
    End Function
End Class

Save and compile. After that, when you declare your data context object as below, you may call the new function that you have written to populate for you a list of custom class based on the data you have selected with your ExecuteQuery statement. The reason that you create a new class file and not stick this function into your datacontext autogenerated file is to prevent future overwrite when visual studio regenerates the code behind.


References :


Update data with LINQ Mapped Entities using Attach method across tier

Filed under: How-to,LINQ,Programming,VB.NET — harveydarvey @ 4:34 pm


Gotta admit, the Attach method is pretty confusing in linq to me. I’m sure most of us hoped that we can perform updates using the following similar method after looking at how easily linq query data :


Unfortunately we can’t. There are alot of discussion going on what is Attach for, and what is Attach not.  I’ve searched for some time on forums and sites, and couldn’t find any clear answer to what I need.

Basically, what I am doing is a 2 tier system. With the UI layer referencing the Business/Data Layer which house the DataContext object, this method is ideal.

Breakdown of code in UI Layer and Business/Data Layer

UI Layer :


Business / Data Layer (using LINQ Attach method)



The method above first attach the mapped entity (objProd) into the datacontext.

The key method for update to succeed is to refresh the mapped entity to bring out the current values from the database while keeping the changed values un-touch.  This means that if the mapped entity has 10 fields, all 8 fields will be retrieved and populated into the entity, leaving the ProductId and ProductPrice un-touched.

The SubmitChanges updates the value back to the database.

Simple isn’t it?

If you’re using 3-tier (UI-Business Layer-Data Layer), your data context would reside in your data layer, and your business layer reference to the data layer. Your business layer and UI layer can create mapped linq entities.

LINQ To SQL – Reading connectionstrings from web.config (from the linq layer, which is your data layer)

Filed under: How-to,LINQ,Programming,SQL,VB.NET — harveydarvey @ 4:22 pm

Recently stumbled into the need to read connection strings from the Data Access Layer.
Why : Linq to SQL classes puts the connection string into the app.config located in your data access layer. When you compile, or publish, this settings is compiled together into a dll file. Now if you try to move your application into different servers with different login credentials, then you see what is the big problem here.
Question : How do you put the connection string in the web.config instead of in the app.config that is automatically generated and compiled when you publish a project?

For me, I use this solution,

  1. Imports System.Configuration into your data access layer code
  2. Add a reference to it (system.configuration)
  3. Open it with a parameter :
    objDB = New MyDatabaseDataContext(ConfigurationManager.ConnectionStrings(“MyConnectionString”).ConnectionString)
  4. Drawback: each time you drag a new table into the linq to sql designer, you need to reset the database connection (in your data context file) to nothing and Application Settings to False (I can live with this additional step).


With this, you can now use your web.config’s connection string from your data access layer now. Your linq to sql classes can initialize the database connection string via this method.

Data Access Layer ———>   Business Layer ——–> Web Layer (with your web.config having the connectionstring)
(using my method above) ——————————————————> (reads the web layer’s web.config)

Additional Info : some resource for the above problem (each has it’s own slightly different approach):


Reading connectionStrings from the Web.Config from your Data Layer or Business Layer

Filed under: How-to,Programming,VB.NET — harveydarvey @ 4:12 pm

If you create a linq data context or perhaps use a sqldatasource, a <connectionStrings> block will be inserted into your web.config (I’m using .net 3.5, it’s most probably the same for .net 2.0, but I’m sure it isn’t available in .net 1.0).

Your web.config would look something like this :

    <add name="myConnString" connectionString="Data Source=(local);Initial Catalog=MyDB;Integrated Security=True" providerName="System.Data.SqlClient"/>

To read this string from business layer code or Data layer code (which are in different projects), simple use

strConn = System.Configuration.ConfigurationManager.ConnectionStrings("myConnString").ConnectionString

(You can also import System.Configuration.ConfigurationManager into your BL or DL to shorten the codes above)

Next Page »

Create a free website or blog at WordPress.com.