Saturday, 21 September 2013

Renaming a branch in git

Many a time we do the mistake of calling it something and figuring out that we really meant something else.  Git branch names are no exceptions :)  So here is how you rename a git branch

git branch -m oldname newname
 
 
Thats it. Short and simple in case you were trying to rename git branches

Thursday, 12 September 2013

Javascript has grown and CDN failures - Oh My!

For a long time I considered javascript to be a fairly childish language (and rightfully so since my days of working with Javascript goes back to the original navigator days) and I had actually lost track of the language  for over a decade!  I have been recently looking at the language as it seems to have become this new programming language for the real time web and frankly surprised by the number of concepts, frameworks and capabilities that it has evolved into over the years.

Coming to more practical matters, I had a steep learning curve  - learnt how they managed to not pollute the global namespace with global variables, how they have classes (sort of...) and how they have objects (sort off...) and in the middle of all this feeling that the world of javascript is just one big hashtable.

But duty calls and I have been attempting to use some of the popular frameworks out there - socket.io, json, jQuery and so on.  That is when I discovered these wonderful CDNs from Google, Microsoft and Cloudflare that will provide hosting for all these popular frameworks.  Now there is an entire school of thought on why CDNs are bad, I as always have an opinion of my own that does not quite agree with the general population so I decided to use the CDNs and still wanted to fall-back to my own servers in case the CDN is down  (yes that is an extremely unlikely event but call me whatever - remember we didn't pay for it).

I found an elegant solution in the Javascript language itself and I thought you may want to use.

Here is how I load JQuery from CDN or fallback to the origin servers when I have to...
 <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' charset='utf-8' type='text/javascript'></script> 
< script type="text/javascript">
// <![CDATA[
            window.jQuery || document.write('<script src="http://i.myorigin.com/fqstatic/js/jquery/jquery.min.js">\x3C/script>')
// ]]> 
 
 
Hope this helps 

Getting rid of the brace matching in VIM

For some strange reason VIM has a very bad habit of matching braces rather greedily.  Every time you get on top of a brace, the cursor jumps willy nilly trying to find the matching brace and possibly making strange noises when it cannot find one.

I personally hate that behaviour as much as I like my VIM so here is how you turn it off.  On your ~/.vimrc add the following


let matchparen=1
 
Thats all there is to it.  No more jumping greedy cursors looking for matching braces ;)

Friday, 6 September 2013

Linux Mint Maya Trackpad trouble

I just got a new thinkpad T430 that has a synaptics trackpad.   Strangely the trackpad would not work correctly once the laptop goes to sleep and wakes up. The little red knob IBM thingy would work fine but the trackpad and the associated buttons were not working fine.    Found a nice workaround for it that I thought I will share.

The idea was to disable and enable the psmouse driver so that it would reset itself.  Here is the script to do the same.  It should be placed in /etc/pm/sleep.d and marked as executable


vivekv@Vivek-Laptop /etc/pm/sleep.d $ cat 71input-reset 
#!/bin/sh
#
# Reload the AT keyboard interface.

case "$1" in
        hibernate|suspend)
                rmmod psmouse
                ;;
        thaw|resume)
                modprobe psmouse
                ;;
        *)
                ;;
esac


Here is my virtual pointer information.


⎡ Virtual core pointer                        id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                  id=4    [slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad                  id=11    [slave  pointer  (2)]
⎜   ↳ TPPS/2 IBM TrackPoint                       id=13    [slave  pointer  (2)]
⎣ Virtual core keyboard                       id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard                 id=5    [slave  keyboard (3)]
    ↳ Power Button                                id=6    [slave  keyboard (3)]
    ↳ Video Bus                                   id=7    [slave  keyboard (3)]
    ↳ Sleep Button                                id=8    [slave  keyboard (3)]
    ↳ Integrated Camera                           id=9    [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard                id=10    [slave  keyboard (3)]
    ↳ ThinkPad Extra Buttons                      id=12    [slave  keyboard (3)]

Linux mint maya outdated ISOs

I just installed Linux mint maya xfce on my new IBM thinkpad T430.  I downloaded the latest ISO from linuxmint.com burned it to a DVD and went through the installation.  The DVD was about 795 MB in size and the installation went fairly smoothly.

Once the installation completed I did the obvious

apt-get update
apt-get upgrade

Boom this hits me now

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages have been kept back:
ginn hplip hplip-data libgnome2-0 libgrip0 libhpmud0 libsane-hpaio linux-generic linux-headers-generic linux-image-generic printer-driver-hpcups printer-driver-hpijs vlc vlc-nox vlc-plugin-notify vlc-plugin-pulse
The following packages will be upgraded:
accountsservice acpi-support activity-log-manager-common alsa-base alsa-utils apt apt-transport-https apt-utils aptdaemon aptdaemon-data aptitude



snipped out a lot of stuff...


585 upgraded, 0 newly installed, 0 to remove and 16 not upgraded.
Need to get 495 MB of archives.
After this operation, 25.7 MB of additional disk space will be used.



This is quite a bit of updates to download right after burning and installing from an ISO only an hour ago.  Not sure why the ISO has not been kept up to date.