hertzen.com September 9, 2011
Posted by addisu in HTML5, Java Script and jQuery.add a comment

Paul Irish originally shared this post:
Mr +Niklas von Hertzen has been doing some very cool experiments lately. (He made html2canvas http://html2canvas.hertzen.com (the thing that basically has a rendering engine written in javascript, yeah, (crazy, right?)))Applying a blur to web content. Demo:http://hertzen.com/experiments/visual-blur/examples/dusky/
He uses html2canvas to rasterize the DOM, blur it, and throws a canvas on top of the page. More: http://hertzen.com/experiments/visual-blur/Sudoku Solver in just CSS:http://www.hertzen.com/experiments/css3sudoku/
The general sibling combinator at work again; it was recently used in some css-only games from Japanese hackers:http://design.kayac.com/topics/2011/06/css-programing.php
Manipulating truetype font data. Load in a ttf, read the data, manipulate the glyphs on the fly, clientside and view the changes.http://hertzen.com/experiments/jsfont/
A happy tree in CSS: http://hertzen.com/experiments/csstree/
I love the markup of the tree branches.
Pathfinding in JS by analyzing canvas pixel data:http://hertzen.com/experiments/pathfinding/examples/map.html
Fine work!
Learning Advanced JavaScript concepts from jQuery Source Code April 8, 2011
Posted by addisu in Java Script and jQuery.add a comment
One of the thing I was so lazy in my career was not considering JavaScript as serious thing. Yeah, it is on my resume and I know stuffs like doing simple validations and so on. But I thought, what is the big deal to spend that much time on it.
But in the past two years or so, I realized I cannot get away with my “basic” knowledge of JScript to do Complex web applications. Any Web 2.0 requires a real deal of advanced JavaScript knowledge. My first hands-on experience on JQuery was since last year, and dude it is so cool thing. I couldn’t believe such a minified code do all these stuffs. Anyways, looking at the Source Code of jQuery, I realized I should have probably spent a lot of time on JS in my past years. I know things like functions are useful to implement Object Oriented style that we developers used to boast off; and I knew that so that I can answer questions during interviews. However, I never wrote any serious stuff with them.
Now, jQuery latest source code is my favorite link on my browser. ( http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js ) Every now and then, I just look at the code to understand what they have done inside. I know these may not be a big deals, but I will just write them here as I come across interesting things to myself.
Self-calling function:
/*!
* jQuery JavaScript Library v1.5.2
* http://jquery.com/
* …
* …
* …
* Date: Thu Mar 31 15:28:23 2011 -0400
*/
(function( window, undefined ) {
/////////
// every thing is here
// code goes here
///////
})(window);
=======================================
So, this is basically a self-initialization way…?? Then, I learnt that this is a common pattern already.
(function() {
/////////
//code goes here
///////
})();
==================================
So, inside there they initialized jQuery variable and others stuffs; that is cool!
Checking isReady (jQuery.isReady) and setTimeout
While trying to understand this implementation, I got caught with the usage of “setTimeout”. One of it is the following for the case of IE Scroll bar checking.
============================================
// The DOM ready check for Internet Explorer
function doScrollCheck() {
if ( jQuery.isReady ) {
return;
}
try {
// If IE is used, use the trick by Diego Perini
// http://javascript.nwbox.com/IEContentLoaded/
document.documentElement.doScroll(“left”);
} catch(e) {
setTimeout( doScrollCheck, 1 );
return;
}
// and execute any waiting functions
jQuery.ready();
}
=============================================
So, basically this is calling “doScrollCheck” itself until the Scrollbar is ready.
- If jQuery is already ready, exit.
- Otherwise, try checking Scrollbar, if successful then jQuery is ready
- But if fail (i.e. catch(e) ), then wait 1 millisecond and call itself (another instance) and exit without saying “jQuery.ready();”
I think, I can think of this applicable to common problems …
Refactoring CSLA.NET NameValueList and Command Object Return Value March 18, 2011
Posted by addisu in .NET 2.0, .NET 3.0, .NET General, C#, CSLA.NET, Open Source Libraries.1 comment so far
In my current project using CSLA.NET, one of the drawbacks that I noticed on the NameValueList and Command object implementation is the fact that it forces one return value type. Ideally, the best light weighted Name Value return is <key, String> but in our case we are required to have Multi-value object for different purposes.
The best example of NameValueList is it use to hold collection for drop down collections and grids. So for example, for the case of Users List some drop down list only need First Name and Last Name. However, sometimes we may need more fields. The return collection can be in different combination of the fields for different purposes.
Hence, forcing to one Return value type has the following problems that I noticed
- People tend to create new NameValueList Class every time they face completely new return type even though the idea of NameValue class is similar; for the case of User, either <key, <LastName, FirstName>> or <Key, <FirstName, LastName, Age, Sex>>.
- Or, add more properties to the existing return Value for the new return type they desire to have.
Elaborating the first problem, even though it is efficient, we might end up creating many similar classes just for the sake of different Return Type. Probably, we might name each NameValueList class with post fix of the return value.
In the second case, having one NameValueList and return value of all combination will have efficiency issue. If we have 20 variables in the return value but we are looking only two return value of collection for one specific case, we will end up initializing 18 return values of collections.
Probably the simplest approach is to have <abstract Class> as a return value instead of actual <Concrete Class> so that we can define as many Return Types inside the NameValue Class.
In my case, <UserNameValueList> will have an empty abstract class <INameValueListResult> as return type.
Inside the class, I have three return Types that implement <INameValueListResult>, namely <GetUserNameListResult>, <GetUseNameAndAgeResult> and <GetFullUserInformationResult>
Depending on the Criteria we use the different return types and consume. Probably, we can have as many return types as we create different Criteria classes. The consumer should know to what Return type it should cast the <INameValueListResult> value.
In my case, I have the following code that utilizes the return type at run time in my aspx page
============================================================
For Each item As UserNameValueList.NameValuePair In userValueList
Dim itemResult As UserNameValueList.NameOnlyResult = _
CType(item.Value, ExpenseReportNameValueList. NameOnlyResult) //Casting to the desired Return Value Type here!!!!!
…
txtFirstName.Text = itemResult.FirstName
…
ASP.NET is already a traditional technology March 17, 2011
Posted by addisu in .NET 2.0, .NET 3.0, .NET General, ASP .NET, ASP .NET 2.0, C#.add a comment
I have spent nearly a decade fascinated by ASP.NET technology, Server Controls, View state and so on. At the beginning, I used to think it is entirely a pure MVC technology. I remember back in 2003, geeks excited with View State and hacking view states. But in between, I was working on J2EE Web application and there I noticed Microsoft is still chasing the rest. I used to undermine PHP but a lot of high performance Web 2.0 sites such as Facebook are developed using PHP.
These are few of the wrongs about ASP.NET that I read recently:
- ViewState: The actual mechanism of maintaining state across requests (ViewState) often results in giant blocks of data being transferred between client and server. I have faced with an issue when the Site uses SSL for the page that uses ViewState heavily since the whole page is encrypted. It can reach hundreds of kilobytes in many real-world applications, and it goes back and forth with every request, frustrating site visitors with a long wait each time they click a button or try to move to the next page on a grid. ASP.NET Ajax suffers this just as badly, even though bandwidth-heavy page updating is one of the main problems that Ajax is supposed to solve.
- Page life cycle: The mechanism of connecting client-side events with server-side event handler code, part of the page life cycle, can be extraordinarily complicated and delicate; Page_Init, Page_PreInit, Page_Load and son. Few developers have success manipulating the control hierarchy at runtime without getting ViewState errors or finding that some event handlers mysteriously fail to execute.
- Limited control over HTML: Server controls render themselves as HTML, but not necessarily the HTML you want. Moreover, the new HTML5 input types are not accessible with the attribute “runat=server”. In addition to that, not only does their HTML often fail to comply with web standards or make good use of CSS, but the system of server controls generates unpredictable and complex ID values, which are hard to access using JavaScript. We have in house JavaScript functions to strip out the complex pre-fix names added by the server.
- False sense of separation of concerns: ASP.NET’s code-behind model provides a means to take application code out of its HTML markup and into a separate code-behind class. At the beginning, these might encourage separation of concerns by writing the C “Control” part in the code behind. Even though it has been widely applauded for separating logic and presentation, but in reality, developers are encouraged to mix presentation code (e.g., manipulating the server-side control tree) with their application logic (e.g., manipulating database data) in these same, monstrous code-behind classes.Without better separation of concerns, the end result is often fragile and unintelligible.
- Untestable: When ASP.NET’s designers first set out their platform, they could not have anticipated that automated testing would become such a mainstream part of software development as it is today. Not surprisingly, the architecture they designed is totally unsuitable for automated testing.
My Gaming PC – How to build an expensive Dell Alienware Type January 29, 2010
Posted by addisu in Computers - General.3 comments
I was looking for something that would allow me to develop using Virtual Machines (Visual Studio, Sharepoint, Biztalk), do video editing (Adobe Premier, After Effect), and music. I am not gamer though! Why would they call this Gaming PC. I use it for living, not for playing with it.
First, I went to Dell website to see their expensive Alienware Area 51, that basically costs more than 2,200CAD. Area 51..huh!!
The componets are:
- Intel i7 920 Processor
- 6GB DDR3 , tripple channel Memory
- x58 Chipset motherboard
- ATI HD 5770 , 1GB DDR5 Graphics Card
- 1GB Harddrive with 7200, 3gb transfer
- DVD/CD combo (NOT blue ray)
This basic spec costs almost 2,200 CAD at Dell. The only catch is, they have Windows 7 Home edition and their power supply is 1KW and also their case looks fancy.
These are my specs and the total price I paid is less than 900 compared to Dell. I have the OS at home, and also I tried to select a good gaming case with a lot of fans around the body. My only concern is my power supply selection may not be that great.
If you want to save some money when you buy your next PC…it is better to build your own.
| Item | Price |
| Intel Core i7 920 Processor | 309.99 |
| Corsair XMS3 Tri Channel 6GB PC10666 DDR3 Memory – 1333MHz, 6144MB (3 x 2048) | 187.99 |
| Gigabyte GA-EX58-UD3R Socket 1366 Intel X58 | 195.99 |
| Sapphire Vapor-X ATI Radeon HD 5770 1GB GDDR5 | 194.99 |
| Western Digital Caviar Black (WD1001FALS) 1GB | 99.99 |
| LG GH24LS50 Black SATA Lightscribe DVD/CD Combo | 34.99 |
| Cooler Master eXtreme Power Plus 550W Power Supply | 59.99 |
| Antec Nine Hundred Two Black Steel ATX Mid Tower Ultimate Gamer Case | 119.99 |
| Labor and warranty | 50 |
| Total | 1253.92 |
Have fun!!

