Thursday, February 27, 2014

Roslyn-powered .NET Framework Reference Source


You can find .NET source code just like you Android source code with super easy to use website. It took me less than few seconds to find the source code for String.Join method. You could do this for last several years but it was never easy as this. Latest version was not updated, Stepping through them with Visual Studio was that easy.

If you ever get curious about how a particular method is implemented in .NET framework, now you can find out. Hopefully Microsoft keeps this site updated, and it seems it is indexed with Roslyn.

Here is link for beta site.

Via [ Scott Hanselman ]

Monday, February 24, 2014

Powershell Gotchas

In any language, you use long enough and you will end up in some dark corners where you don’t want to be. More you know these dark corners, more productive you will be. A good tool will have very few of these gotchas and all of them should be well documented and evangelized. We are all as good as our tools, knowing the strengths, weak points will help you picking the right tool for the job.

Powershell is powerful as the name implies, one of my coworker thinks, batch file set the bar very low, so Powershell seems refreshing and powerful to lot of people. I think that is very true. Batch file has lot of these gotchas. DOS commands can be very cryptic, Can’t set variable values without quote inside an if block, Commenting out a line with :: will behave weirdly in some places, use REM instead.

Though Powershell is refreshing, productive, intuitive, modern and powerful, it has its own set of quirks.
  1. Powershell functions return value differently than languages like C#, Java
  2. When passing arguments to functions, use space not comma. Commas convert the arguments into an array and pass  it as one argument.
  3. Functions has to be declared before they can be called. Problem with this approach is, you have to put your entry point/main logic at the end. If you have big script, you have to read it from bottom or the whole file. I always add a “main” function at the top, and do my logic inside that function and call this function as the last line.
  4. Unlike .bat file, you can’t run .ps1[extension for Powershell script files] by clicking/double clicking. Read Set-ExecutionPolicy. If you don’t want to change the system wide ExecutionPolicy, wrap it with a batch script.
  5. Unlike C style languages, ` is the escape character.
  6. $home and ~ are not same.

These are some useful articles on PowerShell gotchas



It was last Saturday night, I was sitting in a empty hospital hallway. Our friend's mom fell down and having a severe back pain. They said she is fine and it will be couple of hours before we can go home. So I was sitting in a empty hospital hallway, waiting, really bored.

As they say, idle mind is devils playground. My mind started wandering. I was thinking about why I haven't paid my tax yet, why filing a tax is still complicated? how did people do it in hundred years ago when there were no internet? reading a book in your phone sucks, Android battery sucks, why my son gets cold so often? why am I not happy as I used to be? what happened to my job? why ant sucks as build scripting language and what are the alternatives? why Gradle and SBT is not catching up fast enough? how did this cat do it?

If you have critical eyes, you would have noticed these are typical first world problems.

Meanwhile, a lady in her late forties came and sat across me with a stroller. After settling she started talking to the baby in silly language. I figured she is the grand ma. Grandparents standout. They are shameless and they are unbelievable addicted to their grandkids.

We started talking, I was complaining about my wife and my son's sleep habits and how he wakes up at least once a night. She said he is such a good baby and he sleeps through the night. While we continue talking, she mentioned they are looking for a good family to adopt him. His mom is young and she is not taking care of him well. Meanwhile she the grandma taking care of the baby.

I felt a void when I heard it. While we are talking, he had his head buried in her chest. He suddenly turned his head towards me and gave me a baby smile. His smile made me happy but his story saddened me deeply. You have to be a parent to know that feeling.

Here I am, grown up man, complaining about silly things and here he is, not even 4 months old, going though a hell of a life.

Hope you live a long and happy life Joshua.

To us all towns are one, all men our kin,
Life's good comes not from others' gifts, nor ill,
Man's pains and pain's relief are from within,
Death's no new thing, nor do our blossoms thrill
When joyous life seems like a luscious draught.
When grieved, we patient suffer;

Oh, Great Spirit, whose voice I hear in the wind,
Whose breath gives life to all the world.
Hear me; I need your strength and wisdom.
Let me walk in beauty, and make my eyes ever behold the red and purple sunset.
Make my hands respect the things you have made and my ears sharp to hear your voice
Make me wise so that I may understand the things you have taught my people.
Help me to remain calm and strong in the face of all that comes towards me.
Let me learn the lessons you have hidden in every leaf & rock.
Help me seek pure thoughts & act with the intention of helping others.
Help me find compassion without empathy overwhelming me.
I seek strength, not to be greater than my brother, but to fight my greatest enemy - Myself.
Make me always ready to come to you with clean hands and straight eyes.
So when life fades, as the fading sunset, my spirit may come to you without shame.
--Native American - Lakota - Chief Yellow Lark - 1887

Tuesday, February 11, 2014

Publishers love-hate relationship with Amazon


Book publishers’ dependence on Amazon, however unwilling, keeps growing. Amazon constitutes a third of one major house’s retail sales on a given week, with the growth chart pointing toward fifty per cent. By contrast, independents represent under ten per cent, and one New York editor said that only a third of the three thousand brick-and-mortar bookstores still in existence would remain financially healthy if publishers didn’t waive certain terms of payment. Jane Friedman, the former Random House and HarperCollins executive, who now runs a digital publisher called Open Road Integrated Media, told me, “If there wasn’t an Amazon today, there probably wouldn’t be a book business.” The senior editor who met Grandinetti said, “They’re our biggest customer, we want them to succeed. As I recover from being punched in the face by Amazon, I also worry: What if they are a bubble? What if the stock market suddenly says, ‘We want a profit’? You don’t want your father who abuses you physically to lose his job.”

-New Yorker



“Jeff is trying to create a machine that assumes the shape of public demand,” Tim Appelo, the former entertainment editor, said. “He resembles a very, very smart shmoo—he only wants to serve, to make you happy.” Appelo was referring to Al Capp’s smiling blob of a cartoon character, which happily provides people with whatever they need: milk, eggs, butter, even its own tasty self. –New Yorker

Monday, February 10, 2014

Amazon Warehouse in Kenosha


When Amazon announced it’s 1.5 million square feet warehouse in Kenosha, I asked myself, why Kenosha? Location seemed to be the obvious reason. It is 60+ miles north of Chicago and 40+ miles south of Milwaukee and 100+ miles of Madison. Covering 3 populous cities in this area. Today’s New Yorker brings another additional answer to that question. Low wages.

Amazon employs or subcontracts tens of thousands of warehouse workers, with seasonal variation, often building its fulfillment centers in areas with high unemployment and low wages. –New Yorker

Kenosha is hit with high unemployment rate and poverty for a while. This would serve Amazon well, finding people easily  for lower wages. 1500+ jobs are good for Kenosha and it’s residents as well.

Saturday, February 1, 2014