[How to] Block specific Websites with GeckoFX in C#

Have you ever heard of WebBrowser in .NET Application? If yes, then you know how bad is the Default WebBrowser in .NET. In Internet we can find many alternative for the .NET's Default WebBrowser. There are many, such as CefSharp or GeckoFX,....

In this post I will introduce to you GeckoFX and I will show you how to build your first Gecko Browser program with the Blocking Feature.

GeckoFX is the open source component to embedding the Gecko rendering engine from Mozilla Firefox to .NET application.

To download GeckoFX-Source (current version is GeckoFX-45) go to the GeckoFX BitBucket Wikipage https://bitbucket.org/geckofx/geckofx-45.0/wiki/Home

Or we can use "NuGet-Package Manager" to install GeckoFX-45 to your project as the picture below:

NuGet install GeckoFX

After that we'll see the Firefox folder and the 2 new Dependencies in the Project Explorer Window:

Firefox GeckoFX Project explorer

First we have to declare Gecko namespace
using Gecko;

Just one more setting, select all files from the Firefox folder and select "Always copy" or "Copy when newer" to "Output folder" as below:

Copy dll files to Output folder

Now we can use the GeckoWebbrowser. Just declare the GeckoWebBrowser variable and load all the needed dll files as the picture below:

Init GeckoFX - Declare GeckoWebBrowser variable

What is function InitBrowser? It a function to configure the WebBrowser and to add the Browser into the Form

Configure GeckoWebBrowser

The important Thing to use Blocking feature of GeckoFX is we have to enable HttpActivityObserver, so we set here UseHttpActivityObserver = true.

After UseHttpActivityObserver is enabled, we need to add a Event-Handler, in this case is ObserveHttpModifyRequest-Event from GeckoWebBrowser.

When the WebBrowser send any request to any URL the event ObserveHttpModifyRequest will be fired. We can get the URL of the request by using variable request and convert it to string with request.Uri.ToString(). In this example, I block all the Request that contain "google.com" in the URL.

Here is the code:
        public GeckoWebBrowser webBrowser;
        public Form1()
            Xpcom.Initialize("Firefox"); // Init all Gecko DLL files in the Firefox folder inside the Project

        // Init Browser
        void InitBrowser()
            webBrowser = new GeckoWebBrowser { Dock = DockStyle.Fill, // Fill all the Form
                UseHttpActivityObserver = true // This is to enable HttpActivityObserver
            webBrowser.ObserveHttpModifyRequest += (obj, request) => {
                if (!request.Uri.ToString().Contains("google.com")) // if the request URL contains string "google.com"
                    request.Cancel = true; // Cancel the request to the URL
When you have any question, feel free to leave a commend, I will answer as soon as I can. Have fun coding!

P/S: In this tutorial I installed and use GeckoFX-45 32 bit, so when build the project I have to choose x32 Platform (It will give error when you try to compile to 64 bit Application, in case you want to build 64 bit Application, just install GeckoFx45.64 in the NuGet-Package Manager)

[How to] Using multiple PuTTY as tabs

As a server developer/ server manager, you must know PuTTY - a SSH console. But the problem is when you are working with a lot of machine, each PuTTY session will open in a new Windows, it is very inconvenient and chaotic because there will be a lot of Windows.

I found that using PuTTY as tab will be very easy and convenient, because instead of multiple Windows, there will have only ONE Windows (a container) and multiple tabs which are multiple PuTTY session, and you can even NAME those tab so you can easily manage those PuTTY session. And the tool I'm using is

Develop your program in CLOUD

Are you a developer? If yes, then maybe you are used to dev program on your local computer, it take time to prepare an environment to dev. I found out some SAAS website that provide a coding environment online for FREE, that's means you don't need to install IDE, and you can code everywhere with device that can access the internet, also you can customize the environment to what you need (customize the cloud VM with full sudo access).

These service are:
- Koding : https://koding.com
- Cloud9 (C9) : https://c9.io
- Codeanywhere : https://codeanywhere.com

Using these service, you can develop your website/program with any programming language/framework you want such as PHP, Python, Perl, Ruby, Wordpress, NodeJS...
Try them and leave comment of your opinion about these service.

[VPS] Cheapest US VPS $1/month 512MB VPS & Dedicated Servers...!

ChicagoVPS have just started a promotion for new VPS orders that you can use for yourself or share with your friends, this promo is valid throughout the rest of June.

Before order a VPS, please register an account by using this link

Immediately available ChicagoVPS have the following promotions which will be instantly setup upon payment:

Special #1:

512MB Guaranteed RAM
512MB vSwap
20 GB RAID-10 Protected Diskspace
500GB Monthly Bandwidth
1Gbit Port
1 IPv4 Address
OpenVZ Virtualization Platform
Instant Setup
Price: $12 per year (only $1/month!!)
Order Now! https://billing.chicagovps.net/cart.php?a=add&pid=443

Special #2:

2048MB (2GB) Guaranteed RAM
2GB vSwap
50 GB RAID-10 Protected Diskspace
2TB Monthly Bandwidth
1Gbit Port
1 IPv4 Address
OpenVZ Virtualization Platform
Instant Setup
Price: $29 per year ($2.42/month)
Order Now! https://billing.chicagovps.net/cart.php?a=add&pid=444

These promotions will not last long, be sure to order yours and let all your friends know about these awesome specials.

ChicagoVPS have also received a shipment of servers this week so they have stocked up their bargain bin inventory with some more dedicated servers at unbeatable pricing! Check it out, dedicated servers starting at $25/month: https://billing.chicagovps.net/cart.php?gid=30
Use promo code JUNE2014 for an extra $5/m off on any server in the bargain bin!

Please let me know if you have any questions in regards to these specials!

[TUT] How to complete the 2048 tile game

Do you ever heard about Flappy Bird? Flappy Bird is a hottest game a time ago, but it was deleted by it's creator, and the new hot game appear: 2048 tile game. You can download the game on App Store or Google Play, or you can play online at http://gabrielecirulli.github.io/2048/

2048 is a tile game, you need to use your brain. The game has a board included 4x4 tile, the rule is easy: you have to use arrow keys to move entire tile up, down, left, right to complete the game:

 - Each time you move, the number tiles on board will be move to the direction you want and another tile will appear randomly (tile with number 2 or 4) on the empty tiles.
 - 2 tiles with the same number on the way you move will be merge together and become 1 number tile with the value is the sum from 2 tiles before.

To win, you have to merge tiles to create the 2048 tile. It sound easy, but it's hard to win. Anyway, I found a strategy to complete the game, that strategy I called it "3 magic directions".

I called it with that name because the method of this strategy is to use only 3 adjacent directions movement to sort the tile (example: up-right-down, or right-down-left), you shouldn't or avoid using the other direction.

This strategy is use to sort the tile by [n,n*2,n*4,n*8] (example: [64,128,256,512] ) of a row or column at the middle direction in 3 adjacent directions.
 - If you use left-down-right: then sort the 4th row (the last row at the bottom standing at the DOWN direction - the middle direction in 3 adjacent directions)
 - If you use up-right-down: sort the 4th column (the last column on the right - the middle direction in 3 adjacent directions)
2048 tile game how to win
Use left-down-right

Note: Use should only use the other direction if you can't move any more using 3 adjacent directions.

This is my result using up-right-down
2048 tile game win
P/S: use this strategy will increase the chance to win up to 90%
Wish you have a fun time with this game. Any problem, feel free to leave comment. Thanks all ^^