Wednesday, July 7, 2010

Drupal source code and [g]vim/cscope

When you start looking at modules developed for Drupal - you kinda get lost amidst all the references to different system functions - user_external_load, db_query, etc. It becomes really maddening!

Fortunately a cscope-enable gvim binary will ease out the source code browsing angst to a large extent. Amongst all the other things, here is what I have in my .vimrc

if has("cscope")

   function! CScope_Refresh()
cs kill 0
 !find $PWD -name \*.php > files && cscope -b -i files
!find $PWD -name \*.js >> files && cscope -b -i files
!find $PWD -name \*.module >> files && cscope -b -i files
!find $PWD -name \*.info >> files && cscope -b -i files
!find $PWD -name \*.install >> files && cscope -b -i files
!find $PWD -name \*.inc >> files && cscope -b -i files
cs add .
!rm -f files
endfunction
comm! -nargs=0 R call CScope_Refresh()
endif

After you have sourced your .vimrc again, you can navigate into your Drupal install directory, fire up gvim and just hit :R and you will be able to search for symbols, look for references to functions, look for files etc. using the standard cscope commands:

e.g.:

:cs find g user_menu

The above will lead us to the definition of the user_menu function in user.module. 

Hope, this post will relieve some of your source code browsing pangs :)

Sunday, June 13, 2010

Why Drupal..

The first major decision that we at had to take at Yuva was about which infrastructure piece to use for the first version of our product launch. Our's is a web-based product. We want to incorporate elements that engage and inform the user-base in various interesting and socially-viral ways. We also want to provide group based interaction, public-private access control features etc. etc. I hope you get the drift! :)

Coming up with hand-crafted code to do all the above seemed a daunting and an insurmountable task given that we want to be out there ASAP. It was then that we started looking around for open-source alternatives.

Drupal and Joomla came up trumps in that research. The idea was to take something off-the-shelf, understand it better and then customize, extend it for our needs. Then come the difficult part of actually deciding between these two. Googling up can actually be a frustrating exercise. For every positive reference you will find an equally disparaging remark too. For every positive user case study you will find an equally pulling-my-hair-off-in-frustration use case too. Tough job!

In the end we have decided to go with Drupal. They seem to have a large thriving community and a lot of websites seem to be coming up on its platform. Additionally Drupal 7 (when it will be launched) seems to further improve on the capabilities provided and the user-friendliness aspects too. Finding good Drupal talent (to hire) based out of India has been an issue so far. But we are trying to build the expertise in-house, because this is a core-requirement which we think we  cannot out-source at all.

Will post back on our Drupal experiences in the coming months - stay tuned!

Thursday, February 12, 2009

Me, my phone and my calendar!

Recently, I got the entry level HTC smartphone for myself. The 3400i is a VFM phone with all the bells and whistles one would need in an entry level smartphone. Whenever I change a phone, the biggest headache is moving around the contacts and the calendar information. I tend to forget and rely a lot on the calendar to remind me about important events like birthdays, marriage annivs and the likes.

I was looking forward to a dreary timespan trying to update my calendar on the phone for all those important events. Its just today that I read about GoogleSync for mobile phones. Via GoogleSync one can sync their googlemail contacts and calendar events immediately with their smartphone! I was sceptical but it was a total breeze. I just had to enter my gmail address details in ActiveSync (yes mine is a Windows Mobile phone - no bricks please :P) and lo-and-behold my gmail contacts plus all calendar events were uploaded wirelessly onto my mobile! Nice, I say :D

What are you waiting for, go get your mobile synced up!

Friday, January 2, 2009

FC10 woes

So my last posting mentioned the reasons why I upgraded my laptop from FC8 to FC10. But the recent events have left me flabbergasted :(

Last week, the automatic update system informed me of the availability of a new kernel (kernel 2.6.27.9-159.fc10) and I dutifully installed the upgrades. The machine stopped booting up since then! It would directly go to the GRUB prompt and nothing else would occur. 

I thought I will just boot up using a CD, mount my drive and edit grub.conf to start using the machine again. I did so and thankfully the Linux partition started booting up again normally. But in this process my Windows Vista partition got totally messed up (again due to the grub manipulations I would think) and goes into a recovery and rescue mode on every bootup :(. Attempts to mount the partition from within Linux also comes out with an error! 

Now darned if I had taken a backup ever!  To summarize, I have lost my windows partition along with all the data on it and am now in the process of a re-install of WinVista. That this laptop is where I do my work on is what makes matters worse. 

Lesson learnt - do not upgrade to a bleeding edge technology unless it has settled down or you BLEED like me. Guess I should have gone to FC9 first... 

Wednesday, December 3, 2008

FC 10!

So a while ago, I upgraded my laptop from FC8 to FC10. It was a pretty simple process because the upgrade operation identified my existing FC8 partition and smoothly upgraded in roughly an hour and 30 minutes without asking for too much. Simple, nice and easy I say. Anyways, here are some reasons why you should upgrade to FC 10 (or this is what Redhat claims to be the reasons):

#1. Speeding Up the Boot Process
#2. The Excellent Solar Theme
#3. Making Printing Snappy – and Attractive
#4. Better Webcam Support
#5. Improved Virtualization
#6. Live image creation tools
#7. Global community efforts
#8. PackageKit (user-friendly yum!)

Read more details about the above and some more here. And let me close this entry with this quote that I read somewhere today :)

"Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)"

Friday, July 25, 2008

Search Recursion

Something funny happened today. All of us google - ummm to search. Even I was doing it. I was trying to use the "screen" utility on my test machine, so that I could start my test and log out and get back later to it. When I gave the "screen -r" command to reattach, I got the following error:

Cannot open your terminal '/dev/pts/0' - please check.

Some permission issue I guessed, so I thought I will search for the solution by googling. I searched by entering keywords like "screen, terminal, cannot, open" etc. etc. and clicked on the second link that came in (As as aside, which search link do you open from the search results? Should do a poll I guess :)).

I got on to that specific page and instead of getting the answer I get the following blurb:

"This is a common problem. Googling will help here"

Hmmm, scratch-scratch, I just googled didn't I? But I think instead of giving out solutions, people have actually started to say "google out and get it" nowadays. Will there come a day when all results we get be like the one above :P

Btw, a simple chmodding of the pts entry seems to help here for non-root users above..

Thursday, July 17, 2008

Batch Image Resize on Linux

Isn't it the same case always. You go out on a trip somewhere. You become trigger happy and click loads of pictures. You come back and want to share it with friends and need to upload them to either picassa or flickr. Now typically if you use a 6 plus MPixel camera, the pictures generally come out to around 1.7MB in size. Uploading a lot of such pictures is a big pain.

I recently discovered the convert utility on Linux. Using it is pretty simple. Here is a small script that I use to batch resize my pictures before uploading them:

for file in *.JPG;
do echo "Resizing file $file ...";
convert -resize 640x480 $file $file ;
done

Check out some pics (Portland visit for RailsConf) that were uploaded after the conversion above here.