4me

If the planet was going to break up–all right. But while I was alive I would go on living at the best speed I could manage. – “Future Imperfect”

Keys to success of Mr. Obama

Posted by tcle on November 10, 2008

Secret weapon of new leader Barack Obama;

  • Objective and Consistent
  • Flexible performance
  • Friendship at the right moment

barack-obama-is-on-fire

Posted in Observation | Tagged: | Leave a Comment »

Hibernate v.s. Active Record

Posted by tcle on November 2, 2008

Overview

Active Record – adopted by Rails framework is reckoned to be a tough player in single table/object mind set. In short, it is a way to map database rows to objects so every columns then become properties of the objects. Static methods are available for finding instances. There are also methods that provides CRUD functions for you. You might find it nearly like 1:1 correspondent mapping between tables and classes, columns and fields.

Hibernate utilize the Data Mapper pattern which use a mapping layer to moves data between objects and database independently. It requires you to have hands-on job in configuring how these moves is done vie a XML file. The file is responsible for telling how objects and rows, columns and fields are mapped.

Active Record support native SQL while Hibernate make up its own object oriented Hibernate Query Language – HQL which will later be translate into SQL with optimization for the specific database. The intention for a new query language is a serious move and its worth in case of complex queries. Either one will not a big different to developers. Just dig into each and you find yourself comfortable.

IMHO

Hibernate and Active Record do the mapping in its own way. By some magical reflection, Active Record implicitly do the job for you. Just to make sure using it for simple domain models. Hibernate in the other hand explicitly require your efforts in mimicking the objects and database similarly in terms of columns to fields and associations.

Some people might argue on the native of Active Record as a data centric way because Active Record classes  expose the data every from the database (e.g. every object fields is related to columns from database rows). I think it is not a big concern to bring up front because AR is doing good on what its meant to do. Hibernate in conclusion will be good choice for relational database or an existing legacy database schema case.

Posted in Design & Pattern, Rails, Ruby | Tagged: , | Leave a Comment »

How to: Assign task

Posted by tcle on October 29, 2008

Make yourself a simple tool like this to get things done on time

  • quadrant I — manage: the quadrant of necessity; things are both urgent and important
  • quadrant II — leadership and quality: the quadrant of focus; things are important but not urgent
  • quadrant III— (AVOID): the quadrant of deception; things are urgent but not important
  • quadrant IV—(AVOID): the quadrant of waste; things are neither important nor urgent

A No uttered from the deepest conviction is better than a Yes merely uttered to please, or worse, to avoid trouble. (Mahatma Gandhi)

Source : tony khuong

Posted in Observation | Tagged: , , , | Leave a Comment »

Mind Maps – A Powerful Approach to Note Taking

Posted by tcle on October 28, 2008

Related variants: Spray Diagrams, Spider Diagrams, Spidograms, Spidergrams and Mindmaps

Mind Map™ is a trade mark of the Buzan Organization

Mind Mapping is a useful technique that improves the way you take notes, and supports and enhances your creative problem solving.

By using Mind Maps, you can quickly identify and understand the structure of a subject, and the way that pieces of information fit together, as well as recording the raw facts contained in normal notes.

More than this, Mind Maps encourage creative problem solving, and they hold information in a format that your mind finds easy to remember and quick to review.

Popularized by Tony Buzan, Mind Maps abandon the list format of conventional note taking. They do this in favor of a two-dimensional structure. As such, a good Mind Map shows the ‘shape’ of the subject, the relative importance of individual points, and the way in which facts relate to one another.

Mind Maps are more compact than conventional notes, often taking up one side of paper. This helps you to make associations easily. And if you find out more information after you have drawn the main Mind Map, then you can easily add it in.

Mind Maps are also useful for:

  • Summarizing information;
  • Consolidating information from different research sources;
  • Thinking through complex problems; and
  • Presenting information in a format that shows the overall structure of your subject.

What’s more, they are very quick to review as you can often refresh information in your mind just by glancing at one. In the same way, they can be effective mnemonics: Remembering the shape and structure of a Mind Map can give you the cues you need to remember the information within it. As such, they engage much more of your brain in the process of assimilating and connecting facts, compared with conventional notes.

Drawing Simple Mind Maps

The original Mind Tools site was planned and researched using Mind Maps. They are too large to publish here, however part of one is shown below. This shows research into time management skills:

Figure 1: An Example Mind Map

To make notes on a subject using a Mind Map, draw it in the following way:

  1. Write the title of the subject you’re exploring in the center of the page, and draw a circle around it. This is shown by the circle marked 1 in Figure 1, above.
  2. As you come across major subdivisions or subheadings of the topic (or important facts that relate to the subject) draw lines out from this circle. Label these lines with these subdivisions or subheadings. These are shown by the lines marked 2 in Figure 1.
  3. As you “burrow” into the subject and uncover another level of information (further subheadings, or individual facts) belonging to the subheadings above, draw these as lines linked to the subheading lines. These are shown by the lines marked 3 in Figure 1.
  4. Finally, for individual facts or ideas, draw lines out from the appropriate heading line and label them. These are shown by the lines marked 4 in Figure 1.

As you come across new information, link it in to the Mind Map appropriately.

A complete Mind Map may have main topic lines radiating in all directions from the center. Sub-topics and facts will branch off these, like branches and twigs from the trunk of a tree. You do not need to worry about the structure produced, as this will evolve as you develop your mind map.

Note that the idea of numbered ‘levels’ in Figure 1 is only used to explain how the Mind Map was created. All we are showing is that major headings radiate from the center, with lower level headings and facts branching off from the higher level headings.

While drawing Mind Maps by hand is appropriate in many cases, software tools like MindGenius improve the process by helping to you to produce presentation quality Concept Maps, which can easily be edited, distributed and redrafted.

Improving your Mind Maps

Once you understand how to make notes in the Mind Map format, you can develop your own conventions to take them further. The following suggestions may help to increase their effectiveness:

  • Use single words or simple phrases for information: Most words in normal writing are padding: They convey facts in the correct context, and in a format that is pleasant to read. In your own Mind Maps, single strong words and meaningful phrases can convey the same meaning more potently. Excess words just clutter the Mind Map.
  • Print words: Joined up or indistinct writing can be more difficult to read.
  • Use color to separate different ideas: This will help you to separate ideas where necessary. It also makes your Mind Map easier to remember. Color also helps to show the organization of the subject.
  • Use symbols and images: Where a symbol or picture means something to you, use it. Pictures can help you to remember information more effectively than words.
  • Using cross-linkages: Information in one part of the Mind Map may relate to another part. Here you can draw in lines to show the cross-linkages. This helps you to see how one part of the subject connects with another.

Click on the thumbnail below for a great example of a mind map that has extremely high visual impact.


Key points:

Mind Mapping is an extremely effective method of taking notes. Mind Maps show not only facts, but also the overall structure of a subject and the relative importance of individual parts of it. They help you to associate ideas and make connections that you might not otherwise make.

If you do any form of research or note taking, try experimenting with Mind Maps. You will find them highly effective!

Source: mind tools

Posted in Interests, Observation | Tagged: | Leave a Comment »

Implementing HTTP Handlers in ASP.NET

Posted by tcle on October 21, 2008

Notes from Michael Flanakin

When I first started out, it was hard to find information on how to setup an ASP.NET HTTP handler. Of course, after time, I’ve found a wealth of articles, posts, and comments from others on these and other related topics. As my second post in the HTTP module/handler saga, I hope to give you an in-depth discussion on the topic of handlers to include pros, cons, and a sample implementation that you can extend.

Introduction

ASP.NET uses HTTP handlers to process all requests. For general information on HTTP handlers (and modules), see my previous article, Introduction to ASP.NET HTTP Modules and Handlers. In the following sections, I will discuss a few pros and cons of HTTP handlers and provide a step-by-step guide to implementing your own handler.

Most notably, HTTP handlers are beneficial because they provide a way to interact with HTTP requests before they get to a web page. This can be very nice, depending on what you need to do with the request. For instance, perhaps there is a need for logging actions taken by users or controlling access to individual files (i.e. images, executables). For the purposes of this article, I will discuss using handlers for URL rewriting.

This is intended to be a work in progress, so let me know if there is something extra that you’d like to see in it, or, if there are any mistakes/inconsistencies. Any other feedback is welcome, as well.

Creating the Handler

One of the most important things to implementing your HTTP handler is the management of your URL mappings. Before you look at how the handler should be coded, you should put some thought into how flexible you want the mappings to be. There are countless methods for managing your mappings, each with its own set of pros and cons. For instance, you could technically put them in a database; which would allow you to setup a nice front-end to manage them from within your application. The problem with this is that you’ll require a database call simply to find out what page you want to access. This may or may not be adequate. I would assume that the latter would be true in most situations. You should also consider the fact that, in some cases, you may require more than one rewrite or redirect in order to setup your mappings appropriately. For this article, I will keep it very simplistic. We will use the custom app settings section available within the Web.config file. To do this, add the following section to your Web.config file:

Web.config appSettings Configuration

< appSettings >
<add key="/MyApp/LogicalPage1.aspx" value="~/Pages/PhysicalPage1.aspx" />
<add key="/MyApp/LogicalPage2.aspx" value="~/Pages/PhysicalPage2.aspx" />
</appSettings>

The key is intended to be the requested page and the value is the physical page that will be displayed. Pretty simple. Two important things to note are that, using this simplified scenario, the keymust be and the value should be root-relative paths.. For instance, the above specifies that http://localhost/MyApp/LogicalPage1.aspx will actually map to http://localhost/MyApp/Pages/PhysicalPage1.aspx.

Now that we’ve defined our mappings, I recommend that you create a configuration settings reader to load and act upon the appropriate mapping at runtime. For this example, I won’t get into that, though. This simple implementation only requires a one-line lookup, so there is not much of a need to have the settings reader; however, in a real-world app, I would highly suggest using one for extensibility reasons. I will discuss this more in-depth later.

Creating the HTTP Handler

Now that we have decided on our mapping storage method and have ensured a way to read the mappings (built-in configuration support for now), all we have to do is create the HTTP handler. There are a lot of different ways to do this, so the first thing to think about is: What do you want to do? For this article, we’re just rewriting the URL, but for your system, you might want to add application-level logic. If this is the case, I recommend that you create special business objects to handle each logical task that needs to be accomplished. For instance, a LogAction class for logging or a RewriteUrl class for the URL rewriting. Since we will only be implementing a simple URL rewrite, I won’t bother getting into the complexities of a separate class.

Before you set forth with creating your HTTP handler, you should take a look at the IHttpHandler interface, which you will need to implement.

IHttpHandler Interface

public interface IHttpHandler
{
bool IsReusable { get; }
void ProcessRequest(HttpContext context);
}

There is one property and one method to implement. The property, IsReusable, specifies whether ASP.NET should reuse the same instance of the HTTP handler for multiple requests. My thinking is that, unless there is a specific reason not to, you would always want to reuse the HTTP handler. Unfortunately, I haven’t found any guidance suggesting one way or another – at least, not with any real reasoning behind it. The only thing I found was something to the effect of, unless your handler has an expensive instantiation, set IsReusable to false.

The ProcessRequest() method is where you will actually perform the logic to handle the request. Since we’re simply reading from the app settings and rewriting the URL, we can handle this in a matter of lines.

HttpHandler.ProcessRequest() Method

public void ProcessRequest(HttpContext context)
{
// declare vars
string requestedUrl;
string targetUrl;
int urlLength;

// save requested, target url
requestedUrl = context.Request.RawUrl;
if ( requestedUrl.IndexOf(“?”) >= 0 )
targetUrl = ConfigurationSettings.AppSettings[requestedUrl.Substring(0, requestedUrl.IndexOf(“?”))];
else
targetUrl = ConfigurationSettings.AppSettings[requestedUrl];
if ( targetUrl == null || targetUrl.Length == 0 )
targetUrl = requestedUrl;

// save target url length
urlLength = targetUrl.IndexOf(“?”);
if ( urlLength == -1 )
urlLength = targetUrl.Length;

// rewrite path
context.RewritePath(targetUrl);
IHttpHandler handler = PageParser.GetCompiledPageInstance(
targetUrl.Substring(0, urlLength), null, context );
handler.ProcessRequest(context);
}

Now, all we need to do is add the HTTP handler reference in the Web.config file. A lot of people have been falling victim to the following Server.Transfer() error because of incorrect handler configurations, so pay attention to this part.

Error executing child request for [physical page specified in appSettings value].aspx

I’ll discuss the reasoning behind the following configuration, but for now, simply replace "*/Pages/*.aspx" with an appropriate path that represents all of the physicalpages (this is veryimportant), MyApp.HttpHandler with the fully-qualified class path of the HTTP handler, and MyApp with the name of the assembly, minus the .dll extension. Also note that the handler for the physical pages must come first. These handlers are checked in order, so if you put it second, then the first path that the request matches will be used, which will probably be your custom handler.

Web.config system.web/httpHandlers Configuration

<system.web>
<httpHandlers>
<add
verb="*"
path="*/Pages/*.aspx"
type="System.Web.UI.PageHandlerFactory" />
<add
verb="*"
path="*.aspx"
type="MyApp.HttpHandler,MyApp" />
</httpHandlers>
</system.web>

Handling PostBack

Now that we have our URL rewriting in place, it’s time to do some real work. Based on this section’s title, you’ve probably figured out that you’re going to have some post-back issues (if you haven’t already tested that out). The problem with post-back is that, when rendered, the HtmlForm object sets the action to the physical page name. Of course, this means that when you submit the form, your true page is displayed. This is obviously less than ideal for URL beautification. Not to mention it would most likely confuse your users. Well, there are two solutions to consider.

First, you can add a simple script block to fix the problem. This is the easiest solution, but there’s one problem: if a user has scripting turned off (as if that is ever the case, anyway), the fix will be nullified. But, in case you still like this solution (I do), add this code to your Page class. If you don’t already, I’d suggest creating a base Page object for all of your pages to implement. Then, add this code to the base Page class. This allows you a good deal of extensibility as far as adding common features easily.

Register Javascript

RegisterStartupScript( "PostBackFix",
"<script>document.forms[0].action='';</script>" );

Your second option is to extend the HtmlForm class. This is pretty simple, as you will see below, but it comes with its own issues. The main problem that I have with this solution is that you have to explicitly add the extended HtmlForm object to replace the default HTML form tag. Not that it is hard to do, but it can get tedious if you’re creating (or converting) a lot of pages.

Action-less HtmlForm Object

public class ActionlessForm : HtmlForm
{
protected override void RenderAttributes(HtmlTextWriter writer)
{
Attributes.Add("enctype", Enctype);
Attributes.Add("id", ClientID);
Attributes.Add("method", Method);
Attributes.Add("name", Name);
Attributes.Add("target", Target);
Attributes.Render(writer);
}
}

Each method has it’s own pros and cons. They’re pretty simple to understand, so the decision shouldn’t be too hard. Honestly, you can implement the second option through a base Page class, but that adds a lot more complexity to your system then you’re probably looking for. Explore your options and be innovative.

Redirect, Transfer or Rewrite?

Earlier, we implemented a URL rewriting scheme; however, in some circumstances, you may wish to implement a Response.Redirect() or Server.Transfer() instead. One reason to do this is to forward from Default.aspx to another page, like Home.aspx. You may or may not want to do this “behind the scenes,” but that is a decision for you to make yourself. As always, each option comes with its own set of pros and cons.

Redirects are essentially two GET (or POST) requests. The first request gets processed and then the Response.Redirect() sends a response back to the client with an HTTP 302 redirect command. This obviously causes a slight delay as the second request gets processed. Also, since the new URL is sent to the client, it won’t be hidden. This clearly doesn’t support URL beautification, which is the main reason most people implement handlers. Even though redirects won’t solve your problems, they still play an important part in the overall solution and should be considered when developing your mapping solution.

Transfers, unlike redirects, keep control within the application; but, they are still treated as two requests. The difference is that instead of the client handling the HTTP 302 redirect command, the web server handles it. This means that any modules, as well as the handler, will be processed twice . There are three key things to remember when using transfers: (1) the Request object, and all of its properties and methods, will reflect the initial request (logical page) and not the physical page; (2) post-back will not work; and, (3) in order to use the transfer you have to have two handlers specified in the Web.config file. There might be a way to get the post-back to work, but I don’t know what that would entail. Perhaps I will delve into the ASP.NET request process fully one day. As for the two handler issue, let me explain that in a bit more detail. As you may remember from above, you specified two handlers in the Web.config file. The reason for this is because after the Server.Transfer() is executed, ASP.NET will send the second request back through the handler. I’m not completely sure why this is a problem, but it is. So, to fix it, you need to have some way to identify what requests should be handled by ASP.NET’s default handler and which should be handled by yours. I attacked this by putting all of my physical pages in a Pages directory. So, by re-adding the default handler to handle all requests to "*/Pages/*.aspx", we tell ASP.NET how to support each type of request. As I also mentioned before, this will fix the the “Error executing child request” error.

Rewrites provide the best performance because there is no back-tracking to re-handle requests. You simply change the URL and continue on with the request processing. Know that accessing the Request object will now reflect the new (physical) URL and you will not have access to the old (logical) URL. You can get around this by adding custom variables to the HttpContext, but that shouldn’t be necessary for most situations.

To add support for redirects and transfers, we can simply change our Web.config file by prepending “redirect.”, “transfer.”, or “rewrite.” to identify how we want the request handled. Then, update the IHttpHandler.ProcessRequest() method to treat them accordingly.

HttpHandler.ProcessRequest() Method

public void ProcessRequest(HttpContext context)
{
// declare vars
string requestedUrl;
string targetUrl;
int urlLength;

// save requested, target url
requestedUrl = context.Request.RawUrl;
if ( requestedUrl.IndexOf(“?”) >= 0 )
targetUrl = ConfigurationSettings.AppSettings[requestedUrl.Substring(0, requestedUrl.IndexOf(“?”))];
else
targetUrl = ConfigurationSettings.AppSettings[requestedUrl];

if ( targetUrl == null || targetUrl.Length == 0 )
targetUrl = requestedUrl;

// handle type
if ( targetUrl.StartsWith(“redirect.”) )
{
context.Response.Redirect(targetUrl.Substring(9));
}
else if ( targetUrl.StartsWith(“transfer.”) )
{
context.Server.Transfer(targetUrl.Substring(9));
}
else
{
// if type is specified, remove it
if ( targetUrl.StartsWith(“rewrite.”) )
targetUrl = targetUrl.Substring(8);

// save target url length
urlLength = targetUrl.IndexOf(“?”);
if ( urlLength == -1 )
urlLength = targetUrl.Length;

// rewrite path
context.RewritePath(targetUrl);
IHttpHandler handler = PageParser.GetCompiledPageInstance(
targetUrl.Substring(0, urlLength), null, context );
handler.ProcessRequest(context);
}

}

Conclusion

Well, congratulations on your first HTTP handler implementation. There is plenty of room for improvement, so try to think of how you can manage the mappings to add more than just a simple URL rewriting scheme. One thing that you might want to consider is a post-back processing component. Yes, post-back is handled by ASP.NET, but performance can be increased by removing that overhead. Anyway, my point is that there are a lot of things you can do to improve this simple implementation. I encourage you to add to this and let me know how well it works out for you. I’d be interested to hear some of the things people are doing with handlers. Good luck!

Special thanks to By Michael Flanakin,

This article was published on 26 Dec 2004 (http://www.developerfusion.com/article/4643/implementing-http-handlers-in-aspnet/1/ )

Posted in ASP.NET | Tagged: | Leave a Comment »

Suy nghĩ của những nhà kinh doanh đại tài

Posted by tcle on July 13, 2008

sự nhận thức rõ ràng rằng lực đẩy vô hình của tư duy có thể được chuyển hóa thành những phần thưởng vật chất qua việc áp dụng những nguyên lý đã biết

Edwin C. Barnes xuất hiện trước phòng thí nghiệm của Edison và nói với nhà phát minh rằng anh đến với ước muốn được cộng tác kinh doanh với ông. Nhiều năm sau, Edison kể lại cuộc gặp gỡ đầu tiên đó: – Theo VnExpress

Edwin C. Barnes xuất hiện trước phòng thí nghiệm của Edison và nói với nhà phát minh rằng anh đến với ước muốn được cộng tác kinh doanh với ông. Nhiều năm sau, Edison kể lại cuộc gặp gỡ đầu tiên đó:

“Anh ta đứng ngay trước mặt tôi, trông như mọi kẻ lang thang khác, nhưng nét mặt anh làm tôi có ấn tượng rằng người thanh niên này sẵn sàng và quyết tâm thực hiện bằng được những gì anh ta theo đuổi. Qua nhiều năm tiếp xúc với đủ hạng người, tôi nghiệm ra rằng, khi một người thực sự khao khát điều gì đó đến mức sẵn sàng đánh đổi bằng cả tương lai của mình, chắc chắn anh ta sẽ thành công. Tôi đã cho Barnes một cơ hội theo lời đề nghị của anh, bởi tôi biết rằng người như Barnes sẽ không bao giờ bỏ cuộc cho đến khi thành công. Những gì diễn ra sau đó đã chứng minh rằng tôi đúng”.

Điều gì đã khiến Barnes có được một vị trí trong văn phòng của Edison? Do vẻ bề ngoài như một kẻ lang thang của anh ư? Điều đó chỉ gây bất lợi cho Bernes. Nguyên nhân sâu xa là anh có một ý chí mãnh liệt muốn được cộng tác với Edison. Ý muốn mạnh mẽ ấy toát ra bên ngoài, tạo nên một sức hút buộc nhà phát minh phải chú ý đến chàng trai trẻ tuổi.

Barnes không được Edison chấp nhận cộng tác ngay từ đầu. Anh chỉ nhận được cơ hội làm việc trong văn phòng của Edison với một khoản tiền lương rất khiêm tốn.

Nhiều tháng trôi qua. Không có gì tiến triển để giúp Barnes tiến gần hơn tới mục tiêu lớn mà anh cam kết theo đuổi. Nhưng một điều quan trọng vẫn đang diễn ra trong tâm trí Barnes. Anh vẫn không ngừng nuôi dưỡng và làm sôi sục thêm khao khát trở thành người cộng tác kinh doanh với Edison.

Các nhà tâm lý học đã rất đúng khi cho rằng: “Khi một người thực sự muốn làm điều gì thì vẻ ngoài của họ sẽ thể hiện ra điều đó”. Barnes sẵn sàng cộng tác kinh doanh với Edison và anh luôn đặt mình ở tư thế sẵn sàng cho đến khi anh đạt được điều mong muốn.

Anh không tự bao biện với chính mình rằng: “Thôi nào Bernes, cộng tác với Edison thì cũng được ích lợi gì cơ chứ? Ta sẽ đổi ý và cố gắng làm tốt công việc của một người bán hàng”. Ngược lại, anh khẳng định với chính mình: “Ta đến đây để hợp tác kinh doanh với Edison và ta sẽ đạt được mục đích đó dù phải bỏ ra toàn bộ quãng đời còn lại của mình”. Anh thật sự khao khát điều đó. Cuộc đời mỗi con người sẽ khác đi bao nhiêu nếu như họ xác định được cho mình một mục đích rõ ràng và kiên trì theo đuổi mục đích đó cho đến khi nó trở thành nỗi ám ánh của cả cuộc đời họ.

Có lẽ vào thời điểm đó, chàng trai trẻ tuổi Barnes chưa hiểu được điều này, nhưng quyết tâm sắt đá và sự kiên định theo đuổi một ước mơ duy nhất đã gạt bỏ mọi chướng ngại, đồng thời đem đến cho Bernes cơ hội mà anh đang tìm kiếm.

Tuy nhiên, cơ hội lại xuất hiện dưới một hình thức khác và từ một hướng khác so với dự kiến của Barnes. Đó là một trong những vấn đề rắc rối của cơ hội. Cơ hội thường có thói quen “ma mãnh” là “lẻn” vào theo cửa sau và được ngụy trang dưới hình thức một điều bất hạnh hay một thất bại tạm thời. Có lẽ đó chính là lý do khiến nhiều người không nhận ra chúng.

Edison vừa hoàn thiện được một thiết bị văn phòng mới, lúc bấy giờ được gọi là Máy đọc Edison. Những người bán hàng của ông không tha thiết gì với chiếc máy này vì họ cho rằng việc tiêu thụ sẽ rất khó khăn. Nhưng Barnes đã nhìn thấy cơ hội của mình. Cơ hội ấy đến thầm lặng và ẩn mình trong chiếc máy có vẻ kỳ quặc chẳng làm ai quan tâm, ngoại trừ Barnes và nhà phát minh.

Barnes biết rằng anh có thể bán được Máy đọc Edison và anh nói với Edison điều đó. Edison quyết định trao cơ hội này cho Barnes. Và trên thực tế, Barnes đã thành công. Anh bán chiếc máy chạy đến mức Edison đã ký một hợp đồng cho phép anh phân phối loại máy này trên toàn quốc. Nhờ cách hợp tác kinh doanh đó, Barnes đã trở nên giàu có, nhưng anh còn làm được một việc có ý nghĩa lớn hơn thế rất nhiều. Anh đã chứng minh rằng mọi người đều có thể trở nên giàu có nhờ cách nghĩ.

Ý định ban đầu được trở thành người hợp tác kinh doanh với Edison của Barnes thực tế trị giá bao nhiêu tiền? Khó mà tính được một cách chính xác. Có lẽ nó mang lại cho anh hai hay ba triệu đôla lúc bấy giờ (ba triệu đôla vào những năm đầu của thế kỷ 20 tương đương với khoảng năm mươi triệu đôla ở thời điểm đầu thế kỷ 21 nếu xét trên tương quan sức mua). Nhưng số tiền ấy trở nên vô nghĩa nếu so với món tài sản lớn hơn nhiều mà Barnes nhận được: đó là sự nhận thức rõ ràng rằng lực đẩy vô hình của tu duy có thể được chuyển hóa thành những phần thưởng vật chất qua việc áp dụng những nguyên lý đã biết.

Barnes đã thực sự luôn tâm niệm rằng mình phải trở thành người cộng tác với Edison vĩ đại. Anh cũng luôn tâm niệm rằng mình phải trở nên giàu có. Barnes khởi đầu từ con số không. Tài sản duy nhất anh có được là sự nhận thức rõ ràng bản thân mình muốn gì và quyết tâm theo đuổi ước muốn ấy cho đến khi thành công. Nhưng chính “khối” tài sản tinh thần vô giá đó lại là thứ quan trọng nhất giúp anh đạt được những ước muốn trong cuộc đời mình.

Theo Napoleon Hill – tác giả cuốn sách “Cách nghĩ để thành công”, một trong những nguyên nhân phổ biến nhất của thất bại là thói quen dễ dàng từ bỏ mơ ước khi gặp phải những thất bại tạm thời. Trong cuộc đời mình, mỗi người chúng ta ai cũng đã từng phạm phải sai lầm này, không lúc này thì lúc khác.

Ông nhớ lại: “Tôi có một người bạn là R.U. Darby. Vào thời điểm mà người ta đổ xô đi đào vàng, ông chú của R.U. Darby cũng bị cuốn theo “cơn sốt vàng” đó và đã đi về hướng tây đến Colorado để đào vàng với hy vọng trở nên giàu có. Chưa ai nói với ông rằng số vàng được “khai thác” từ tư tưởng con người lớn hơn nhiều số vàng đã được khai thác trong lòng đất. Ông ấy đã đánh cuộc và vác cuốc xẻng ra đi.

Sau nhiều tuần lao động vất vả, ông chú của Darby phát hiện ra một mỏ quặng sáng lấp lánh. Ông cần có thiết bị để đưa quặng lên khỏi mặt đất nên đã âm thầm lấp mỏ và trở về nhà ở Williamsburg, Maryland. Ông kể với người thân và một vài người láng giềng rằng mình đã dò trúng mạch. Họ gom góp tiền để mua máy móc và chở đến đó. Darby cũng quyết định tham gia và cùng với chú mình quay trở lại mỏ.

Chuyến xe đầu tiên chở quặng vừa khai thác được chuyển tới một xưởng nấu kim loại. Kết quả cho thấy họ đã tìm được một trong những hầm mỏ có hàm lượng vàng cao nhất Colorado. Chỉ cần vài chuyến xe chở quặng như thế này nữa là họ sẽ đủ khả năng trang trải hết nợ nần và sau đó tha hồ mà làm giàu.

Càng đào xuống sâu thì hy vọng của Darby và ông chú càng lên cao. Thế nhưng ánh sáng hy vọng dường như đã tắt ngấm. Các mạch vàng bỗng dưng biến mất. Giấc mộng của họ tan vỡ trong phút chốc khi suy nghĩ mỏ vàng mà họ đang tìm kiếm bỗng nhiên không còn ở đó nữa. Họ cố gắng đào tiếp một đoạn nữa nhằm tìm lại dấu vết của mạch vàng nhưng dường như mọi cố gắng đều trở nên vô ích.

Cuối cùng họ quyết định bỏ cuộc.

Họ bán hết máy móc cho một người mua phế liệu để lấy vài trăm đôla, rồi lên tàu lửa trở về nhà. Người mua phế liệu mời một kỹ sư mỏ đến xem xét đánh giá lại và làm một vài tính toán nhỏ. Người kỹ sư nói rằng sở dĩ việc khai thác thất bại vì chủ hầm cũ không biết nhận ra những tuyến đứt gãy địa chất. Tính toán của ông ta cho thấy mạch chính chỉ cách nơi chú cháu Darby đã ngừng đào có gần một thước. Và đó mới chính là túi chứa vàng.

Người thu mua phế liệu kiếm được hàng triệu đôla từ hầm mỏ đó bởi ông ấy biết tìm chuyên gia tư vấn có kinh nghiệm trước khi bỏ cuộc.

Sau đó nhiều năm, Darby có được một tài sản lớn hơn nhiều lần kho báu hụt trước đó nhờ phát hiện ra rằng khát vọng có thể được chuyển thành vàng. Phát hiện này đến với Darby khi anh bước vào nghề kinh doanh bảo hiểm nhân thọ.

Để hụt mất một kho báu chỉ vì từ bỏ khi còn cách vàng một thước đã trở thành một bài học khó quên với Darby. Nhưng anh đã ứng dụng bài học bổ ích đó để thành công trong lĩnh vực kinh doanh mới của mình. Anh luôn tự nhủ: “Mình đã từng bỏ cuộc khi chỉ còn cách kho báu gần một thước, nhưng mình sẽ không bao giờ dừng lại nếu khách hàng nói “không” khi mình mời họ mua bảo hiểm”.

Darby trở thành một trong số rất ít người có doanh số bán bảo hiểm nhân thọ trên một triệu đôla một năm. Giờ đây, anh đã có được “sự bền gan vững dạ” nhờ bài học từ việc “bỏ cuộc giữa chừng” trước đó.

Bất kỳ ai trước khi đi đến thành công đều gặp phải rất nhiều khó khăn thử thách và có thể cả thất bại. Khi gặp khó khăn trở ngại, cách dễ dàng nhất và có vẻ như hợp lý nhất là bỏ cuộc. Đó cũng chính là cách mà đa số chúng ta vẫn thường làm.

Hơn năm trăm người thành đạt nhất nước Mỹ đều nói với tôi rằng những thành quả lớn lao nhất mà họ đạt được thường chỉ cách thất bại trong gang tấc. Thất bại là một tên đại bịp ranh mãnh luôn châm chọc người khác. Hắn rất thích khoèo chân, ngáng bước bạn khi thành công gần như đã nằm chắc trong tầm tay”.

Bài học 50 xu về lòng kiên trì

Không lâu sau khi nhận bằng “tốt nghiệp” từ “Trường Đại học Thất bại”, Darby đã chứng kiến một câu chuyện khiến anh nghiệm ra rằng từ “Không” không nhất thiết phải có nghĩa là “Không”.

Một buổi chiều trong khi anh đang phụ ông bác xay lúa mì trong nhà xay cũ của ông ấy – ông bác này làm chủ một trang trại lớn trong đó có một số nông dân da màu làm công hưởng hoa lợi – thì cánh cửa nhẹ nhàng mở ra và một cô bé da màu, con gái của một tá điền, bước vào và đứng bên cửa.

Ông bác nhìn lên, trông thấy cô bé và quát cộc lốc: “Mày muốn gì?”

Cô bé lễ phép đáp: “Mẹ cháu bảo ông đưa cho mẹ cháu năm mươi xu.”

“Tao không đưa!”, ông bác nạt lại. “Mày biến về nhà đi!”

Nhưng cô bé không hề nhúc nhích.

Ông bác tiếp tục cặm cụi làm việc của mình nên không nhận thấy cô bé vẫn còn đứng đó. Khi ông ngẩng đầu lên lần nữa, và nhìn thấy con bé, ông ấy hét: “Tao đã bảo mày về nhà kia mà! Đi đi, không tao quất cho một trận bây giờ!”

Cô bé vẫn đứng bất động.

Ông bác quẳng bao lúa mì mà ông sắp cho vào máy xay xuống và hằm hằm tiến về phía cô bé.

Darby nín thở và chắc rằng mình sắp chứng kiến một trận lôi đình của ông bác tính tình nóng nảy.

Khi ông bác đến gần chỗ đứa bé đang đứng, nó nhanh chóng bước lên một bước, nhìn thẳng vào mắt ông và rít lên: “Mẹ cháu phải có năm mươi xu đó!”.

Ông bác sững lại, nhìn chằm chằm vào cô bé rồi cho tay vào túi lấy năm mươi xu đưa cho nó.

Cô bé cầm tiền và chầm chậm lùi về phía cửa trong khi mắt vẫn nhìn xoáy vào người đàn ông to lớn vừa bị khuất phục trước nó. Sau khi cô bé đi khỏi, ông bác ngồi bệt xuống một cái thùng, ánh mắt thất thần nhìn ra khoảng trống vô định ngoài cửa sổ trong hơn mười phút. Ông ngẫm nghĩ trong bàng hoàng về “ngón đòn” mà cô bé đã sử dụng để hạ gục mình.

Darby cũng đang suy nghĩ. Đây là lần đầu tiên trong đời, anh thấy một đứa con nít da màu nhỏ bé ung dung hạ gục một người đàn ông da trắng. Cô bé đã làm điều đó bằng cách nào? Điều gì đã tước mất sự hung hãn của ông bác và biến ông trở nên ngoan ngoãn như một con cừu non? Cô bé ấy đã sử dụng sức mạnh kỳ lạ nào để làm chủ được tình thế? Những câu hỏi như thế cứ liên tục nảy sinh trong tâm trí Darby. Nhưng mãi nhiều năm sau, khi kể lại cho tôi câu chuyện này, anh mới tìm được câu trả lời.

“Điều kỳ lạ là Darby đã kể cho tôi nghe câu chuyện khác thường này chính tại căn nhà xay cũ kỹ, ngay chỗ ông bác của Darby bị “trúng đòn” của cô bé”, Napoleon Hill nói.

“Darby thuật lại câu chuyện trên trong nhà xay lúa mốc meo cũ kỹ đó và kết thúc bằng câu hỏi: “Anh có thể giải thích được không? Cô bé kia đã sử dụng sức mạnh thần kỳ gì để hạ gục hoàn toàn ông bác tôi?”.

Câu trả lời đầy đủ cho câu hỏi của Darby sẽ được tìm thấy trong những nguyên tắc được đề cập đến trong quyển sách này. Câu trả lời rất tường tận và hoàn chỉnh, chứa đựng mọi chi tiết và những chỉ dẫn giúp bạn hiểu và áp dụng sức mạnh mà cô bé đã ngẫu nhiên sử dụng.

Hãy tập trung cao độ và bạn sẽ hiểu được chính xác sức mạnh kỳ lạ nào đã cứu cô bé. Có thể bạn đã nắm bắt được phần nào sức mạnh ấy trong chương này hoặc bạn sẽ nhận thức được nó trong những chương kế tiếp. Rồi đâu đó trong quyển sách này, bạn sẽ tìm thấy một ý tưởng đẩy nhanh khả năng lĩnh hội của bạn và khiến bạn lúc nào cũng có thể kiểm soát được nguồn sức mạnh không gì có thể cưỡng lại được ấy. Nó có thể xuất hiện dưới hình thức một ý tưởng đơn lẻ, một kế hoạch đầy đủ hay một mục đích nào đó. Ngoài ra, sức mạnh ấy có thể khiến bạn nhìn lại kỹ càng hơn những khó khăn hay thất bại trong quá khứ. Điều này sẽ giúp bạn rút ra được một vài bài học bổ ích mà nhờ nó bạn có thể lấy lại được những gì đã mất.

Sau khi tôi giải thích cho Darby sức mạnh mà cô bé da màu đã vô tình sử dụng, anh đã hồi tưởng lại ba mươi năm kinh nghiệm trong nghề bán bảo hiểm nhân thọ, và anh nhận ra rằng thành công của mình có phần không nhỏ từ bài học anh đã học được từ cô bé.

Darby kể lại: “Mỗi lần một khách hàng tiềm năng nào đó chào tiễn tôi ra cửa mà không mua bảo hiểm của tôi, tôi lại nhớ đến hình ảnh cô bé đứng đấy trong cái nhà xay cũ, mắt mở to đầy thách thức, và tôi tự nhủ: “Tôi phải bán bằng được hợp đồng bảo hiểm này.” Phần nhiều những hợp đồng mà tôi bán được đều từ những người đã từng nói “Không” với tôi”.

Anh cũng nhắc lại sai lầm của mình khi bỏ cuộc cách mỏ vàng chưa đầy một thước. Anh nói: “Nhưng đúng là trong cái rủi có cái may. Lần thất bại đó đã dạy tôi rằng phải luôn nỗ lực không ngừng cho dù có khó khăn đến đâu. Đó là một bài học cần thiết trước khi có thể thành công trong bất cứ việc gì”.

Những kinh nghiệm của Darby rất đỗi bình thường và khá đơn giản, vậy mà chúng nắm giữ chìa khóa quyết định cho số phận của anh. Vì thế, chúng cũng quan trọng như chính cuộc đời anh. Darby đã gặt hái lợi ích từ hai kinh nghiệm sâu sắc trên vì anh đã biết phân tích chúng và tìm thấy bài học ẩn chứa trong đó.

Sẽ ra sao nếu như bạn không có dịp trải nghiệm qua những câu chuyện có ý nghĩa sâu sắc như thế? Sẽ ra sao đối với những người trẻ tuổi chưa từng gặp phải những va vấp thất bại trong cuộc đời để phân tích? Ở đâu và bằng cách nào họ có thể học được nghệ thuật chuyển bại thành thắng, chuyển thách thức thành cơ hội?

Câu trả lời nằm trong mười ba nguyên tắc. Những nguyên tắc đó có thể đứng riêng lẻ với nhau hoặc tập hợp lại như những chất xúc tác. Hãy luôn nhớ rằng câu trả lời mà bạn đang tìm kiếm có thể đã có sẵn trong chính tâm trí của bạn rồi. Việc nắm bắt những nguyên tắc này sẽ chỉ như một chất xúc tác giúp bạn biến câu trả lời đó thành một vài tư duy rõ ràng, một kế hoạch cụ thể, hay một mục đích nhất quán mà thôi.

Một ý tưởng đúng đắn, kiên định là tất cả những gì bạn cần để đi tới thành công. Những nguyên tắc được đề cập đến trong quyển sách này chứa đựng những phương pháp và phương tiện tốt nhất, hữu ích nhất giúp bạn sáng tạo nên những ý tưởng như thế.

Ý thức về sự thành công

Trước khi tôi đi xa hơn trong việc mô tả những nguyên tắc này, bạn nên nắm bắt được gợi ý quan trọng sau. Khi của cải bắt đầu đến, nó đến nhanh và nhiều đến mức người ta tự hỏi rằng không biết trong những năm tháng gian khó vừa qua nó đã trốn nơi đâu?

Phát biểu trên có thể làm bạn kinh ngạc, đặc biệt nếu như bạn luôn suy nghĩ theo quan niệm thông thường rằng sự giàu có chỉ đến với những người làm việc chăm chỉ trong một khoảng thời gian dài.

Khi bạn bắt đầu nhận thức được rằng cách nghĩ có thể mang lại sự giàu sang, bạn sẽ thấy rằng sự giàu có luôn bắt nguồn từ một trạng thái mang tính chất tinh thần, từ một mục đích rõ ràng chứ không phải bởi bạn có làm việc cật lực hay không. Những gì mà bạn và mọi người khác nên biết là làm thế nào để có được một trạng thái tinh thần tạo ra sự giàu có như thế. Tôi đã dành hai mươi lăm năm để nghiên cứu điều đó vì bản thân tôi cũng muốn biết “những người giàu có đã làm thế nào để đạt được những thành quả như vậy”.

Bạn sẽ nhận thấy rằng ngay khi bạn nắm được những nguyên tắc của triết lý thành công này, và bắt đầu ứng dụng những nguyên tắc đó, tình hình tài chính của bạn sẽ được cải thiện. Nói một cách hoa mỹ thì mọi thứ bạn “chạm tay” vào sẽ biến thành “vàng”. Bạn cho rằng không thể được ư? Thế mà đúng như vậy đấy.

Một trong những điểm yếu của người bình thường là họ luôn có xu hướng nghĩ mọi việc đều “không thể”. Đối với họ thì mọi quy tắc đều vô tác dụng, mọi ước mơ đều không thể thực hiện được. Cuốn sách này được viết cho những người đang thật sự nỗ lực tìm kiếm những quy tắc đã giúp những người thành đạt đi tới vinh quang và sẵn lòng đặt cược mọi thứ vào những quy tắc đó.

Thành công chỉ đến với những ai thật sự có ý thức mãnh liệt muốn đạt được nó.

Thất bại sẽ đến với những người luôn nghĩ rằng mình sẽ thất bại.

Một điểm yếu khác của con người là thói quen đánh giá sự việc và những người xung quanh bằng cảm giác qua lăng kính chủ quan của riêng họ. Rất nhiều người không tin rằng chỉ bằng suy nghĩ người ta có thể đạt được sự giàu sang. Đơn giản chỉ bởi nếp nghĩ của họ từ lâu đã hằn sâu một quan niệm rằng số phận của mình sẽ phải chịu cảnh nghèo nàn, cực khổ, khó khăn và thất bại.

Kiểu suy nghĩ thiếu tích cực như vậy gợi tôi nhớ đến câu chuyện về một người Trung Quốc đến Mỹ du học tại trường đại học Chicago. Một ngày nọ, Hiệu trưởng Harper gặp người thanh niên trẻ tuổi ấy trong khuôn viên của trường đại học và dừng lại trò chuyện với anh ta trong vài phút. Ngài Hiệu trưởng đã hỏi anh ta rằng đặc điểm nào dễ nhận thấy nhất trong tính cách của người Mỹ làm anh ấn tượng.

“Ồ” Anh sinh viên nói lớn, “đó chính là đôi mắt lệch của ngài.”

Người thanh niên Trung Quốc đã dùng cách chơi chữ rất mỉa mai để ám chỉ tính cách thiên kiến, thói quen nhìn mọi sự lệch lạc của người Mỹ.

Tất cả chỉ là vấn đề của quan niệm và thói quen.

Chúng ta thường không tin cái mà chúng ta không hiểu. Chúng ta không tin vào những điều kỳ diệu mà con người có thể đạt được bằng suy nghĩ của mình. Chúng ta luôn có thói quen nhìn cuộc sống bằng quan niệm của mình vì thế chúng ta cho rằng giới hạn của chúng ta là thước đo đúng đắn cho mọi giới hạn.

Chiếc Ford V8 với động cơ không tưởng

Khi Henry Ford quyết định chế tạo chiếc xe hơi V8 nổi tiếng của mình, ông dự định thiết kế một loại động cơ mới với toàn bộ tám xi-lanh gộp thành một khối. Ông chỉ thị các kỹ sư của mình vẽ mẫu thiết kế cho động cơ này. Bản thiết kế đã được hình thành trên lý thuyết nhưng các kỹ sư đều đồng loạt cho rằng, trên thực tế, việc chế tạo một động cơ với tám xi-lanh là không tưởng.

Nhưng Ford kiên quyết: “Bằng mọi giá, hãy chế tạo ra nó!”.

“Nhưng thật sự là không thể làm được!”, các kỹ sư trả lời.

“Cứ cố gắng hết sức mình đi”, Ford ra lệnh. “Hãy làm cho đến khi các anh thành công, dù phải mất bao nhiêu thời gian đi nữa.”

Các kỹ sư lại lao vào tìm tòi, thiết kế. Sáu tháng trôi qua, không có gì tiến triển. Rồi sáu tháng nữa lại trôi qua, vẫn chẳng có gì mới mẻ. Các kỹ sư đã thử đủ mọi cách để giải quyết vấn đề, nhưng mọi thứ chỉ có thể gói gọn trong hai từ “không thể”.

Cuối năm, Ford đến gặp các kỹ sư của mình. Một lần nữa, họ lại cho ông biết rằng không có cách nào giải quyết được vấn đề nan giải đó.

“Hãy tiếp tục!”, Ford nói. “Tôi muốn có nó và tôi phải có nó!”

Họ lại tiếp tục. Và sau đó, như có phép màu, điều bí ẩn đã được khám phá.

Lòng quyết tâm của Ford một lần nữa lại chiến thắng!

Henry Ford thành công vì ông đã hiểu và áp dụng những nguyên tắc dẫn đến thành công. Một trong số những nguyên tắc đó là niềm khao khát thành công: biết rõ những gì mình thật sự mong muốn. Hãy ghi nhớ câu chuyện của Ford, hãy trích ra những dòng miêu tả lại bí quyết để đạt được thành quả kỳ diệu như của ông ấy. Nếu bạn có thể làm được điều đó, nếu bạn có thể cảm nhận được những nguyên tắc cụ thể đã làm cho Henry Ford trở nên giàu có, bạn cũng có thể đạt được những thành tựu không kém gì Ford trong gần như tất cả những ngành nghề phù hợp với bạn.

(Trích cuốn “Cách nghĩ để thành công” do Công ty First News phát hành)

Posted in Interests, Observation | Tagged: | Leave a Comment »

Short-cut you might not know in Ubuntu

Posted by tcle on June 24, 2008

nautilus / gnome:

ctrl-h : show hidden files

ctrl-t : move to trash

f9 : toggle side-pane

alt-home : jump to home folder

alt-enter : file / folder properties

alt-f1 : launch applications menu

alt-f2 : launch “run application” dialogue

ctrl-alt – right/left arrow : move to the next virtual desktop

ctrl-alt-shift – right/left arrow : take current window to the next virtual desktop

firefox:

ctrl-k : firefox search field

ctrl-l : firefox address bar

ctrl-pgup : next tab (left to right)

ctrl-pgdn : previous tab (right to left)

ctrl-t : new tab

ctrl-r / f5: reload page

ctrl-u : view page source

Source: http://ubuntu-tutorials.com/2007/02/20/shortcut-keys-you-might-not-know-about/

Posted in Interests | Tagged: , | Leave a Comment »

Install Google Gadgets on Ubuntu

Posted by tcle on June 21, 2008

Google has released a platform for running their widget applications (Google Desktop Gadgets and web-based Universal Gadgets) on Linux. Google Gadgets for Linux is an open source project, and includes front-ends for GNOME and KDE environments.

Google Gadgets for Linux provides the largest missing feature from the Linux version of Google Desktop, which includes gadgets only in the Windows and Mac OS versions.

Compiz desktop effects or another compositing window manager are recommended for running Google Gadgets. Note that Google Gadgets is still in a development stage. You may also be interested in Screenlets, which can also run Google’s universal gadgets.

a few Google Gadgets

Install Google Gadgets from GetDeb
GetDeb.net has an Ubuntu package of the latest version of Google Gadgets. Download the package, and double click the file to open the installer.

Install Google Gadgets from repository
An unofficial repository for Google Gadgets is available. Unfortunately, this repository has not been updated at the time of writing to the latest version (0.9.3) of Google Gadgets, which includes some important fixes. I’ll leave these instructions here also for when the repository is updated.

Open System->Administration->Software Sources, and select the Third-Party Software tab. Click Add, and paste in this repository entry:
deb http://ppa.launchpad.net/googlegadgets/ubuntu hardy main

Close the Software Sources dialog and when prompted, reload the software repositories.

Install Google Gadgets for Linux from the package google-gadgets (click the link to install), or by running the command below in your terminal:
sudo apt-get install google-gadgets

Running Google Gadgets for Linux
You can run Google Gadgets from the Run Application dialog (Alt-F2), or from the terminal with this command:
ggl-gtk -ns

The -ns option disables the sidebar, which I have found to work very poorly. Remove this option from the command if you want the sidebar.

Once Google Gadgets is running, you can control it from the notification area icon. Right click on it and select Add Gadgets to get started adding Gadgets to your desktop.

Google Gadgets browser

Start Google Gadgets Automatically
To start Google Gadgets when you log in, open System->Preferences->Sessions. Click Add and create a new item for Google Gadgets with the command ggl-gtk.

Compiz Widget Layer integration
Just like with Screenlets, you can use Compiz’s Widget Layer plugin to get an effect similar to Mac OS’ dashboard. You will need to have the Advanced Desktop Effects Settings tool (CCSM) installed, and be using the custom desktop effects level.

Launch System->Preferences->Advanced Desktop Effects Settings. Enable the Widget Layer plugin, and enter its preferences screen. Select the Behavior tab, and type the following into the Widget Windows text box:
class=Ggl-gtk

Your gadgets should now be hidden. Press F9 to toggle the widget layer to show and hide them.

Posted by Tom in software

Posted in Interests | Tagged: , , | 1 Comment »

Aggregation v.s. Composition (a review on UML)

Posted by tcle on May 20, 2008

Aggregation

Aggregation is a kind of association that specifies a whole/part relationship between the aggregate (whole) and component part. This relationship between the aggregate and component is a weak “has a” relationship as the component may survive the aggregate object. The component object may be accessed through other objects without going through the aggregate object. The aggregate object does not take part in the lifecycle of the component object, meaning the component object may outlive the aggregate object. The state of the component object still forms part of the aggregate object.

An example of aggregation is a History-Class object contains zero or more of Student objects. The state of each Student object has an influence on the state of the History-Class object. If the History-Class object is destroyed, the Student objects may continue to exist.

The UML diagram above illustrates the aggregation association line with an open diamond on the aggregate side.

Composition

Composition is a kind of association very similar to aggregation except where the composite object has sole responsibility for the disposition of the component parts. The relationship between the composite and the component is a strong “has a” relationship, as the composite object takes ownership of the component. This means the composite is responsible for the creation and destruction of the component parts. An object may only be part of one composite. If the composite object is destroyed, all the component parts must be destroyed, or the reference and responsibility of the component part must be handed over to another object. Composition enforces encapsulation as the component parts usually are members of the composite object.

An example of composition is a House object contains zero or more Room objects. The state of each Room object has an influence on the House object. If the House object is destroyed, the Room objects will also be destroyed.

The UML diagram above illustrates the composition association line with a solid diamond on the composite side.

Source: http://www.javadesign.info/DesignConcepts/OOConcepts/aggregationcomposition

Posted in Design & Pattern | Tagged: | 14 Comments »

Creating a Self-Signed SSL Certificate without a mess of makecert.exe (using SSL Diagnostics Tool)

Posted by tcle on May 20, 2008

Introduction:

So you have a server and you need to implement SSL to allow secure (https) communication. What choices do you have? You can buy a certificate from certification authority or you can issue a Self-Signed certificate to yourself. The difference is that your browser “knows” it can trust the certificates from the authorities (it has it installed). But when the browser encounters the https connection with a server with the self-signed certificate, the user is presented with a message like this:

Thus, self-signed certificates are OK for test and development web sites, but generally not OK for public websites.
This article will show you the simplest ways to create a Self-Signed SSL Certificate.

Here are your options. (Or just go to the Best Solution )

Solution 1 (quite long, but recommended by Microsoft)
Setting Up SSL Using IIS and Certificate Server

MS recommends that you get the certificate from the certificate server. This means that you have to have an access to Window 2000 or Windows 2003 server with “Certification Services” installed. You use IIS MMC to generate request to this server. Then using browser you submit this request to the server. Then, when somebody at that server approves the request, you will get back a certificate.
See details at http://support.microsoft.com/default.aspx?kbid=299525

Solution 2 (fast, but sometimes could be tricky)
Creating Self-Signed SSL Certificates using makecert.exe

It is a quite simple solution. The only problem is that sometimes it just doesn’t work, and it’s hard to determine what is wrong. The makecert.exe comes with VS.NET. It you don’t have .NET Framework 1.1 installed, the makecert might be outdated. You can download a newer version from http://download.microsoft.com/download/platformsdk/Update/5.131.3617.0/NT45XP/EN-US/makecert.exe
Just replace yourservername with the computer name of your PC and run:

makecert -r -pe -n “CN=yourservername” -b 01/01/2000 -e 01/01/2050 -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localMachine -sky exchange -sp “Microsoft RSA SChannel Cryptographic Provider” -sy 12

Then go to the IIS “Web Site Properties”, “Directory Security”, “Server Certificate…”, “Assign an existing certificate” and select the new certificate from the list.
It works? Fine! No? Go to the Best Solution

Solution 3 (OK for not-technical users)
Download a test certificate from certification authorities
The certificate companies like VeriSign and Thawte issue test certificates, but they expire after 90 days or so, and the process of getting it could be quite tedious.

Solution 4 (The Best and Recommended)
Create a Self-Signed Certificate using SSL Diagnostics Tool

Avoid all this pain with a nice tool from Microsoft: SSL Diagnostics . Download setup.exe (2112 KB) from here: http://www.microsoft.com/downloads/details.aspx?familyid=CABEA1D0-5A10-41BC-83D4-06C814265282&displaylang=en

Install it and run. In the main window of SSL Diagnostics, right-click the Web site level (shown by [W3SVC/<site number>]), and then click Create New Certificate.


That is it. You are done. Don’t forget to explore other capabilities of this nice tool.

Source: http://pranas.net/Tutorials/ssl/SSLDiagnostics.htm

Posted in ASP.NET | Tagged: , | 3 Comments »