Interesting · Open Source · Programming · Web Tech

Pug.js

What is pug.js?

Pug.js a HTML template engine for Node.js. You can write a simple pug code which the compiler will compile it to HTML code and later on browser will render it.

How does pug code differ from html code?

Pug code is a crisp piece of code which looks like a paragraph which helps in readability. Pug supports JavaScript, so using JavaScript expressions, we can format HTML code. HTML code is consists of tags and Pug also uses same tags. But pug doesn’t have closing tags.

Some thoughts…

Since pug comes as a npm package we can run using browser or on node.js using cli. One should take care of white space while writing pug code, because it can cost a big time.

 

Advertisements
Interesting · Poetics

Shah-Jahan

You knew, the Emperor of India, Shah-Jahan
That life, youth, wealth, renown
All float away down the stream of time
Your only dream
Was to preserve forever your heart’s pain
The harsh thunder of imperial power
Would fade into sleep
Like a sunset’s crimson splendour
But it was your hope
That atleast a single, eternally-heaved sigh would stay
To grieve the sky
Though emeralds, rubies, pearls are all
But as the glitter of a rainbow tricking out empty air
And must pass away
Yet still one solitary tear
Would hang on the cheek of time
In the form
Of this white and gleaming Taj Mahal
O human heart,
You have no time
To look back at anyone again 
No time
You are driven by life’s quick spate
On and on from landing to landing,
Loading cargo here,
Unloading there
In your garden the south wind’s murmurs
May enchant spring ‘madhabi’ creepers
Into suddenly filling your quivering lap with flowers
Their petals are scattered in the dust come twilight
You have no time
You raise from the dew of another night
New blossom in your groves, in jasmine
To dress with tearful gladness the votive tray
Of a later season
O human heart
All that you gather is thrown 
To the edge of the path by the end of each night and day
You have no time to look back again
No time, no time
Thus, Emperor, you wished,
Fearing your own heart’s forgetfulness
To conquer time’s heart
Through beauty
How wonderful the deathless clothing
With which you invested
Formless death – how it was garlanded!
You could not maintain
Your grief forever, and so you enmeshed
Your restless weeping
In bonds of silent perpetuity
The names you softly
Whispered to your love
On moonlit nights in secret chambers live on
Here
As whispers in the ear of eternity
The poignant gentleness of love
Flowered into the beauty of serene stone
Poet – Emperor
This is your heart’s picture
Your new ‘Meghaduta’ 
Soaring with marvellous, unprecedented melody and line
Towards the unseen plane
On which your loverless beloved
And the first glow of sunrise
And the last sigh of sunset
And the disembodied beauty of moonlit ‘cameli’ flower
And the gateway on the edge of language
That turns away man’s wistful gaze again and again
Are all blended
This beauty is your messenger,
Skirting time’s sentries
To carry the wordless message
“I have not forgotten you, my love, I have not forgotten you”
You are gone, now, Emperor
Your empire has dissolved like a dream
Your throne is shattered
Your armies whose marching
Shook the earth
Today have no more weight than the windblown dust on the Delhi road
Your singers no longer sing for you
Your musicians no longer mingle their tunes
With the lapping Jumna
The jingle of the anklets of your women
Has died from your palaces
The night sky moans
With the throb
Of crickets in their crumbling corners
But your tireless, incorruptible, messenger
Speaks to us with sombre melody
“Stare no matter how distantly
That traveller is no longer here, no longer here
His beloved kept him not
His realms released him
Neither sea nor mountain could bar him
Today his chariot
Travels at the beck of the night
To the song of the stars
Towards the gate of dawn
I remain here weighted with memory
He is free of burdens; he is no longer here
-Rabindranath Tagore
Interesting

Ubuntu and Africa

Ubuntu unlike the operating system as we computer techies know it, is a African traditional concept which comes from Zulu and Xhola languages. It is often translated as “I am because we are,” and also “humanity towards others”, but is often used in a more philosophical sense to mean “the belief in a universal bond of sharing that connects all humanity”.

The values accepted in ubuntu emphasize caring, sharing, reciprocity, co-operation, compassion and empathy in recognition that for human beings to develop, flourish and reach their full potential, they need to conduct their relationships in a manner that promotes the well-being of others.

From the beginning of time the divine principles of ubuntu have guided African societies. It is extremely important in Africa and the world at large – as the world needs a common guiding principle of human values.

Interesting · Programming · Web Tech

Quirks mode & Standard mode

Quirk in general means peculiarity or characteristic. In order to maintain backward compatibility for web pages designed for older versions of some of the browsers which does not comply to standards of W3C(World Wide Web Consortium )and IETF(Internet Engineering Task Force). Its a non-standard mode.

The recent browser follow a standard mode which complies with W3C wherein the behaviour is as per HTML and CSS specifications. For HTML documents browsers use a DOCTYPE at the beginning of the document for handling the webpage in standard mode. <!DOCTYPE html> provides the purpose of activating the full standard mode.

Interesting · Poetics

Millennial

They are millennial

All in one phone is their breath

Undisruptive presence on social media platforms

Gives a dignity to their identity

The technology rebels, as they are

Their day begins posting, reading status than TV News

They show their care with a What’s up? on whatsapp

Post instant photos on instagram

Dopamine and oxytocine released with likes, follows and posts

Prefer talking over messages

rather than a telephonic conversation

Interesting · Memoirs · Poetics

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 calling each other, 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

Interesting · Programming · Web Tech

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].