Pages

Thursday, December 24, 2015

JS: Insertion Sort

Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at a time.

Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data, finds the location it belongs within the sorted list, and inserts it there. It repeats until no input elements remain.

Here is a practical implementation of it.
    

JS: Fibonacci sequence

The first 21 Fibonacci numbers Fn for n = 0, 1, 2, ..., 20 are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765.

The sequence can also be extended to negative index n using the re-arranged recurrence relation

Fn-2 = Fn - Fn-1

So here is a sample program to generate Fibonacci series or sequence.
 

Friday, October 16, 2015

App: The Legacy Game of FLAME

It is a legacy game of FLAME, that children and teenagers use to play on their crushes. The theory of flame states that it could forecast the relationship in between 2 person by doing a flame-test on their individual names.

The result of flame-test would be one out of these
  • F = Friends 
  • L = Lovers 
  • A = Affectionate 
  • M = Marriage 
  • E = Enemies

Now keep the worry aside and let's play the game of flame.


The FLAME test result is NA

Although it's fun but please don't rely on this as a matter of concern.
Have fun!

Sunday, June 21, 2015

Sanskrit: The dictionary of बीजाक्षर

It is not correct to say that one Sanskrit word can be used in different places with different meaning in different contexts as संस्कृत is considered, even by Western Indologists [uncompromising people], as a scientific language which means in-variance in truth factors, a basic requirement of a scientific entity and, it consists basically of 'बीजाक्षर' – conceptual seeds, embodying an entire ‘Concept’ in a Phenom.

The dictionary of बीजाक्षर is as follows:
अ = antonym of, 
आ = invite, 
इ = include, 
उ = uplift, 
ए = era, 
ओ = old, 
अं = to the edge, ultimate,
क = what, question, inquiry, 
ख = space, sky, 
ग = to move, 
घ = to bend, 
च = and, in connection with, 
छ = clean, 
ज = to take birth, 
झ = splash, 
त = place, placement, 
थ = heavy placement, heavily placed, 
द = to give, 
ध = holding, 
न = negative, non, 
ट = virtue, 
ठ = large, 
ड = scare, causing fear, 
ढ = poisonous, 
ण = atom, very small quantity. 
प = guard, to take guard, 
फ = to manifest, 
ब = aspire, 
भ = suddenly appear, from unknown to known, 
म = welfare, 
य = go away, exit, 
र = acquire, 
ल = act of taking, 
व = carry, hang on to, 
श = pure, clear of impurity, 
ष = superior, supreme, the best, 
स = inseparably together, 
ह = forcefully carry away, 
क्ष = exist invisibly, 
ज्ञ = know, 
क्र = exchange, 
प्र = regimented, regulated, 
त्र = defender, protector, 
घ्र = sniff, 
भ्र = revolve, 
नृ = hero, principal, 
कृ = grace, 
तृ = twinkle,
व् = veil, cover, 
उ = uplift, develop, 
क्ष् = exist invisibly.

(श + इ + व): शिव = possess and carry purity; 
(नृ + प):नृप = Principal protector;
(क्र + य): क्रय = gone in exchange; 
(न + भ): नभ = negative of sudden existence – previously existing: 
(ख + ग): खग = moving, mover in sky, space; 
(क्ष + ण): क्षण = invisibly atomic, small unit; 
(व + ह): वह = carry forcibly; 
(ह + व): हव = forceful carrier; 
(ध + न): धन = non holding, expendable; 
(छ + व + इ): छवि = clean placed inside; 
(ल + व ): लव = act of taking the carrier; 
(र + ण ): रण = acquiring a small possession; 
(ल + क्ष +म = इ): लक्ष्मि = taking possession of welfare not yet known; 
(घ + न): घन = unbending; etc. 

So, the ‘concepts’ involved in 
वृक्ष are → [a cover, veil of] + [uplift, develop, evolve] + [that exist invisibly]: 
Existing invisibly a surrounding/veil of evolution.

Thursday, February 5, 2015

JS: Open on InAppBrowser for Cordova/Phonegap based mobile application

There is requirement when we want to load the external link inside our mobiapp. So to ease the process I have created a class that will help in achieving it. You just have to create an instance of it. That's it!
var OpenOnInAppBrowser = function () {
        window.name = "projectname";
        var iabRef = null;

        window.notifier = {
            flag: false,
            start: function() {
                if(!window.notifier.flag) {
                    window.notifier.flag = true;
                    navigator.notification.activityStart('Loading!', 'Please wait ...');
                }
            },
            stop: function() {
                window.notifier.flag = false;
                navigator.notification.activityStop();
            }
        }

        var iabLoadStart = function (event) {
            console.log('OpenOnInAppBrowser -> iabLoadStart: ' + event.type + ' - ' + event.url);
            window.notifier.start();
        }

        var iabLoadStop = function (event) {
            console.log('OpenOnInAppBrowser -> iabLoadStop: ' + event.type + ' - ' + event.url);
            window.notifier.stop();
            var curl = event.url;
        }

        var iabLoadError = function (event) {
            console.log('OpenOnInAppBrowser -> iabLoadError: ' + event.type + ' - ' + event.message);
            window.notifier.stop();
        }

        var iabClose = function (event) {
            console.log('OpenOnInAppBrowser -> iabClose: ' + event.type);
            window.notifier.stop();
            iabRef.removeEventListener('loadstart', iabLoadStart);
            iabRef.removeEventListener('loadstop', iabLoadStop);
            iabRef.removeEventListener('loaderror', iabLoadError);
            iabRef.removeEventListener('exit', iabClose);
        }

        this.init = function (iUrl) {
            console.log('OpenOnInAppBrowser -> init: ' + iUrl);
            iabRef = window.open(iUrl, '_blank', 'location=no,toolbar=no,hidden=no');
            iabRef.addEventListener('loadstart', iabLoadStart);
            iabRef.addEventListener('loadstop', iabLoadStop);
            iabRef.addEventListener('loaderror', iabLoadError);
            iabRef.addEventListener('exit', iabClose);
        }
    };

/*
 * Usage
 */

var openOnInAppBrowser = new OpenOnInAppBrowser();
openOnInAppBrowser.init(link);

// link = 'http://www.google.com/'