Sunday, January 31, 2016

How to Run in Cgywin from C#

Use the following code:

public  string runCygwin()

            using (Process p = new Process())

                /*Use the bash shell in cygwin folder*/
                ProcessStartInfo info = new ProcessStartInfo(@"D:\cygwin64\bin\bash");

                /*Put the command to be run in test.bsh*/
                info.Arguments = @"--login ""/cygdrive/D/C_Drive/Desktop/z3-str/tests.bsh""";

                /**Side Info:Content in test.bsh file**/
                string bshContent =
                    "/cygdrive/D/C_Drive/Desktop/z3-str/ -f " +

                info.RedirectStandardInput = true;
                info.RedirectStandardOutput = true;
                info.UseShellExecute = false;
                p.StartInfo = info;
                string output = p.StandardOutput.ReadToEnd();
                // process output
                return output;

Monday, January 11, 2016

Some JavaScript Special Scenarios

for (i = 0,j=0; i < 3, j < 2; i++,j++) {
    console.log(i+" "+j)
The answer is 0,0 and 1,1 only j<2 applies
function f(a) {
  var a;

The answer is 4, since variable in javascript only has local and global scope

Original source
    for (i = 0,j=0; i < 3, j < 2; i++,j++) {
        console.log(i+" "+j)

The answer is 0,0 and 1,1
only `j<2` applies

    function f(a) {
      var a;


The answer is 4, since variable in javascript only has local and global scope

Saturday, January 9, 2016

How to Point GoDaddy Domain to Amazon EC2

You bought a domain from GoDaddy, and you have a server on Amazon EC2, perfect, follow the following easy steps to point Godaddy domain to Amazon EC2 server.

Get Elastic IP from Amazon
On EC2 Management console, click on “Elastic IPs”, click on Allocate New Address

Click Yes, Allocate

You got the New Address assigned.

Right click the elastic IP, click Associate Address.

Choose the instance you are running

Use the default values for all textboxes, Click Associate

Configuration for GoDaddy
Login into your godaddy account, Under the upper menu click “Domains” and then click “Manage my Domains”, Select the domain you would like to change by clicking the link to the domain on the table under “Domain Name” column.
When you see the following screen select DNS Zone File

Click on Edit Record under A(Host), Edit the record to point to the Elastic IP address you have set just now

After that click on Save Changes

 That's it, have fun!

Thursday, January 7, 2016

How to Enable FTP on Amazon EC2 (using FileZilla here)

Are you having problems in configuration Amazon EC2 with FTP? No problem, here are the step by step guides.

Configurations on Amazon EC2 console
1.       Click on instance in EC2 console, locate your EC2 instance, and scroll it to the right

2.       Click on the link under Security Groups

3.       Under the Security Group, right click on the item there, and select Edit inbound rules

4.       Add the two rules as follows, and click on save, that’s it.

Configurations on Windows Instance
1.       Login to the Windows instance, click on the Windows button, and key in Windows Firewall

2.       Turn off the Windows Firewall (only for public network settings). Amazon has the configurations to protect you (like those you set in Amazon EC2 console previously).

Configuration of Filezilla Server
1.       Install FileZilla Server
2.       Connect it, retain the orginal setting, and click OK.

3.       Got to Edit > Settings >Passive Mode Settings, set the following. For Use the following IP, key in your Amazon instance IP like, and Click OK.

That’s it, you can connect it with your File Zilla Client, using port 21.

Wednesday, January 6, 2016

How to Create a Free Windows EC2 Instance on Amazon EC2

Want to setup a free Windows EC2 instance on Amazon? Following the following step-by-step guides for doing it.

1.      Go to on Sign in to the Console and login

2.       Click on EC2

3.       Click on Launch Instance to create a new instance

4.       Click on the Windows Server instance and click Select

5.       Select an instance that is free tier eligible and click Review and Launch

6.       Click Launch

7.       When prompt to create key file, create a new one, give a proper name, and download it (by selecting download key pair). Store it properly, we may need to key file in future like for the purpose of enabling remote desktop. Click on Launch Instances, that’s it.

That's it, enjoy your Amazon EC2 Windows instance!

Monday, January 4, 2016

How to move Amazon EC2 instance to new region/availability zone

Say if you have setup your Amazon EC2 instance on US West (Oregon), and you want to move it to Asia Pacific (Singapore)? No problem, follow the following step-by-step guides:

Stop the instance, then right click on the instance and select create image

After the AMI image is created, right click on it and select Copy AMI

Select the Region you want to copy to, give a name and description, and click Copy AMI

After the AMI is copied to new region, click on the Launch button to launch it.

That's it :)

Friday, January 1, 2016

Khan Academy Payment Storing Services

To donate to Khan Academy

Khan Academy uses Stripe to accept payment.