Tuesday, 10 July 2012

Webcam on Dell Latitude E6520 on Arch linux

On my Dell Latitude E6520, I have a webcam integrated into the front panel. I am not very used to video calls so I hardly use it. However, recently I wanted to talk to my brother using video call on Skype. So, I started digging in so that I can configure it. The first step was to see if it is already configured and works out of the box. I tried getting video to work during a Skype call; but it did not. So, I started looking for the actual model. I got the following output on lsusb.


Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 413c:8187 Dell Computer Corp. DW375 Bluetooth Module
Bus 001 Device 004: ID 05ca:181c Ricoh Co., Ltd
Bus 002 Device 003: ID 0a5c:5800 Broadcom Corp. BCM5880 Secure Applications Processor


I could not figure out which one is the webcam. So, I looked into the output of lspci as well; but nothing there either. So, I was having a hard time figuring out which device is my webcam. The other question running in my head was the rare possibility of my kernel not detecting my webcam. I checked out /var/log/dmesg.log to see if it was detected. I ran the following grep.

grep webcam /var/log/dmesg.log

I was disappointed to find nothing. After some time, I realized my mistake and tried the grep query in case insensitive mode.

grep -i webcam /var/log/dmesg.log

This time I found the device.

uvcvideo: Found UVC 1.00 device Laptop_Integrated_Webcam_FHD (05ca:181c)
input: Laptop_Integrated_Webcam_FHD as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5/1-1.5:1.0/input/input8


Looking at the output I tried loading the uvcvideo kernel module and tested the webcam with the following vlc self-recording command.

vlc v4l:// :v4l-vdev="/dev/video0"

It worked fine. So, I looked into the Arch wiki for more details. It mentioned that linux-uvc was now in kernel. Looking into a more exhaustive list of devices supported by uvcvideo, I found the following matched my device closely.

05ca:181a
05ca:181b

So, I guessed 05ca:181c should also be supported by uvcvideo but being a new model was not listed there. So, I have reported this to the dev team and added the module uvcvideo the list of modules in my rc.conf.

MODULES=(acpi-cpufreq cpufreq_ondemand cpufreq_powersave uvcvideo)

Interestingly it is a Ricoh device but the driver is not the Ricoh driver [mentioned in the wiki].

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.