Extract HTML data from Yahoo! Finance web page into JSON using .Net

Screen Shot 2012-10-31 at 12.51.04 AM

Few hours back, I need to load stock data from free/unpaid source. First option come to mind was to utilize Yahoo! Finance data via their Yahoo! Query Language service, but unfortunately YQL service no longer support for Yahoo!Finance stock data or maybe I don’t know how to grab it from new version of YQL. However, on Yahoo! Finance standard page, I still able to view historical data. Thus, I try to build a small program to extract data from Yahoo! Finance page and return it as JSON format.

Continue reading Extract HTML data from Yahoo! Finance web page into JSON using .Net

The different between “==” and “===” operand on JavaScript

I believe most web developer familiar with JavaScript “==” operand, it is used to check if a value is equal with another value. But what about “===”, do you ever know about this operand before?

Both “==” and “===” are actually have same purpose. They will perform comparison between 2 variables, the output of this operand will be boolean type true and false. However,  they have different comparison mechanism. “==” will do variable data cast/conversion before do comparison, to  make sure that both variable have same data type. “===” in other hand will not do any data conversion.

Continue reading The different between “==” and “===” operand on JavaScript

Rename file or folder on Mac OS X

Rename file or folder on Mac OS X

I am consider as a user who rarely change file name from file system. Once it is downloaded or saved, its name will remain same. Mostly I will use “Save As” function on respective software related with the file, say like Word for document, Excel for spreadsheet or else. But sometime, there is a chance where we have mood to tidy up how our file and folder are stored on our computer, hence opening file one by one and save as different file name will not be an efficient way to do. Luxury of press “F2” button that we have on Windows to activate “rename” mode of file seems doesn’t work either on Mac OS. Well what to do?

Continue reading Rename file or folder on Mac OS X

Return simple string on ASP.NET MVC

Today I teach some of my junior programmer on how to work with ASP.NET MVC, first question they ask once they see the sample of MVC from standard Visual Studio 2010 template is “what if I want only return Hello World as the output?”, coincidently this question is the same question always being asked to me by MVC newbie.

MVC concept segregates layer of development into Model, View and Controller. Most of time developer effort will be on Controller and View and these 2 layers have a mutual relationship, because Controller will handle all business logic and/or data processing while View is meant for UI handling purpose. Sometime as programmer, we will need to test our business logic function has proper output or not, and the output normally just simple object or value. Build a different view to render the output seems too many effort to do and will add more “to-be-deleted” file on our solution, hence question on how to send simple output directly from Controller is really logical.

Okay, back to the issue, what is the solution? ASP.NET MVC have a class “ContentResult” to accomodate this problem. Code should be like below:

 

   1:  public class HomeController : Controller
   2:      {
   3:          public ActionResult Index()
   4:          {
   5:              String ret = "Hello World!";
   6:   
   7:              //-- build return string here
   8:              return Content(ret);
   9:          }
  10:     }

Have a nice MVC Controller test !!!

Open .7z file on Mac OS X

7z is probably one of best compres format, unfortunately stocked archive application on Mac OS X is not comply with this file. For those who have this file and have issue to extract it on your Mac, simple application “The Unarchiver” will solve the problem.

Download “The Unarchiver” from this link http://unarchiver.c3.cx or we can donwload the same from Mac App Store, install it on our Mac and we are ready to read any .7z file.

Since the application is free and will always remain free (thanks to Unarchiver developer), and if feels get enough benefit from this application, I think it would be wise if we donate to developer through Paypal. Link for can be found on download section on Unarchiver link written above.

How to make our Windows logon automatically

Windows Auto LogonLock our computer with user name and password is good for security concern. However, there are some circumstances where we may want to make our Windows automatically logon after we boot our computer. Some of reasons we want to do this are:

  • it is a personal computer and no one may use computer without our permission
  • we running our computer for home computer purpose, gaming or something not confidential
  • require to restart our computer often for specific reason
  • run Windows on Virtual Machine (I do this, and hell ya, logon dialog bugging me a lot)

So, here is an easy way to tweak our Windows to let auto login feature.

Continue reading How to make our Windows logon automatically

Lock screen on Mac OS

Being secure is one of most important concern we need to have when deal with nowadays technology where all data flying around and easily broadcasted with a single click of button. And that is why most system will have lock screen feature so anyone can’t missused our system when we are not around. Ctrl + L is handy keyboard combination to lock our screen on Windows OS, but for Mac OS magic buttons are Ctrl + Shift + Eject.

Autolock also another feature we need to manage in case we forget to lock the screen when we leave our system. It is possible to happen, especially if we are on rush.

For Mac OS we can find tweak this from menu System Preferences -> Security & Privacy -> General and click on “Require password after sleep or screen save begins”, lesser time or immediate is better, but it is really depends on how our work behaviour is. For instance, being locked just by leave our computer for 1 minute because we want to pour more coffee from our coffee maker machine or another errand will be frustrated.

How to create a method returns new LINQ Join on .Net

I am in situation where I need to join 2 big tables often, doing such on physical database will consume tons of CPU resources and roundtrip overhead between business logic and data layer may kill my application performance. Hence I am thinking to  load tables into memory for first time only, use a LINQ Join and encapsulate this LINQ join query into a method and return the output as a reusable object. But I get an issue because of data returned by LINQ Join known as IEnumerable<Anonymous> and .NET need to have a valid cast before we can use the data.

Continue reading How to create a method returns new LINQ Join on .Net

Mac OS X – Move cursor one word left or right

Move cursor one wordI often use keyboard shortcut to navigate cursor within my document, especially during on development mode. When port to Mac, I able to find almost all shortcut to navigate my cursor position, except one, move one word left or right.

Continue reading Mac OS X – Move cursor one word left or right

Don’t trash watermelon rind, it is good for our health

watermelon-sliced_10330_600x450When we talk about watermelon, our mind will think about a red sweat and juicy fruit. Because of it’s taste, watermelon edible is often consume directly or combine with other fruit/ingredient as salad or cocktail. In contrast, outer pale flesh of watermelon, or rind, being trashed even before it is being served. I do the same, until today when I read a facebook status of my friend who say about his vitality boost and weight being reduced after consuming watermelon rind.

Continue reading Don’t trash watermelon rind, it is good for our health