Wednesday, 26 December 2012

Rails is re-inventing the wheel

In recent years, there has been a surge in web applications. To support the growing market, frameworks have developed around scripting languages for developing web applications fast. Of those Ruby on Rails seems to be the most mature. Django, the most advanced Python framework for web applications is yet to come at par with it.

Be it Django or Ruby on Rails, both follow a model-view-controller architecture to web applications. Now, many web applications using these frameworks follow 'skinny controllers, fat models'. As a result the models become home to a lot of business logic. Models are intended to serve only as an abstraction to the database. They are meant to be 'models of data'. Also, when the application grows huge, we run into issues of scalability and we resort to techniques like sharding. Now, there are of course multiple ways of sharding and you need to decide what suits you better. Here, I list a few ways for Rails applications.
Now, sometimes the sharding logic also creeps into the models. Obviously objects of model classes do not have a single purpose any more. Over time, the model classes obviously become too complicated. It becomes difficult to maintain and debug. The Rails community is becoming increasingly aware of these issues. There are multiple ways in which developers are trying to move business logic away from models. Here I list of couple of those ways.
Looking at the overall scenario reminds me of building N-tier applications using Java Enterprise Edition. The sharding logic and details of data fetching can be a tier below models and the business logic can be a tier above it. ' seems to me developers using web frameworks like Django and Rails are just re-inventing the wheel. Also, Java has optimized garbage collection which can be tuned to various needs. In Ruby garbage collection seems to be a big issue, though good work in the area is coming in the next version.

So much in the name of innovation, eh? In case my ideas seem to waver from reality do point me in the right direction.

Update: You can follow the discussion on Hacker News on the topic.

Monday, 24 December 2012

Rails time formats

During programming, I do tend to forget the various time formats available in Rails. Also, there are so many options available that a simple typo like capitalizing (or not) changes meaning. It is best that this part be always tested properly.

Sunday, 16 December 2012

Apple Magic Mouse with Dell Latitude E6520

Recently, I found some free time at office and my colleague's Apple magic mouse was lying on my table. It sure is a cool device. So, I thought why not connect it to linux and see how it works. So, I turned on the bluetooth daemon on my system with the following command.

systemctl start bluetooth

I use Bluedevil. So, I clicked on the tray icon and ran a scan for bluetooth devices in range. The pairing key required is 0000. Initially the mouse pointer movement was too fast and scroll was too slow. So, I changed the configuration using this blog.

It is cool, indeed. However, I found it difficult for regular use because I am not used to it and it is a touch mouse unlike other mice. When I am moving the mouse, I have to make sure my index finger is not touching the surface, else there is unwanted scrolling.

Friday, 14 December 2012

Enjoying writing

Recently while waiting for a flight at Mumbai domestic airport, I decided to write down my thoughts. Of late, I have been writing on some keyboard mostly but this time I was writing with a pen and I actually enjoyed doing it. So, I write  about writing only. This is what I wrote:

Is it possible to write with this pen?
Well not completely impossible. Also I realize the benefit of writing with a thick pen. With a thick pen, you tend to write each letter well while with a thin pen, you write a letter away [especially the letters towards the end of word]. [It] Reminds me of a friend who recently advised me to try a thick pen and I have to admit I am really loving this experience. At school, I hated writing with a thick pen because it slowed me down. However, now that its not my writing speed by my writing that I care about, I think I will use this thick pen more often.

Compared typing on a keyboard, while penning down the flow of thoughts was better. I liked it and decided to do it more often.

Friday, 16 November 2012

UTF-8 encoded Rails Console in linux

Although, initially while working on Rails project, we do not pay much attention to the character encoding, soon it bites us bad. When we try to play with a string containing Unicode characters in an ASCII encoded Rails console, it complains about it and we are stuck.

It is quite easy to get a UTF-8 encoded Rails console. All we need to do is properly set the LANG environment variable of the terminal first.

export LANG=en_US.UTF-8

Rails picks up this variable and sets its encoding. So, when we fire up Rails console now and enter the following command, it shows that we have UTF-8 encoded console.

puts __ENCODING__

Now, we can easily play with UTF-8 strings.

Sunday, 4 November 2012

Skype uses its own DNS

Skype is a really interesting software. Its text chat UI is mature and audio and video chat facility are very nice. Skype has this interesting ability of working independent of the DNS configuration of your system. Even when the DNS server your system is configured for, gets poisoned, Skype does not get affected.

In fact, I leverage this ability of Skype to detect network issues due to DNS service being down. On such an occasion, when the browsers were not working but Skype was, I pointed my DNS configuration to Google's DNS servers (listed below) and the browsers worked fine.

To take a deeper look, I tracked the connections Skype was making. I used the following to do that.

netstat -taucp | grep skype

Initially it was sending out packets from port 51395 of my localhost. After I logged in, I find the following connections:

tcp        0      0 *:42520                 *:*                     LISTEN      19207/skype      
tcp        0      1 H:47078    SYN_SENT    19207/skype      
udp        0      0 *:42520                 *:*                                 19207/skype      
udp        0      0 localhost:51395 *:*                                 19207/skype

H about is the hostname of my system and the IP is owned by Microsoft, Microsoft Singapore to be specific. Interesting sequence of connections, when I lookup a contact and open the corresponding chat window.

tcp        0      0 *:42520                 *:*                     LISTEN      19207/skype      
tcp        0    516 H:46808     ESTABLISHED 19207/skype      
tcp        0      0 H:47078    ESTABLISHED 19207/skype      
udp        0      0 *:33626                 *:*                                 19207/skype      
udp        0      0 *:41980                 *:*                                 19207/skype      
udp        0      0 *:42520                 *:*                                 19207/skype      
udp        0      0 localhost:51395 *:*                                 19207/skype      
udp        0      0 H:32897          *:*                                 19207/skype

The IP maps to Skype Technologies. After sending a line of text on  the chat window, the following connections were made.

tcp        0      0 *:42520                 *:*                     LISTEN      19207/skype      
tcp        0      0 H:46808     ESTABLISHED 19207/skype      
tcp        0      0 H:47078    ESTABLISHED 19207/skype      
tcp        0    236 H:44172     ESTABLISHED 19207/skype      
tcp        0      1 H:45020   SYN_SENT    19207/skype      
tcp        0     75 H:48246     ESTABLISHED 19207/skype      
udp        0      0 *:33626                 *:*                                 19207/skype      
udp        0      0 *:42520                 *:*                                 19207/skype      
udp        0      0 localhost:51395 *:*                                 19207/skype      
udp        0      0 H:32897          *:*                                 19207/skype

The IPs,, map to Microsoft Corp Redmond, Skype and Entreprise des Postes et Telecommunications respectively. After that, when I was not doing any more activity on Skype, the following network activity was seen.

tcp        0      0 *:42520                 *:*                     LISTEN      19207/skype      
tcp        0      0 H:47078    ESTABLISHED 19207/skype      
tcp        0      0 H:47362 ESTABLISHED 19207/skype      
tcp        0      0 H:48246     ESTABLISHED 19207/skype      
udp        0      0 *:42520                 *:*                                 19207/skype      
udp        0      0 localhost.localdo:51395 *:*                                 19207/skype does not have any DNS entries. Suggestions for digging further are welcome.

Saturday, 6 October 2012

Formatting column entries for IN query

Extracting entries of a column in a spreadsheet and using them in an IN query is not a rare scenario [at least for me] at work. Now, copying and pasting the entries in a comma separated and sometimes quote-enclosed format is tedious and when there are 100 entries, doing that by hand is unacceptable for me. On top of that when each entry has to be modified a bit before passing in the IN query, then the whole process becomes drudgery. Today, when faced with such a situation, I used emacs and sed to save myself a lot of time and boredom.

Let us consider that the spreadsheet has a column that has the following entries:


Now, lets consider that I have to strip the first suffix, enclose the values in quotes and pass them in the IN query. So, I copy the column and paste in a text file and run the following commands on the file.

sed -i 's/-1//' ./myfile.txt
sed -i 's/-2//' ./myfile.txt

Now the file had the following contents.


Now, I opened the file in emacs and ran a keyboard macro to get the following string.

'12345', '23456', '34567', '45678', '56789',

Now, I could easily use it in my query. Now, the macro I used was simple. I started recording the macro using `C-x ('. The macro consisted of the following keys in sequence [try it yourself to be clear]:

' -> End -> ' -> , -> Delete -> Space

I ended recording the macro using `C-x )'. Now, I had one line edited so I let emacs run the macro 4 times using the following command:

C-u 4 C-x e

I got the inspiration for using macros in the following video.

Thursday, 13 September 2012

JVM crash: an eye opener

I had done some programming but I guess I had not hit many walls. In C, my programs had segfaulted; but every time that happened I knew that my program broke; but there was never a notion of the programming environment breaking down. I, of course, know that when one is coding specifically to break the environment, it is not impossible; but I am talking about cases when the break is not intended. I could never imagine the shell, in which I am running a program for connecting to some website and getting some data, breaking down in between the running of the program.

However, recently I was using Rubymine to test some XML parsers I had written and suddenly it crashed. Initially, I thought may be Rubymine crashed, so I went back to shell where I had started it. To my utter surprise, it was the JVM that had crashed. That is when it hit me that programming environments can also crash. I have reported the bug; but there is not much done from Oracle's side about it.

Well, I do not expect much from them either; but the lesson I learnt is valuable: it is not only the program; but also the program's environment that can crash. Its not that I did not know it but it is not something I regularly expected. From now on, I will though. It did change the way I looked at errors. I guess this is what counts as experience.

Thursday, 30 August 2012

Showing tmp folder in Rubymine

I have been using RubyMine for a few months now. I must say it has served me well. Recently, I was writing and reading files in the /tmp folder of root directory of my Rails project. However, in my project pane, it was not showing the /tmp folder. So, I had to go to the folder using my file manager and check the files. When I was through with my task, I wanted to figure out why that folder was not shown in the project pane. Getting the folder to show up was easy. In the project settings, in "Project Structure" section, there is a list of excluded folders. We just have to remove the entry for the /tmp folder.

Monday, 6 August 2012

Using sed to remove unwanted lines

I have written about sed's utility before as well and it has impressed me time and again by the amount of time it saves. Recently while testing E17, I generated backtraces using GNU debugger. However, the file to which I redirected the backtrace contained a large number of lines about reading and loading symbols. I wanted to quickly get rid of those lines so that the developers can directly view the backtrace instead of scrolling down pages before the actual backtrace. So I decided to use sed for the purpose. The approach I took to achieve my desired result was as follows:

  1. I wanted to deletes lines that mentioned about loading or reading symbols. So, the sed operation I required was delete matching lines.
  2. I wanted to edit the files. So, I turned the edit in-place option on.
With this approach in mind, I ran the following two lines and the file was formatted properly.

sed -i '/Reading symbols/d' my_file
sed -i '/Loaded symbols/d' my_file

N.B.: If you want to test the output, remove the -i option.

Thursday, 2 August 2012

Audio settings for Skype on Archlinux

By default Skype on Arch linux does not take input from the microphone. It is usually because the channel to capture audio input is set to zero. It can be easily changed in alsamixer. Start by running the command alsamixer in console.
The default view above does not show all channels. Hit F5 to view all channels and increase the values of the channels 'LR Capture' and 'Digital' as shown below.

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.


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>

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
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

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 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:

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

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


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 script.

[blog@domain ~]$
$ 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.

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 ( in the above case) and copied its contents to add a new key on Github. I tried ssh -vT 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
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to [] 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

Monday, 16 April 2012

AlpsPS/2 ALPS DualPoint TouchPad on Arch linux

In my new Dell Latitude, there is an AlpsPS/2 ALPS DualPoint touchpad. When I installed Arch linux on it the touchpad worked fine for me. I do not use the touchpad button and prefer to tap on the touchpad for a click. This feature worked fine with the initial configuration. However, after a system update which included a kernel update too, tap did not work.

I had not gotten into details of the touchpad before this incident. When I found it was not a Synaptics touchpad, I got scared that I might not get a decent linux driver for it. Just about a month ago I was looking for a decent driver that supports Nvidia Optimus tecnology; but all my efforts were in vain.

As I started looking for a driver for my touchpad, I found out that the synaptics driver is not only for synaptics touchpads. So, I installed xf86-input-synaptics package. Tap for click started working as the default /etc/X11/xorg.conf.d/10-synaptics.conf has the configuration for tap.

        Option "TapButton1" "1"
        Option "TapButton2" "2"
        Option "TapButton3" "3"

Also, two finger scroll started working. I had no idea that my touchpad supports it. The documentation however specifies a config for Alps touchpads. I read through synaptics configuration on Arch wiki to configure the touchpad to suit my usage. The Gentoo wiki also provides a number of configurations, in case you want to try things out. The AccelFactor value mentioned in these wikis turns out to be too slow for me. So, I increased its value. 

Tuesday, 3 April 2012

Customizing system-wide gem install

I hardly use gem documentation and mostly install with --no-ri and --no-rdoc options. So instead of typing these options each time I install a new gem, I decided to apply these by default. Adding the following to /etc/gemrc achieved it.

gem: --no-ri --no-rdoc

Saturday, 31 March 2012

When "justified" is not justified

While using Microsoft Office, "justified" alignment is not properly implemented.

Thursday, 29 March 2012

System-wide accessible gems

As I was configuring my system for my friend's rails project, I found that when I install gems are root, they are available only to the root user and system-wide. When I install something as root, I expect it to be accessible system-wide. So, I dug into the issue and found that it was happening so because /etc/gemrc was configured to install gems for root user only. Getting system-wide installation of gems was achieved by commenting out the following line in /etc/gemrc

gem: --user-install

Now, instead of getting installed in /root/.gem/ruby/1.9.1/gems/ gems were installed to /usr/lib/ruby/gems/1.9.1/gems/ and were available to all users. Previously installed gems had to be uninstalled and re-installed so that they were available to all users.

Wednesday, 28 March 2012

Boot message: Unable to register miscdev on minor = 130

On my new Arch linux installation I was getting a line saying "Unable to register miscdev on minor=130 (err=-16)". In /var/log/errors.log, I was getting the following lines:

Mar 28 19:37:16 localhost kernel: [13926.292770] watchdog: error registering /dev/watchdog (err=-16).
Mar 28 19:37:16 localhost kernel: [13926.292771] mei: unable to register watchdog device.

A comment on Archlinux forum clarified that it was caused because the kernel supports only one watchdog. The solution is two blacklist MEI driver. That can be done using the following line.

echo blacklist mei > /etc/modprobe.d/mei.conf

You read more about IMEI here.

Sunday, 25 March 2012

Reusing packages from one system in building a new one

While installing Arch linux on my new Dell Latitude, I wanted to reuse packages on my existing Arch installation on my old laptop. As soon as I was through with the initial install using the net install image, I put all packages from /var/cache/pacman/pkg to a folder called repo on a USB stick. From the command line I mounted the usb stick on my new installation to /mnt/usb.

mount -t vfat /dev/sdb1 /mnt/usb
Now, all I had to do was to tell pacman to look for packages in the repo folder in the USB stick. I achieved this by setting CacheDir variable in pacman.conf to /mnt/usb/repo.

#DBPath      = /var/lib/pacman/
CacheDir    = /mnt/usb/repo/
LogFile     = /var/log/pacman.log

Actually, you can also try creating a local repo. It is there in the pacman manual pages. However, this seemed easier and faster to me and worked on first go.

After this setting, when I tried installing Xorg it told me that there is no extra.db and community.db; but I had those repos enabled and therefore it failed. I realized only core.db existed in my system and I had not synced the repo databases even once. I could have achieved that by pacman -Syu; but for my internet connection to work I needed to install wvdial and usb_modeswitch as I use a 3G USB internet card. So, I just copied extra.db and community.db from my old system into the new one and things worked fine.

Wednesday, 22 February 2012

Partial upgrade messed my system

Although I am aware of the potential risks of a partial upgrade, due to slow connection I thought I will go ahead with it. I was feeling confident that if things mess up I will be able to handle them. I had installed grep and udev without installing upgraded versions of kmod and pcre.

When I restarted [may be I should not have done that], during boot only the system started throwing errors about grep being unable to find libpcre and kmod not being found. I was able to boot into kdm but my keyboard and touchpad were not working. The root of the problem is still unknown; but I thought of trying installing pcre and kmod. However, to install I had to get to the command prompt at least.

So, I created a Gentoo boot disk using my flash drive and chrooted into my system. I connect using 3G USB dongle and from the chrooted environment the mode was not switched. So, I had to get packages downloaded separately and then install them through the chrooted environment. I should have installed the same version as in my system's pacman database; but I installed the latest one. With that I fixed the boot problems and my keyboard was working but it broke a few other things and kdm did not work any more. When I booted now, it took me to the command line. I reinstalled kdebase-workspace; yet the issue persisted. To make things worse, I found that emacs and irssi were also not working. So, I couldn't get to any IRC channel to ask for help. The only good thing that happened was I was able to get to a command line. So, I did not have to download packages elsewhere and install it.

 When I connected to the internet from my system and ran pacman -Syu it showed me downloads of around 650 mb. I found that many of those packages like libreoffice and 32-bit libs are not absolute necessity from a repair perspective. So, I decided to download a small subset to get my KDE back. I downloaded

  • avahi 
  • ca-certificates 
  • compositeproto 
  • cpio 
  • kdelibs 
  • kactivities 
  • libxrandr 
  • xdg-utils 
  • qt  
  • oxygen-icons 
  • kdepimlibs 
  • kdepim-runtime 
  • libxml2 
  • libqalculate  
  • libxcomposite 
  • libmysqlclient 
  • libvorbis 
  • libshout 
  • sdl_image 
  • zvbi 
  • vlc
 The list above is a subset of the packages pacman wanted to download for the system upgrade; but at the same time they also form a superset of the packages I believed could cause my KDM issues.This solved my problem and now I am blogging from my revived linux system.

Experiments like these should not be undertaken unless
1. You are crazy like me.
2. You have a backup system and have your /home folder on a separate partition so that even if your system can't be fixed, you can install a fresh new system without losing data. [You can also save configurations in /etc.]
3. You have sufficient bandwidth.

Sunday, 5 February 2012

Cleaning KDE "Open with" list

I had installed MPlayer and uninstalled it long back. However, since then KDE always showed it in the "Open With" list for media files. Just to make sure it was not installed on my system I ran

pacman -Rcus mplayer

as root. Obviously the target was not found. After some chatting on #gentoo, I resolved the issue by deleting mplayer.desktop file from ~/.local/share/applications. Along with that, I cleaned some other stale applications from that directory.

Saturday, 4 February 2012

Alarming state of linux distributions

A random peek at Distrowatch showed me that the top linux distributions were all losing popularity.

Does this mean linux is losing popularity or some rarely known distribution is gaining prominence in the background?