Wednesday, August 27, 2014

Three.js, first animation

So, i tried my hand on three.js to have a small animation... basically a CUBE having shadow, and camera is moving in a circular fashion around the cube.
Very basic but first one.

important points,
1) lights are very important, without that it will be black.
2) high light number produce more bright light

Code is here,
https://github.com/tapeshmaheshwari/JavaScript/blob/master/initial_experiment/first_example.html

Sunday, August 24, 2014

window.onload and addEventListener usage

main.html:
<script src="main.js"></script>
<input type="button" id="test" value="click here"></input>
<div id="display"></div>

main.js:
var button = {
counter : 0,
click : function() {
button.counter++;
document.getElementById("display").innerHTML = button.counter;
}
};

window.onload = function()
{
var b = document.getElementById("test");
b.addEventListener("click", button.click, false);
}


Important notes:

Without this onload function, putting 'addEventListener()' directly in global scope will give error, because we are attaching <script src="main.js"> before the <input type> for 'test'. So, JS will not get this element in DOM tree. hence, onload function will wait till document is not getting loaded fully and all elements are available in DOM tree.

Friday, August 22, 2014

Handmade UnitTest framework for JavaScript

Well, I was also needing a UT framework (a very simple one) and decide to write my own in JS.

At the same time, i realize that i need to have a public GIT repository to keep all my sample code, hence i have created this link,
https://github.com/tapeshmaheshwari/JavaScript.git


So, i wrote my first JS program which is a Unit Test Framework.
@ https://github.com/tapeshmaheshwari/JavaScript/tree/master/unittest


It looks like below and based on 'assert' function.


JavaScript Unit Test Framework



  • The first pass test case simulation
  • The first fail test case simulation
  • Add two numbers.
  • GitHub file/folder addition/deletion CLI

    Launch Git Bash program installed on your system.

    To connect to sum GIT repository
    git init
    git remote add origin https://github.com/tapeshmaheshwari/JavaScript.git

    To add a file/folder into repository
    git add test.html
    git commit
    git push

    To remove a file from repository
    git rm test.html
    git commit
    git push

    To checkout full repository
    git clone https://github.com/tapeshmaheshwari/JavaScript.git

    Thursday, August 21, 2014

    JavaScript ... first post

    I have decided to learn JavaScript a bit seriously. Why? because I think there is a lot of potential in this language. From mobile apps to gaming and animation to pretty dynamic UI, all can be done with JS.

    In short, JavaScript future is bright and if someone interested in web programming, it's the must language.

    Here are some good resources i found for Web programming:

    cofee console - fast way to write js code
    sublime editor - nice editor to write JS code

    Some code example,
    http://github.com/tkmagesh => "repositories" => Cisco-AdvJs-Aug-2014

    Some JS libraries:
    http://underscorejs.org/
    http://backbonejs.org/
    https://angularjs.org/

    Books:
    secretes of the java script ninja - reading this book now a days
    speaking java scripts
    A journey through java script mbc jungle 

    Unit test and tools:
    unit test: grant.js (complete echosstem for application workflow)
    bower - dependency managment
    unit test - jasmin , mokka , signon

    Extra:
    html5 websockets - a way for server to push data/event to client
    http://www.csszengarden.com -> cool example of same html and multiple css
    http://todomvc.com/  -> same program, multiple JS scirpt

    Sunday, August 17, 2014

    How to run a simple HTTP server using python

    python -m SimpleHTTPServer
    
    
    Just run this and root directly from wherever you are running this will become the core root directly and search for index.htm (or otherwise just do the file listing)