Category Archives: English

Navigating Dark Nebula

Its been two tri-weeks,

we entered into this dark nebula.

Like dreary dark winters of old-earth,

this is extremely difficult on crew.

We wished for a glimpse of at least a single star –

the hell, we even prayed to almighty.

Forced to conserve energy –

means indoors are not lit bright.

adding bonus frustration and depression.

The doctor is busy,

patients are plenty.

Bridge is deserted, other than few ensigns.

Then there is little glimpse.

Is it for real?

Or only in our imaginations?

Only time will tell …

We continued our journey across dark nebula.

An old woman and her Rooster which wakes up the sun!

Long long ago there was a village, in that village lives an old woman alone in her humble hut. Her husband passed away few winters back, her sons and daughters didn’t survived beyond infantry. She was a good person at heart. The village folks are busy during farming season and busy preparing for farming in off-season. They never bothered to visit old woman and say Hello!

The old woman had a rooster, it is very bright, energetic and young. Every day before sunrise it climbs up on the hut and sings cock-a-doodle-doo three times. After that sun comes up. Old woman sees this every day and she was so proud of her rooster who wakes up sun with a good morning song.

One day the village celebrated harvest festival. But everybody forgot about old woman, nobody invited her to celebrations! Her heart felt really bad, depressed and she got angrier. Then she got an idea to punish the villagers. She took her rooster along with her and went to forest and started living there. She knows – once the sun stops coming as rooster no longer sings – the villagers will call her back.

It has been quite a number of days – nothing changed. But she is adamant and strongly believed the villagers can not stay for more than couple of weeks without sun.

She started living in a cave and travels to nearby water stream every day twice. One day she met with a rabbit whose skin is a tan burned as it escaped northern forest fires and came to this forest recently. The woman felt pity and used her medical knowledge to apply some soothing oil to the rabbit’s skin.

After that she ended up treating broken-winged-eagle, limping deer, broken-hand-bear. She removes thorns from several animals with kindness. She brushes monkeys every day with her special comb and they are grateful for that.

One day old woman looked sad, as the villagers seems to have learned how to survive without sun and never came back to her. Animals saw that she is sad – asked her what’s the matter. She explained every thing.

Then all the animals met in a secret meeting and decided to send eagle as an agent to the village to invite old woman back. Then eagle went to village and tried to talk to the villagers, but everybody is so busy – nobody stopped to listen to the eagle.

Eagle felt annoyed and used her magic to disappear the sun! The villagers felt panic!! Then eagle used big magical voice to say “Until you fetch the old woman and her rooster back to the village the sun won’t return”

All the villagers now remembered old woman and her rooster which sings to the sun every day. They also realized they haven’t seen her from quite some days. They flocked to forest and convinced old woman to come back to village

Old woman said – “I am happy here, but take this rooster along with you, she will sing to the sun and everything will be alright”

The animals and old woman lived happily ever after in the forest.

Single drop of salty liquid –

rolled out from my right eye,

carrying all my burden away.

Single poem of sweet nectar –

rolled out from my left heart,

carrying all of me away.

My face is now a mural –

painted out on a front wall,

flashing all light railers.

My story is now forgotten –

extracted out from the back of,

all souls carrying ocean inside.

This is summer

This is summer,

warm some times,

blazing hot mostly.

Berry picking,

Cherry picking,

Merry riding.

Long days,

long drives.

blue skies,

camping clouds,

mapping birds,

running rabbits,

producing gardens,

jolly weekends ,

This is summer.

c# new feature request : AutoInitListsOnFirstUse

Another sugar coating – a compiler should easily generate code for this (?) without any side effects. why force people to do new boiler plate code ?

List<string> myListOfStrings;

myListOfStrings.Add(“firstString”);

This throws NullReferenceException until we do new List<string>();

The probability of it happening is more when this is part of another data class, which we initialized but forgot to look into all hose other initializations we need to do.

In case somebody want to avoid this behavior we should have an attribute to support old behavior.

[SansAutoInitListOnFirstUse]

c# using custom attributes to validate prerequisites for methods, controller APIs

If you have bunch of prerequisites to be validated for more than one method, we could make code more cute by using an attribute.

For normal methods, this new custom attribute’s constructor could throw exception in case of failure.

But throwing exception in Controller API is bad idea. We want to return more gracefully.

Instead of extending Attribute, extend AuthorizeAttribute and override IsAuthorized() [ or AuthorizeCore() ] method to return true or false. This is more graceful way of doing prerequisite check.

I know this AuthroizeAttribute is to check authorization, but we could mis-use it to validate any prerequisites until a better way is available.

/*****************************************************************************************/

using System;
using System.Web;
using System.Web.Mvc;

namespace WebApplication1.Controllers
{
internal class MustBeAuthorizedAttribute : AuthorizeAttribute
{
protected override bool AuthorizeCore(HttpContextBase httpContext)
{

if (preRequsitesFail)

{
return false;

}

return true;
}
}
}

/*****************************************************************************************/

[MustBeAuthorized]
public ActionResult Index()
{
return View();
}

/*****************************************************************************************/

Thanks to @philip instead of AuthroizeAttribute  ActionFilterAttribute is better. We could return any return value (e.g.. MethodNotAllowed, InternalServerError); see https://stackoverflow.com/questions/16822365/web-api-how-to-stop-the-web-pipeline-directly-from-an-onactionexecuting-filter 

notes, unit testing c# mock, stub, shim!

What to unit test?

Some times it feels why the heck are we adding this unit test? Some times did we really added at least minimum required unit tests or not?

I spent good amount of time researching this topic.

My thumb rule is :

Assume you are adding a document with samples directly taken from Unit tests (except Mocking part though) ; We want our Unit tests to test what customer typically do.

Unit Test is a shield:

Unit test works like a shield. It protects from the minute it is born. This unit test shield will protect the code from your future self. This unit test shield will also protect from others working on this piece of code. Mistakes which will break some existing user can be avoided with this unit testing strategy.

Mock Vs Fake(Stub/Shim)

Use whatever works! External DLLs are better faked. But there are some beasts which will have give tough fight to be faked. In that case do not directly call this external DLL, rather call via a thin layer, a layer with zero business logic but with an interface+class design. Then mock this layer instead of trying to fake your external DLL. Unit tests are saved!

Idea : Rating Display Card for retail shelves

One big difference between online Vs offline retail shopping experience is its rating experience.

Why not retail shelves include a rating card for for all its items on shelf? Customers can view current rating and enter their rating.

It is challenging, but not impossible.

Some of the challenges

1. How to avoid duplicate rating ?

2. How to authenticate users?

(Adding Finger print based rating will solve both above problems. Again which finger? How sensitive is this finger print data? What are security/privacy implications? How to provide accessibility? )

But all these are solvable and fun to work on.

arate

——

Background : I purchased a scrub in QFC (supposed to be better than the one we buy in costco), it cleans OK like in between steel scrub vs sponge scrub but thats where the goodness stops, it spoils everything it touches! For some reason it puts dirty marks on the sink and floor. If the same item is purchased in any online store, I might have read reviews/ratings and may not have purchased the same.