Android Emulator Failed to load libGL.so

Android Emulator on my system failed to find libGL.so which was clearly available in both /usr/lib and /usr/lib64 provided by mesa-libGL.i686 and mesa-libGL.x86_64 respectively. Here is the exact problem I had.

$emulator -avd nexus5 -qemu -m 512 --enable-kvm
$Failed to load libGL.so
$error libGL.so: cannot open shared object file: No such file or directory
$Failed to load libGL.so
$error libGL.so: cannot open shared object file: No such file or directory

After searching Google extensively, I failed to find something that worked for me. The two prominent answers that came back were as follows.

  • Link libGL.so.1 from /usr/lib to the tools‘ lib folder.

    ln -s /usr/lib/libGL.so.1 ~/android-sdk-linux_x86/tools/lib/libGL.so

Source

  • Another person suggested to install mesa-libGL.i686 which I already had installed.

    yum install mesa-libGL.i686

Source

Since they both failed. I tried to install various packages related to libGL and I found mesa-libGL-devel.x86_64.

So to solve Failed to load libGL.so you need to run following command.

yum install mesa-libGL-devel.x86_64

127.0.01

127.0.0.1

127.0.0.1

While going through #dgplug’s July 16th log I ignored service sshd start and went ahead trying to ssh into testacc which is a test user account. No surprise I encountered an error as follows.

ssh: connect to host 127.0.0.1 port 22: Connection refused

Lessons here is to try not to act smart by skipping instructions.

This reminds me I could replace 127.0.0.1 with localhost and also with my hostname. Previously, on my Arch Linux box I have always append my hostname in /etc/hostname file but since moving on to Fedora and lack of documentation I used systemd to set hostname like hostnamectl --set-hostname <hostname> and didn’t bother messing up with any config files.

This is a nice moment in space and time continuum to catch up on 127.0.0.1. According to Wikipedia, localhost literally means this computer. localhost is associated with IP address 127.0.0.1/8.

I wish there was enough time to go through man pages of all the command we use.

July 16th Log

How to Manage Multiple SSH keys on Fedora KDE?

Passwords are cumbersome to remember and annoying if you have to remember and present several of them several times per session. I started using SSH keys in order to remove the need of regularly entering password whenever I push updates to my github repository or make changes on my server.

This guide assumes that you are using Fedora's KDE flavor. If you are not then you better be. In order to be verbose I have following ssh packages installed on my system.

rpm -qa | grep ssh
fuse-sshfs-2.4-5.fc20.x86_64
ksshaskpass-0.5.3-6.fc20.x86_64
openssh-6.4p1-4.fc20.x86_64
openssh-clients-6.4p1-4.fc20.x86_64
libssh-0.6.3-1.fc20.x86_64
libssh2-1.4.3-9.fc20.x86_64
openssh-server-6.4p1-4.fc20.x86_64

We will be using several pieces of technology and their short definition are as follows.

ssh – You probably know this but according to man pages it is an OpenSSH SSH client.

ssh-agent – It is the program that runs in background and manages your multiple keys.

ssh-add – This small utility basically unlocks your ssh keys and adds it to ssh-agent.

ksshaskpass – This KDE program will provide a password prompt, through pinentry-qt, in your KDE environment.

That out of the way, it is important that you make sure ssh-agent is auto-started and running on your system. If ssh-agent is running the following command will return a process ID.

echo $SSH_AGENT_PID

You also need to make sure that ksshaskpass is set to ask for passphrase of your ssh keys. The assumption is that it already is. You could run following command to make sure of that.

echo $SSH_ASKPASS

How to generate keys? There are a few strategies that you could employ to have a sane ~/.ssh folder. Mine is to just add the server name to the key file.

ssh-keygen -t rsa -f ~/.ssh/test_ssh_key_1 -C "yours@yours.com"
ssh-keygen -t rsa -f ~/.ssh/test_ssh_key_2 -C "yours@yours.com"
ssh-keygen -t rsa -f ~/.ssh/test_ssh_key_3 -C "yours@yours.com"

ssh-keygen will generate a key of type rsa and save it to file ~/.ssh/test_ssh_keys_# with your email id as a comment. You could have a long list of keys that can be easily identified as github_id_rsa.pub or bitbucket_id_rsa.pub, etc.

You could start using them right away by adding them to ssh-agent by following command.

ssh-add ~/.ssh/test_ssh_key_1

It will ask for your password and then any command you type in your terminal will be executed by your server without login password prompt.

We want to have access to our keys all the time during a session and in all terminal sessions. So we need a script to do that. A little note here is if your read SSH’s documentation $SSH_ASKPASS is only triggered if $SSH_ASKPASS is set and you are not in a terminal session. The easiest way to save your passwords in kwallet so that you are not asked them ever again is by running ssh-add command through KRunner as follows.

ssh-add ~/.ssh/test_ssh_key_1
ssh-add ~/.ssh/test_ssh_key_2
ssh-add ~/.ssh/test_ssh_key_3

You will be asked to enter password for each key. Make sure to check remember password and all your password will be saved in your encrypted kwallet.

Now we need a script to automate aforementioned commands which you will save as ~/.kde/Autostart/ksshaskpass.

#!/bin/sh
export SSH_ASKPASS=/usr/bin/ksshaskpass
ssh-add ~/.ssh/test_ssh_key_1 &lt; /dev/null
ssh-add ~/.ssh/test_ssh_key_2 &lt; /dev/null
ssh-add ~/.ssh/test_ssh_key_3 &lt; /dev/null

These commands will will be executed at the beginning of each session for which passwords are already saved in kwallet and /dev/null is used to suppress any warnings.

Also make sure to correct file permission of the auto-start script.

chmod 755 ~/.kde/Autostart/ksshaskpass

You log-out and log-in and you have access to all your keys without entering a single password.

You can easily check which keys are unlocked by and being maintained by ssh-agent by running following command.

ssh-add -l

Update:- It is a good idea to chmod ~/.ssh folder, key files, config, and authorized_keys on server.

chmod 700 ~/.ssh
chmod 600 ~/.ssh/config ~/.ssh/authorized_keys ~/.ssh/test_ssh_key_1

#dgplug

I have officially decided to become a hipster and join #dgplug. My knowledge of computer science has serious gaps in both technical level and social level due to lack of formal training in computer science. I am hoping #dgplug could fill up that space.

I came to know about #dgplug through an ambitious post by Kushal Das on Planet Fedora. I actually came to know about several of these Indian open source communities through Planet Fedora and mailing list. I followed through and registered to the course.

The training started late June. We have come to learn a lot of stuff including how to communicate on IRC and mailing lists, basic Linux commands, vim text editor, file system hierarchy, reStructuredText, and personal lives of a few developers and past participants of #dgplug.

As far as communication, basic Linux commands, and file system hierarchy are concerned, I am already well versed in it. I also got to know how to use Git as a result of previous MOOC I took.

I have been a Markdown fan. Markdown is such a simple tool which makes commenting on internet a pleasurable experience. I knew about reStructuredText but Github, Reddit, and several websites that I use already use Markdown so it became a natural choice to me. As we looked into reStructuredText in #dgplug I came to realize it is pretty handy and probably more powerful than Markdown. I plan to seriously pursue it in future.

I am personally moved by beginning of developmental careers of several contributors who are participating as mentors. You have to read IRC logs to get the full juice. I think it is nice of the contributors to spend their free time teaching us.

One suggestion I could give #dgplug maybe is to post class notes in form of slides beforehand so that folks can work on them at their own pace and sort out their problems. It can take too much time to participate in the IRC sessions daily. Although from now on IRCs will be thrice a week.

In the end #dgplug makes me wish if there was a local lug I could go and participated personally.

Purpose of Blogging

I have been blogging for many years. It goes back to the time I wanted to write secretly on the web, yeah. As far back as I can remember my official blog started with writing film reviews. I wasn’t popular at all but I did it consistently and I enjoyed it.

I think about purpose of blogging over and over. My personal hero Matt Mullenweg’s blog has always been a source of inspiration. His blog has a linear flow where he posts anywhere from a line, a quote, or a full post. Sometimes I think that when someone visits my website I would want it to be a place to tell the visitor everything about me. I want a mix of static page and a blog of constant thought experiment. So far I have failed to materialize it.

One of the problems I have with blog that run page after page is that their is no way to tell what is important for visitors to know. To be realistic some posts are going to be purely bad and some are going to be nicely written and the flow of blog should not disrupt that. I think same problems are valid for new aggregating sites like Hacker’s News and Reddit. Unless you are a regular reader you will miss things. And on missing things I think google does the best job of finding relevant information better than any of us.

This little mental exercise makes me realize that I should create a website that is primarily a blog but a top or bottom or side panel could bring the visitors to the right information.

Auto Rickshaw Ride in India

Auto Rickshawphoto credit: pabak sarkar via photopin cc

I went from Surendra Palace to Bima Kunj this afternoon. I was asked to to pay Rs 200. It didn’t sound right, so, I asked the auto-rickshaw-driver to reduce the price by Rs 50. He replied that how can I ask him for Rs 50 discount. He agreed to Rs 190. I saw his fellow auto-rickshaw-drivers laughing for some notorious reasons I am not aware of. When I came back from the Bima Kunj to Surendra Palace an hour later, I asked the same question to another auto-rickshaw-driver and he replied that he would charge me Rs 120.

Just because you sound non-familiar everyone in the town would sell you crap at a very high rate. To play devil’s advocate, auto-rickshaw-drivers, vegetable vendors, etc. are the poorest of poor in India. They have big families and they tend to be open to idea of mischieves and are illiterate. They have greater requirement of the funds.

Truthfully, it is less about losing money but more about being victimized by the poorest of the poor. Nothing could justify lying. Maybe a little bit of lying is fine. Maybe you make a few rupees off each customers for your greed but outright robbing them is just so wrong.

It makes me want to not travel across India. One thing is sure I will be fooled and I will be robbed.

State of Affairs

IndiaNarendra Modi has become the Prime Minister of India. I have to say I had my doubts. This year a difficult election. The Sonia-Rahul-Manmohan led UPA failed to do anything meaningful for past 5 years. You see I had to use three names just to say who actually is the leader. Congress party failed at everything they pursued. And it was clear that people were going to boot them out but I didn’t expect people throwing Congress out of the window. There were no indication that BJP could pull what they did in the election. Congress certainly played a good role in its dismissal.

Narendra Modi even if not complicit in Gujarat’s massacre he failed to put a full stop on the mass murder. With these doubts and general doubts of all politicians being corrupt Modi became the Prime Minister in a blaster win. His tone sounded like he could be a powerful leader at the center. He seems focused and polarizing in his party.

Development in India has been disastrous. You come back to you home town find same folks in same shops in same market only with their broken shops. The time has not been very favorable to them. For past 10 years, the government has failed to build road which connect my town to two of the major cities in the region. The road being a prominent national highway.

You go for a run in the morning and you will find 100 boys and 1 girl exercising in the stadium. We will obviously be hateful towards the opposite gender in such a disparity.

photo credit: betta design via photopin cc

How to Install Caffeine in Fedora 20

Caffeine is a “A status bar application able to temporarily prevent the activation of both the screensaver and the “sleep” power saving mode.” It comes very handy when you are watching a movie (VLC already blocks screensavers) or working on a project that requires you to get off the screen from time to time.

zhonghuaren has graciously packaged caffeine for OpenSuse and Fedora at build.opensuse.org.

Adding the repository.

cd /etc/yum.repos.d/
wget http://download.opensuse.org/repositories/home:zhonghuaren/Fedora_20/home:zhonghuaren.repo

zhonghuaren‘s package is missing two vital packages gconf and pynotify for Caffeine to work.

Installing dependencies.

yum install notify-python gnome-python2-gconf

Install Caffeine

yum install caffeine

The above dependencies might not be needed depending on your choice of desktop environment.

Name Popularity Search Tool Based on the Social Security Administration Data in Java

NameSurfer in Java

NameSurfer in Java

NameSurfer is a tool to search and graph popularity of names based on data provided by the Social Security Administration in the last century. As you can see in the picture, names can be entered in the names field which are graphed either by enter key or the graph button. Graphs are shown on a scale of a thousand. Zero means the name didn’t show up on the thousand most popular names list. One is the most popular and a thousandth is the least popular in the list.

I have made satisfactory progress in the course CS106a. I have learned about the graphics class GObject, BufferedReader class, RandomGenerator class, and, ACM and Java utilities. Interactors were something new in this section of the course. Although I used similar Canvas method in Yahtzee, I am not so sure about subtle difference between the ConsoleProgram and the Program class. As always following the videos and instructions on the assignment sheet pays well in the course of finishing an assignment. A mix of more doing and less theoretical knowledge definitely assuages the boredom of theoretical knowledge. And in due time theory makes more sense.

With the positive energy after Yahtzee, I started implementing NameSurfer as soon as I finished the last assignment. I tend to batch watch the lectures, then read the assignment and then work on it. I improved up on my workflow and started with reading the assignment. A good number of problems were already making sense which resulted in a clean mental picture and basic implementation of the NameSurfer. Some of the methods like BufferedReader to read the names-text file, store information in a HashMap, and store per graph information in an ArrayList, were pretty clear even before the start of the program. Also lectures were making more sense as I was watching them along with implementing the program. I tend to watch a single lecture per day but this time I was watching two lectures per day. As soon as I got done watching four lectures I sat down and worked crazily on the project. I finished it in record two days. And it took me a night of sleep and a 20 minutes next morning to fix some last moment bugs.

toString() didn’t make much sense when I read it the first time. It was very helpful to implement it to make data human readable in NameSurferEntry class. Similar is true for two Integer class methods that I had forgotten about. Both Integer.parseInt(String) and Integer.toString(int) came handy in converting String to int and int to String, respectively. Life would have been much more problematic if I had to parse integers out of a String manually.

Working with five different classes, NameSurfer, NameSurferEntry, NameSurferDataBase, NameSurferConstants, and, NameSurfergraph was interesting. NameSurfer played the role of assembling all other classes in a comprehensive program. I got to use StringTokenizer class in NameSurferEntry Class. It broke down the string into name and year and stored this information in an Array. I broke down the names file in NameSurferDataBase class. Passes single entry in NameSurferEntry to be stored in the array. Then I created a HashMap with template String and NameSurferEntry. Name as a String was used as a key and NameSurferEntry was stored as value.

NameSurferGraph was the trickiest to implement. It took me a whole day to implement it. The NameSurferGraph was to be responsive. The starter package included the code for the responsiveness. ACM graphics aren’t my favorite part. The whole class was written in a very old graphic toolkit. I tend not to mess too much with it. The grid layout was easy to implement with GLine and GLabel. The trick was aligning the graph lines. It took me several trials to get it right. I had clear idea how I was going to do that but implementation could get messed up. There were two important constants, the array had 12 cells and number of decade value were 11. I had to be very picky about when to let the loop run a less, equal or a more than NDECADES. I also decided to restrict the graph between the top and bottom horizontal line which required me to convert the thousand scale to in-between space of the graph. It is always interesting to see the vast difference generated by using int instead of double or a using long mathematical formula in a line.

Implementing colors to cycle between black, red, blue, and magenta was quite mind bending. I thought about various ways to implement it, for examples, using array, loop, if-for statements, etc. None worked as I had thought. In the end, it was as simple as taking a mod of user’s count in the array list by 4 which the number of colors we want to cycle through. I also made sure that empty strings and same names didn’t end up in the array list.

At the end of the day, it was very hard to get anything done when I had myself exhausted but sleeping on it payed well the next day. A fresh mind is what you need to solve the problems of programming.

As always you can check the code in my Github repo.