The Nandanvan Park

There’s a park opposite my window
“Nandanvan” is its name

Standing still, changing its shades with seasons
From vivid green to dry yellow tan
Through the clouds of rain
Scorching sunny summer
And windy winter
Bushes of short shrubs, tall thick trees
Chirping birds, racing squirrels
Witnessing diversity all around

From lively kids to limping patients,
From gossiping women to debating men,
From a headphone stucked lonely stranger to couples in romance,
From casual strollers to disciplined joggers/runners

Selflessly, with no prejudice
Embraces warmly, one and all
Part of this park solaces them all

Haply, “Nandanvan” seems to be an apt name
After all

Composed by Vinit Desai

Advertisements

Fun with JS array functions

If you are a JS programmer you must have used arrays quite often. While working with arrays, we somehow always tend to use for loop or Array.forEach() function followed by conditional if-else block checking. To bring into practice the use of already existing prototype array functions we have to understand when to use which functions. So, lets have some fun in understanding and KISS(Keep It Simple, Stupid!). Most of this function are self explanatory from their names itself.

Array.find() method returns the value of first element present in the array that satisfies the testing condition else returns undefined.
var arr = [35, 98, 78, 1, 8, 3];
var findEle = arr.find(function(ele){
return ele > 50;
});
console.log(findEle);

This will return 98 which is the first element that satisfies condition ele > 50.

Array.findIndex() method returns the index of the first element in the array that satisfies the provided testing function else returns -1.
var arr = [35, 98, 78, 1, 8, 3];
var findEleIndex = arr.findIndex(function(ele){
return ele < 10;
});
console.log(findEleIndex);

This will return 3 which is the index of first element that satisfies condition ele < 10.

Array.includes()method determines whether an element is present and returns boolean.
var arr = [35, 98, 78, 1, 8, 3];
var isPresent = arr.includes(98);
console.log(isPresent);

This will return true as 98 is present in the array arr.

Array.some() method determines whether atleast one element of the array satisfies the testing condition and returns boolean.
var arr = [35, 98, 78, 1, 8, 3];
var isPresent = arr.some(function(ele){
return ele > 50;
});
console.log(isPresent);

Array.every() method tests whether every array element passes the test and returns boolean.
var arr = [35, 98, 78, 1, 8, 3];
var test = arr.every(function(ele){
ele > 10;
});
console.log(test);

This will return false as 1 and 3 are less than 10 and test condition fails.

Array.map() creates a new array by applying some action on every element in the original array.
var arr = [35, 98, 78, 1, 8, 3];
var mapValue = arr.map(function(ele){
return ele * 2;
});
console.log(mapValue);

This will return an [70, 196, 156, 2, 16, 6].

Array.forEach() executes action(s) for every elemnt in the array. It is similar to for loop.

Array.filter() creates a new array depending on if the condition is satisfied or not.
var arr = [35, 98, 78, 1, 8, 3];
var mapValue = arr.filter(function(ele){
return ele > 50;
});
console.log(ele);

This returns [98, 78].

Invictus

Invictus means undefeated” in Latin. A poem written by British poet, William Ernest Henley about how a human spirit overcomes challenges in the face of adversity.  There is a movie titled Invictus(wherein, this poem is recited masterfully) that narrates the true story of how a great leader like Nelson Mandela joined forces with the captain of South Africa’s rugby team, to help unite their country and won the world cup.

Out of the night that covers me,
Black as the pit from pole to pole,
I thank whatever gods may be
For my unconquerable soul.

In the fell clutch of circumstance
I have not winced nor cried aloud.
Under the bludgeonings of chance
My head is bloody, but unbowed.

Beyond this place of wrath and tears
Looms but the Horror of the shade,
And yet the menace of the years
Finds and shall find me unafraid.

It matters not how strait the gate,
How charged with punishments the scroll,
I am the master of my fate,
I am the captain of my soul.

XML, XTHML and SGML

XML is eXtensible Markup Language is a markup language developed by W3C(World Wide Web Consortium).
It defines a set of rules that are self descriptive.
It is designed to store and transport information or data which is wrapped in non-predefined tags unlike HTML which has predefined tags. The author of XML has to define the tags and document structure.

XML separates data from presentation. That is, it carries the data but does not carry any information about how to display it. The formatting and displaying is taken care of by HTML. A typical XML document is tree structure that starts with a root and branches to leaves. XML has syntax rules and any XML document that conforms to these syntax rules is said to be “Well Formed” XML document.

XHTML stands for eXtensible HyperText Markup Language. It is almost similar to HTML but more stricter than HTML. XHTML is developed by combining HTML and XML. Where is it strict?

  • XHTML DOCTYPE is mandatory
  • XHTML document must have one root element
  • <html>, <head>, <title>, and <body> are mandatory
  • XHTML elements must be in lowercase, properly nested and closed

SGML stands for Standard Generalized Markup Language is a standard for specifying a document markup language or tag set. Such a specification is called Document Type Definition(DTD). Therefore, it is not considered language in itself but a metadata.

SGML was derived from GML (Generalized Markup Language), which allowed users to work on standardized formatting styles for electronic documents. Apparently HTML and XML use SGML principles. Meaning, SGML is a superset of HTML and XML.

ECMAScript

What is ECMAScript ?

ECMA is a short form for European Computer Manufacturer’s Association. ECMAScript (ES) defines a standard and contains specifications for scripting languages such as JavaScript (Netscape /Mozilla browser implementation of the ECMA specification)and JScript (Microsoft’s Internet Explorer) developed by Brendan Eich in 1995. Therefore, one can also say that ES is a superset of JS and JScript.

That means it is used for client side scripting such as JavaScript and  for writing server side applications and services using Node.js.

Several editions with new feature support per edition have been published for ECMAScript. It should be noted that with each version release, there were support compatibility issues with some browser’s versions.

 

 

Javascript bundling and minification

Bundling is basically concatenating all small or big javascript and or css files into one huge file to minimize the number of requests and hence load on the server.

To speedup loading of a webpage bundling and  minification of the bundled code is necessary. Minification is the process of removing unnecessary characters like whitespace, comments, new line characters etc. from source code to reduce the overall size of the content without changing the functionality of the code.

So, less file size means lesser time to process and download files. Of course, there are various approaches to bundling and minification using bundlers like Webpack,  Browserify, RequireJS etc.

No Indispensable Man

Today is 1st May, Labour’s Day – an annual holiday all over India that celebrates the achievements of workers. But with AI(Artificial Intelligence), robots and machines trending in I fear Labour is put back by machines, not completely, though.

Yes! but future talks about taking it  over completely. Some thoughts on the same and also when you are in need of introspection, this is the poem by Saxon White Kessinger

Sometime when you’re feeling important
Sometime when your ego’s in bloom
Sometime when you take it for granted,
You’re the best qualified in the room
Sometime when you feel that your going,
Would leave an unfillable hole,
Just follow these simple instructions
And see how they humble your soul.  

Take a bucket and fill it with water,
Put your hand in it up to the wrist
Pull it out and the hole that’s remaining,
Is a measure of how much you’ll be missed.
You can splash all you wish when you enter,
You may stir up the water galore,
But stop, and you’ll find that in no time,
It looks quite the same as before.  

The moral of this quaint example,
Is to do just the best that you can,
Be proud of yourself but remember,
There’s no indispensable man.