Thursday, September 30, 2010

List IIS application pool

Start Menu -> Run -> type cmd -> Press Enter key

type: iisapp pool

Press Enter

Tuesday, September 21, 2010

LinQ2SQL GUID

This example shows how to compare/filter GUID or UniqueIdentifier types  on Linq2SQL:

String guid = "5236DFEC-A4DB-40B5-B873-F2468697B282";
Guid filterGuid = new Guid(guid);

var matchDB = (from c in db.FormsSubmissions
                         where
                              c.GuidColumn.Equals(filterGuid)
                          select c).First();

Monday, September 20, 2010

MSSQL alternative to MySQL's GROUP_CONCAT

Here's a MSSQL equivalent of the group_concat()  from MySQL:
DECLARE @itemFields varchar(MAX)
SELECT  @itemFields = COALESCE( @itemFields + ',', '') + QUOTENAME([fi].[Name])     
FROM [forms_items] fi     
GROUP BY [fi].[Name]

MSSQL GROUP+

MSSQL GROUP+

MSSQL alternative to Distinct clause

Here's an alternative way of using DISTINCT clause. I've tested this several times versus the DISTINCT clause and yields to faster performance.

using DISTINCT clause:

SELECT DISTINCT([name]) FROM Table1

alternative:

SELECT [name] FROM Table1
GROUP BY [name]

See screenshot:

MSSQL alternative to Distinct clause

Here's an alternative way of using DISTINCT clause. I've tested this several times versus the DISTINCT clause and yields to faster performance.

using DISTINCT clause:

SELECT DISTINCT([name]) FROM Table1

alternative:

SELECT [name] FROM Table1
GROUP BY [name]

See screenshot:

Wednesday, September 15, 2010

C# Dynamically execute a function from string

/**
* from other post (http://dotnet-anythingabout.blogspot.com/2010/09/dynamically-create-instance-of-object.html)
*/
String typeName = "Yournamespace.yourclassname";
Object objectInstance = Activator.CreateInstance(Type.GetType(typeName));

object[] parameters = new object[2]; /** or new object[] {"test","markg"} **/
parameters [0] ="test";
parameters [1] ="markg";
string methodName = "Add";

objectInstance .GetType().InvokeMember(methodName, BindingFlags.InvokeMethod, null, objectInstance , parameters);

OR

Type[] paramTypes = new Type[2];
paramTypes[0] = Type.GetType("System.String");
paramTypes[1] = Type.GetType("System.String");

MethodInfo methodInfo = objectInstance.GetType().GetMethod(methodName, paramTypes);
methodInfo.Invoke(objectInstance ,parameters);

C# Dynamically create instance of object from string

String typeName = "Yournamespace.yourclassname";
Object obj = Activator.CreateInstance(Type.GetType(typeName));

Saturday, September 11, 2010

chicken adobo

Ingredients:

oil
garlic
onions
salt
black pepper powder
coriander powder (optional)
black pepper seeds
soy sauce (i suggest kikkoman)
vinegar
oyster sauce (optional)
worcestershire sauce (optional)
chicken meat

Steps:

1. heat some oil
2. add the garlic and after 3 seconds add the onions and stir
3. add the meat and stir from time to time until it's stale (or pale)
4. add some salt to taste
5. add pepper powder, coriander powder and stir
6. add some soy sauce and vinegar (the suggested ratio would be 3:1 depending how sour the vinegar is)
7. add some water and stir
8. repeat steps 4-5 if necessary. (note that it's better to make it a less salty or slightly lower your taste.. see step 11)
9. let it boil
10. add the black pepper seeds and stir
11. simmer for a few minutes until sauce becomes thick. Stir from time to time.
12. serve

cheesy spaghetti

Ingredients:

2 tbsp olive oil
450g cheese
1kg pasta
1kg ground beef
450g sliced hotdog (optional. adds flavor and color)
1kg spaghetti sauce (or your own choosing of sauce - sweet, sour, etc)
pepper
salt
tomato ketchup (optional)

Step A:

1. Boil water with oil and add enough salt to taste
2. Add the pasta and let it cook for approx. 10-12 minutes, depending on the packaging's suggestion
3. Drain the pasta

Step B:

1. Heat the oil
2. Add the ground beef and hotdogs and stir
3. Add some salt to taste
4. Add some pepper and stir
3. Let it heat for a few minutes and stir from time to time until the beef is cooked (repeat steps 3 and 4 if necessary)
4. Add the cheese and stir well until it's fully melted and mixed with the meat
5. Add the spaghetti sauce and stir well.
6. You can add some tomato ketchup depending on your taste.
7. Set the heat to the minimum and stir the mixture from time to time until it's cooked (do not overboil)
8. Slowly mix the sauce and pasta and let it heat for a few minutes. This will let the sauce sip into the pasta (or you can serve the pasta separately with the sauce)
9. Serve.

Thursday, September 9, 2010

chicken biryani

Ingredients

1. garlic
2. onions
3. tomatoes
4. coriander leaves
5. biryani masala
6. coconut milk
7. basmati rice
8. salt
9. olive oil
10. black pepper powder

Step A:

1. soak rice on water for 30 minutes
2. boil water and add some salt and oil (make sure the salt is enough to taste and there is enough water to cover the rice)
3. add the rice in the boiling water
4. watch carefully until the rice is 50%-75% cooked (don't let it dry)
5. drain the rice

Step B:

1. heat oil in a pan
2. add the garlic and after 3 seconds add the onions and stir
3. add the chicken and stir
3. add plenty of tomatoes
4. stir from time to time until tomatoes creates a paste and chicken is half cooked
5. add biryani powder
6. add pepper powder and stir
7. let it heat until you smell the biryani
8. add tiny amount of coconut milk and coriander leaves and stir
9. let it heat until meat is cooked

Step C:

1. heat a separate cooking pot
2. place small amount of chicken biryani (thin layer)
3. layer it with some rice. (just enough to cover the first layer)
4. repeat steps#2-3 until done.
5. cover the potand let it heat for a while until rice is cooked
6. serve

chicken curry

Ingredients:

1. sliced garlic
2. onions
3. salt
4. coconut milk
5. curry powder
6. black pepper powder
7. chili powder (optional)
8. chicken
9. basil leaves
10. coriander leaves

Steps:

1. heat oil in a pan
2. add garlic and after 3 seconds add the onions and stir
3. add the chicken
4. stir until the chicken until it becomes stale (or pale)
5. add the curry powder and coriander powder and stir
6. add the black pepper and chili powder (optional) and stir well
7. add some salt to taste
8. let it heat for a few moments until you smell the curry
9. add the coconut milk
10. add the coriander leaves and basil leaves then stir
11. let it boil until chicken is cooked or until sauce becomes thick
12. serve

stir-fry noodles

Ingredients:

1. minced garlic
2. minced ginger
3. onions
4. onion spring
5. mushroom
6. carrots
7. snow peas
8. cabbage
9. celery
10. green bell pepper
11. chicken
12. soy sauce
13. oyster sauce
14. worcestershire sauce
15. black pepper powder
16. salt

Steps:

1. Boil water and add some salt
2. Cook the noodles for three minutes or until it is "al dente"
3. Drain the water
4. On a separate pan/wok, heat oil
5. Add the garlic and after 3 seconds add the ginger
6. Add the onions
7. Add the chicken
8. Let the chicken tender and stir from time to time
9. Add the carrots, bell pepper, mushroom, snow peas and celery
10. Stir
11. Add the pepper powder, soy sauce, oyster sauce and the worcestershire sauce
12. Stir well
13. Heat for a few minutes until the vegetables are done
14. Mix the noodles and the cabbage
15. Stir well until noodles are full mixed with the sauce and cabbage is cooked
16. Add the onion spring and serve

Wednesday, September 1, 2010

C# Dynamically get and set values of a property from string


This sample code will let you retrieve the list of properties of an object and will also let you assign and get values dynamically given a property name as string.

Don't forget to include the System.Reflection namespace:

using System.Reflection;

MyClass myObject = new MyClass();
String objectValue;
String objectName;

//get properties
foreach(PropertyInfo info in myObject .GetType().GetProperties())
{
      objectName = info.Name;
      // get value
     if(info.CanRead)
         objectValue = info.GetValue(myObject,null);

     //set value
     objectValue = "Hello Pilipinas!";
     if(info.CanWrite)
       info.SetValue(myObject,objectValue,null);
}


Or you can access the property directly given it's name as string

PropertyInfo info = myObject.GetType().GetProperty("myPropertyName");

// get value
if(info.CanRead)
     objectValue = info.GetValue(myObject,null);


//set value
objectValue = "Hello Pilipinas!";
if(info.CanWrite)
    info.SetValue(myObject,objectValue,null);