Posts

    Tuesday, 8 September 2015

    The Infamous battery re-calibration bug in Lenovo Thinkpad

    My brand new Lenovo Thinkpad is a beast and is supposed to give up to 8hrs of battery backup. But there was a weird problem. As soon as the battery remaining reached 30%, it used to drop to 6% in a second. When I looked up on google, I found out that I was not the only one facing this problem. Most of them suggested that my battery was shot and that I had to buy a new one. This is highly improbable as it is brand new. I wanted to give fixing it a try before contacting customer care. And I was successful!

    Before - See the battery percentage drop from 30% to 6%

    For some reason, I suspected that it was somehow TLP's fault. TLP is the best power management utility for Thinkpad in Linux. It allows you to set max charging threshold so that you will be able to connect your laptop to the plug point without worrying about over charging (among many other features it provides). I felt that it is because of this, battery calibration was getting screwed up. So I set the maximum threshold to 100%.

    Open /etc/default/tlp and set following variables.


    START_CHARGE_THRESH_BAT0=100
    STOP_CHARGE_THRESH_BAT0=100


    Then I restarted my laptop to bring this to effect. As the calibration was already offset by a great extent, the only way to fix it was to keep it charged for a long time. I kept it charging for almost a day.


    After - Fixed!
     Then to test it I kept discharging it. And to my surprise, it didn't drop from 30% to 6% this time!!
    So the problem was with calibration and not because the battery is broken. If you face this problem, you can try this solution once before you spend $$$ on buying a new battery.

    Now that I have changed the battery threshold back to 85%, if this problem occurs again, all I have to do is follow the above steps.

    Sunday, 6 September 2015

    Download only part of a repository in github

    Sometimes you would want to download only a part of a repository in Github but you don't want to download / clone the entire repository, specially when the repo is huge or has too many other things that you are not interested in. There are many ways to do this. For example you can do a shallow clone, or you can use Github API (there is a limit on number of requests per hour)..etc. However, none of them are simple and straightforward. 

    I recently found out that Github supports svn to some extent. So I tried the age old svn export to download a part of the project I was interested in. And it worked.

    svn export https://github.com/<username>/<project name>/trunk/<folder path>

    For example:


    If you want to download only docs from Bootstrap repository,

    svn export https://github.com/twbs/bootstrap/trunk/docs

    Now, suppose you want to download it with a different name,

    svn export https://github.com/twbs/bootstrap/trunk/docs bootstrap-docs