07 December 2022

Add shutdown and reboot menu options to GRUB

I have ALWAYS wished for this, and can't believe it was only now that a lightbulb lit up in my head. There are plenty of times you'd be at the GRUB (Grand Unified Bootloader) menu, and wish you could simply shutdown from right there, instead of pressing the power button or booting into the operating system and then shutting down. 

This should have been a default option in GRUB. Anyway, here's how you add it:

I saw this technique here, and this is why I like Linux more than Windows or Mac. There are tons of things you can customize.


This file allows you to add custom menu options to GRUB:

 sudo gedit /etc/grub.d/40_custom

Add these options to the end of the file, save and exit:

menuentry "Reboot" {
      reboot
}

menuentry "Shut Down" {
      halt
}

Update GRUB:

sudo update-grub

Reboot the computer.

27 November 2022

Why a Macbook is no longer good for Linux programmers

I have relatives who use a Mac because somebody told them it's a good quality product or because they want to go with the brand-hype created around the Macbook. I understand brand-craze or the desire for a product that makes one feel good or something that offers the right features. So if a programmer is comfortable with (and actually wants) a Macbook (after evaluating if it’s really going to help be productive), let them buy one. The rest of them would be more-than-happy with any other good computer which has Linux installed. For non-technical people who don't understand why many Linux programmers abhor the Macbook, I'm listing out the reasons here so that you don't inadvertently purchase them a Mac, thinking you are doing something nice for them (there was a time when I heard a relative was planning to buy me an expensive Apple product for my birthday, and I promptly sent back a message through the grapevine that I'm not fond of Apple products).

Linux is not Unix.

There’s no more of the “good build quality” that was once synonymous with Apple. There’s no more of the good design decisions either. 


I’ve used Mac’s for almost four years, and the only thing I’ve liked about it is the absolutely amazing display quality. Besides, for programmers who work on Linux, it’s far better to have a computer that runs Linux and has a hardware architecture that is compatible with the software they commonly use.

Reasons not to use a Macbook

  • No Type A USB ports: This is by far the biggest horribly deranged decision that Apple has taken. Not having Type A USB ports means that you can’t use your existing pen drives or mouse unless you buy a Type C USB 3 adapter. What drove this decision? Greed?
  • No cut and paste in Finder: You can’t right-click to cut a file and paste it. You are expected to copy it to a destination folder and then come back and delete the original file. There is of course a shortcut, and you can drag and drop the file to move it, but somebody in Apple doesn’t seem to understand good engineering.
  • Hardware architecture changed: Macbooks now have an ARM-based architecture. I’ve already had trouble compiling certain programs on it. I've also had trouble building some Docker containers that used x86-based programs, because of this underlying ARM architecture.
  • Glassy monitor: Even when I turn the monitor away from any windows, and it’s facing a wall, I still see my own reflection and the wall on the monitor. Constant glare.
  • Key functionality like Home and End don’t work: There are keyboard shortcuts for the Home and End buttons, but they don’t work when using the Terminal. They’ve also wrongly named “Backspace” as “Delete”. Programmers use Home, End, Del, Page Up, Page Down, and Backspace a lot. Not having these keys tends to get frustrating.
  • Caps-Lock and other keys sometimes not detected: This is one example of the poor build quality. When I press the caps-lock key, the key press does not always get registered. The same happens even for the Ctrl and Command keys. This is on a brand new Macbook.
  • Ctrl sometimes; Command sometimes: In Linux, a lot of functionality just uses Ctrl+some.other.key. On Mac, it’s sometimes Ctrl and sometimes Command. I know the functionality can be changed to some extent in settings, but it doesn't always work out the right way. Why did Apple have to meddle with such a basic functionality?
  • Terminal not available on right click: For a programmer, one of the little pleasures in life is to open up any folder, right click on an empty space there and open a Terminal. That’s not available on Mac. It can be enabled, but being disabled by default shows that a Mac is clearly not designed for programmers. There are more terminals that can be installed.
  • Headphone not detected on startup: I keep my headphones plugged in, and when I start the Mac, sound plays through the default speakers. Only when I disconnect the headphone jack and re-connect it, the sound is played via the headphone. An example of poor testing procedures.
  • Vim lazy exit won’t work: The vim editor has a shortcut for saving and exiting. You can press Esc and then Shift+ZZ. It’s called the “lazy exit”. On a Mac, if you’ve opened a file using sudo, the lazy exit won’t work. You’ve got to use the “hard-working” exit ;-) Esc, wq!. Or Esc, x.
  • Keyboard backlight not available at login screen: Yet another example of poor testing. At the login screen, the keyboard backlight does not turn on.
  • psutil won’t work without sudo: This is meant to protect programs from accessing other program’s memory, but it’s really annoying that if I’m using a Python program that uses psutil, I’m expected to run the program each time as sudo python3 prog.py and type the password. The least that the designers of the OS (Operating System) could have done, was to provide a modal box that asks and marks a program as trusted, so that Users won’t have to keep using sudo.
  • psutil functions like io_counters not available: So if I want to create a Python program to measure network I/O, it’s not easy. Wonderful.
  • bashrc and profile don’t work: Apple shifted those files to /etc/profile, so it’s only after a lot of searching that you get to have your aliases and startup scripts work. Then after restarting, you realize that even that doesn't work. Use ~/.zshrc.
  • Barely any good default favourites in Finder: Normally, it helps to have commonly used folders like Home, Downloads, Desktop etc. in the Finder favourites pane on the left by default. But no. You are expected to drag and drop them to create it.
  • Icons don’t auto-align in Finder: Even setting the icons to snap to grid and making it the default for all, won’t make it work for all folders.
  • Properties being “Get Info”: In Windows and Linux, when you want to see the properties of a file, you right click and find the properties option at the bottom of the menu. In Mac, you’ve got to adapt to recognizing it as “Get info”, and it’s not at the bottom of the menu. Nice in some ways, but annoying in other ways.
  • Workspaces need work: Being able to use Ctrl+Alt+Arrow keys to switch between workspaces is one of the pleasures of using Linux. Mac OS seems to allow it only if you go to settings and enable it. Moreover, the “hot corners” tend to get confusing when one accidentally takes the mouse pointer to one of the corners and all windows suddenly disappear.
  • Can’t dual-boot Linux natively: On modern Mac’s that have a silicon chip, you can’t install a dual-boot Linux OS on the Mac anymore. Great way to create a monopoly and drive away people.
  • Bash history not enabled by default: There are plenty more people asking about this. It was a silly decision not to save history...and then make it even more difficult to find the right options to enable history.
  • Exit does not exit: If you select the "Quit" option from the menus on the top right, the application does not actually quit. You are expected to go to dock and right click and exit. This gets annoying when using apps like GEdit, where if it's opened from the terminal, you can't proceed unless it has fully exited.
  • Shutdown does not shutdown: Select shutdown from the menu, and the Mac does not shutdown. You have to select shutdown again for it to shutdown. Who are these people ruining the Mac UX?
  • Updates downloaded for different version: I was shown update suggestions for some software and a suggestion for upgrading to the next version of MacOS. I didn't want to upgrade, but I decided to update the other software. So I start the time-and-resource-consuming 1.5GB update and lock screen. I come back after a while to see that the downloaded update encountered some error. After another try, I realize that these updates are meant for the next version of Mac OS. Why on earth did it download before the OS was upgraded? Such large updates even for installed software are another issue with Apple.
  • Renaming is a pain: Right click to rename a file or folder, and even though the name is shown as highlighted, when you start typing, you realize that the text isn't getting edited. Then you have to right click or click again to make it work. 
  • Pointless audio previews: If you click the middle of a video file, it starts playing the audio from the file, when you just wanted a video player to open the file. So you have to be careful to click at the edge of the file icon. Who designed this usability nightmare?

There may be more points I’d include soon. Linux is far more customizable and programmer-friendly. Do a favour to your Linux programmers, and give them a computer that has Linux installed natively. It is especially helpful when they need to test locally and deploy onto Linux-based servers. There's more discussed on Workplace Stackexchange.

03 November 2022

Adjusting subtitles of a video

 

Many of us have been through the annoying feeling of viewing a video where the subtitles are off by one or two seconds. This is especially true when it's a foreign language video, and the subtitles are extremely important. Have you ever thought of using a software to adjust it? Well, there are plenty of them.

I tried Gnome Subtitles recently, and under the "Timings > Adjust" menu option, I could shift multiple selected subtitles by the number of seconds I wanted to adjust them (make sure the name of the video and the subtitle file are same, in order to ensure that the video opens up automatically when you open the subtitle file). Quite a handy tool! For more recent versions of Ubuntu, you can use many other software, including KDenLive.

You can also adjust subtitles using VLC or FFMPEG.

The SRT file

Although called "SubRip" files, the SRT stands for SubRip Text (in web format, they are Subtitle Resource Tracks). The time that each subtitle should be displayed is represented as <hour>:<minute>:<second>,<millisecond>. There's even support to specify the font colour, font style and even the coordinates to display the text at.

Generating subtitles

There are people whose jobs involve performing audio transcription. They'd listen to audio, type in the text and the time at which the text appears. The process is very cumbersome because they need to constantly move forward and backward along the audio track, while needing to type what they hear. This means their hands are always occupied. So some enterprising individuals decided to create a foot-operated pedal which the transcriptionists could use to control the audio playback. The pedal allowed them to rewind, pause, play or fast forward.

Of course, today there are machine learning algorithms which detect speech and automatically generate subtitles. Even if the transcription is incorrect at places, it's easier for the transcriptionist to fix it. 

I'll leave you with an amusing "interview" of a person who is quite confident that he does not require subtitles.


05 October 2022

Does your food pass my Stomach Test?

Have you too been taught from a young age to “respect” food? To gobble it up without question? To politely compliment everyone’s cooking “skills” if they cook something for you? To chime in with everyone’s comments on “the food was good/great”? I’ve met many people who go through stomach pain, sleep loss, acid reflux, flatulence (fart attack?) and bloating, but they either have no clue about which foods are causing the problem, or they fear speaking up about the food quality. Perhaps it’s also a loss of hope that things would ever improve.

It’s time we brought The Stomach Test into the picture, to provide our digestive systems a beacon of hope. It’s not yet a comprehensive test. It’s a start. It needs inputs from your experience, to be refined and improved. “Stomach” here, is meant to encompass the entire digestive system.

The Stomach Test

When delving into finding The Real Cure for Eye Strain, I desperately had to figure out what caused my sleep loss. So I kept track of everything I consumed for a year. You’ll not realize the importance of these points if your digestive system recovers quickly enough. People tend to think they have a stomach of steel. However, as you age, or when you suffer on a daily basis, you’ll notice what I did. Food has to pass my six tests to qualify as “good food”:

  1. No burnt food: Burnt particles in food cause digestive discomfort, which leads to sleep loss. I now throw off the black, burnt spots from bread toast, barbecued chicken, parathas/rotis, etc. If onions, mustard seeds, cumin seeds, curry leaves or anything else gets burnt when frying them, throw it away and start over.
  2. No under-cooked food: Food that felt like chewing-gum, also resulted in sleep loss (it wasn’t cooked properly) and it’d result in flatulence and/or loss of appetite (I believe the digestive system creates this loss of appetite, to take time to recover). Cooking rice, parathas and other rotis properly is especially necessary. I’ve written more about it below. Well-cooked food also kills germs and tapeworm eggs, for example (you should also be aware that some bacteria form heat-resistant spores). I would also add unripe fruits to the category of “under-cooked” food.
  3. A healthy, balanced proportion of ingredients: Spicy food is never really a problem if it’s balanced well with other ingredients. Avoid foods that contain excess salt, oil, or sugar (many processed/packaged foods have these in excess). It’s important to diligently follow the ingredient proportions of well-established recipes.
  4. No adulterants: Oh I just don’t know what to say about the evil/ignorant scum who adulterate food. It’s not just adulterants. Ideally, this point should also encompass pesticides and formalin used to preserve fish. Why on earth are people not actively investigating and eliminating food adulterants? Water from certain water filters that left a “layery” feeling in my mouth and even the way certain coffee was prepared, resulted in stomach discomfort that led to sleep loss.
  5. Hygiene: You know about washing hands before eating. What you may not know, is how Helicobacter pylori is transmitted and how it damages the stomach. Avoid places where people or situations can cause bodily fluids, dust, pollutants, insects, or filth to contaminate the food.
  6. Spoilage: This one is obvious. Don’t let the “respect food” philosophy convince you into eating spoiled food just because you don’t want it to be wasted. Simply throw it away.

Miscellaneous info

  • Rice and flat-breads: Remember this: It is not necessary that that rice grains should be separate from each other when cooked. It’s more important that rice is cooked with sufficient water for the right duration (or even boiled with excess water and then drained). Most varieties of rice need four or five cups of water per cup of rice. I know you’d be surprised if you’ve been taught to use just two cups of water. Do a bit of searching and understand the role of amylose and amylopectin. Freshly cooked rice has reasonably separate grains, and that texture feels good while eating. On cooling, rice will clump up, and that’s normal. Using less water to ensure that cooled rice grains remain separate, is counterproductive. Rice cooked with insufficient water can cause sleep loss. I’ve also noticed that many people don’t ensure that chapathis and parathas get fully cooked (inner portion).
  • Cooking knowledge: There are many stalls and eateries, where the people who cook the food are not professionals. They need to be trained. Even people in well-to-do families are often not taught how to cook. This leads to serious errors not just in the way they cook food, but also in how they use cooking equipment. I’ve heard of certain European schools which teach children how to cook. Wouldn’t it be prudent to have a professional cooking course in school or at least in college? Cooking and cleaning are basic life-skills. Knowledge about what constitutes a well balanced diet (and why it’s necessary) is also essential.
  • Hair loss: When the digestive system suffers from the effects of bad food, the body seems to go into a state of distress. Sleep loss is one characteristic, but I’ve noticed that excess hair loss (from the head) also happens. Given that DHT (DiHydroTestosterone) is one reason for baldness, I’d suspect that excess DHT or testosterone is produced when the body goes into this distress mode. I’m not sure about this, but I did notice a drastic reduction in excessive hair loss, once I started getting better sleep as a result of eating food that passed my Stomach Test.
  • Identifying what causes it: Flatulence and loss of appetite can be signs that certain foods caused trouble in the digestive system. Different people respond to various foods differently, so over a period of time, diligently figure out which foods are affecting your sleep. It can be food from a hostel, a restaurant, a stall, a bakery, cafe or a packaged snack or even from somebody at home who does not understand the principles of cooking. Make sure you get well-cooked home-food.
  • The best drink: It’s not coffee, tea, beer, or a carbonated beverage. The best drink is DiHydrogen Monoxide (water).
  • Cooking time and water quantity: As mentioned above, rice requires 4 to 5 cups of water per cup of rice. Upma requires 3 cups of water per cup of rava. Chapathi’s and porota’s/parathas need to be heated until properly browned (but without any black burnt spots). It’ll become crisp at this stage. Alternatively, avoid flour and refined flour if it isn't cooked/baked properly. I’ve noticed a strong correlation with consuming it and the eruption of dandruff and skin flaking.
  • Recognizing problematic meat and dairy: Although food-poisoning symptoms are well known, a recent problem has manifested after eating meat, which appears to be a urinary tract infection or kidney stone, but is probably not. So doctors will prescribe urine tests and ultrasound scans, and everything will turn out normal, but the excess urination, urinary incontinence and a cringing feeling at the kidney areas won’t stop. I’ve found this to happen with some purchases of chicken, fish and dairy. It sends the kidneys or bladder into overdrive. Causes excess urination, and the kidneys or bladder reacts adversely to various foods. Also, one loses appetite but does not feel weak. When this happens, and the doctors have confirmed that it isn’t a problem they recognize, the best thing to do is to throw away the meat and switch to eating very small meals of vegetables and upma only when hungry. Drink plenty of water and wait for a few days for the problem to resolve on its own. I don’t know what causes it, but my guess is that meat may be affected by diclofenac, poultry may be affected by antibiotics or hormones, fish may be affected by formalyn, and dairy may be affected by melamine.
  • Meat diet: I came across a person who claimed to suffer ulcerative colitis on consuming grain, fruit or vegetables. He survived on a meat diet (which isn’t exclusively meat though, as per the stories of Vilhjalmur Stefansson). There is a critique on such a diet, and there’s speculation on whether the lack of a diverse microbiome or helminths could be a reason for the problems. In any case, this was interesting information, which is why I’m mentioning it here, but the advice and constant monitoring of a doctor is necessary if one chooses such remedies.

The Impact

When you see people who snap and get irritated at the slightest annoyance, there’s a good chance that they have not got proper sleep. Sleep loss does that to people. There’s a lot of friction in this world that can be avoided when people are calm and composed. Having access to food that passes my Stomach Test is one part of ensuring good sleep.

We really need to do a lot more, to ensure that our loved ones and the people of our country have access to well cooked, nutritious food. Knowledge, training and awareness are a large part of ensuring it happens.

07 September 2022

Stop Google Chrome's annoying update notification

It's annoying. Open Chrome and click the address bar to type an address, and suddenly the cursor disappears and Chrome's annoying update notification is displayed and given focus.

Sure, updates are necessary. But not when I'm busy with something. This update notification is exactly as annoying as the silly forced wait time enforced by Microsoft Windows updates. Interaction designers at Microsoft and Google really need to educate themselves on improving user experience. There are better ways to implement security updates.

Anyway, on Ubuntu, the way to get rid of it is by setting a faraway simulated update date:

sudo gedit /usr/share/applications/google-chrome.desktop

Search for the lines starting with "Exec=" and add a --simulate-outdated-no-au='Tue, 31 Dec 2099 23:59:59 GMT' flag.

So a line that looked like this:

Exec=/usr/bin/google-chrome-stable %U

Would become this:

Exec=/usr/bin/google-chrome-stable --simulate-outdated-no-au='Tue, 31 Dec 2099 23:59:59 GMT' %U

That's it. Now you can start Chrome without the annoying update notification.

If you want it to start in incognito mode each time or in fullscreen mode each time, you could also add these flags: --start-fullscreen --incognito.


In Windows, as this answer states, simply use RegEdit to open the key [HKEY_CLASSES_ROOT\ChromeHTML\shell\open\command] and add this argument:

--simulate-outdated-no-au=\"01 Jan 2199\"

 

If you are an Engineer, remember this. Design software to be usable. Instead of making users go through this complex process of disabling the update notification, provide a checkbox to set a reminder date and time or to switch off those notifications.

12 August 2022

Making Ubuntu recognize and use the swap partition instead of using the swap file it created

This happened when I deleted my old Ubuntu partition and re-installed a newer version of Ubuntu. Even though there was a logical swap partition present, Ubuntu simply ignored it and created its own swap file. A glance through the Swap FAQ showed me how to fix it.

First, you need to have a look at what the UUID of your swap partition is. Do that by running:

blkid

Search for the line containing TYPE="swap", and note the UUID at the start of the line. This is the UUID of the swap partition. For example, the UUID may be fdb91fbe-e580-467f-8819-b672d89261eb.

Now open up fstab.

sudo gedit /etc/fstab

If there's a line starting with "/swapfile", comment out that line using a hash at the start of the line "#/swapfile". This is the swapfile that Ubuntu used instead of using the swap partition you had created.

Now add a new line to the file, where you mention the UUID that Ubuntu can use to recognize the swap partition:

UUID=fdb91fbe-e580-467f-8819-b672d89261eb none   swap    sw      0       0

Save and exit. Reboot.

Voila! The swap partition will now be recognized.


11 August 2022

Another of Google's Easter Eggs: Dog and cat paws. Even Batman zooming across the screen!

It's a relief from the daily grind to see one of Google's Easter Eggs in the form of some animations, games or silly suggestions. This time, it was to celebrate international cat day. When you Google "cat" on your desktop web browser, or with your mobile phone browser switched to "desktop mode", you'll see a paw icon animating on the right side. Click it and then click anywhere else on the screen, and a cat will leave a paw mark. You can see the same when you search for "dog" or "bruce wayne".



I decided to have a look at how they did it, and there was a difference in the code of the page when there is an animation and when there isn't. Just a bunch of JavaScript.

It's nice that Google allows its employees to show some creativity from time to time. Something that other companies could learn from.


05 July 2022

Discover the sneaky application that's taking up your hard disk time

At times, the noise from the hard disk is very persistent. It's busy accessing something, but I only have a web browser open, and it's doing nothing that should be consuming so much of hard disk time. So I try running top and even install htop and run it, but it does not show me what's taking up so much hard disk time.

A bit of searching leads me to iotop. This cool application shows you hard disk usage in the same way that htop and top show you memory and process usage.

Install using:

sudo apt-get install -y iotop

And use as:

sudo iotop


In my case, it was the silly snapd daemon that was pointlessly using up hard disk time. So I set it to more reasonable timings.


07 June 2022

How to boot Windows 10 or Ubuntu 22.04 on a legacy computer without UEFI

When attempting to install Windows 10 or Ubuntu 22.04 on legacy systems, you need to have something more than just the ISO image on the pen drive that you use as a boot medium.

For creating a bootable Windows 10 medium


If your plan is to create the bootable pen drive in Ubuntu, don't do it. Instead, go to a Windows system and download Rufus. Run Rufus, select your pen drive and ISO file from the options in Rufus and select MBR instead of GPT. The GPT option is for modern systems which have UEFI. 

Also, select the checkbox for installing additional 'things' for legacy system support.

Now your install will work without problems.

For creating a bootable Ubuntu 22.04 medium

When I used Ubuntu's startup disk creator and tried booting from the pen drive, the screen just showed a blinking cursor on the top left of the screen and the installation didn't proceed. The same thing happened when I used Rufus to write the Ubuntu ISO to the pen drive, without selecting the checkbox for installing the additional 'things'.

However, when I used Rufus with the checkbox, everything worked fine.

On second thought, don't bother installing Ubuntu 22.04. There are still some errors that they haven't fixed, and some third party programs do not seem to have developed API's to be fully compatible with it. As Jesse Smith wrote: "I think the launch of Ubuntu 22.04 is a clear sign Canonical is much more interested in publishing releases on a set schedule than producing something worthwhile. This version was not ready for release and it is probably going to be a costly endeavour to maintain this collection of mixed versioned software and mixed display server and mixed designs for a full five years. It's a platform I would recommend avoiding".

02 June 2022

Preventing Snap from consuming resources indiscriminately


The snap daemon can often take up a lot of processing power, RAM and even hog your internet connection if you don't define a specific time during which it is allowed to perform updates.

The solution is provided on the Snap website, but I thought I'd mention it here for easy reference.

For example, if you don't want it to disturb you at all,  you could set it to:

sudo snap set system refresh.timer=fri,3:00-3:01

This is of course, assuming you won't be using the internet on Friday at 3am :-)

 

Other options are (taken from the Snap website):

  • Mondays at 10:00, Fridays at 15:00: sudo snap set system refresh.timer=mon,10:00,,fri,15:00
  • Mondays at 10:00 and 15:00, Fridays at 10:00 and 15:00: sudo snap set system refresh.timer=mon,fri,10:00,15:00
  • Monday to Wednesday and on Friday, twice between 9:00 and 11:10: sudo snap set system refresh.timer=mon-wed,fri,9:00-11:00/2
  • Mondays, some time between 9:00 and 11:00, and on Wednesdays, some time between 22:00 and 23:00: sudo snap set system refresh.timer=mon,9:00~11:00,,wed,22:00~23:00
  • Monday and on Wednesday, at 0:00: sudo snap set system refresh.timer=mon,wed
  • 2nd Monday of the month, through the following Wednesday, between 23:00 and 24:00: sudo snap set system refresh.timer=mon2-wed,23:00-24:00
  • Last Friday of the month, from 23:00 to 1:00 the next day: sudo snap set system refresh.timer=fri5,23:00-01:00

02 May 2022

How to get Android Studio in Ubuntu application menu

Installing Android Studio in Linux is kind of boring. They just give you a compressed file which you have to extract, and the installation instructions say this:

  2. Open a console and cd into "{installation home}/bin" and type:

       ./studio.sh

There's a simpler option. Install it using snap. 

sudo snap install android-studio --classic

However if you don't want to use this version created by the Snapcraft ream, use the default Android Studio from the official website. First, navigate into that bin folder using a terminal and make the sh file executable using:

chmod +x studio.sh


Now type:

sudo -H gedit /usr/share/applications/AndroidStudio.desktop

and enter the following contents in the file:

[Desktop Entry]
Version=1.0
Name=Android Studio
Comment=Android SDK
GenericName=IDE
Keywords=IDE, Android, SDK, Studio
Exec=/home/yourUsername/android-studio/bin/./studio.sh %u
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=/home/yourUsername/android-studio/bin/studio.png
Categories=GNOME;GTK;
StartupNotify=true


That's it. After you close the file, you'll be able to start Android Studio from the Ubuntu app menu.

27 April 2022

How Prince of Persia was made

Recently, I came across Jordan Mechner's video in which he explains how he used rotoscoping to animate the characters in Prince of Persia. It was his brother who did a lot of the jumping.  Prince of Persia also won six Guinness World Records, among which one was that it was the first motion-capture animation used in a video game. It reminded me of some of the games I created. Especially Digger Forever, for which I painstakingly drew animations on paper and typed out each pixel into the program. You can scroll down the code here (starting from line 593) to see the animations. During those days I considered rotoscoping to be "cheating". At that time I expected people to simulate human motion via algorithms.


You can play the game online if you like. There appear to be some downloads that could probably be used via dosbox.

One other pleasant surprise was that the princess we rescued, was also played by a real person: Christina Marie LaDeau "Tina" Ciccone. She was an 18 year old at the time, and the daughter of Jordan's colleague. Here's the hug sequence being played by the two shy youngsters.


When you think about it, the dungeon and palace that the prince has to run through, is rather amusing. You have lonely guards standing at odd places with swords drawn the whole night. You have spikes, unstable flooring, tiles floating in the air, metal jaws operated without electricity, potions kept at odd places, deep pits, guards who show no weakness after being struck by the sword, and the "horror" of fighting a sword-fighting skeleton. 

 

Plump guard in level six. This is where I learnt to use the up arrow key for defence

Floating tiles

So who brings the guards their food? If they were to visit the canteen, do they have to run and jump to catch hold of some ledge and then clamber up and down? Do they have to navigate the spikes and metal jaws when they go to pee? There's no toilet in the palace or dungeon either :-) There's even a big, friendly neighbourhood mouse that not only knows its way around the palace, it also knows who the prince is, and it knows how to open gates. Toward the end, Jaffar does not even bother having a few guards to protect him. Quite amazing how we ignore these to be able to solve puzzles and save the graceful princess.

Preparing to fight Jaffar

Anyway, it was indeed a lovely game. Quite challenging to figure out the puzzles (jumping through the mirror in the fourth level, using "ahimsa" against the shadow Prince in the level twelve, using the slow-fall potion in level seven, figuring out how to run over invisible tiles in level twelve). I managed to do it without referring to any walkthrough and without using cheat codes. I still remember a lot about how to get through the game. Carefree days. *sigh*


Message shown after completing the game


Prince of Persia on other platforms and re-makes

David X Newton created a video that shows how Prince of Persia was ported onto various platforms, the new ideas and bugs that they had.

Variations on various platforms

 
Reaching "hell" in the lower sections

Anime cut-scenes in the CD version

A change in scenery

Some kind of a demon or god who drops things on you

Another one of David's videos reveals a surprisingly good looking 3D look of the game. This version allows you to do back-flips too.


 

3D princess and an amusing ticking hourglass

Stunningly brilliant scenery and lighting

 

The prince being pushed into the dungeon initially by the guard

 

Some people have posted about "secret levels", which are just bugs that show up when you use cheat codes to revive a dead prince. People have even created custom levels and mods.

That's quite an impressive amount of effort and time put into this iconic game!

Update: July 2023: A person with the alias n3cr0ph0b1a on 9gag, used the pixelated princess image and used AI to create this beauty:




02 April 2022

Examining the source code of a Firefox addon / extension

When using a Firefox extension created by someone, you grant access to various websites you visit and to the content of the websites. How do you know if the extension can be trusted?

I recently wanted to check an addon, and it was possible to do it this way:

First, right click the "Add to Firefox" button and copy the link.


The link I copied is: https://addons.mozilla.org/firefox/downloads/file/3915177/i_dont_care_about_cookies-3.3.7-an+fx.xpi

Open a terminal and use the following command to download the addon:

curl -L https://addons.mozilla.org/firefox/downloads/file/3915177/i_dont_care_about_cookies-3.3.7-an+fx.xpi > theAddon.xpi

 

The downloaded addon is an XPI file (pronounced as "zippy") which can be extracted using your existing unzip program. 

Just right-click the file and extract.

 

Once extracted, you can examine the source code of the addon. Note that some authors may have minified their code, which not only makes it difficult to read, it also slows down the text editor, when you open the file, because all the source code will be in a single line.

So, before opening minified code, first un-minify it using a pretty-printer or an un-minification tool.


That's it. Examine the source code and see for yourself if the extension is trust-worthy.


18 March 2022

Using Android apps on a PC or Mac

This actually began as a search for whether I could install Ubuntu on my phone. Turns out there are some ways. There's even the Pine Phone. These would actually be a much better option than our current phones that contain bloatware and are gleefully invading our privacy.

Then I wondered, if Ubuntu could be installed on a phone, could Android OS be installed on a PC? Recently, WhatsApp had notified my uncle that it would no longer run on his old iPhone, and in the effort to help him find a solution, I found ways to install Android on PC or Mac.

 

CAUTION:  Before using any emulator or app, please read all license terms and check if what you are doing is permitted as per the EULA of the software.


Trying WhatsApp on BlueStacks

If you try BlueStacks (which I've written about earlier too) to install WhatsApp, you can do it as listed below (but make sure you check the license agreement to see if it's ok to do so):


  • Install BlueStacks5 and select the APK button on the right side menu and select the apk file you just downloaded.

  • Follow instructions on the screen to install WhatsApp.
  • Enter your phone number and you'll receive an SMS to confirm it. Once you verify it, you can add new contacts and start sending and receiving messages in WhatsApp.

Note that in this whole process, it isn't necessary to install WhatsApp on the phone. Whether using BlueStacks is safe or not (in terms of privacy and security), I don't know though. So I'd typically consider using it from within a sandbox or virtual box (again, it's necessary to check the license agreements to see if it's ok to do so).


Other Android options

You can also download ISO files and install Android on your computer just like how you'd install Ubuntu or any other operating system. This would possibly mean that it could be installed via Virtual Box too (I'll be trying this out in a while).

While there are various options, I'll probably also try one or more of: PrimeOS, Android x-86, Bliss OS or LineageOS

If you are a big fan of Android games, and while playing on your mobile phone you see yourself being defeated easily, there's a good chance the other players are either playing the game from their PC, using one of these operating systems or they would've connected a keyboard and mouse to their phone.


ps: Framework laptop even brings us modular laptops that we can repair ourselves. Not yet available in India though.


12 March 2022

Companies be careful: Your open source salad may go kaput if you don't perform basic checks

When providing my expertise to a company as a consultant many months ago, I reviewed their code and architecture. One of the suggestions I asked them as a question, was whether they maintained backups of the various versions of the open source code they used. That question seems ever more relevant now.

Today, I came across a shocking article by Niclas Gustaffson, which outlines how an open source developer introduced malicious code in his open source project as a mark of protest. This went on to cause problems in even a large company that used the code. 

 

What did he do?

According to the article, this developer named Marak Squires, introduced an infinite loop...

for (let i = 666; i < Infinity; i++;) {

...which caused a Zalgo text issue that makes gibberish appear on the screen of projects that used some of his code.

The gibberish that appeared on one users screen

The changes were made to colors.js (2,67,01,901 weekly downloads and allegedly, 19K projects dependent on it) and faker.js (apparently used to have 2.8 million weekly downloads and 2.5K dependent projects).

 

Why he did it

Marak had apparently announced in Nov 2020, that he'd no longer be supporting large companies who used his software for free. 


Why this isn't right

When anyone is accepted into the open source community as a creator or a contributor, it's done with a great amount of trust and respect. It should be an honour for a person that so many people use their open source project. If Marak didn't want to support large companies unless they paid him, he could have made an announcement that he's no longer working on the project, and stopped updating the repository. By introducing malicious code, he broke everyone's trust and even maligned the good reputation of the source community. A stark contrast to all the responsible developers who have built reliable systems like Linux, Git, Firefox and so many open source projects.


What can be done by companies?

  • Well, first of all, setup a CI/CD system right from day one. There are companies involved in projects of high importance (I'm not going into details), which do not have such basic infrastructure setup. The CI/CD infrastructure will ensure that you always have multiple working, shippable versions of your software even if the latest build broke.
  • Keep backup versions of all the open source code you use. Remember that the code comes with no guarantees.
  • Build a test-run framework where you can test the latest version of the project before you actually deploy it to a customer-facing server.
  • Have a security team perform an audit of all your code. Even the open source libraries you use. Learn about zero day exploits.
  • Consider donating to open source developers, Wikipedia, StackOverflow or any other such source where you get knowledge and resources for free. There are many ways to contribute.
  • Consider involving your developers in open source projects. Not on their time. Do it on company time. I know ThoughtWorks allows this.

 

I condemn what Marak did. However, it also reminded me of various ways in which deserving people like scientists are exploited (they make discoveries and publish it but don't get royalties or anything in return, even when companies use those ideas and massively profit from it), while un-deserving and deceitful people like fake god-men and other corrupt people and certain corporations are given respect and are allowed a pompous lifestyle by a gullible society. 

Anyway, open source developers, please maintain your integrity.

06 March 2022

A Guide for People Researching Eye Strain

During the past decade, on consulting multiple doctors, I realized that they were unable to cure my eye strain because of a lot of incorrect information floating around. This in turn, was possibly affecting the direction of research, because researchers probably didn’t know what to analyze.

Rather than begin with commonly propagated notions about the cause and cure of eye strain. A better way to begin, is by speaking with people who have experienced severe eye strain. It’ll help dispel a lot of the myths, when they tell you what solutions didn’t work.

My tips for researchers

Find a way to measure strain of the intraocular and extraocular muscles

It is necessary to find an objective method of measuring the various stages of severity of eye strain. These objective metrics need to be correlated with subjective feedback from the test subjects and compared with a control group. If there are mismatches, then a better method needs to be invented/innovated. This needs to be done under baseline conditions, and during variation of various test parameters. In subjects with chronic strain, at least the spasms of the inferior oblique muscles are somewhat easily detectable. The sharp, stabbing pain at the superior oblique, lateral and superior rectus are also important.

Name and quantify the various stages of eye strain

There are various stages. One is when the healthy eye begins to water a little, and there are reflexes where the tired eyes try to gently close, as a message to the person, to stop straining the eyes. People tend to ignore this and continue torturing the eyes. Then there’s the stage where the forehead muscles are tensed and pain (which people call “headache”). There’s another stage where the front of the eyeballs have a burning feeling. This is a severe stage. Then there are sharp stabbing pains around and behind the eyeball. This is an acute or chronic stage. In the chronic stage, even the cheek muscles are strained. There are possibly more severe stages, as experienced by Jack.

Know what factors affect the strain

At least in my experience, eye strain is affected by sleep duration (specifically, not getting uninterrupted sleep for an age-appropriate duration), food (proteins giving muscle endurance, and how various foods affect the digestive system, causing sleep loss), age, spectacle lens-type (plastic vs. glass), duration of strain, nature of strain (watching a movie, driving, reading a book, looking at a digital screen etc.), duration and quality of rest, naps, angle of viewing (also take note of which muscles get to relax while the subject reads when lying down), brightness, blink rate, muscle tension, and perhaps other medical conditions. Measure these with and without using aids like eye drops or spectacles. Check and find out how natural, commonsense methods can reduce strain.
The response from the subjects would also depend on their ability to comprehend and honestly respond to the test questions. The observations need to be noted everyday for a few years at a stretch. Sleep duration, interruptions in sleep and the type of edibles consumed (the quality and whether it was properly cooked/baked/fried) needs particular attention (because it affects sleep quality and muscle endurance).

Check and quantify if and how parts of the eye are affected by strain

These include the intraocular muscles, extraocular muscles, eye lens, pupils and cornea. It would also help to check if there are variations or swelling that affect the shape or size of any part of the eyeball, especially in cases of chronic strain. I would not be surprised if constant tension on the eyeball could be one reason for progressive myopia.
 

Measure the extent and rate of recovery when strain causing situations are removed

Remember that the rate of recovery differs. People with mild strain recover quickly, but people with severe strain can take months or years to recover. This can help avoid pointlessly prescribing spectacles to people who don’t really need spectacles. It can also help organizations and schools create guidelines that prevent people from overworking and damaging their eyesight. Normal vision is too precious a gift to ruin.
It may also be possible to re-design computer work in a way that does not require us to focus our eyes at a single location for too long.

Obtain statistics on normal sighted people too

Perform large-scale surveys on normal-sighted people. Check how many of them in rural and urban populations, have slight myopia, hypermetropia, astigmatism or any other eye issues, and are yet able to lead normal lives without requiring spectacles or medical intervention. Check for how many years the situation remains unchanged (or how and when it changes). This will help create a baseline and help provide deeper understanding into when medical intervention is really necessary and when it can be avoided. For example, it’ll help gauge if it is normal for one eye to be of a slightly different power than the other eye. It’ll help understand how eye power varies over the course of a day and returns back to normal, without any severe or long-lasting consequences.

Establish guidelines for spectacles

Measure how poorly aligned spectacles/lenses affect strain. Check how the position of the focal point of the spectacles affects strain. Objectively verify how distortions caused by lens-types affect the amount of adjusting that the eye muscles need to do (you’ll need test subjects with chronic eye strain to get measurable results). Quantifying the minute light distortion among various lens types at various radii and angles from the focal point, will also help (perhaps using lasers could help verify this). Establish guidelines for opticians and spectacle manufacturers to follow. Many of them are amateur/irresponsible enough to not even take any measurements when they take an order for spectacles. Some even try to force improperly aligned lenses onto their customers. It’s necessary to establish strict rules for opticians to measure the dimensions of the subject’s face and position the lenses at the correct focal point, at the right angle and distance from the eyes.

Establish guidelines for eye tests

The results from the studies above, can help establish guidelines for what questions doctors need to ask a patient. The one fundamental question I’ve noticed that’s lacking, is that doctors don’t bother asking and verifying if the patient is getting sufficient sleep, rest and nutrition. It would help to do more groundwork to help identify the right tests to do and identify the various stages of strain and know the causes. This can help avoid a lot of pointless tests (there are certain tests being done unnecessarily even though no symptoms are observed). There also needs to be a mechanism to periodically check and correct problems and alignment issues with the frames that hold trial lenses and perhaps even the computerised eye test equipment.


Know the source of funding

Know who is funding your research. Make sure it is from an unbiased source that actually cares about people’s health and wishes that people can enjoy normal vision.


Most importantly, don’t forget to think out of the box and look for other causes/factors/cures. If you discover that any of my assumptions were incorrect, do let me know (after thoroughly verifying it). As a person of science, I’ll be happy to correct myself.


Say thank you or donate

25 February 2022

Creating template files in Ubuntu

In Ubuntu 20, the right click menu didn't have an option to create a new document. So when I looked it up, it turned out that it was possible to achieve this functionality, simply by creating a Templates folder and creating a file in it.

mkdir ~/Templates

touch ~/Templates/Text\ File.txt

I was skeptical that this would work, but surprisingly, it actually did!!!

New Document works!!!

Wanting to get to the bottom of how this works, I asked around, and was shown this page that revealed this as a standard feature where you can simply place a template file.

So I tried creating an xlsx file using Libre Calc, and saved the file in the Templates folder.


Sure enough, simply placing it in that folder was enough to make it appear in the right click menu.


Terrific functionality that's useful to anyone who does a lot of boilerplate file-work. I'm sure there would be people who have used Linux all their lives, who don't know about this functionality.