Sunday, July 25, 2010

Pickups - July

1.When Ideas have Sex
Good one on how important 'exchange' has been to human evolution and progress. Exchange of 'ideas' is even more important than exchange of 'goods'. The human history is telling us how societies who were closed to exchanges have not progressed and some times even recessed.


2. MURALI
Murali is the greatest cricketer Sri Lanka has produced. I had my doubts few times over his career, but now that it's over it has sunk in. He's the BEST. I'm putting down some articles I've found off him over the last week. So long MURALI...

Muttiah Muralitharan is carried off the field by Kumar Sangakkara and Dammika Prasad, Sri Lanka v India, 1st Test, Galle, 5th day, July 22, 2010


Monday, July 05, 2010

Way we eat

(Photo from Animals Australia)
A vast majority of Animal Rights Activists fight against typical attrocities towards animals like Using animals for research, Using animal fur for clothing, Using animals in circus etc... But the reality is that all of these measure very little when compared to the enormous amount of Animals killed for human consumption as meat/fish/eggs etc... The matters become far worst and horrifying when you find out how these animals are breed & raised in factory farms which provides an overwhelming majority of animal food for the world. All these done for the sake of creating efficiencies and making the cost of meat lower and lower.

The famous Australian professor Peter Singer and his American friend from a traditional farmer family Jim Mason has authored an amazing book 'The Way We Eat - Why our food choices matter" on the same subject. Importantly they put down some practical steps you can take to make a change. This is specially applicable if you live in the developed world which is the culprit for this inhumane and unsustainable act of cruelty to our fellow earth beings fir te

I will just put down some numbers I found while reading the book. I was astonished while reading the book and continue to be so while referring some other materials. I suggest you read it as well.

1. Amount of meat the world eat
The developed world has increased its meat consumption by a few folds during the past 50 years.

40 Million - Maximum number of birds and mammals killed for research each year within USA
2 Days - Number of days it takes for America's slaughterhouses to kill 40 million animals (See how trivial the impact of research compared to factory farming of animals when it comes to killings)
10 Billion - Total number of birds and mammals killed only in USA each year for human consumption

2. Cheap food and the hidden costs.
The industry has innovative techniques of producing cheap animal products to feed more meat to more people. But the hidden costs are beared by the innocent animals, environment and workers.

99% - Percentage of factory farmed chicken out of total sold chicken in USA
A4 Sheet - Total living area of a market sized chicken
120 - Number of chicken processed (killed) per minute in a typical process line (How can they handle them with care with such speeds)
22 - Number of chickens that is scalded alive per minute in a typical chicken process line
90,000 - Number of chicken a slaughter have to kill each shift in a typical chicken factory farm

3. Is seafood any better
One natural step out of meat is to go for fish. But fish is not far behind when it comes to inhumane treatments.

27 million Tons - Weight of by-catch (Sea creatures caught unintentionally while catching other fish) trashed each year
0.5 million - Number of Norwegian farmed salmon escaping each year from
14:1 - By-catch proportion of shrimp farming in Thailand

Although not so obivious our food choices are as ethical a problem as other choices like marraige, work, sex life, stealing etc... When choosing food it's not just ones personal health that matters, we have to think how it impacts on other beings as well. And most of the time that external impact is quite severe.

For people who can not find time to read a book, have a look at this video clip (pretty old one) narrated by Sir Alec Baldwin.

Tuesday, March 30, 2010

Story of Stuff

I've come across Story of Stuff again. This time I'm gonna make sure that more people are going to watch it. If you haven't seen it, this is a 20 minutes of fun filled video with a very important message. I'm positive that you won't regret this 20 minutes.



http://www.storyofstuff.com

This is a similar style video on carbon emission reduction plans. This method of 'CAP and TRADE' is apparently supported by Obama as well.

Wednesday, March 24, 2010

HTML Editors in DNN Modules

You might need to include a HTML editor in a particular module as a mean of providing a good content editing experience to the users. There are many very good commercial options including CuteSoft. I needed a free option and the most straight forward thing I could find is to use the DNN default text editor it self.

DNN 5 by default uses the FCKEditor. However it is integrated under a flexible provider model which allows developers to plug in different HTMLEditors (even commercial ones) without changing the core modules.

So things looked pretty straight forward and I just had to use <dnn:texteditor> markup (A control which was introduced with the above provider model enhancement) within my module (ascx file) to include the HTMLEditor control. And here lies the problem. The <dnn:texteditor> markup actually boils down to a control named 'TextEditControl' and the steps to include this is no different to general ASP.Net way, which is using Register Directives on top of the page/control;

1. Reference the relevant assembly (<%@ Register TagPrefix="ControlVendor" Assembly="AseemblyName" %>)
2. Add a reference to the control (<%@ Register TagPrefix="TextEditor" TagName="header" Src="Controls/ControlName.ascx" %>

(There's a better way proposed by Scott Gu here)

Now the problem with TextEditControl is that the same control (name) can be found in 2 DNN assemblies. Worst part is these 2 are different as well. I think one of them is a residue from previous DNN versions or may be they actually have real purpose. But why the hell can't they name the controls differently?

The proper one to use in this instance is the TextEditControl from 'DotNetNuke.UI.UserControls'. So make sure you refer to that assembly in your module (ascx file).

So it was hard toiling for a few hours before I caught this and it once again emphasized the real need of good documentation for DNN.

Some more tips on TextEditControl

Saturday, March 13, 2010

Page vs Front Controller

MVC has been a tried and tested method of structuring your applications for a long time. Generally MVC mainly focuses on seperating model and view and less attention on the controller. Specially in rich client applications the view and the controller tends to lie close together. But in web applications this seperation is more critical since the view is essentially happening at client side (browser) while the most of the controller sits in the server side.
There are 2 basic ways of structuring the 'C' of the MVC, i.e Controller. The 2 basic methods are the Page Controller method and the Front Controller method.

The Page Controller is the more simple and straight forward way. Every request to the server is directed to a page (controller) of its own.



Under the Front Controller all requests will reach a single controller and it will dispatch the task to appropriate command class.


Let us analyze the 2 methods with respect to several aspects.

Criteria
Page Controller
Front Controller
Complexity / Ease of Implementation
Low complexity. Suits simpler web applications. Most of the time the commercial web application frameworks have built-in support.
Complexity is high compared to page controller. The single controller it self can be complex. However many CMS frameworks have this built in. (Eg: DNN)
Code Duplication / Code quality
Duplication can be high as the application grows. Has to implement a BaseController from which all page controllers extend.
Low code duplication. All common tasks can be put inside the front controller
Testability
Can be low. Has to go for a 2 part controller where one is HTTP dependant and the other is independant and testable.
The front controller will only handle transfer of the request to independant commands which could be testable. Has to be careful
Adaptability/Flexibility
When the pages of the web application is very different from each other, the code duplication can be higher. If you try to counter this with seperate inheritance tree, it can grow complex soon.
Since the front controller is centralized it's highly configurable. That's why many CMS frameworks use front controller to increase flexibility.
Performance
No extra bottleneck if plain page controller is used. However if a deep inheritance hierarchy is used performance can be a bit lower than normal.
The single front controller can end up being a bottleneck since it answers to all requests. Should avoid doing I/O or DB calls in the front controller as much as possible.
Thread Safety
The same page controller instance might handle (Depending on the web application framework, eg: ASP.Net) requests for the same page and thread-safety has to be considered. Use of static instances might be problematic.
Front controller can instantiate new command objects for each request and ensure thread safety at controller level. However model code still has to be thread safe.
Work distriubution and responsibility
Easier to distribute the work among developers since each area of work can be done completely seperately
Each developer has to have a good understanding of the Front Controller behaviour as everything depends on it.

Thursday, February 25, 2010

ASP.Net 4.0


We have been living in the ASP.Net 2.0 world for too long. The latest and the (not-so) greatest (because its beta) ASP.Net version (.Net framework 4.0 beta) is out for a while with the latest version of Visual Studio as well. Some of the key new features of the new ASP.Net version are mentioned below for you to realize that ASP.Net 2.0 is too old for our own good.

There was a lot of hype around ASP.Net MVC in the past few months and it had mislead people to think that the next versions of ASP.Net is all MVC. Actually speaking ASP.Net 4.0 consists of lot more. ASP.Net MVC is just 1 of 4 main components.

The 4 components are;

1. ASP.Net Web Forms (What we use to know - However lot of new things here as well)
2. ASP.Net MVC
3. Ajax
4. Dynamic Data

The purpose of this post is to discuss new features added to ASP.Net web forms and will be really useful for someone who's not particularly interested in MVC but still want to try out new ASP.Net version.

Let me list down some cool features of ASP.Net 4.0

1. FormView Control
- Uses CSS instead of Tables to create the layout (Efficiency)
- Standard Compliant (Better chance of cross-browser compatiblity)

2. ViewState changes
- Always turned off by default
- Base control classes has a new property 'ViewStateMode' which can be used to put it on only when needed

3, Client ID
- It used to be lengthy non-predictable Client IDs. With this one users have flexibility over how client - IDs are generated
- A new property 'ClientIdMode' is introduced which has values like 'static','Predictable' etc.

4. ASP.Net routing
- Originally for MVC, but a more simpler version is available for web forms now.
- Rest like simpler, SEO friendly URLs

5. QueryExtender Control
- Filters DB results according to client side selections. Limits number of DB calls and optimizes the application.

6. ASP.Net Core Enhancements
- Session State Compression
- Cache improvements
- Browser capability extender

I will try to discuss in more detail about the areas which I find useful in some upcoming blog.

Friday, December 11, 2009

War Heroes - Then and Now

This was drawn by the artist on 9th October 2009. Much before any SF-Presidential election story. Should appreciate his futuristic view.

However I’m pretty sure that couple of more notices (even after the one in front) are still missing. But don’t worry, we will soon see them….in TV, Radio and Roads.

The Sri Lankan people surely know how to do 'Kelaguna Salakeema'. It's in our blood man!

Just think about the sheer effort, resources and money put in to the huge campaign of the government. The propaganda units of the Nazis would learn a few things from this. Who pays for all these?

I was no fan of war anyways but the way treat someone who had saved the government asses so far which hasn't done anything positive beside the war (i.e in the minds of majority Sinhalese at least) is shameful. If they treat someone like SF this way, what do you expect they'll do with someone like Lasantha.

I thought Sri Lanka was only going in circles. Now I think we are just a turning our selves to a well functioning time machine, only thing is this goes back in time in record speeds.