says: "i am dreaming of a white lens.."

Got this idea from a photography forumer. His work is way better but i like mine too! :D Basically it shows my main activities at home :P Weird to see so many of yourself at the same time…

multiple-me!

20080624 Today’s Photo

June 24th, 2008

Ah, been a while since my last post :D Was too bored on a Sunday afternoon and actually spent some times in bathroom to take pictures of water droplets. Yeah, i was really bored :P Anyway, managed to come out with the picture below. What do you think? Feel free to use it as your wallpaper :P :P

wallpaper-water_700

Click for the full size

20080527 Today’s Photo

May 27th, 2008

Finally had a chance to get my hands on a set of extension tubes (in case you are blur, extension tube is meant for macro photography). Played around with it for couple of hours and am really amazed at the result! Well i am not praising my shooting skill but the details that you can capture with it. Paired it with my faithful EF 50mm f/1.8, it can do magic!

One of the OK shots

_MG_6901a

Project SsSS

May 9th, 2008

Ha! Been almost a month since the last post. This project is my first into the world of DIY in photography. I love DIY!

So what do you do with a empty box lying around? (actually i got mine from MPH warehouse sales)

_mg_6386.JPG

Cut off the flaps. You can leave them too as ‘extension’ or ‘box-hood’

_mg_6387.JPG

Draw the lines on where you wanna cut. Size is up to you

_mg_6389.JPG

I cut 3 sides. You can cut 4 if you like :D

_mg_6393.JPG

Book wrapper isn’t just for book! It is used here as a ‘diffuser’ for the lighting

_mg_6395.JPG

There you go, a bare box. You can add on by adding white paper as the inner wallpaper

_mg_6397.JPG

Tested with lighting. Note that the light temperature isn’t suitable. Go for one with cool daylight.

_mg_6399.JPG

Added a near black background paper. Aw, wrong type as you can see reflection on the paper

_mg_6422.JPG

Test shot without the background

_mg_6401.JPG

Test shot with the background

_mg_6406.JPG

Cheap and easy, you have a photo tent for product shot or anything you can fit in there. With 3 openings, you can add on or move the lighting anywhere you like.

Cost
——————
Paper box : FOC
Book wrapper: RM1.90
Paper background: RM0.60
Tools: I am sure you have it around your household
Total: RM2.50
Result: Priceless
Bonus: You do your part in recycling! :D

Oh, what’s SsSS? My own-made-up-acronym that stands for Small stuff Shooting Studio! :P

C# Generic Comparer

April 17th, 2008

This morning I ran into a situation where i need to sort an array of ServiceController before binding into a combobox. So I looked around and I found Array.Sort (or List.Sort). Tried with the parameter-less call, but .NET doesn’t like it. One of the required overloaded methods requires a IComparer. Hmm, looks familiar and found some straightforward examples online. Immediately I have a simple class that solves my problem.

private class ServiceControllerSort : IComparer<ServiceController>
{
	public int Compare(ServiceController x, ServiceController y)
	{
		return string.Compare(x.DisplayName, y.DisplayName, true);
	}
}

Now what? What if next time I want to sort on my ExtendedServiceController class (as if there is necessity to do one)? I will have more and more IComparer implementations. I decided to explore further and this page says it all. Took the code, clean it up and woots, I have a generic comparison class that is usable for almost all types.

/// <summary>
/// Custom sorter based on property
/// </summary>
/// <typeparam name="T">Target Type</typeparam>
public class ExtSortComparer<T>: IComparer<T>
{
	private ListSortDirection _sortDirection = ListSortDirection.Ascending;
	private PropertyDescriptor _targetPropDescriptor;
 
	/// <summary>
	/// Constructor
	/// </summary>
	public ExtSortComparer()
	{
	}
 
	/// <summary>
	/// Constructor
	/// </summary>
	/// <param name="PropertyName">Name of property to sort on. Case sensitive.</param>
	public ExtSortComparer(string PropertyName)
	{
		_targetPropDescriptor = TypeDescriptor.GetProperties(typeof(T))[PropertyName];
	}
 
	/// <summary>
	/// Constructor
	/// </summary>
	/// <param name="PropertyName">Name of property to sort on. Case sensitive.</param>
	/// <param name="SortDirection">Sort direction</param>
	public ExtSortComparer(string PropertyName, ListSortDirection SortDirection) : this(PropertyName)
	{
		_sortDirection = SortDirection;
	}
 
	/// <summary>
	/// Constructor
	/// </summary>
	/// <param name="TargetProperty">Descriptor of property to sort on</param>
	public ExtSortComparer(PropertyDescriptor TargetProperty)
	{
		_targetPropDescriptor = TargetProperty;
	}
 
	/// <summary>
	/// Constructor
	/// </summary>
	/// <param name="TargetProperty">Descriptor of property to sort on</param>
	/// <param name="SortDirection">Sort direction</param>
	public ExtSortComparer(PropertyDescriptor TargetProperty, ListSortDirection SortDirection)
	{
		_targetPropDescriptor = TargetProperty;
		_sortDirection = SortDirection;
	}
 
	/// <summary>
	/// Compare two given object
	/// </summary>
	/// <param name="x">Object A</param>
	/// <param name="y">Object B</param>
	/// <returns>Result of comparison</returns>
	public int Compare(T x, T y)
	{
		//ensure there is proper property description
		if (_targetPropDescriptor != null)
		{
			int intRetValue = _CompareValues(_targetPropDescriptor.GetValue(x), 
											_targetPropDescriptor.GetValue(y));
 
			//reverse the sorting if descending
			if (_sortDirection == ListSortDirection.Descending)
				return intRetValue * -1;
 
			return intRetValue; //return the result
		}
 
		return 0; //return neutral if insufficient information to sort
	}
 
	/// <summary>
	/// Compare values of target property
	/// </summary>
	/// <param name="ValueX">Value of property (Object A)</param>
	/// <param name="ValueY">Value of property (Object B)</param>
	/// <returns>Result of comparison</returns>
	private int _CompareValues(object ValueX, object ValueY)
	{
		if (ValueX is IComparable) //if X can be compared
			return ((IComparable)ValueX).CompareTo(ValueY);
 
		if (ValueY is IComparable) //else if Y can be compared
			return ((IComparable)ValueY).CompareTo(ValueX);
 
		//when both can't be compared, resort to string value.
		return ValueX.ToString().CompareTo(ValueY.ToString());
	}
}

The comments should explain what is happening internally. Another good addition to my common library! If you have any thoughts, shoot!

Been very long time since i bought any camera stuff and i came across this should-be-useful item while surfing with no aim. I managed to find it at one of the local online store and instantly made an order. The total damage, RM40. The item reached my hand today (prompt shipping, thumbs up!) so immediately ran a test trial with it. Let the results speak themselves

Without With
_MG_6043 _MG_6047
_MG_6050 _MG_6049
_MG_6057 _MG_6059
_MG_6051 _MG_6052

So what do you think? Is it worth the purchase? I think it does coz sometimes you wouldn’t want a harsh light especially on closer subjects.

C# Generic Constraints

March 28th, 2008

Generic is a new wonder in .NET with the flexiblity it introduces to coders. But when you wish to explore further, you might face the limitation of only able to work with Object capabilities. This is because generic doesn’t know your type details, and since all types are Object, so you only have Object to play with. To overcome this, we have Where keyword in C# (VB.net has As, i think). Apart from be able to constraint the types that generic accept, it also allows you to use the constraints capabilities.

Generics support few types of constraints:

  • Interface: Allow only types that implement specific interfaces to use your generic.
  • Class/Base class: Allow only types that match or inherit from a specific base class to use your generic.
  • Constructor: Require types that use your generic to implement a parameterless constructor.

Say you have a custom Interface as below

public interface IMyCustomOne
{
	string WhatsMyName();
}

and a generic method

public bool CheckNameEqualJohn<T>()
{
	return (T.WhatsMyName == "John");
}

Compiler will throw you at the instant you try to build.

To solve this, we add Where at the end

public bool CheckNameEqualJohn<T>() where T : IMyCustomOne
{
	return (T.WhatsMyName == "John");
}

Woots, compiler is now happy! The obstacle has been removed and off you go to maximize your creativity. If you need 2 constraints, how to go about it?

public class MyClass<T,U>
	where T : IMyCustomT
	where U : IMyCustomU
{
	//....
}

Some additional jargons about this constraint that will make you look cooler in front of your peers

Unbound Type Parameter
Basically this refers to the most basic way of us using generic

public class MyClass<T>
{
	//....
}

Naked Type Constraint
When a generic type parameter is used as constraint

public class MyClass<T>
{
	public void MethodOne<U>(U param) where U : T
	{
		//....
	}
}

Happy Generic’ing!

Suppose you have an enum list and a variable which value comes from external source. What do you usually do to compare against the enum list?

If (MyValue == "3") { //3 means ok, do some stuff }

What if one day you decide that you don’t like 3 (for whatever reason) and change it to 30? You will have to find and replace the repeated value all over your project. Yes, you have the FindAndReplace function with most IDE, but holy cow, you only realize that the last couple of 3 meant something else!

So a safer way is to cast the value into appropriate enum for comparison or any other operation.

'VB.NET
dim myEnumValue as TheEnum = CType([Enum].Parse(GetType(TheEnum), _
				tempValue.ToString()), TheEnum)
If myEnumValue = TheEnum.NumberThree Then
	'..
End If

//C#
TheEnum myEnumValue = (TheEnum)Enum.Parse(typeof(TheEnum), tempValue);
if (myEnumValue == TheEnum.NumberThree) { //.. }

“Hey, that looks useful. I want it in my SuperCoolReusable library” you might say. With the power of Generic, we can put it into a common call.

'VB.NET
Public Shared Function ParseEnum(Of T)(ByVal Value As Object) As T
	Return CType([Enum].Parse(GetType(T), Value.ToString()), T)
End Function

//C#
public static ReturnType ConvertStringToEnum<ReturnType>(string Value)
{
	return (ReturnType)Enum.Parse(typeof(ReturnType), Value);
}

Another simple yet useful tip! ;)

Facts, in case you wonder :

1. It takes less than half a second to turn off the water tap while brushing your teeth, and that in turn saves 14,600 litres of water a year!

2. It requires less than 0.1% of your brain power to remember to turn lights out when not required, and that action saves 68kilogram of CO2 a year!

3. It requires less than couple of mouse clicks to print 2 pages a sheet, and that setting saves half a tree every year!

Those are my pledges to prevent the earth from deteriorating. You don’t have to be involved in lots of activities to save the earth when you can even start small at your own pace. Make your pledge today here! Together, we can :)

Perth, an option

February 26th, 2008

I went to Perth on 21 Feb 2008 to make my first entry as a PR of OZ. Initially, i planned for Gold Coast, but since the airfare cost as much and i’ve never been there, i changed my destination. After this trip, i can conclude that my friends have been feeding me wrong information about the place. Yeah, you can say it is boring, but i like the pace and setting. Near to 30, you don’t expect me to jump up and down every minute anymore, right? I spent about 3+ days there at an auntie place. She is very friendly, and so are the other family members. Thanks to them, i had a superb yet real relaxing break there. Don’t wanna spend my time writing long stories where people don’t finish, i will just summarize my itinerary.

Here goes:

20th Feb - took the night train down to Singapore. My first and last. There was place to sleep, but the train ride was noisy and rocky. So if you are a light sleeper, forget it. Next time i rather travel by bus earlier.

_MG_5829 _MG_5832 _MG_5835
_MG_5836  

21st Feb - loiter around Singapore since my flight was at 3pm. Nothing much to buy after considering currency conversion. Reached Perth at 11pm and had no problem going through the custom. Slept like a pig after supper and a long day

22nd Feb - woke up late and auntie accompanied me down to city just to show me a few tips. After that, i was all alone. Took a bus up to King’s Park first and the view was great. Not going to describe here as i sucks at it, so browse the gallery. Walked around the city and explored their factory outlets which are just nearby. Followed auntie’s direction home. Nearly lost but i reached in one piece :D

_MG_5861 _MG_5865 _MG_5882
_MG_5897 _MG_5912

23rd Feb - Woke up very early to follow auntie to wholesale market. You never get price so cheap here and i was pretty shocked! Where do you get a box (a big one) of brocollis for mere AUD5?! And lots of fruits too! Joined the gang to Fremantle Market since most guides talk about it. Quite disappointed at the size but content matters. We walked around the beach area after and went home to runaway from the burning sun.

_MG_5914 _MG_5917 _MG_5920
_MG_5941 _MG_5958

24th Feb - Met up with old secondary classmates for lunch! Been a couple of years (ten years for one of them) since i last met them. It was great to catch up ;) In the late afternoon, went to the Cottesloe beach, and i find it very nice, and somemore it is near! Auntie brought me to Point Walter too, to see the stretch of strolling path which leads into the river. Time to go home tonight and quite sad to leave them. Gonna miss you all!

_MG_5969 _MG_5973 _MG_5977
_MG_5995 _MG_5997

All these while, i was considering Melbourne only as my migration target. After this trip, i like Perth very much too! Auntie kept asking me to move over there, and even starts to look out for house for me. Well, we will see in near future where i will end up at :)

Browse the gallery