Black piece vs white piece who wins this chess game?

It is the summer time and the best method to cool down your body is to play a game of chess. My opponent who plays the white pieces is a IM but he is not playing well today as you can see there are many holes in his game. We both start our first few moves in the standard fashion. Then the situation on the chess board starts to change after he has made a very strange move by exposing my “left flange”. I know what he wants and I also can see there is a big hole in his game! The game continues and I further solidify my position on the chess board by bringing out my left knight into the game…

The last few moves are the one that really secure my victory against this player who ranks higher than me. He resigns after I move my knight…

How to create a random float in javascript?

The below javascript code will create a random float and shows it on the alert box. The Math.random method from javascript is very useful when it comes to creating a random number with javascript.

var random_v = Math.random();
alert(random_v);

The code above will cause the below outcome.

js random
js random

How to multiply two numbers with javascript function?

Javascript function is often used to carry out multiple tasks ranging from showing alert box to changing the inner html value of a webpage. Below code will create a function which will multiply two numbers passed into it and showing the result trough the alert box!

multiply(3, 4);
function multiply(a, b)
{
var factor = a * b;
alert(factor);
}

In order to use the above javascript multiply function all we need to do is to pass two numbers into that function and it will carry out it’s job accordingly.

How to detect the browser keydown event with javascript?

Here is how you can detect the browser keydown event and saved that keycode to an array.

//record keyevents
document.onkeydown = function(e){
  e = e?e:window.event;
  keyPressList[e.keyCode] = true;
};

We use the document’s onkeydown listener to listen for the keydown event on our web browser with the above code.

How to stop windows from auto downloading updates to your computer?

Some windows users just do not want windows to keep on auto downloading the softwares or updates that they don’t need to their computer. If you are just like me who uses a limited bandwidth’s broadband then those auto downloading jobs will really cost you lots of unnecessary bandwidths. If you have decided to disable the windows auto downloading job then the below method will help you out.

The method I am going to show you does not guarantee will 100% stop the auto downloading job because windows os actually can start the auto downloading job again if it wishes to, we simply cannot beat the operation system. However this method will certainly help you to temporary stop windows from auto downloading files into your computer. Here are the steps you need in order to temporary stop the updates from windows os.

  1. Open up the Windows OS Services manager. Find the Background Intelligent Transfer Service windows os
  2. Right click on it then select Properties to open up it’s Properties panel, under Startup type selection box select Disabled, also click on the Stop button below the Service Status to stop the auto downloading job if you need to, then click on the OK button to confirm your action.                                              BITS
  3. That is it! Now windows will not download anymore updates until you restart the auto downloading service again.

Good or bad, you decide:-

Do you really want the auto updating service to stop? There might have some important updates from windows that your will miss out if you disable the auto downloading function.

How to create a star on html5 canvas with canvas api?

This article will show you how to create a star on html5 canvas with the canvas api. Basically what we need here is a whole bunch of points for us to plot the star and then we will loop through those points and connect them together with line.

var context = document.getElementById('canvas').getContext('2d');
context.strokeStyle = 'yellow'; //assign line color to yellow color
context.shadowColor = 'rgba(144, 145, 148, 1.0)'; //assign the color of shadow
context.shadowOffsetX = 1; 
context.shadowOffsetY = 1;
context.shadowBlur = 1;
context.lineWidth = 3; //set line width
context.lineCap = 'round';

//the points we need to plot the star
var array1 = [[326,248],[328,248],[331,248],[333,247],[336,246],[339,245],[344,243],[351,240],[359,237],[369,232],[379,227],[401,217],[413,211],[428,204],[441,197],[456,189],[471,183],[488,178],[523,169],[561,160],[577,156],[590,153],[613,147],[623,145],[630,143],[642,140],[650,138],[654,138],[656,137],[655,138],[654,138],[653,139],[652,139],[652,140],[650,141],[649,142],[646,144],[644,146],[642,148],[640,150],[637,153],[633,158],[626,164],[621,168],[616,172],[607,181],[598,191],[587,204],[567,228],[553,244],[539,262],[523,279],[510,296],[497,313],[484,330],[474,345],[464,357],[455,369],[446,379],[441,386],[430,399],[424,406],[419,412],[416,415],[416,417],[416,415],[416,408],[416,388],[416,380],[416,363],[416,344],[415,311],[415,286],[414,261],[410,236],[406,214],[402,194],[397,175],[394,156],[392,137],[392,121],[392,109],[392,98],[392,85],[392,78],[392,72],[392,70],[392,71],[395,77],[405,92],[414,106],[424,120],[434,132],[444,143],[454,156],[465,166],[475,173],[484,182],[497,192],[509,203],[522,213],[537,223],[549,234],[562,244],[580,260],[590,272],[602,287],[611,299],[619,310],[626,319],[632,326],[635,330],[638,334],[640,336],[639,336],[635,335],[629,333],[614,327],[600,323],[584,317],[570,312],[557,308],[547,304],[540,301],[531,297],[524,295],[516,291],[509,289],[503,288],[495,284],[486,283],[479,281],[471,279],[462,277],[458,276],[452,275],[447,273],[442,273],[435,271],[431,271],[426,270],[420,268],[412,266],[408,265],[401,262],[397,261],[393,259],[389,257],[386,257],[382,256],[378,254],[374,254],[369,253],[365,252],[361,252],[358,251],[355,250],[352,250],[348,249],[347,249],[346,248],[345,248],[344,248],[343,248],[342,248],[341,248],[339,247],[335,246],[332,246],[330,246]];

//start drawing star
context.beginPath();
context.moveTo(324,248);
for (var i = 0; i <array1.length; i++) {
	context.lineTo(array1[i][0],array1[i][1]);
	context.stroke();
}
context.closePath();

The final outcome is as follow:-

HTML5 Star

Great chess opening Danish Gambit reviews

When the first time I look at the Danish Gambit chess opening I was simply shocked that how on earth can someone even thinks of this masterpiece? When you see this opening in the first time you will really think that your opponent must be out of his mind by giving out piece after piece but before you realize that a trap is waiting for you at the end you are almost done! Nobody can deny that danish gambit is the work of a genius, we lost pieces at the beginning but at last we are the winner, that is the beauty which hides behind Danish Gambit.

The mindset of the Danish Gambit player:

Get ready to lost as many pieces as you need in order to achieve the final glory.

The mindset of your opponent:

He thinks you are silly but before he realizes his mistakes he is over!

The mindset of the creator:

He comes from a culture and civilization which is willing to give up everything just to achieve the ultimate victory.

We really need to practice this formation for at least 100 times before we can master it, we also need to take a risk and prepare for a quick lost if we have decided to use this Gambit as our commonly use chess opening. Once we have mastered the Danish Gambit we will see lots of weaknesses and holes in our opponent game during the match which we can then capitalize and easily defeat even the strongest opponent on earth such as the Russian or the US player!

How to draw circle on html5 canvas

Drawing circle on HTML5 canvas is relatively simple. We just need to define the radius and the center point of the circle then we can start to draw circle with the canvas’s context object.

var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
// center point of the circle is at the center of canvas
var centerX = canvas.width / 2;
var centerY = canvas.height / 2;
var radius = 150;

context.beginPath();
context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
context.fillStyle = 'blue';
context.fill();
context.lineWidth = 1;
context.strokeStyle = 'black';
context.stroke();

The outcome of the above program is as follows.

circle

How to loop through the javascript array with the for loop

Suppose you have created a javascript array and need to loop through all the elements within that array then the best method to use will be either the for or the while loop. In this article we will use the for loop.

var array1 = ["hello", "this", "world"];
for(var i=0; i<array1.length; i++)
	alert(array1[i]);

The above program will loop through the javascript’s array with the for loop and shows the alert box in every passes of the loop.

Show alert with javascript prototype

Every object in javascript has the prototype property which we can attach a new function or property to it. Below javascript program will show two alert boxes once you have loaded the webpage.

function helloWorld() {
	alert("Hello World!")
}

helloWorld.prototype.helloAgain = function(name) {
					alert("Hello " + name);
				}
								
var helloTwice = new helloWorld();

helloTwice.helloAgain("John");

We first create a function named helloWorld then we added another function (which will show the name of a person) to helloWorld’s prototype. Next we create an object which owns all the properties of helloWorld then pass in the name of a person which will be used by the helloAgain function. The “Hello World!” alert will show first follows by the second alert in the helloAgain function.

hello world

hello john

Show alert with javascript prototype program is super simple, isn’t it?