Category: tip


Hướng dẫn cài đặt Google Custom Search

Như bạn biết, WordPress có kèm công cụ tìm kiếm nhưng công cụ này hoạt động chưa thật sự hiệu quả. Mỗi lần search là 1 lần truy xuất vào Database, đối với các Blog lớn, lượng người search cao thì điều này sẽ ảnh hưởng không tốt , cụ thể là tốc độ tải site sẽ chậm đi do quá nhiều truy xuất tới Database.

Google Custom Search là 1 công cụ tìm kiếm hiệu quả, sẽ loại bỏ tất cả các khuyết điểm trên. Ưu điểm của Google Custom Search:

  • Tìm kiếm cực kì chính xác
  • Không truy xuất tới Database của trang web
  • Kết hợp được với tài khoản Google Adsense để kiếm tiền
  • Nhiều tùy chỉnh cho việc hiện kết quả

Bài viết này, Minh Mèo sẽ hướng dẫn cách thiết lập Google Custom Search và cách chèn vào blog của bạn.

Cài đặt Google Custom Search

Vào Google Custom Search để tạo/quản lí nếu bạn có/chưa có bộ tìm kiếm nào.

Nhấn nút Create a Custom Search Engine

Màn hình tiếp theo yêu cầu bạn nhập thông tin cho bộ tìm kiếm này

  • What do you want to search: lựa chọn các trang web muốn tìm kiếm
  • Select some sites: điền tên các trang web muốn tìm kiếm ( ở đây tớ điền :http://minhmeo.info/* để tìm các kết quả trong trang web của tớ thôi)

Còn lại bạn làm như hình rồi nhấn Next sang bước tiếp theo. Ở trang tiếp theo này không có gì cả, chỉ là trang preview nên các bạn tiếp tục nhấn Finish. Lựa chọn bộ tìm kiếm bạn tạo, nhấn control panel

 

Nhấn vào Control Panel để cài đặtNhấn vào Control Panel để cài đặt

Ở cột Control Panel bên trái, kéo xuống dưới chọn Look and Feel.

  • Choose a hosting option: nơi kết quả hiện ra

  1. Search element: hiện ngay kết quả trên trang web bạn đang tìm kiếm ( Minh Mèo dùng cách này cho đơn giản )
  2. Iframe: hiện ra ở 1 trang khác trên website của bạn. Giả sử: http://minhmeo.info/tim-kiem/
  3. Google-hosted page: hiện kết quả trên website của Google
  • Choose a layout for Search element: chọn layout Compact để chèn vào Sidebar cho nhỏ gọn

  • Choose or customize a style: lựa chọn skin hiện kết quả. Blog Minh Mèo sử dụng Minimalist cho nổi bật so với tông màu trắng của Blog.

Nhấn Get Code để lấy code chèn vào Blog.

 

Đây là Code của bạn. Copy!Đây là Code của bạn. Copy!

Chèn code vào Blog.

Vào Appearance > Widgets. Chọn Text , thả vào sidebar bạn muốn hiện bộ tìm kiếm và copy đoạn code trên vào ô Content sau đó save lại.

 

 

 

Như vậy là bạn đã cài đặt thành công bộ tìm kiếm cho Blog của mình

 

Removing The Dotted Outline

Anchor links (<a>’s) by default have a dotted outline around them when the become “active” or “focused”. In Firefox 3, the color is determined by the color of the text. I believe in previous versions and in some other browsers it is by default gray. This is default styling for the purpose of accessibility. For folks without the ability to use a mouse, they still need some visual indicator that they currently have a link active (so, for example, they can press enter to navigate to that link). Continue reading “Removing The Dotted Outline” »

The Evolution of the Web Developer

In the past, memory leaks haven’t posed huge problems for Web developers. Pages were kept relatively simple and navigation between different locations within a site was a great way to clean up any loose memory. If there was a leak, it was most likely small enough to go unnoticed.

New Web applications live up to higher standards. A page might run for hours without being navigated and retrieve updated information dynamically through Web services. Language features are pushed to the breaking point by combining complex event schemes, object-oriented JScript, and closures to produce entire applications. With these and other changes, certain memory leak patterns are becoming more prominent, especially those previously hidden by navigation.

The good news is that memory leak patterns can be easily spotted if you know what to look for. Most of the troublesome patterns you might face have known workarounds requiring only a small amount of extra work on your behalf. While some pages might still fall prey to small memory leaks, the most noticeable ones can be easily removed.

Leak Patterns

The following sections will discuss patterns of memory leaks and point out some common examples of each pattern. One great example of a pattern is the closure feature of JScript, while another example is the use of closures in hooking events. If you’re familiar with the event hooking example, you might be able to find and fix many of your memory leaks, but other closure-related issues might go unnoticed.

Now, let’s look at the following patterns:

  1. Circular References—When mutual references are counted between Internet Explorer’s COM infrastructure and any scripting engine, objects can leak memory. This is the broadest pattern.
  2. Closures—Closures are a specific form of circular reference that pose the largest pattern to existing Web application architectures. Closures are easy to spot because they rely on a specific language keyword and can be searched for generically.
  3. Cross-Page Leaks—Cross-page leaks are often very small leaks of internal book-keeping objects as you move from site to site. We’ll examine the DOM Insertion Order issue, along with a workaround that shows how small changes to your code can prevent the creation of these book-keeping objects.
  4. Pseudo-Leaks—These aren’t really leaks, but can be extremely annoying if you don’t understand where your memory is going. We’ll examine the script element rewriting and how it appears to leak quite a bit of memory, when it is really performing as required.

Circular References

Circular references are the root of nearly every leak. Normally, script engines handle circular references through their garbage collectors, but certain unknowns can prevent their heuristics from working properly. The unknown in the case of IE would be the status of any DOM elements that a portion of script has access to. The basic principle would be as follows:

Figure 1 Basic Circular Reference Pattern

Figure 1. Basic Circular Reference Pattern

The cause of the leak in this pattern is based on COM reference counting. The script engine objects will hold a reference to the DOM element and will be waiting for any outstanding references to be removed before cleaning up and releasing the DOM element pointer. In our case we have two references on the script engine object: the script engine scope, and the DOM element expando property. While terminating the script engine will release the first reference, the DOM element reference will never be released because it is waiting on the script engine object to release it! You might think it would be easy to detect this scenario and fix the problem, but in practice the basic case presented is only the tip of the iceberg. You could have circular references at the end of a 30 object chain and those would be much harder to detect.

If you are wondering what this pattern looks like in HTML, you can cause a leak by using a global script engine variable and a DOM element as shown.

<html>
    <head>
        <script language="JScript">

        var myGlobalObject;

        function SetupLeak()
        {
            // First set up the script scope to element reference
            myGlobalObject =
                document.getElementById("LeakedDiv");

            // Next set up the element to script scope reference
            document.getElementById("LeakedDiv").expandoProperty =
                myGlobalObject;
        }

        function BreakLeak()
        {
            document.getElementById("LeakedDiv").expandoProperty =
                null;
        }
        </script>
    </head>

    <body onload="SetupLeak()" onunload="BreakLeak()">
        <div id="LeakedDiv"></div>
    </body>
</html>

To break the leak pattern you can make use of explicit null assignments. By assigning null before the document unloads you are telling the script engine there is no longer an association between the element and the object inside the engine. It can now properly clean up references and will release the DOM element. In this case, you as the Web developer know more about the relationships between your objects than the script engine does.

While that is the basic pattern, it can be difficult to spot more complex scenarios. A common usage of object-oriented JScript is to extend DOM elements by encapsulating them inside of a JScript object. During the construction process, you generally pass in the DOM element you want to attach to and then store a reference to the DOM element on the newly constructed object while at the same time storing an instance of the newly constructed object on the DOM element. That way your application model always has access to everything it needs. The problem is this is a very explicit circular reference, but because it uses different language aspects it might go unnoticed. Breaking up this kind of pattern can become more complex, and you can use the same simple methods discussed earlier.

<html>
    <head>
        <script language="JScript">

        function Encapsulator(element)
        {
            // Set up our element
            this.elementReference = element;

            // Make our circular reference
            element.expandoProperty = this;
        }

        function SetupLeak()
        {
            // The leak happens all at once
            new Encapsulator(document.getElementById("LeakedDiv"));
        }

        function BreakLeak()
        {
            document.getElementById("LeakedDiv").expandoProperty =
                null;
        }
        </script>
    </head>

    <body onload="SetupLeak()" onunload="BreakLeak()">
        <div id="LeakedDiv"></div>
    </body>
</html>

More complex solutions to this problem involve registration schemes to note which elements/properties need to be unhooked, having the peer element hook events so that it can clean up before the document unloads, but often you can run into additional leak patterns without actually fixing the problem.

Closures

Closures are very often responsible for leaks because they create circular references without the programmer being fully aware. It isn’t immediately obvious that parent function parameters and local variables will be frozen in time, referenced, and held until the closure itself is released. In fact this has become such a common programming tactic, and users have run into issues so often, there are quite a few resources already available. Because they detail some of the history behind closures as well as some of the specific instances of closure leaks we’ll check those out after applying the closure model to our circular reference diagram and figuring out where these extra references are coming from.

Figure 2 Circular References with Closures

Figure 2. Circular References with Closures

With normal circular references there were two solid objects holding references to each other, but closures are different. Rather than make the references directly, they are made instead by importing information from their parent function’s scope. Normally, a function’s local variables and the parameters used when calling a function only exist for the lifetime of the function itself. With closures, these variables and parameters continue to have an outstanding reference as long as the closure is alive, and since closures can live beyond the lifetime of their parent function so can any of the locals and parameters in that function. In the example, Parameter 1 would normally be released as soon as the function call was over. Because we’ve added a closure, a second reference is made, and that second reference won’t be released until the closure is also released. If you happened to attach the closure to an event, then you would have to detach it from that event. If you happened to attach the closure to an expando then you would need to null that expando.

Closures are also created per call, so calling this function twice will create two individual closures, each holding references to the parameters passed in each time. Because of this transparent nature it is really easy to leak closures. The following example provides the most basic of leaks using closures:

<html>
    <head>
        <script language="JScript">

        function AttachEvents(element)
        {
            // This structure causes element to ref ClickEventHandler
            element.attachEvent("onclick", ClickEventHandler);

            function ClickEventHandler()
            {
                // This closure refs element
            }
        }

        function SetupLeak()
        {
            // The leak happens all at once
            AttachEvents(document.getElementById("LeakedDiv"));
        }

        function BreakLeak()
        {
        }
        </script>
    </head\>

    <body onload="SetupLeak()" onunload="BreakLeak()">
        <div id="LeakedDiv"></div>
    </body>
</html>

If you are wondering how to break this leak, it won’t be as easy as a normal circular reference. The “closure” can be viewed as a temporary object that exists in the function scope. Once the function exits, you lose reference to the closure itself, so what would you end up calling detachEvent with? One of the most interesting approaches to this problem was demonstrated on MSN spaces thanks to Scott Isaacs. The approach uses a second closure to additionally hook the window’s onUnload event, and because this closure has the same “scoped” objects it is able to detach the event, detach itself, and finish the clean up process. To make everything easily fit with our model we can also store the closure on an expando, detach it, and then null the expando, as in the following example.

<html>
    <head>
        <script language="JScript">

        function AttachEvents(element)
        {
            // In order to remove this we need to put
            // it somewhere. Creates another ref
            element.expandoClick = ClickEventHandler;

            // This structure causes element to ref ClickEventHandler
            element.attachEvent("onclick", element.expandoClick);

            function ClickEventHandler()
            {
                // This closure refs element
            }
        }

        function SetupLeak()
        {
            // The leak happens all at once
            AttachEvents(document.getElementById("LeakedDiv"));
        }

        function BreakLeak()
        {
            document.getElementById("LeakedDiv").detachEvent("onclick",
                document.getElementById("LeakedDiv").expandoClick);
            document.getElementById("LeakedDiv").expandoClick = null;
        }
        </script>
    </head>

    <body onload="SetupLeak()" onunload="BreakLeak()">
        <div id="LeakedDiv"></div>
    </body>
</html>

In a Knowledge Base article, we actually recommend that you try not to use closures unless they are necessary. In the example, I’ve given we don’t need to use a closure as the event handler, instead we can move the closure to a global scope. When the closure becomes a function, it no longer inherits the parameters or local variables from its parent function so we don’t have to worry about closure-based circular references at all. Most code can be fixed by creating an architecture that doesn’t rely on closures where they aren’t necessary.

Finally, Eric Lippert, one of the developers of the scripting engines, has a great post on closures in general. His final recommendations are also along the lines of only using closures when truly necessary. While his article doesn’t mention any of the workarounds for the closure pattern, hopefully we’ve covered enough examples here to get you started.

Cross-Page Leaks

Leaks that are based on order of insertion are almost always caused by the creation of intermediate objects that don’t get cleaned up properly. That is exactly the case when creating dynamic elements and then attaching them to the DOM. The basic pattern is attaching two dynamically created objects together temporarily which creates a scope from the child to the parent element. Later, when you attach this two-element tree to the primary tree, they both inherit the scope of the document and a temporary object is leaked. The following diagram shows two methods for attaching dynamically created elements to the tree. In the first model, attach each child element to its parent, and finally attach the entire subtree to the primary tree. This method can cause leaks through temporary objects if other conditions are met. In the second model, we attach elements into the primary tree working our way from top-level dynamically created element down through all of the children. Because each attachment inherits the scope of the primary document we never generate temporary scopes. This method is much better at avoiding potential memory leaks.

Figure 3 DOM Insertion Order Leak Model

Figure 3. DOM Insertion Order Leak Model

Next, we are going to cover an example of a leak that is transparent to most leak-detection algorithms. Because we don’t leak any publicly visible elements and the objects we leak are very small you might never notice this problem. For our example to work, the dynamically created elements will have to contain a script pointer in the form of an inline function. This will allow us to leak an internal script object that is created temporarily as we attach elements together. Because the leak is small, we’ll have to run thousands of samples. In fact, the objects leaked are only a few bytes. By running the sample and navigating to an empty page, you can see the difference in memory consumption between the two versions. When we use the first DOM model of attaching child to parent, then parent to the primary tree, our memory usage goes up a bit. This is a cross-navigation leak and the memory isn’t reclaimed until you restart the IE process. If you run the sample a few more times, using the second DOM model of attaching the parent to the primary tree and then the child to the parent, your memory won’t continue to climb and you’ll find that you’ve fixed the cross-page navigation leak.

<html>
    <head>
        <script language="JScript">

        function LeakMemory()
        {
            var hostElement = document.getElementById("hostElement");

            // Do it a lot, look at Task Manager for memory response

            for(i = 0; i < 5000; i++)
            {
                var parentDiv =
                    document.createElement("<div onClick='foo()'>");
                var childDiv =
                    document.createElement("<div onClick='foo()'>");

                // This will leak a temporary object
                parentDiv.appendChild(childDiv);
                hostElement.appendChild(parentDiv);
                hostElement.removeChild(parentDiv);
                parentDiv.removeChild(childDiv);
                parentDiv = null;
                childDiv = null;
            }
            hostElement = null;
        }

        function CleanMemory()
        {
            var hostElement = document.getElementById("hostElement");

            // Do it a lot, look at Task Manager for memory response

            for(i = 0; i < 5000; i++)
            {
                var parentDiv =
                    document.createElement("<div onClick='foo()'>");
                var childDiv =
                    document.createElement("<div onClick='foo()'>");

                // Changing the order is important, this won't leak
                hostElement.appendChild(parentDiv);
                parentDiv.appendChild(childDiv);
                hostElement.removeChild(parentDiv);
                parentDiv.removeChild(childDiv);
                parentDiv = null;
                childDiv = null;
            }
            hostElement = null;
        }
        </script>
    </head>

    <body>
        <button onclick="LeakMemory()">Memory Leaking Insert</button>
        <button onclick="CleanMemory()">Clean Insert</button>
        <div id="hostElement"></div>
    </body>
</html>

This leak deserves clarification, because our workaround goes against some best practices in IE. The key points to understand about the leak are that DOM elements are being created with scripts already attached. This is actually crucial to the leak, because if we create DOM elements that don’t contain any script and attach them together in the same manner we don’t have a leak problem. This gives rise to a second workaround that might be even better for larger subtrees (in the example we only have two elements, so building the tree off the primary DOM isn’t a performance hit). The second workaround would be to create your elements with no scripts attached initially so that you can safely build your subtree. After you’ve attached your subtree to the primary DOM, go back and wire up any script events at that point. Remember to follow the principles for circular references and closures so you don’t cause a different leak in your code as you hook up your events.

I really wanted to point out this issue because it shows that not all memory leaks are easy to find. It could take thousands of iterations of a smaller pattern to become visible, and it might be something slight, like the order of insertion of DOM elements that causes the problem to arise. If you tend to program using only best practices, then you think you are safe, but this leak shows that even best practices can exhibit leaks. Our solution here was to improve upon the best practice or even introduce a new best practice in order to remove the leaking condition.

Pseudo-Leaks

Often times the actual behavior and expected behavior of some APIs can lead you to misdiagnose memory leaks. Pseudo-leaks almost always appear on the same page during dynamic scripting operations and should rarely be visible after navigation away from the page to a blank page. That is how you can eliminate the issue as a cross-page leak and then start to work on whether the memory consumption is expected. We’ll use script text rewriting as our example of a pseudo-leak.

Like the DOM Insertion Order issue, this issue also relies on the creation of temporary objects in order to “leak” memory. By rewriting the script text inside of a script element over and over again, slowly you’ll begin to leak various script engine objects that were attached to the previous contents. In particular, objects related to debugging script are left behind as are fully formed code elements.

<html>
    <head>
        <script language="JScript">

        function LeakMemory()
        {
            // Do it a lot, look at Task Manager for memory response

            for(i = 0; i < 5000; i++)
            {
                hostElement.text = "function foo() { }";
            }
        }
        </script>
    </head>

    <body>
        <button onclick="LeakMemory()">Memory Leaking Insert</button>
        <script id="hostElement">function foo() { }</script>
    </body>
</html>

If you run the above code and use the Task Manager trick again, while navigating between the “leaking” page and a blank page, you won’t notice a script leak. This script leak is entirely within a page and when you navigate away then you get your memory back. The reason this one is bad is due to expected behavior. You expect that after rewriting some script that the original script won’t stay around. But it really has to, because it might have been used already for event attachments and there might be outstanding reference counts. As you can see, this is a pseudo-leak. On the surface the amount of memory consumption looks really bad, but there is a completely valid reason.

Conclusion

Every Web developer builds a personal list of code examples that they know leak and learns to work around those leaks when they see them in code. This is extremely handy and is the reason the Web is relatively leak-free today. Thinking about the leaks in terms of patterns instead of individual code examples, you can start to develop even better strategies for dealing with them. The idea is to take them into account during the design phase and make sure you have plans for any potential leaks. Use defensive coding practices and assume that you’ll need to clean up all your own memory. While this is an overstatement of the problem, you very rarely need to clean up your own memory; it becomes obvious which variables and expando properties have the potential for leaking.

In the interest of patterns and design I highly recommend Scott’s short blog entry because it demonstrates a general purpose example of removing all closure-based leaks. It does require a bit more code, but the practice is sound and the improved pattern is easy to spot in code and to debug. Similar registration schemes can be used for expando-based circular references as long as care is taken that the registration method itself isn’t riddled with leaks (especially where closures are used)!

About the author

Justin Rogers recently joined the Internet Explorer team as an Object Model developer working on extensibility and previously worked on such notable projects as the .NET QuickStart Tutorials, .NET Terrarium, and SQL Reporting Services Management Studio in SQL Server 2005.

Fix Firefox Memory Leak & Lower RAM Usage

Firefox Browser is general resource intensive and this increases with the number of Add On’s installed and tabs open while browsing the web. The new latest versions were expected to be fast loading and use less RAM but its still the same problem with the browser always using high RAM. Check out this screenshot of the current usage of firefox which is around 430Mb considerably very high.

Firefox RAM Memory Usage

Firefox Logo

Process to Reduce RAM Usage :
1. Open Firefox and go to the Address Bar. Type in about:config and then press Enter.
2. Right Click in the page and select New -> Boolean.
3. In the box that pops up enter config.trim_on_minimize. Press Enter.
4. Now select True and then press Enter.
5. Restart Firefox.

I made the above changes in the config section of my firefox browser and restarted the browser and checked out the Task Manager to find that how much RAM is saved using this tweak. Try out the changes and you can surely find your system would run great and hve a better browsing experiance.
firefox memory usage speed

If you have a home network and are running Windows 7 and have XP on other PC(s) you might want to share files between them.  Today we will look at the steps to share files and hardware devices like a printer.

Sharing Files In Windows 7 and XP

Sharing folders between two Windows 7 machines with the new HomeGroup feature is an easy process, but the HomeGroup feature is not compatible with Vista or XP.  For this tutorial we are using Windows 7 x64 RC1 and XP Professional SP3 connected through a basic Linksys home wireless router. Continue reading “Share Files and Printers between Windows 7 and XP” »

While I’m preparing a different post related to this topic, I noticed administrative shares not working in my Windows 7 workgroup computer. If the computer becomes part of domain, it started working for domain administrator, but in workgroup, no luck. After several tries and searches, this way helped me fix the issue.

By default all local drives (Partitions) shared for administrators to access over the network even when they are really not shared. These type of shares called admin or administrative shares in Windows 7. Normally it can be accessed by typing Computer IP address or name with partition letter and dollar ($) sign at the end, as shown below. Continue reading “Fix it Now, Administrative Shares (C$) Not Working in Windows 7 Workgroup Computer” »

How To Develop iPhone Apps on Windows

Not many developers speak Objective C, the Mantra for writing iPhone applications. And majority of the developers don’t own Mac either, so what is the way to go ?

Of course one can buy a macbook and do it. Here’s what will make it possible do all that on Windows, Linux

Top 5 Ways:

Method 5. Toolchains: There are several toolchains available (like winChain) that actually lets you write and build iPhone applications on windows. There are several associated tutorials to build the Objective C code on Windows. But there is a problem, the apps hence developed will work on Jailbroken iPhones only. We’ve seen few hacks to get over that and make it to App Store, but as Apple keeps on updating SDKs, toolchains need regular updates. It’s a hassle to make it up all the time. That’s why this is the least of the recommended methods.

Method 4. Use other Languages instead of Objective-C

(i) Code in Java: For Java developers, there is a workaround: XMLVM.

XMLVM is an extensible cross-compiler toolchain which instead of cross-compiling on a source code level, XMLVM cross-compiles byte code instructions from Sun’s Java virtual machine and Microsoft’s Common Language Runtime (CLR). And the Result: The byte code instructions are easier to cross-compile and the difficult parsing of a high-level programming language is left to a regular compiler and you get to write apps in different language and then compile and convert to a different one. The diagram below shows an abstract idea:

Without laying much stress on it, I`ll share my experience. The project is a great piece of Innovation but is still in it’s early phases. On one side, I was able to use their API and develop fairly well application (Simple game, Travel app), but when it comes to complex graphics, features, this method looked pretty immature. However, over time this should change and we could see the project doing almost everything the original SDK does. And yes, you can test your apps on the Java based simulator and deploy on jailbroken iPhone.

There are several other frameworks (like  Appcelerator`s Titanium) that let you code iPhone apps in Java, but the limitations are similar thought they are all worth giving a look for most day-to-day apps.

Update: (ii): Code in C/C++

DragonFireSDK: Say no to Objective C, say no to forced-Mac and yes to C/C++, Windows. This founds the base for DragonFireSDK that uses Microsoft Visual C++ to develop, test iPhone apps.

Apps, Games created with DragonFireSDK can be completely written and debugged in Windows and are also fully compliant for distribution and sales at the Apple iPhone App Store.

There is a quick Starter Guide available that help you kick start writing your first iPhone app and run it inside the emulator that ships with it. The API is quiet simple to use and is available here. One of the Apps: Un Stacker developed using this SDK is already available on App Store [link]. In addition, 5 Sample Apps are demonstrated and explained with code.

Method 3. Hackintosh: This is one of the effective ways of doing it: Install Mac on PC and then run the Native iPhone SDK. This is already a popular practice among OSx86 communities. The only limitation is that it could get tricky and time consuming for the newbees. You can refer to our Hackintosh Guides:

Method 2: Cross compilation of Adobe apps: You can write your apps in Flash Actionscript 2, ActionScript 3 or Adobe AIR, Flex and then cross compile it to ARM binary that is executable on iPhone. This can be done installing Project Sprouts for which sample Flex applications source is available here.

Here is a video on how this is done:

Method 1. Flash CS 5: This is in fact the most effective and easiest way to make it to App store doing all the “legal stuff”.

Flash CS 5 introduces new Feature that let’s you develop iPhone native applications just like you develop Adobe AIR apps. Recently, Adobe announced support for Multitouch, Accelerometer, GPS support in Flash 10.1 for phones. CS5 adds new APIs that lets developers leverage these modern Phone features and hence develop application not just for iPhone but for all Phones that support Flash.

So the Horizon is quiet big, and CS5 with ActionScript could find a great way to develop applications on iPhone. If you are familiar with a scripting language, say, Javascript, learning ActionScript is as easy as an ApplePie.

Already, App Store has a number of Apps built based on Flash (I believe they are using Crosscompilation): you can checkout few full blown apps here.

Only bad part of this method is, it’s still unavailable. However This is what Official adobe site has to say about it:

When will the Flash Professional CS5 beta be available for download?
The beta will be available for download from Adobe Labs before the end of 2009.

You can develop, build and test in native Flash debugger, however, soon we should see a simulator for mobile devices, especially for the iPhone.

I needed more clarity whether the final step, signing of Apps would be possible on Windows. I contacted Adobe on this. Alexander MacDonald said “Once you have created your content it is compiled into an iphone executable, then signed by our ADT tool and then zipped to create an ipa—the only thing you need from apple is your developer certificate. The crypto algorithms used by Apple to sign iPhone apps are all industry standard ones which anyone can implement on any platform they wish,” which in the case of Flash CS5, also includes Windows.

The app hence created can be installed to iPhone via iTunes for testing to substitute absence of simulator for the mean time. So all in all, everything would be legal, and will work great.

However, here is the demo of how applications will be created in Flash CS5:

Today, it doesn’t support everything SDK supports, but it would soon do. With Flash opening up a way to iPhone development, Adobe is adding millions of new developers to the iPhone App store contributors.

For more iPhone, Programming, Open source, Windows, Mac OSTech Guides and Tech News catch us on Twitter @taranfx or subscribe below:

Xử lý dữ liệu phân tán với MapReduce

Quy trình giúp xử lý tập hợp dữ liệu siêu lớn, đặt tại các máy tính phân tán; giúp tiết kiệm chi phí xây dựng máy chủ lưu trữ dữ liệu; phát triển điện toán mây…

Bài toán đặt ra

Chúng ta có khối lượng lớn dữ liệu (terabytes) phân bố trên hàng ngàn máy tính biệt lập, và có rất nhiều dự án khác nhau cần dùng cũng như phân tích trên khối dữ liệu này. Làm thế nào để việc thao tác, xử lý dữ liệu hiệu quả, tiết kiệm nhất?

Đây là bài toán đặt ra khi mà mạng xã hội, dịch vụ trực tuyến… ngày càng phát triển mạnh mẽ.

Các khó khăn khi phải xử lý một tập hợp lớn dữ liệu phân tán:

- Quản lý, sắp xếp lịch trình truy xuất I/O

- Quản lý tiến trình song song và phân tán

- Theo dõi trạng thái dữ liệu

- Xử lý lỗi

- Quản lý số lượng lớn dữ liệu có quan hệ phụ thuộc nhau

- ….

MapReduce (MR) là quy trình giúp xử lý tập hợp dữ liệu siêu lớn đặt tại các máy tính phân tán, có thể xử lý được dữ liệu không cấu trúc (dữ liệu lưu trữ dạng tệp tin hệ thống) và dữ liệu cấu trúc (dữ liệu quan hệ 2 chiều). Trong MR, các máy tính chứa dữ liệu đơn lẻ được gọi là các nút (node)

MR định nghĩa dữ liệu (cấu trúc và không cấu trúc) dưới dạng cặp khóa/giá trị (key/value). Ví dụ, key có thể là tên của tập tin (file) và value nội dung của tập tin, hoặc key là địa chỉ URL và value là nội dung của URL,… Việc định nghĩa dữ liệu thành cặp key/value này linh hoạt hơn các bảng dữ liệu quan hệ 2 chiều truyền thống (quan hệ cha – con hay còn gọi là khóa chính – khóa phụ).

Quy trình xử lý

MapReduce được xây dựng từ mô hình lập trình hàm và lập trình song song. Tăng tốc độ thực thi xử lý dữ liệu là mục đích quan trọng nhất của MR. Quy trình này gồm 2 phần:

- Map: Đầu vào là nút chủ (master node) và sau đó chia nhỏ nó ra thành các vấn đề bé hơn. Gọi là các split 0, split 1, split 2, …

- Reduce: Từ các đầu ra trung gian sẽ tổng hợp lại để đưa ra các kết quả cuối cùng cho vấn đề master.

Một ví dụ về hàm Map:

def map (key, value):
list = []
for x in value:
if test:
list.append( (key, x) )
return list

Một ví dụ về hàm Reduce:

def reduce (key, listOgValues):
result = 0
for x in listOgValues:
result += x
return (key, result)

Để xử lý khối dữ liệu bao gồm rất nhiều cặp (key, value), lập trình viên viết hai hàm map và reduce. Hàm map có đầu vào là một cặp (k1, v1) và đầu ra là một danh sách các cặp (k2, v2). Như vập hàm Map có thể được viết theo dạng: map(k1,v1) => list(k2,v2). Và hàm reduce có dạng reduce(k2, list (v2)) => list(v3).

(1): Thư viện MR mà chương trình người dùng (User Program) sử dụng chia các tập tin đầu vào (dữ liệu cần xử lý) thành các phần nhỏ. Dung lượng mỗi phần từ 16 megabytes đến 64 megabytes (MB). Và sau đó sao chép chương trình thành các tiến trình song song chạy trên các máy tính phân tán chứa dữ liệu.

(2): Chương trình điều khiển Master sẽ gán mỗi phần dữ liệu cho một hàm Map và một hàm Reduce.

(3) – (4): worker là phần được gán một hàm Map và Reduce để xử lý, nó sẽ đọc dữ liệu, phân tích cặp key/value ở đầu vào và phân tích thành các cặp trung gian khác được lưu tại vùng nhớ đệm.

(5): Định kỳ, các cặp dữ liệu trung gian sẽ được đẩy đến các worker tương ứng (do master điều khiển) để hàm reduce xử lý. Các thuật toán sắp xếp, so sánh, phân vùng dữ liệu sẽ được sử dụng tại giai đoạn này. Các tập dữ liệu trung gian có cùng key sẽ được sắp xếp cùng một nhóm.

(6): Khi tất cả các tác vụ Map và Reduce đã hoàn tất thì sẽ cho ra kết quả cuối cùng của quy trình MR.

Với MR, rất nhiều máy tính trung gian có thể sử dụng để xử lý dữ liệu mà trước kia không thể.

MR cho phép lập trình viên dễ dàng sử dụng thư viện định tuyến MR để lập trình song song chính xác và hiệu quả, không phải bận tâm đến việc trao đổi dữ liệu giữa các cluster khác nhau vì sự độc lập dữ liệu khá cao; không phải theo dõi xử lý lỗi, các tác vụ…

Hiện nay đã có một số mô hình MR trên các ngôn ngữ Java, C++, Python, Perl, Ruby và C. Lập trình viên có thể lựa chọn ngôn ngữ và thư viện MR để xây dựng ứng dụng của mình. Thường các cài đặt MR đòi hỏi phải chạy trên một hệ thống tệp tin phân tán thích hợp, ví dụ như Google File System (GFS), Amazon S3,…

Ứng dụng thực tế

Năm 2009 dự án mã nguồn mở Hadoop của Apache đã lập kỷ lục thế giới về sắp xếp khối dữ liệu siêu lớn (sắp xếp một petabyte dữ liệu trong 16,25 giờ và một terabyte trong 62 giây). Mỗi ngày có đến vài nghìn hay vài chục nghìn chương trình MR được chạy ở Google, và rất nhiều công ty khác trên thế giới.

MR là giải pháp tốt cho các dạng bài toán xử lý khối lượng dữ liệu phát sinh khổng lồ với các tác vụ phân tích và tính toán phức tạp và không lường trước được, trong các lĩnh vực như khai khác dữ liệu (data mining), phân tích tài chính, mô phỏng, … Một số ví dụ:

- Sắp xếp dữ liệu phân tán: một khối lượng dữ liệu lớn được đặt tại nhiều máy khác nhau và cần phải sắp xếp chúng một cách đồng bộ để các ứng dụng truy xuất đạt hiệu quả cao.

- Đếm tần số truy cập một địa chỉ URL: hàm Map sẽ xử lý nhật ký (log) các yêu cầu truy xuất đến trang web có địa chỉ URL cần đếm và đầu ra là cặp giá trị <URL, 1>. Hàm Reduce tiếp tục xử lý và kết quả là cặp giá trị <URL, total count> (total count: là tổng số truy cập vào URL đó).

- Dùng trong trí tuệ nhân tạo khi phân tích thống kê.

- Xử lý dữ liệu bản đồ (đường, địa điểm…).

- Bài toán xếp thứ hạng (ranking) một trang web theo mức độ quan tâm của người dùng.

Bằng cách tập trung vào cốt lõi của thuật toán, sử dụng MR tiết kiệm được khá nhiều chi phí xây dựng các máy chủ lưu trữ dữ liệu. Ngoài Google, các hãng Yahoo, Facebook, Rackspace, …cũng đều đã sử dụng MR để xử lý dữ liệu.

Hiện nay người ta bắt đầu sử dụng MR cho việc phát triển các đám mây điện toán, thuật ngữ Cloud MapReduce hứa hẹn mở ra một hướng mới.

Nếu bạn đang tìm kiếm một dịch vụ VPN miễn phí với tốc độ tốt thì PacetiX.NET là dịch vụ bạn nên thử, phiên bản miễn phí của dịch vụ mang đến tốc độ duyệt web rất tốt qua máy chủ được đặt tại Nhật Bản (VPN là giao thức mạng riêng ảo, giúp bạn có thể truy cập từ xa, bất kì đâu tới máy tính của bạn cũng như giúp bạn vượt qua các tường lửa, rào chắn của chính phủ, các trang web, các nhà cung cấp dịch vụ).

Không giống như nhiều dịch vụ VPN khác như logmein, AlonWeb …, PacetiX.NET mang đến phần mềm máy trạm VPN dễ dàng cài đặt và sử dụng.

Với các bước sau, bạn có thể sử dụng dịch vụ VPN miễn phí, tuyệt với này:

- Tải và cài đặt phần mềm máy trạm VPN, có 2 phiên bản cho Windows 32bitWindows 64bit.

- Tải tệp tin cấu hình tự động tại đây.

- Chạy phần mềm máy trạm VPN.

Sau khi làm theo hướng dẫn của trình thuật sĩ, bạn chuột phải vào mục Create new VPN connection và chọn Import VPN Connection Setting.

Sau đó, bạn trỏ đường dẫn tới nơi bạn đặt tệp tin cấu hình tự động bạn tải ở trên.

Khi đã import tệp tin cấu hình vào cửa sổ quản lý máy trạm VPN, bạn sẽ có một kết nối như hình:

Bạn chuột phải vào kết nối Secure và chọn Connect, quá trình kết nối với máy chủ VPN sẽ được bắt đầu.
Bạn sẽ phải đồng ý với những đòi hỏi, cam kết của dịch vụ, nếu đồng ý bạn nhấn vào dòng Agree to the Term of Service and start connection ở dưới cùng của cửa sổ.
Máy chủ VPN sẽ kiểm tra kết nối và xác thực người sử dụng.

Giờ đây bạn đã kết nối với dịch vụ.

Một biểu tượng mạng kết nối sẽ hiển thị tại khay hệ thống, thông báo bạn đã kết nối thành công tới dịch vụ

Địa chỉ IP của bạn sẽ là IP ở Nhật Bản. Để chắn chắn hơn, bạn vào các trang web trả về vị trí địa lý từ địa chỉ IP như http://www.whatismyip.com.

Giờ bạn gõ www.google.com vào trình duyệt, bạn sẽ được đưa tới phiên bản tiếng Nhật của Google. Vậy là bạn đã thành công trong việc vượt qua các trở ngại, tường lửa của các trang web, nhà cung cấp dịch vụ.

Theo : http://xahoithongtin.com.vn

Windows 7: How to display .chm content

Why does my CHM have a blank content pane?

This is a relatively old problem now, but one that keeps popping up.

You open a CHM but you don’t see your content in the right-hand pane of the HH window. You see a cryptic browser message “Navigation to the webpage was canceled” or “Action canceled”.

image5.jpg

This is due again to Microsoft plugging security holes in Windows. I’ve listed all the HH security fix problems here.  This particular problem is either:

  1. CHMs no longer work on the Intranet or Internet
    This can be fixed by a simple registry tweak (see link)
  2. Downloaded CHMs cannot be opened
    After downloading, right-click the chm file, select properties, then click “Unblock”.

hhsec2.jpg

Powered by WordPress | Theme: by 85ideas. Editor by Khoanguyen