Wednesday, 13 June 2012

GMail experience is too slow

Some time ago, I posted about the "Google" experience, where I mentioned about ease of use and speed being essential aspects of our regular usage of Google products and how Google [in my opinion] is doing it wrong by moving away from these key aspects. Here is one more incident. For the past two days, I have seen the following page a number of times.
It never happened to me before and I have been using GMail since the beginning of GMail itself. When I finally logged in successfully, I wanted to clear out my trash as it was huge. While it was deleting, it showed me the following lightbox.

It took more than 3 hours to complete the deletion of trash. I know that my trash is huge; but the time it took is way more. Overall GMail experience for me has slowed down considerably. When I create or update a filter, it takes at least 3 minutes to get back. People initially switched to Google because of its ease of use and speed; but now Google is gradually losing on those key aspects.

Tuesday, 12 June 2012

Reboot on Dell Latitude E6520 with Arch linux

On Dell Latitude E6520 and some other Latitude models, a number of distributions were having issues with reboot. Rebooting by any method, viz.

  • restart command
  • shutdown -r now command
  • or restart from GUI

stopped all processes. The run level goes to 6 and everything works fine. Finally the system shows a message that it is rebooting now but the reboot does not happen. Ubuntu had this bug too but they fixed it and when my friend tried Ubuntu on the same hardware, reboot worked fine for him. I filed a bug in Arch and discussed it on #archlinux. The developers said it is an upstream issue and I was able to find an already reported bug upstream. Looking into the bugs and comments, I figured I should try setting the kernel parameter 'reboot' to 'pci'. So, I changed the kernel line in /boot/grub/menu.lst to include 'reboot' parameter as follows.

kernel /boot/vmlinuz26 root=/dev/sda2 resume=/dev/sda1 ro reboot=pci


After the above change, my system rebooted successfully.


N.B.: 1. Here, /dev/sda2 is my root partition and /dev/sda1 is my swap partition.
         2. Read more about rebooting a system.

Saturday, 9 June 2012

Standards of "The Times of India"

From the name "The Times of India", one might expect high standards to be maintained in the newspaper in line of the British newspaper 'The Times'. However, gradually I have seen the standards of the newspaper going down. Some time ago, I saw their front page was a full page advertisement. The front page should be the place for the most important news for the day. Probably their editors thought the advertisement was more important than any event.

Recently, I saw a copy of The Times of india lying on the table and having nothing else to do, I thought to me "let me try the sports section". The article was called "Big Three in the making." It was about Indian cricket team, focussing on the players: Suresh Raina, Virat Kohli and Rohit Sharma. Reading through the section for Rohit Sharma, I found the following:

"Though he is an all-rounder and can fetch wickets too, his main strength is his batting and he has become one of the key members of Indian team. In the absense of biggies like Sachin, Laxman and Dravid he is one player on whom Indian team can depend fully. In the absense of biggies like Sachin, Laxman and Dravid he is one player on whom Indian team can depend fully. He can strengthen the middle order to fill the space after Laxman and Dravid's retirement."

The repetition of sentences above is not my mistake; but that is how it appeared in the newspaper. I was thinking to myself, "don't they even do any proofreading before sending an article for printing?"

Monday, 4 June 2012

Connecting to wifi network on Motorola MC3100

While attempting to connect a Motorola MC3100 to my wifi network, I was getting a popup message saying that I might not be able to connect due to regulatory issues. Looking into the logs, I found the following message.

"Country code not acquired yet"

I guessed some sort of country code has to be sent my the wifi access point for the device to work. So, I looked into hostapd configuration manual and found that in the 'IEEE 802.11 related configuration' section, we can set country codes. So, I changed the following variables:

country_code=<your country code>
ieee80211d=1


When I restarted the wifi hotspot, the device could connect to internet successfully.

Setting environment variables in ruby on rails

I use GMail's SMTP gateway for sending out system generated emails in my RoR project. Once, I got everything working, I thought of deploying it on Heroku. However, I host my code on Github and did not want to commit the id and password on the GMail account. So, I decided to read the email id and password as environment variables.

I set the environment variables on Heroku using the following:

heroku config:add ID=my.id@gmail.com
heroku config:add PASS=mypass


In the code I accessed these variables using ENV['ID'] and ENV['PASS'] respectively. So, the code was somewhat as follows:

class Emailer < ActionMailer::Base
    default from: "#{ENV['ID']}", :charset => "UTF-8"
    # other methods
end


With this I could easily send out mails from Heroku.

Whenever I want to test anything on my local using emails, I set environment variables before running the Rails server.

export ID=my.id@gmail.com
export PASS=mypass
rails s

Thursday, 24 May 2012

Putting data from a tab separated(.tsv) file into MySQL database

Many a times we need to populate data dumped by someone into a tab-separated file into our database. It can be done using the following ruby code:

   begin
      row = []
      File.open("/path/to/file.tsv") do |f|
        f.each_line do |tsv|
          tsv.chomp!
          row << tsv.split(/\t/)
          method_to_store_detail(row)
        end
      end
    rescue Exception => e
       puts "------exception------#{e.inspect}"
    end



However, the file runs into hundreds of MBs, this will be way too slow. Instead we can use the following MySQL query.


LOAD DATA LOCAL INFILE '/path/to/file' REPLACE INTO TABLE table_name IGNORE 1 LINES (column1, column2, column3, column4);

The "IGNORE 1 LINES" part ensures that the first line containing the header is ignored. In case there are no headers, this part may be excluded. Also, if relative file paths are to be used, the LOCAL keyword may be dropped. This process is way faster than any other process; but validations are bypassed.

Tuesday, 15 May 2012

Perl REPL

While trying to translate a Perl script to a ruby script, I found the necessity of testing things on the interpreter. Ruby provides IRB for that. If you are using Ruby on Rails, you might prefer Rails console over IRB. However, I could not find anything similar in Perl. I could do some tasks from the command line as follows:

perl -e "print 'Hello World';"

However, whenever I was trying any assignment, it was not working. For example,

perl -e "$k = 'Hello World';print $k;"

did not work. I later came to know it was because bash was gulping $k because I had used a double-quoted string. Using a single-quoted string works fine.

perl -e '$k = "Hello"; print $k;'

A quick search showed that I can use Devel::REPL for this purpose. So, I obtained it from CPAN.


cpan -i Devel::REPL

I prefer using the Perl REPL interpreter using the re.pl script.

[blog@domain ~]$ re.pl
$ my $k = "Hello World"
Hello World$ print $k;
1$ Hello World
$ 

Thursday, 3 May 2012

The "Google" experience

Earlier the "Google" experience was very simple. In the typical "Google" workflow, i.e. the workflow followed in most of its products, interfaces were uncluttered and never came in your way. However, recently they are becoming increasingly cluttered. Youtube, for example, has a lot many things on its homepage now. However, earlier it just had videos. When you go to Youtube, you want to watch videos and that was what it showed to you. Wil Wheaton calls this as a huge mistake on the part of Google. He is not alone.

Another important aspect of the "Google" experience was speed. Now I am experiencing considerable speed reduction in almost all Google products. Be it Gmail, Blogger or Youtube. They have implemented instant search but their faster search pages were much more helpful. I can always do without instant search. When I come to search page, I know what I want to search. Suggesting instantly only reduces the number of letters I type.

Next aspect of the "Google" experience is coolness. Stopping the code search facility is not cool at all. By coolness, I mean positive rapport with the open source developer. Google used to inspire developers worldwide; but it is not that cool any more. DuckDuckGo is way cooler than Google.

Semantic search is the milestone that Google and its competitors are heading for. Social sites like Facebook are becoming important because they have better results at semantic search but in a restricted domain. Same is the case with many other tools that are providing or have the potential of providing better results at semantic search in various domains. For the ads market, the better the semantic search result the higher is the increase in likelihood of the ad getting attention and being clicked. So, instead of ruining its own experience Google should work on finding ways of improving semantic search in more and more domains.

Friday, 27 April 2012

Using multiple keys for github

Recently, I was working from my office laptop. I had set up ssh keys for Github on that system. However, when I had to work from my personal system, I realized that I don't have those ssh keys with me on this system. Also, the ssh keys on the current system were used for another purpose. So, I decided to have multiple keys on Github as well as on my system. I created my new keys with the following command:

ssh-keygen -t <rsa/dsa as per your choice> -f <new private key file like ~/.ssh/id_dsa.github> -C "comment"

This created a new key pair for me. Now, I had to configure ssh to use this key for github. So, I added the following lines to ~/.ssh/config file.

Host github.com
IdentityFile ~/.ssh/id_dsa.github
User git


Now, I had to add this new key to my ssh keys on Github. I opened the new public key file (id_dsa.github.pub in the above case) and copied its contents to add a new key on Github. I tried ssh -vT git@github.com and verified that it was using the new key and I was able to access Github successfully.

OpenSSH_5.9p1, OpenSSL 1.0.0g 18 Jan 2012
debug1: Reading configuration data /home/me/.ssh/config
debug1: /home/me/.ssh/config line 9: Applying options for github.com
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to github.com [207.97.227.239] port 22.
debug1: Connection established.
debug1: identity file /home/me/.ssh/id_dsa.github type 1
debug1: identity file /home/me/.ssh/id_dsa.github-cert type -1