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.

Advertisements

The fence eats the crop

A slew of charitable institutions had popped up in the Kerala Catholic Church along with the rise of the Charismatic Movement, which I find nothing but Evangelical Protestantism in disguise. Mostly they are so empty-hearted that people who are in charge of such institutions run it like a business like a shop or office. No matter what happens, someone will open it in the morning, every light and fan will turn on like scheduled, and will close for the day in the evening. It is okay for a business, but for a charitable institution this can be ridiculous.

For example, I have known a place where HIV +ve people will get money for medicines. Suppose a person who is not HIV infected goes there and asks for help. They are unable to give any significant help, because funds are not allocated for any  purpose other than HIV medications. The most they can do is direct him to other places.

There is an institution called the Jail Ministry. Their mission includes preaching in jails and rehabilitation of prisoners. But in practice, the clergymen who run it are either criminals or have turned into criminals after starting this ministry.

I had once entrusted all my household articles with them in the place where ex-criminals were rehabilitated. When I came back after a few months, though everyone had known that I had not kept any valuables like cash or jewellery there, I realized that my paraphernalia had been scoured for valuables.

A table still had all my certificates with the key in my hands. I used to live in a men’s dorm at that time. Someone might have accessed my keys from there and I found out that my table’s lock has been cleanly and squarely opened, and all my papers including my educational certificates were stolen from this place that was almost five miles (12 kilometers) from where I lived at that time.

How did someone with access to the keys just enter this place? With the help of the authorities of course, and these authorities are Catholic priests. And the hierarchy can be mapped up to the very people who founded and run the ministry.

I am no Bill Gates. And every year I would think of finishing my graduation. I can’t do it because my certificates are lost. Getting duplicates of SSLC Book and PDC certificate is so cumbersome that I shirk when I think of it.

I do not know what  should I do to get my certificates back?  I would like to complete graduation and I am contemplating legal action.

In Finland, they have a saying which translates into English, The goat guarding the cabbage patch.  Like a fox guarding a henhouse. For me, the Jail Ministry is like the fence which eats into the crop which it promises to guard.

Where the philosophy is inherently flawed

Being born and raised in a traditional Catholic household, I am often worried about the direction where the world is going now. When India embraced capitalism in the 1990s and changed from a socialist economy to a capitalist economy, the aftermath of certain reforms were so radical – since a socialist economy has strong similarity to Catholicism (if not the same).

In capitalism, wealth or capital is of paramount importance although capital is not just money. People are supposed to do a job, earn money, and amass wealth which then can be used to buy goods and services. It supposedly promotes enterprise and hard work. But on the flip side, as I see in the United States, there are a large number of destitute parents, unemployed people, almsmen, homeless people, drug addicts, sex-traders, transgenders and people who are in bondage and slavery.

People like LGBT, transgenders, and the people who support them are  – some knowingly – mostly unknowingly– revolting against the one who created us. God created us with a particular sex. Man is not allowed to tamper with it. Period.

When the leader leads the followers follow. I doubt whether capitalism is playing the proverbial Pied Piper of Hamelin here. India and other third-world nations who embraced capitalism will follow suit. There will be a lot of unfortunate people here interlaced with a few ‘poster boys’ who are being hailed as the success stories of capitalism.

The problem of capitalism– taking a word from their own dictionary ­– is of the mindset. It is flawed because it is devoid of one important ingredient – Love.

Since the whole idea of capitalism is about wealth, other, more important values in life takes a back seat: virtues like humility,  kindness, abstinence, chastity, patience , liberality, and diligence. The degradation in values is not that happens mindfully. As William James, the father of modern psychology, observed –  amassing wealth and the ways-of-a-saint are quite the opposite.

I can personally vouch that my only sister is alive today because I felt compassionate enough to give her all my reserve money, an insignificant amount, so that she could go to the hospital –  and subsequently she was diagnosed with a major illness. What if I had gone the capitalist way and clung-on to my savings – which ironically I was saving for my sister also?

Retirement fund, wealth creation, savings etcetera are inherently flawed ideas. In our society our parents did not have any retirement fund just because children looked after them after retirement. We took care of our parents – for generations. Gladly too – It is our privilege.  And we do it in the generations to come.

Experience is not everything; it is the only thing

Information plays a vital role in modern life. Thanks to the internet and search engines like Google, information is freely available. Acquiring and sharing knowledge is zeitgeist, as the Germans call it. The spirit of the time. For me, gone are the days when factory owners sent their army of spies to pry on the processes of their competitors. Everything is searchable and reference-able on the internet.

This availability of knowledge has made a paradigm shift in the attributes of the average workforce. The internet makes it a level-playing field for anyone. Rejoice! Whether you are wealthy or poor, able or disabled, white or a colored person, talented or otherwise  –  you are playing at the same level with your peers. Or competitors, if you look from that perspective.

Let me explain. You are a C++ programmer by profession. You write C++ code for a living. Suppose, one day you are struck with a problem. Naturally you search for it in the internet. And the same resource is available in the internet to anyone who searches for it.

You are a doctor. You suspect something in the patient. And you can search the internet to bolster or belie your assumptions. Again, the patient himself could have looked for it if he had the experience to suspect like the doctor.

So, for us, who grew up with the internet – our calling is to become a jack-of-all-trades. From computer repairs to word-processing-software, and chess-openings to playing Solitaire;the internet provides us with the information.

So searching the internet and acquiring knowledge – will it help you to become better at your job? Well – only if you do not already know how to search the internet.  Well, for me, paradoxically, the key is just the opposite. It is called specialization. Knowledge is freely available. Google and the internet will be there tomorrow also. To contribute effectively in the workplace, you have to find your niche. You have to be better at a particular craft than anyone else.

Recently, I saw a programmer job with this line. “Please apply only if are able to code without the help of the internet.”

Whether it is computer programming or graphic design, content writing or chip-design, rocket science or medical research, the key is focus and practice. In the end, all the hours you spent on practice will show up on your work. Work hard, work smart, and work long on your skills.

Just as the man in the audience told the great musician after a concert, “I’ll give my life to play like that”; the musician replied. “I did”.

I am thinking of a career in Computer Programming

It was 1988 – 1989, and I was in ninth standard (ninth grade). One computer training institute under the auspices of the Archdiocese had ‘sold’ their student-computer-training-course to our school. I was one of the few students who got the money from our homes to do that introductory course. The theory session covered all the basics of computers and also the basics of GW BASIC programming language which were being taught right after school in the evenings. A handful of practical sessions were also arranged in the air-conditioned computer lab for which we had to go to their institute on holidays. I still remember the two PCs costing about Rs 100,000 each at that time. Intel 486 or 386’s ? I think it was 386s. Rs 100,000 was also the price of a new Ambassador Car at that time. So, adjusting for inflation, those PCs cost somewhere in the region of Rs 300,000 to 350,000.

We learned about Charles Babbage, Analytical Machine, valve-based computers, LSI and VLSI,  first , second, third, and fourth generation computers and the impending fifth generation. But there was no mention of Ada Lovelace.

For the practicals, we started with computer games and then ran the GW BASIC programs we learned.

10 REM PROGRAM TO FIND THE PRODUCT OF 2 x 3

20 LET A = 2

30 LET B = 3

40 LET C = 2*3

50 PRINT C

60 END

and then hit ‘RUN’

Voila 6!

From then onward PCs exploded onto the scene, and by 1996 computers were ubiquitous. At least it was like that for students. That was when I decided to learn a course in Computerized Accounting. I went to the same institute and this time, I was a grown-up. The curriculum had an overlap with PGDCA students (Post Graduate Diploma in Computer Applications), so for the theory classes I had to sit with them.

Basics of Computers, binary number system, and the like. That was when I learned that to do a subtraction in binary, you just have to swap (in the number to be subtracted) ‘all the zeros with one’ and ‘all the ones with zeros’ and do an addition. The result would be the same. That is how computers handle subtraction.

I remember Java becoming popular.  Java compiles into code that is run on the JVM (Java Virtual Machine). So it is platform independent. Whether you have Windows, Mac, Linux, or any other operating system, once JVM is installed, it will run Java. It is unlike C language, which compiles into machine code which is different for different computers.

Notwithstanding all these, I never thought that I could become a computer programmer. I was totally frustrated by the thought of communicating with a machine that knew nothing but machine code, a string of 0s and 1s. Then I decided to learn more about programming. The findings astonished me.

In the basic sense, computer programming is asking to do the computer what we want to do. If we type something onto a word processor and we don’t like the font, we change it by selecting whatever we have already typed, and then pull down the font menu; and after selecting the new font, we press ‘Enter’. The font is changed. This is using a word processor, but the idea is same. You are asking the computer to do what you want to do.

We need not reinvent the wheel. We all learn the multiplication table in school. 7 x 7 is 49. We learn it by heart.  Whenever we encounter 49 in life, we can break it down to 7 times 7 or vice versa. This is the gist of programming. All the code is broken down to simpler code, and all the simple codes are assimilated into complex programs. And ultimately, it is compiled down to binary that the computer can understand.

In the above analogy, code is already written to make a word processor. When we select what we have already typed, and then pull down the font menu; and select the new font, and press ‘Enter’ – code is executed in the background.

In the same sense, for a piece of computer program, I select a few lines of code that is already written, and modify it to suit my needs. If I write it properly, it will run smoothly. I need not worry about all the binary code that is ultimately going to get processed.

It is the quality of our human brain. We can only process a certain amount of data at the same time. We can only deal with a few things at the same time. But hundreds of people, or even an individual can use hundreds of instances to process small chunks of data. When sequentially and logically written, it becomes one big piece of software.

The problem solving approach is the right way to look at programming. You need learn to program logically, learn about computer algorithms, study about data structures and the like. I am thinking about a career in computer programming.

There are serious flaws to our education system

As a part of my current job as typist near a University, I am regularly encountering all sorts of thesis reports.  From an undergraduate level to Ph.D.  These tomes are a part of their requirement for the award of the Degree from a University: whether it is B.Com, BBA or MBA ; or M.D. for medical doctors, and Ph.D for teachers.  What I see is terrible standards of writing.

My job as typist, and MS Word Specialist, is to edit all these reports into printable form so that they can be digitally printed and bound into a presentable format. Spelling is a problem for many. The universally accepted convention is to follow either British or American spelling throughout the document. Follow either British or American spelling, but there has to be consistency.  I suppose the culprit is the default dictionary in our word processor like MS Word. Most people have an American dictionary installed, and since Indians like to use British spelling, things can get complicated.The solution: change the dictionary.

Even some doctorate level scholars do not know the difference between ‘effect’ and ‘affect’. The government effected a change, and it affected people. It has to be as simple as that. I still consider these scholars to have domain knowledge, but it could have been better if their English is impressive also.

But when it comes to undergraduate students – BBA, B.Com, and even students of courses like M.B.A, things get very pathetic. Totally made up thesis reports, plagiarism, and the grammar can’t be edited without change in meaning. Sometimes, I do not understand what is being written. Without understanding the semantics of a sentence, syntax can’t be changed.

In my days, two decades ago, the government was very supportive of education up to Matriculation, or Class 10. The government, or the education system, would give ‘moderation’ or free marks to ensure that you pass out to the next class. If you need to go any higher than Class 12, then no ‘moderation’ or free marks were there. You got to earn it yourselves. That is why we have good scientists even to send our small spacecraft to Mars – a feat never achieved by any nation in their first attempt.

Currently our education system is something like this. You spend some time and some money in pursuing an undergraduate degree or an M.B.A. After the stipulated number of years, if you follow the system – bunk classes, make up attendance registers, use dissertations and thesis reports that are ‘recycled’ at least ten times – you get your degree, no matter what. Is has become as simple as that.

For thesis reports that are ‘recycled’ at least ten times, I guess the process is like this. It starts with fewer mistakes. Every typist who typed it would add to the errors and ‘typos’ of the former typist, and after about  ten ‘recycling’  the current report will have no resemblance to the original. I mean, “What does this sentence mean?” type of errors. Every report is ratified – signed and co-signed by the teachers also. ???

Personally, I would not recruit any of them. I am not an employer, and I do not intend to become one, but my advice to potential recruiters would be to stay clear of these people. These are people with degrees with the value of the paper that is used to print the certificates.

How to be more productive at work?

Every boss or manager would be happy if their employees’ productivity is increased.  Increased productivity means increased output which translates into increased profit. Employees also like to increase their productivity, because the more productive they are the more valuable they are to the company which means that at least their take-home-pay would be higher.

If productivity is so important, then how to be more productive at work? When it comes to being productive at work the most important component is motivation. Motivation can be both intrinsic and extrinsic.  Rewards such as increased pay and bonuses are extrinsic motivation.  But the most important type of motivation comes from within – we try to be more productive because we like to me more productive. This is a well researched and well debated subject.  This is why increased pay and material rewards do not always make employees more productive.

How to be more productive at work? A simple method is to work longer. This is commonsense. If an employee works longer, rest assured, he will produce more output.  This is not always possible due to labor issues.  If an employee is rewarded with a pay that is commensurate with output he will be motivated to work longer.  Japan was literally ground zero after World War II but was quickly able to recuperate and became one of the biggest industrialized nations of the world.  It is mainly attributed to their work culture.  A 12 hour workday was (and still is) more of a rule rather than the exception.  But as people of Japan realize that there are more important things in life than literally die doing work, Japan is also adopting the strategy of decreasing working hours and increasing output in whatever hours they work.  In other terms they are also thinking about how to be more productive at work.

How to be more productive at work?  The key is to be focused at work. Keep workplace chit-chats and personal emails to a minimum.  Also while we do this, it is important to know the output we are supposed to give. If something can be measured it can also be delivered. While working, note down the things that increase or decrease productivity.  Also, motivation is of paramount importance.  It is the job of managers and bosses to keep their employees motivated. A workplace filled with eagerness and excitement is bliss. And let us strive to make our workplaces one like that.