St Francis of Assissi and the fires of hell

While I was writing and coding a tribute page on Ayrton Senna, I found out that this quote belonged to him.

“Wealthy men can’t live in an island that is encircled by poverty. We all breathe the same air. We must give a chance to everyone, at least a basic chance.”

We breathe the same air.

Jesus Christ said “Love thy neighbor”.

Not love your countrymen.

But it is unfortunate that certain unscrupulous businessmen violate this very rule, ‘Love thy neighbor’, to make money.

In my former neighborhood there was a wealthy man.

In broad daylight he was a man of the church.

But in the night he sent spies to pry on the neighbors.

Including me.

Everyone has secrets: Bad deeds. Transgressions. Law violations.

According to this particular businessman secrets are power.

To know other people’s secrets is a way to exploit and/or undermine them.

So how did he do it?

During sleep, the people in the house and his neighbors has access to a person.

Anyone with a basic understanding of how the mind works can influence another person in sleep.

It requires at least two people.

One person will try to influence him.

Pamper him, canoodle him, frighten him, threaten him.

And the second person will intently try to extract information from his mind.

Kind of narcoanalysis. Minus the injection.

It is collectively using more than two people’s resources against a single person.

Evil.

This businessman is long dead.

But his family still follows his practice.

The world is moving forward.

In his years there were no multimedia players.

Currently, one can plug a mobile phone to the ears before sleeping.

Listen to Mozart, Beethoven, or Bach.

Or hear his own speech he had made in the last sales meeting.

Sleep uninterrupted.

That is how I am still sober to write this blog.

Advertisements

Three biggest JavaScript mistakes for beginners

It is great joy to see your little computer program work as expected.

The joy is accentuated by the fact that you are really not a computer programmer. You do not know how to write a device driver in ‘C’. Hence, successfully writing and running code in relatively simpler scripting languages like JavaScript can be extremely satisfying.

JavaScript has a syntax that is borrowed from Java which in turn is borrowed from ‘C’.

So in another words, JavaScript has a ‘C’ like syntax.

The main difference is that ‘C’ is strongly ‘typed’. ‘Typing’ is a concept where we declare the ‘type’ of each variable when it is declared.

int a;       // Here we are explicitly stating that the variable ‘a’ is an integer.

float b;   // variable ‘b’ will be a floating point number a.k.a. decimal fraction.

The type of each variable cannot be changed during its lifetime.

But in JavaScript, variables are ‘loosely’ typed. We need not declare the type of each variable beforehand.

var a;

We can assign anything to a. ‘a’ can be an integer, a floating point number, a string, anything.

The JavaScript interpreter will determine its type during run-time.

When I started to program in JavaScript, I realized that my idea was right most of the time. But errors prevented the code from running successfully.

I found out that just three kinds of errors accounted to more than 80% of all the beginner errors.

#3: Bad spelling

I had to include this. Beginners typically will not use editors that help you with code hinting. When using the browser console, it is very important to spellcheck your code. If a function is spelled myfunction(); trying to invoke it with myfuntction(); will throw an error. Your hard work is not rewarded.

So always spellcheck your code.

For example,  there is an extra ‘t’ in myfuntction();

# 2: Always put quote marks around strings

const myvar = “name”;
This is the one of the biggest mistakes beginners make. It doesn’t need too much explanation.

Always wrap a string in quote marks.

const number = 10;
console.log(number); // will log 10. No quote marks because number is an identifier for 10.

console.log(“sentence”) // will log sentence. Notice the quote marks.
// console.log(sentence) will throw an error.

Single or double quotes?

It is a style preference. But be consistent, and always remember to put one around a string.

#1: ‘=’ is the assignment operator; and ‘===’ is the strict equality operator

Look at this code:
var myNumber;
myNumber = 10;
if (myNumber === 10) {
console.log(“The number is 10”);
}
else {
console.log(“The number is not 10”);
}

It is so easy to make this mistake:

if (myNumber = 10) {
//bad code
}
“=”  is used to assign value to a variable. To check “is equal to” you have to use either “==” or “===”.

These are the biggest mistakes a newbie programmer make. Personally, I find the rate to be over 80%.

So just avoid these three beginner mistakes, and rest assured, your code will run cool.

Happy coding!

 

The first person ever to have used Malayalam in JavaScript Code

Malayalam is the language of Kerala, the southernmost state in India. Compared to the major languages of the world, only a minority of people speaks it. But Malayalam has a rich and colorful heritage.  Kerala state government is even trying to make it the language for official communications. English was used hitherto.

Typing in Malayalam was cumbersome. There was not even an unified keyboard layout. Things have vastly improved in the last couple of decades. The last ten-or-twenty years saw more improvements than in the last century taken altogether.

But running JavaScript in Malayalam? It is not possible in its entirety. Not just in Malayalam, but not in any other language other than English. Because web browsers like Chrome and Firefox has to interpret it. JavaScript syntax is written and interpreted in English.

As it turned out, I found that the Array method forEach() accepts any argument for its callback function. Basically, what the forEach() method does is that it iterates over every item in the list.

Out of curiosity, I decided to pass an argument written in Malayalam for this.

One problem here is that the computer does not understand Malayalam. So when encountering foreign languages, what programmers do is that they convert it into their Unicode equivalent.

I typed out Malayalam and converted into its Unicode equivalent. I then used it as the argument for the callback function here.

See it for yourself. The interpreter parses it just as fine.

Malayalam in JavaScript

Owing to the complexity of this method, and the experimental nature of the project, I presume I might be the first person ever to do this.

Typing Malayalam into JavaScript code.

I know nobody ain’t gonna give a s* about it.

The problems of studying when knowledge is aplenty

To learn something new, traditionally people used to rely on books. It is said that books are the collective wisdom of men who have lived in all the generations throughout the history of mankind. So when a man of humble origins wanted to have ‘success’ in life, he would typically refer to books to gain knowledge in those areas he wanted to learn and master. Those were older days.

Look at this day. It seems that God has heard all the prayers pertaining to information and learning, and knowledge is freely available. It is available in quantities that would have made the older generations guilty of possessing.

But to become learned, availability of information is only one factor. It is only a piece of the puzzle. I have already written an earlier blog which stresses the importance of experience to learn anything. Experience comes with practice. And to practice in this information–guzzling, data-driven, well-connected world you have to ignore all those information coming in. There lies the paradox. It is a great challenge that only a trained mind can tackle.

Let me explain. If you sit with the internet to learn something, after a few minutes you will start to get distracted. Firstly, it will be an innocuous link. Something that promises to teach you more of something you want to learn. You click on that, and you land on another page. And whether or not you get more information, the internet is luring you with even more data.

Get swayed by this temptation, and after sometime you don’t gain anything for all those pages visited. The gain-to-noise ratio is too small.

Let me talk about computer programming. To learn anything of value you have to whack your brain. You have to focus hard. And the process is so hard that I personally get discouraged and distracted after a few moments. Adding to that, with the information overload, you are tempted to skim the surface rather than resort to hard work.

I do not know what to do. To browse and skim the surface is a lot of fun, but it does not add value to the learning process. It is just a waste of valuable time. Better use the internet and the information-superhighway to get access to the materials you want to learn. After that, shut out. Block everything. It is time for the old-fashioned way of burning brain-glucose by taking the strain and feeling the pain.

And self discipline can help here a lot. It is more beneficial for learning than having all the bandwidth available.

Make my day!

It is 6.00 a.m. in the morning. The sun is starting to light up the room through the window. I comfortably lie on my bed just out of a dream. I twist and turn to sleep again because there is no work today.

Anyone reading this would assume that today would be a holiday, but actually everyday is a holiday for me right now. I quit my job last month and finding another one has not been successful yet.

Being single, and being jobless is a very bad idea. Apart from the fact that I find it really hard to pay my bills, I am overwhelmed by the feeling of loneliness. I have no one to talk with.

Today, after scrambling out from bed, I started to research on the subject of strategy: Military Strategy- Alexander the Great vs Darius. It was 300,000 of Darius’ Persian Army vs 45,000 of Alexander’s Macedonians.

In those days, (and still today), being superior in numbers is often the deciding factor. In a regular battle, the larger army would slaughter the smaller one. But this battle was different. Alexander outsmarted, outmaneuvered and outran (through the flanks) an army five times about his size! Hundreds of thousands of Persians were butchered that day and their bodies lay on the ground waiting for the raptorial birds to prey on.

Strategy is a good subject. It is especially good for reading on a holiday or on a long journey. But reading it on a day like this will not hold me in good stead in my quest to find my next job.

I thought about it for a while. What value can I give for a potential employer? I do graphic design. I write. I do DTP. I design websites. I would be of potential help to some ad agency.

Or if nothing works out, I can do medical transcription. I was a professional medical transcriptionist some time ago, albeit for shorter durations.

Days like these are bad for certain reasons. Apart from no-pay, there is the problem of wasted time. It is a valuable resource that I can’t redeem if not used properly.

So what do I do? I make a list of on-job skills that I want to get better at. I plan for my each day the night before. I work on my skills that I want to improve. I make it quantifiable.  And I review it every night before I go to bed. I ask, “What improvements did I make?” “What can be done differently to make an even better advance?” “Did I waste my time doing things that did not make any difference?”

I am single, and periods like this will recur. I feel it prudent to acknowledge it. This way I will be better prepared every time it happens.

TV and social media is destroying humanity. It is not like you would think.

Kerala is a small southern Indian state by the Arabian sea. As late as 20 years ago, people had at least three dialects that correspond to the three regions – south, middle, and parts of Kerala north-of-the-town-of-Thrissur. People native to these areas used to speak with slight variation in pronunciation and stress.

Malayalam is not a stress-time language. Still, with the idiosyncrasies in stress and pronunciation there was clearly more than one dialect. Not anymore.  Due to the spread of TV, and the popularity of Malayalam channels, everybody now speaks a standard  version of Malayalam.

Consider the people of France, Spain and Italy. They all spoke the same language – Latin. People of these countries used to speak the same language with their characteristic variations. Gradually, these three dialects evolved into three distinctive languages ­- French, Spanish, and Italian.

What if they had TV and electronic media during those early days? Latin would have stayed the same. Arguably, these countries collectively would have had little or no cultural improvement.

If everybody craved for the same things, the world would not function normally. People have varied interests. That is how it was and always been. Some people like to sing while other people like to play a musical instrument. Some love apples while some others love pineapples.

The problem is that people are influenced by what they see and hear. Not just TV. There is internet and social media on everybody’s pocket thanks to the mobile phone.

There is this story of The Babel Tower from The Old Testament.

People turned arrogant and they started building a tower intending to reach up to heaven. God foiled them by confusing their languages. Since nobody understood each-other no more, their attempt was thwarted.

For me this is vital: For humanity to survive, there has to be originality within societies. Among civilizations.

If we need uniqueness in arts and culture, I do not think we are living in the right age. Thanks to TV and the social media. And it is high time we thought about the consequences.

The Joy of Writing (and Running) simple scripts on a web page

For me, the one quality that separates the good ones from the bad is continuous learning. I would suggest that everyone learn something new continually for the rest of their lives. The results can be outstanding.

One example I can show is the venerable Raju Narayana Swamy. An alumnus of my school and college, he had acquired the habit of going deep on a subject early in his life. When he topped the SSLC exam in the state, he reportedly had books on Differential Calculus in his study at home – a subject other students would start to learn only from the next year. He topped literally every exam he has written in his life including the Civil Services (he was No.1 in India). It seems that he has a habit of continually acquiring degrees.  Last time I checked out, it was a few years ago, this brilliant civil servant had just earned a degree in Cyber Law.

I have a tip for learning. Always add to what you already know. Do not bother too much about what you do not know. If you know how to drive a car, try to learn to drive a 6-wheeled truck. If you know basic cooking, try to learn to do specialty dishes. If you do public speaking in your family gatherings, try to speak in the town hall.

Going by that analogy, I am learning to write simple scripts in JavaScript. When the web started out, there were other languages that could be used, like, VB Script and Java to manipulate the DOM. What is DOM?  For the uninitiated, I would say that DOM is the various elements on a web page. DOM stands for Document Object Model.

Currently, JavaScript is the de facto programming language of the web.

I can attach a ‘hook’ to the body element.

<body id=”hook” > </body>

I create a button and add the onclick event handler.

<button onclick= “changeColor ()” > Change Color </button>

I define the function here. (inside script tags)

function changeColor () {

document.getElementById(“hook”).style.backgroundColor =”yellow”;

}

I see a button named ‘Change Color’ on the screen. And when I click on that, the function is called, and the background color of the web page is changed to yellow.

A lot of people might consider me crazy for writing this.

This is even crazier. Look at the image below.

News Headlines

I did not not use any JavaScript for this. I simply used Inspect Element (Cntl + Shift +I for Chrome on Windows). I then selected one of the news headlines and manually changed it. The above image is the screenshot of the web page.

This is much simpler than it meets the eye.