24 December 2020

The better way to calculate permutations programmatically

When wanting to calculate factorials and permutations, I was surprised that C++ didn't have a built-in function to do it. Sure, it's a simple function, but cmath could have had one instead of expecting users to write their own function. Anyway, I created a class for it and soon realized that even unsigned long long was unable to hold the large numbers that I was calculating permutations for.

This led me to the online calculators, which did ok for conditions like 81 numbers taken 81 at a time (which gives a huge result: 5797126020747367985879734231578109105412357244731625958745865049716390179693892056256184534249745940480000000000000000000).

However, calculations like 129600 taken 2 at a time, were not supported, so when I searched for which programming language could help, I found that Python was just perfect for this. Turns out, numbers in Python are only limited by the amount of RAM you have. Intelligent people, these people who maintain Python. 

Python does have a limit on how deep your recursion can go, so rather than use recursion to calculate factorials, it's better to use the humble for loop. Here's how it's done:

def factorial(n):
    fac = 1
    if n == 0:
        fac = 1
    else:
        for i in range(n,0,-1):
            fac = fac * i
    return fac

print("To calculate permutations:")
print("n!/(n-r)!")
n = int(input("Enter number of possibilities (n): "))
r = int(input("Enter how many at a time (r): "))
print("Permutations: ", factorial(n)/factorial(n-r))



11 November 2020

The Real Cure for Eye Strain

When faced with eye strain, should you use eye drops, new spectacles, do eye exercises and work harder or should you take rest?  

Some more info:

Consider it this way: if you ran a marathon everyday even if your legs were paining and cramping, would you do more leg exercises, use crutches and apply oil on your legs to continue the marathon, or would you take rest? The marathon is an analogy to the way we use our eyes without taking rest. The crutches and oil are an analogy to how we use spectacles, eye drops, eye exercises, blue light filters etc., hoping that it would cure us. 

(blue light filters were researched and there was no evidence of it being effective: Paper1, Paper2, more citations).

Sure, if the strain is mild, some remedies do appear to give a little relief, but they are only treating the symptoms. We should not pretend that it is working. We need to treat the root cause and cure it. I realized after a decade of chronic eye strain, that there's an obvious, common-sense first-step to the healing process.


Discovering the truth

Doctors tend to focus on intraocular muscles. A less considered fact is how extraocular muscles (shown in red) are affected. I’ve felt excruciating pain in those areas for many years.

In my case, it began with a burning feeling at the front of my eyeballs. Then came the light sensitivity, occasional sharp pains at the sides of the eyeballs, which became sharp stabbing pains all around and behind my eyeballs. I ignored that too and continued working. Then came severe pain all over the eyes, eye muscles twitching, tightness at the cheek muscles that even spread to the forehead muscles. The sharp stabbing pains continued, and my eyes were paining every waking minute of the day. I found it difficult to even keep my eyes open for too long. This is what chronic eye strain feels like. During the next few years, I consulted plenty of doctors (even at highly recommended eye specialty hospitals). They examined my eyes and found no defect other than myopia. No doctor had even heard of such a severe case of eye strain. They tried their genuine best to help, and I could see they felt bad, because they wanted to help me recover (bless them), but they didn’t know how to cure me. Medical science doesn’t seem to have given enough attention to the root causes of fatigue-related eye strain. Practitioners of ancient traditional medicine couldn’t help either.

My eyes just continued aching and burning every single day, throughout the day for six more years, and I continued using the computer for many hours as usual, despite the pain…because I thought I had no other option. Added to that was the mockery from many who thought I was exaggerating.

The persistent pain finally drove me to note down daily experiences. Over a period of few years, multiple experiments, correlations and keen observation, coupled with consultation with a doctor, I finally found the cure and started recovering.

 

The Cure

It’s necessary to follow these points very strictly. Depending on the level of strain, it can take anything from a few months to few years to get cured, but this is the only way to cure fatigue-related eye strain. Nothing else works.

Table created by Hirshkowitz M, et al.(March 2015)
 

  1. Eight hours of uninterrupted sleep every night: This is the foundation. Without this, nothing else will cure the strain. We assume we are getting enough sleep because we feel refreshed when we wake up…and then don’t notice that we still feel sleepy during the day. Before my eye strain became chronic, I hadn’t noticed I was getting only 4 or 6 hours of sleep for many months (a polysomnography didn't help, since doctors were blissfully unaware of what to evaluate for fatigue-related eye strain). During my own experiments, I noted that it was only after 8 hours of uninterrupted sleep, that my eyes felt fine. Interruptions in sleep or short duration of sleep does not seem to allow the muscles and tissues to heal. Strain appears to accumulate everyday due to lack of proper sleep. You’ll also notice that you are able to see much clearer than usual, after you get 8 hours of restful sleep. Children need more than 8 hours of sleep, and noise etc. disrupts sleep.
  2. Closing the eyes after 20 minutes of strenuous work: Twenty minutes (or lesser) of work followed by closing the eyes, relaxing the face muscles and neck muscles and waiting until the strain subsides (the way we maintain tension in our muscles is a part of the problem). It helps to install software that reminds you to rest at intervals. Even if you don’t feel strained, stop after 20 minutes and rest. It’s necessary. Some people say 40 minutes. That's wrong. It's 20, and it applies even to people without eye strain. The “20” is not some random number. It’s from many years of experimentation. Still, rather than blindly follow a number, pay attention to how much time it takes for your eyes to get strained, and try resting your eyes before the pain starts. There is no work that is more important than your eyes. I’ve tried eye drops, an eye gel, anti-reflective coatings, blue-light reduction, eye exercises, washing the eyes, the 20–20–20 rule, expensive eye glasses and all the other advice that doctors and common folk think is a cure for eye strain. Nothing worked. At my level of severity, even minor differences were noticeable. The ONLY way to rest the eyes and get relief from fatigue-related strain, is to keep the eyes closed until the strain subsides.
  3. Stop using wrong spectacle lenses: Over many years, I noticed that for strained eyes, computerised eye tests or even a manual eye test were not necessarily sufficient to determine the correct power. When spectacles caused strain, it was important to stop using them, and find out what the eyes felt comfortable with. More details are mentioned in the "Precautions and Observations" below.
  4. A well balanced diet of properly cooked food: It’s extremely important to know that when food is not properly cooked or even slightly burnt, it causes discomfort in the digestive system (most of the time you won’t even notice this discomfort) that leads to sleep loss (I’ve mentioned more about this in the stomach test blog post). Take some extra time to chew your food well. Also, ensure you search the internet and understand what a “well balanced diet” means, and why it’s important. Instead of searching only for foods that can help the eyes, make sure your entire body gets the nutrition it needs. Bodily functions are highly interconnected. When muscles go through strenuous activity, they need a proportional amount of protein (There’s a wide variety of proteins. Chicken meat worked best for me. I have no clue about what protein sources would work for vegetarians). The body also needs natural foods that help with long duration sleep and deep sleep.
  5. Disbelief in magic: If you wish for a quick magical cure, you will get cheated by people selling such “cures”. It’s like having a fractured leg, using a bandage that promises to cure leg pain, and running a marathon everyday, while complaining that the leg pain isn’t reducing. If your eyes are burning/paining frequently, you’ve likely entered an acute (recovery takes weeks or months) or chronic (recovery takes months or years) stage of strain. You may recover faster, but since my strain was extremely severe, it took 3 years for the constant soreness of my eye muscles to stop, and it stopped only because I strictly followed the 3 points mentioned above. Prior to the 3 years, I suffered the pain for 6 years because I didn’t stop the long hours of computer use and didn’t ensure that I got proper sleep. To recover, you need patience and discipline. Not magic. The earlier you start, the faster you'll recover. When the body needs rest, give it rest. Any other work can wait. Else, you’ll end up with a severe burnout that will prevent you from working anyway. It's not worth getting permanent health damage for a company that'll fire you without hesitation. Definitely not worth damaging your eyes for playing games.

Eye strain and myopia can be caused by many other factors too. Those are best diagnosed and treated by a qualified ophthalmologist. Everything I’ve mentioned here, is only for eye strain that’s caused by excess fatigue to the eyes and lack of sleep.

 

Precautions and Observations

  • No eye exercises: Tired muscles need rest. Not exercise. When your eyes are strained, do not do eye exercises. Just close your eyes to rest them.
  • Full body exercises: It was of no use in curing or reducing eye strain, and it resulted in better sleep only during the first week. However, full body exercises are very necessary for general health.
  • The “SCREAMING”: The pain/burning/discomfort is basically your eyes screaming at you, begging for rest. Never ignore or delay it.
  • Prevention better than cure: Instead of allowing eye muscles to cross the threshold of endurance and enter a state of pain, and then using eye drops or warm compresses to soothe the pain, it’s far better to rest your eyes before the pain starts. I have not needed eye drops ever since I ensured I took periodic rest and got proper sleep.
  • The 20–20–20 rule: It’s wrong. The right way to do it is to close the eyes, relax all muscles, and wait for as long as it takes for the strain to reduce.
  • Digital screen settings: It helped a little bit when I reduced my computer and smartphone brightness to the lowest level I was comfortable with, and used the monitor’s preset “warm” setting. Alternatively, the free night-filter/red-shift apps are also good, but these won’t cure strain. What also helped, was positioning the screens in such a way that reflections on the screen did not cause glare. Anti-glare coatings did not reduce my strain even a little bit because digital screens or blue light was not the reason for strain. Strain was caused by the lack of periodic rest and sleep. 
  • “exact power” myth & “wear always” myth: My eye power is measured -4.5 (right) and -4.75 (left), but my eyes feel comfortable only if both spectacle lenses are -4.5. Also, for near-work (like computer use or reading the newspaper), my eyes are a lot more comfortable with lenses of power -2 (ordinary glass lens spectacles without any coatings, purchased in 1998, and I’ve had absolutely no problem using a lower power). When eyes are strained, lenses of a power lower than the measured eye power have been a lot more comfortable. I’ve also realized that it isn’t necessary to wear the spectacles always. When reading a book or viewing my phone, or walking around my house, I don’t need spectacles. However, when safety is important (like driving, etc.), I use spectacles of -4.5.
  • Dry eyes: It was extremely rare, and happened only when I lost sleep or when my eyes were over-strained. When I took rest, it always got resolved on its own within a few hours. Doctors found my tear film to be normal. Don’t forget to drink sufficient water and blink.
  • Proper lens alignment: Even some expensive frames are designed wrongly. Even experienced opticians fit lenses at incorrect angles. It is astonishing how many of them don’t care, and tell people that nothing will happen, just to make a sale. Ensure that the lenses are properly aligned.

  • Incorrect diagnosis: Doctors seem to assume astigmatism, or that the eye power is higher than what it actually is, when patients complain of eye strain (one doctor even jumped to the conclusion that I had dry eyes, even though I didn’t). Strained eyes can result in significant variations in eye power. It does not mean that one needs to immediately switch to new lenses. It’s important to reduce the strain first by getting proper sleep and rest. Doctors even prescribed cylindrical correction lenses which I couldn’t tolerate for even a few minutes (I detected the discomfort early because my eyes were already very severely strained. Like how simply touching a wound, hurts badly. I wonder how many people with lesser strain end up trying to tolerate such lenses because they don’t realize that it’s the wrong power). Even computerized eye tests and the pupil dilation test showed astigmatism and the wrong power. Oddly, every doctor gave me a slightly different eye power prescription, and each time, the cylindrical correction angle was different from the previous reading. I started spending most of my days either not wearing spectacles or using spectacles of a lower power (which didn’t cause any issue, by the way. It actually gave more relief), and when I started getting better sleep and rest, the strain reduced. This time, after getting a good night’s sleep, when I went to the doctor with well-rested eyes, my eye power was diagnosed correctly. Three doctors eventually concluded that I don’t have astigmatism. Over a period of time, my high level of strain helped detect and eliminate many misconceptions (which are still floating around). One doctor even recommended an MRI, but my family doctor told me not to, because there’s no point doing an MRI if you don’t know what you are looking for. One doctor prescribed antidepressants, saying the eye strain may be anxiety-related. My family doctor who couldn’t reach a conclusion, eventually said the stomach issues and eye issues may just be psychological. Doctors really need to receive more training to be better at diagnostics. To consider the entire case-history and lifestyle of a patient, and to be willing to look beyond the textbook.
  • “Is this lens better or this one?”: As long as the spectacle lenses feel right, that’s the eye power to stop at (for driving etc. 20/20 vision from spectacles is obviously required. Commonsense). When my eye power was -4.25, and the doctor added another lens to make it -4.5 and asked whether the higher power was better, it appeared clearer and sharper to me (I didn’t realize it was too powerful), so I chose -4.5. I shouldn’t have done that. -4.25 was the correct power. When using the computer, I switch to -2.0 power ordinary glass lens spectacles without any coatings, and I’ve had absolutely no problem (spectacles purchased in 1998). When eyes are strained, lenses of a power lower than the measured eye power feel a lot more comfortable. Some people recommend wearing spectacles even if it feels uncomfortable or if it gives a headache, saying that the eyes would adjust after a few weeks. That’s very wrong advice. There are two scenarios I know of that causes this. 1. The lens power prescribed is wrong, or 2. The lenses are not aligned correctly, as shown in the image below. In both situations, I learned not to wear those spectacles. It caused more strain.
Spectacle lens fitted at wrong angle

Sometimes, the spectacle lens ends up at a slightly incorrect angle. This image shows one axis. The angle variation can happen along other axes too. This caused my eyes to get strained faster. Don’t try to adjust to it. Ensure that an optician fixes the error or get a new frame/lens. Also, there are a lot of measurements that need to be done accurately when selecting the focal point, frame width and fitting the lens to the frame.



  • Low power prescriptions: I’m hearing of a lot of people being prescribed -0.25 or -0.5 prescriptions for one eye or both eyes. Even a cylindrical correction, just because they complain of eye strain. Please consider that these powers may just be a result of excess strain and/or lack of sleep. Wouldn’t wearing spectacles constantly prevent them from recovering to normal sight? We need to do better research and make life livable, to rescue people from poor habits that lead to weak vision, instead of providing people with spectacles at the slightest excuse.
  • Bad habits from childhood: For goodness sake, please don’t mess up children’s sleep cycle. Not even for exams. Hard work is good, but losing sleep repeatedly to do hard work is foolish. Right from childhood, we have been taught to ignore discomfort and persevere, but we should have also been taught to recognize when we should stop and give our body the rest it needs.
  • Work environments: Even in the most well-meaning work environments, bosses are pushed to deliver results quickly. But that doesn’t mean you need to damage your health in the process. Six hours of computer use a day is what I’d say is the safe-limit (eight hours may work for you, but never skip the rest breaks). When recovering from chronic eye strain though, not more than 4 hours is what I found is best. The entire world is realizing this necessary truth, and you shouldn’t be ashamed to take rest. Being a responsible person who gives their body the rest it needs is one thing. Laziness is an entirely different thing. Any sensible boss or colleague will know the difference.
  • Online classes and smartphone/TV use: Teachers and parents need to ensure that students get some necessary breaks during online classes, smartphone use or while watching TV. Kids by nature won’t listen, but please ensure they get their rest, sleep and nutrition. Their disappointment at not being able to play video-games for long, is tiny compared to the disappointment of having to wear spectacles lifelong. The need to wear spectacles itself shows that the eyes are seriously affected. Don’t make it worse. Better still, don’t even allow it to reach a stage where anyone needs spectacles. Protect the eyes.
  • Daytime sleep: If you couldn’t get proper sleep at night, you will feel sleepy during daytime. It is extremely important to take that nap. It gives some very essential rest for the eyes that’s even more effective than just keeping the eyes closed.
  • Coffee/tea: When the body badly needs rest and you feel sleepy, you should sleep. Drinking coffee or tea to remain awake is a silly thing to do.
  • The angle: If you extend your hand in front of you and hold a dumbbell for long, your muscles will start aching after a while. When it starts aching, if you raise your hand to hold the dumbbell above your head, some of your arm muscles will be spared of the weight of the dumbbell and get a chance to relax. The extraocular muscles holding the eyeball, are like the arms holding the dumbbell. Closing your eyes and lying down facing the ceiling helps those muscles relax a little bit (it gives just a slight bit of relief).
  • Spectacles are not a cure: Some people assume that if they constantly wear spectacles or contact lenses for a few years, they will get cured to normal sight. It won’t. I've never tried "print pushing" though, but in the case of strained eyes, the first priority should be to allow the eyes to heal by getting proper sleep.
  • Glass lenses are better: The medical and optical community is largely unaware of how distortions in refraction affects strained eyes. During my chronic levels of strain, plastic lenses always caused my eyes to get strained quicker than when I used glass lenses. For some years, the discomfort was instant. Even Jack reports similar issues. Not wearing spectacles gave the most relief. Now that I’ve recovered a lot, I experience the strain a bit lesser, but long hours of strain add up quickly, so I still prefer glass lens. Glass is well known for offering better visual acuity and lesser distortion (provided it is of good quality). Of course there’s a safety benefit to plastic lenses, but while sitting in front of a computer, glass works best for me. Some opticians may bluff, saying that glass lenses are not available. It is available and can be half the price of plastic lenses. Do spectacles really need to cost as much as a phone?

A certain company handbook I saw recently, mentioned that employees were only entitled to a ten minute break every two hours. A classic example of how rules are formulated from poor knowledge on Repetitive Stress Injuries. Please realize the seriousness of the matter and establish processes that help in creating a nation of healthy people. This also goes for everyone who knowingly or un-knowingly deprive people of sleep and rest right from childhood.

The human eye was not evolved to handle this kind of strain. Too many people are getting incorrect advice and hurting their eyes. Please tell more people about getting proper sleep and rest. There are not enough doctors emphasizing this.

Like someone once said: 

If you do not give time for wellness, you will be forced to make time for illness”.

 

CAUTION

Don't give up too soon. It can take several weeks/months to recover from acute strain, and it takes several months/years to recover from chronic strain. I initially took a 15 day vacation to check if it would cure the strain (during which I continued using the computer a lot). When it didn’t, I assumed that taking rest was of no use. I didn’t realize that I had severe sleep loss and was still overworking my eyes. The strain had built up to such a severe stage that longer periods of rest and sleep were required. The right thing to have done would have been to take a sabbatical for a year to ensure I got rest. Due to ignorance and bad advice, I continued working, and the problem persisted for several years. This applies even to conditions like back pain etc. When the body needs rest, give it rest. Any other work can wait. Else, you’ll end up with a severe burnout that will prevent you from working anyway.

p.s.: Do read through the article a few more times to understand all points, and when you get cured, please return to leave a comment. I recovered fully in October 2022. An ordeal that started in July 2011, and wrecked my career. It was prolonged due to the poor medical advice I received, the marketing nonsense that lies about being able to cure the strain, and due to the glaring lack of a support system in companies and in society.

 

Keywords: computer eye strain, eye strain glasses, eye strain headache, reduce eye strain, eye strain causes, digital eye strain, eye strain from computer, glasses for eye strain, eye strain relief, eye strain in one eye, what causes eye strain, eye muscle strain, how long does eye strain last, why do my eyes hurt, eye drops for eye strain, glasses for computer eye strain, how to get rid of eye strain, burning eyes, eye drops for burning eyes, pain in eye, pain behind eye, right eye pain, left eye pain, headache eye pain, sharp eye pain, eye pain causes, sharp pain behind right eye, pain relieving eye drops, home remedies for eye pain, eyes hurt, pain above right eye, pain in eyeball, pain over left eye, how to relieve eye pain, how to stop eye pain, reason for eye pain, medicine for eye pain, eye pain home remedies, eye strain symptoms, headache and eye pain, eye socket pain, stabbing pain in eye.


02 October 2020

Install PyEnv if you want various Python versions on Ubuntu

One of the major issues with installing new versions of Python is that if you try removing it or try removing the existing version, it'll cause problems with the working of the operating system, because Ubuntu uses Python for many of its system functions.

As an alternative, people suggest using Anaconda or Miniconda. When I tried it, I ran into errors where the package versions installed with Anaconda conflicted with the system Python versions. At my wit's end, I finally gave PyEnv a try and it worked beautifully. (Also have a look at Poetry)
  1. sudo apt-get install -y make openssl build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl curl
  2. curl https://pyenv.run | bash
  3. Follow the instructions shown on the terminal to add commands to bashrc. If you see any warning messages, follow the advice mentioned in the message. Close terminal. Open a new one. 
  4. sudo apt-get install -y gcc make zlib1g-dev libreadline-dev libreadline8 sqlite3 libsqlite3-dev libbz2-dev python-tk python3-tk tk-dev
  5. pyenv install --list to see the latest versions of python available.
  6. pyenv install -v 3.8.3  (or install one of the latest versions 3.9 or any other, but do remember that the higher versions of Python would need higher versions of dependent libraries which may or may not be available with the version of Ubuntu you have installed)
  7. pyenv global 3.8.3
Useful commands:
  • To see which versions of pyEnv are installed: ls ~/.pyenv/versions/ or pyenv versions
  • To remove any version: pyenv uninstall 2.7.15 or rm -rf ~/.pyenv/versions/2.7.15
  • Check which is the system default version: python -V
  • To revert back to the default system python: pyenv global system
  • Commands available with pyenv: pyenv commands
  • Getting help for any of those commands: pyenv shims --help
  • Check if pip is installed: pyenv which pip
  • Set a global version: pyenv global 3.6.8
  • Set a local version for a specific application's directory: pyenv local 2.7.15
The most impressive parts of PyEnv are the ability to switch between Python versions and have separate local and global versions.
Although the next step would be to install a virtual environment using pipEnv, I didn't like it because the updates portion is poorly implemented. There's also venv you could try.

05 September 2020

Keyboard cleaning

The good thing about freelancing is that one gets a good amount of spare time to relax the eyes and go for a digital detox. Add to that a global pandemic, and you get to learn some new things.
I decided to open my keyboard which had been gathering dirt for many years. Here's the "before" picture.


Opening it up showed how much dirt had accumulated over the years. But I also noticed that the reason that the keys didn't have a smooth movement when pressed down was not the dirt. It was because they had to slide down the plastic, and there was no lubrication.


This is the membrane the keys push down. It's a "dome switch" which completes the circuit when the finger presses it down.


The circuitry under the domes. I was surprised at how minimalist it is.


A word of caution. When removing the key caps, don't use a compass or an object that exerts force at a single point, because it'll cut a groove in the plastic, as shown in the image below. It's better to use an old debit card or a professional key cap remover or even make one yourself using metal wires.


After cleaning and drying, the keyboard looks good as new!!! I wanted to apply some grease too, but some forums and comments warned against using grease or oil without first checking how it'd affect the plastic.


Don't forget to take a photo of the keyboard before opening it up. It'll help when you are putting back the key-caps.
Next time I'd go for either an ergonomic mechanical keyboard or a buckling-spring keyboard.
 
[update: Jan 2021: Since the keys felt difficult to use as the plastic was scraping against plastic, I took off the key-caps again and used a small paintbrush to apply a thin layer of grease at the portions that were scraping. It worked really well after that. Do take care that you shouldn't use grease that affects plastic negatively].

09 August 2020

Saying Thank You

We are so accustomed to receiving knowledge or services for free on the internet, that we don't realize how much a kind gesture would help.

Reach me with a simple thank you:

Google Form: https://forms.gle/aw3EzLVnLVSjSm2B8

 and / or

Surprise me with something from my Amazon wishlist:

Amazon wishlist: https://www.amazon.in/hz/wishlist/ls/2V4F7N8K7CYX5?ref_=wl_share

 


02 August 2020

When using the Hemmingway Editor, take the grading with a pinch of salt

For writing assignments, many people recommend the free Hemmingway editor, which help remove unhelpful adverbs, passive voice and in general, helps improve your sentences by making them simpler and easier to read. These features are really useful.

However, recently when I wrote some simple sentences, the editor said they were at Grade 11, when these were simple sentences that even a 7th or 8th grader could understand. So I did a little experiment. I chose sentences from two children's books and checked to see what Hemmingway editor would report.

First book: The call of the wild.

This is a version simplified for children, meant for 3rd, 4th or 5th graders. While most paragraphs showed a “Grade 5” or “Grade 6”, a sentence whose only fault was that it was too long, showed a “Grade 7” difficulty.


Moreover, copying and pasting the same sentence repeatedly, brought the score up to Grade 11. From there, it was not difficult taking it up to Grade 13. This is a serious flaw in the algorithm.






Second book: Chips (story of a rabbit).

This book has very simple sentences meant for children in the 2nd or 3rd grade. While most paragraphs showed grades ranging from “Grade 5” to “Grade 9”, some sentences gave these results:


Oddly, removing a few sentences brought it to Grade 10.



Removing more sentences pushed it to Grade 11.



By repeating the same sentence, I could push it to Grade 14.


I've written to the creators of the editor, showing them these examples. Hope they'd correct it soon. Meanwhile, writers should take the gradation score with a pinch of salt. The editor is still a good method of evaluating your text for the other features it provides.

01 July 2020

Repairing grub in a dual boot system without using Boot Repair

After installing Windows, installing Ubuntu detects Windows and installs fine, giving you a dual boot system. But if you re-install Windows or install another OS on another partition, chances are you'll get a MokManager error that looks like this:


Before attempting to repair Grub2, go to your BIOS (as shown in this page) and select the grubx64.efi file or whichever efi file is relevant to your installation, and reboot. Chances are that the non-booting is just being caused because the computer does not know which efi file is safe. I think this happens due to secure boot being enabled, but please don't disable secure boot. Just specifying the correct efi file may help.

If it still isn't booting and you want to repair Grub2, follow the steps in this or this website. I had tried using Boot Repair, which worked nicely, but only once. So I now prefer doing it manually.

Steps:
1. Boot from a live CD or live USB which has the same Ubuntu version as your latest installed Ubuntu.
2. Use sudo fdisk -l and sudo blkid or GParted to determine which sda Ubuntu is installed on. Let's assume it's on sda4.
3. sudo mount /dev/sda4 /mnt
4. for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt$i"; done
5. If Ubuntu is on an efi partition (check using sudo fdisk -l | grep -i efi), mount it with sudo mount /dev/sda4 /mnt/boot/efi.
6. This command won't work if you are using a 32 bit live boot disk on a 64 bit computer, so make sure you use a 64 bit live boot disk: sudo chroot /mnt
7. update-grub (if this doesn't work, goto step 8. Else, step 10).
8. grub-install /dev/sda
9. update-grub. To locate and add Windows to grub menu.
10. If Ubuntu was installed in efi mode, run this: blkid | grep -i efi; grep -i efi /etc/fstab
11. Reboot the computer.

Even now, the "Failed to start MokManager" error may show up. Just go to BIOS and select the right efi file and reboot. Everything should work fine now.



Say thank you or donate

09 June 2020

Removing malware from PDF's

Sometimes PDF files can contain malware. Although the techniques listed below are not a fool-proof guarantee of getting rid of malware, it can get rid of malware that's embedded in the metadata of PDF files.

First, confirm that the PDF has malware.

Now create the following bash script in a file named malwareRemover.sh:
(make sure you use a tab instead of spaces for the lines within the for loop).

#!/bin/bash
clear
for f in *.pdf; do
    echo "Removing malware from $f:"
    echo "-------------------------------"
    echo ""
    #---convert
    tempFilename="temp.ps"
    echo "Converting $f to $tempFilename"
    pdf2ps $f $tempFilename
    echo "Deleting $f"
    rm $f
    echo "Converting $tempFilename back to $f"
    ps2pdf $tempFilename $f
    echo "Deleting the ps file"
    rm $tempFilename
done


Change the permissions of the file and install ghostscript:
chmod +x malwareRemover.sh
sudo apt-get install ghostscript

Run it with all the PDF files in the same folder as malwareRemover.sh.
./malwareRemover.sh


If you are using Didier Stevens' tools, this script will help:

#!/bin/bash
clear
for f in *.pdf; do  
    echo "Scanning $f for malicious data:"
    echo "-------------------------------"
    echo ""
    #---scan
    python3 pdfid.py $f
done

echo ""
echo "How to interpret the info:"
echo "------------------------------"
echo "* Almost every PDF documents will contain the first 7 words (obj through startxref), and to a lesser extent stream and endstream. I’ve found a couple of PDF documents without xref or trailer, but these are rare (BTW, this is not an indication of a malicious PDF document)."
echo "* /Page gives an indication of the number of pages in the PDF document. Most malicious PDF document have only one page."
echo "* /Encrypt indicates that the PDF document has DRM or needs a password to be read."
echo "* /ObjStm counts the number of object streams. An object stream is a stream object that can contain other objects, and can therefor be used to obfuscate objects (by using different filters)."
echo "* /JS and /JavaScript indicate that the PDF document contains JavaScript. Almost all malicious PDF documents that I’ve found in the wild contain JavaScript (to exploit a JavaScript vulnerability and/or to execute a heap spray). Of course, you can also find JavaScript in PDF documents without malicious intend."
echo "* /AA and /OpenAction indicate an automatic action to be performed when the page/document is viewed. All malicious PDF documents with JavaScript I’ve seen in the wild had an automatic action to launch the JavaScript without user interaction."
echo "* The combination of automatic action  and JavaScript makes a PDF document very suspicious."
echo "* /JBIG2Decode indicates if the PDF document uses JBIG2 compression. This is not necessarily and indication of a malicious PDF document, but requires further investigation."
echo "* /RichMedia is for embedded Flash."
echo "* /Launch counts launch actions."
echo "* /XFA is for XML Forms Architecture."
echo "* A number that appears between parentheses after the counter represents the number of obfuscated occurrences. For example, /JBIG2Decode 1(1) tells you that the PDF document contains the name /JBIG2Decode and that it was obfuscated (using hexcodes, e.g. /JBIG#32Decode)."
echo "* BTW, all the counters can be skewed if the PDF document is saved with incremental updates."
echo ""

 

06 May 2020

Which conferences and journals allow pre prints on ArXiv and which don't?

ArXiv, TechRxiv (owned by IEEE) and HAL are pre-print repositories where scientific papers can be submitted as proof of precedence, so that the ideas do not get scooped. Especially when you are submitting a paper to a journal, it's better to put it on a pre-print repository, because the journal's review process can take very long and the process of making corrections and resubmitting can take many years until the paper finally gets published.
But there may be conferences or journals which may not allow authors to publish their work on pre-print repositories, because it would interfere with the double-blind review process.


These are conferences/journals which allow authors to publish on ArXiv:


These are conferences/journals that don't allow it:
  • KDD. Prior to 2019, KDD used to allow pre-prints on ArXiv.

I hope to update this page with more names of conferences and journals. If you know of any, please mention it in the comments.

02 April 2020

GMail's autocorrect messing up your email?

We don't allow children to drive cars, but somehow people think it's ok to allow a self-driving car on the road...an algorithm that has no clue about what the world is and no clue about what driving is. AI has a long way to go before becoming intelligent.

Similarly, GMail tended to autocorrect our words for us, without even highlighting the words it autocorrected. The result? I typed "presenter" in a sentence and in the next sentence when I typed "presenting", GMail discreetly autocorrected it to "presenter", giving the sentence a grammatical error which gave a bad impression to the reader. I noticed the error only after sending the email. The minimum GMail could have done was to highlight the word that had been autocorrected or to ask for my consent before introducing the feature. Google seems to need better engineers.

When I first heard that a person lost his job because of autocorrect correcting a word to "hash brown" when he emailed a colleague, I didn't actually believe it happened unintentionally. But after seeing how autocorrect messed up my email, that man has all my sympathies.

There are many such examples. Some of these may be fictional, but they do drive home the point.

Autocorrect can be switched off in GMail in the General Settings. I recommend switching off all of the AI features that aren't reliable.

01 March 2020

IISc Open Day 29th Feb 2020

The Indian Institute of Science's Open Day is a yearly event during which the general public can visit the campus free of cost and every department exhibits some fascinating experiments or presents the research that students are doing there. Most of these are at the cutting edge of technology, so it's an excellent learning experience for everyone. The campus is so vast that even for someone arriving at 9am, it's hard to visit all the stalls and view all demo's and experiments. Of the many demo's, here are some:


Also known as Magic Mud or Oobleck, the video I took, shows how a person who inserts their hand slowly into the liquid is able to, but the person who jumps on it does not sink. The liquid is just a 1:1.25 ratio mixture of water and corn-starch. The corn-starch doesn't dissolve in the water, and stays suspended as a non-Newtonian fluid. If you are gentle, the liquid parts and allows solids to enter. If you punch it or run over it, if feels like a solid object. I took a thin, sturdy leaf stalk and thrust it into the liquid, but it wasn't able to penetrate. So surface area didn't matter. I'd like to have seen if a knife edge's surface area would be able to penetrate. When I suggested it could be used for bullet-proofing, the organisers said that's one of the applications considered for this fluid. I jumped on it, ran on it and even punched it. Solid as a rock! Be gentle, and it's cooperative. Made me realise that many people behave like non-Newtonian fluids too. :-)



Studies are being conducted on the structure and role of certain proteins which play a role in how ambient light affects the body's sleep cycle.



This was an actual brain-machine interface demo where the person wearing a skull-cap that noted his brain's gamma waves, was able to control a circle on the screen and make it move left or right just by using his thoughts.






Hardware relics from the past.



The presence of such ponds and greenery in an institute campus speaks a lot about the quality and care that goes into maintaining it.



This is a pacman game where they train a deep neural network using the visitor's hand gestures that indicate up, down, left or right motions. The visitor then uses these gestures to move pacman on the screen and play the game of escaping the ghosts. Cumbersome, but interesting.



A functional hydroponics setup that's 90% more water-efficient than traditional farming. The nutrient-enhanced water mist gives nutrition to the roots.




Just a car that follows a trail using infra-red light.




Research being done on mice to understand how the hippocampus stores information on spatial recognition. The brain has grid cells, head direction cells, boundary detection cells etc.




A working demo of the Tesla tower. The CFL bulb glows due to wireless electricity (ionization).




A demonstration of how Tsunami waves are formed, how the wave appears to recede just before the main wave strikes and how barriers may help push the wave backward to cancel out incoming waves; demonstrated by a guy who appears to be infected with the Corona virus :-).




One of the e-rickshaws at IISc that the public could use for free. They are labelled "Transvahan", which initially gets interpreted as "Transformer vahan", but don't worry; it's not going to turn into Optimus Prime. It's actually "Transport vahan". There's very few of these vehicles, and most of the time I saw them transporting water and food. It would've been nice if there would be plenty of bicycles that'd help traverse the vast expanse of the campus during such events. They did a really good job of arranging for plenty of good quality drinking water sources all over the campus.

There were so many many more stalls and demo's that I didn't mention just for the sake of brevity. Overall, a really good experience. Open Day is a must-visit for science-lovers.


04 February 2020

Configuring LiClipse to run Anaconda or Miniconda

I'll have to admit, it is indeed better to use a virtual environment when dealing with Python. If you mess up your native Python, the system won't work properly. But the problem with using Python this way, is that there may be packages that aren't available for install via conda for particular versions of Python. That gets very annoying.
This article explains how to setup LiClipse to work with Anaconda or Miniconda. Specifically, Miniconda.

Open LiClipse. In the main menu, goto Window > Preferences.
Type "interpreters" in the search box.
Click "Python interpreter".
Click the "Browse for Python/pypy exe" button.
Close the first window that opens and you'll see this:


Browse to your Miniconda folder and select the python3 or python file in ~/miniconda3/bin.

In Interpreter Name, enter a name of your choice: MinicondaPython3.7, for example.

One more window opens up. Click Ok.

Now (assuming your Python project is open), in the main menu of LiClipse, select Run > Run Configurations.
In the left column, right click on Python Run. Select "New Configuration".

Under the "main" tab, choose your project name and specify the main file.
In the "interpreter" tab, select MinicondaPython3.7.

That's it. Install any necessary Python packages using the conda command, and you are ready to run your project!

02 January 2020

Clearing swap space in Ubuntu

When having two large applications open in Ubuntu can cause slow performance because of swapping memory from hard disk to RAM, it leaves one perplexed to see swap space still being used after all applications are closed.



I investigated this a bit more to find out that it's better not to mess around with the kernel's swappiness parameter, and that using the "top" program or other scripts is not really necessary. You don't even need to use vmstat to check the si and so columns to see if swaps-in and swaps-out are happening.

There's a far simpler option that promptly copies all swap memory back to RAM.

sudo swapoff -a; sudo swapon -a


I opened a large application by the time I took the screenshot, hence the greater usage


Enjoy!