Enable Hibernation on Ubuntu

One of those note-to-self posts!

Why does Ubuntu come with Hibernation disabled by default?

Ubuntu had to resort to such measures as users experienced a lot of issues like:

  • No resume after suspending the PC — in a limbo
  • Open files and folders gone — Shutdown instead of hibernation
  • Wifi etc devices not working after waking up — the worst nightmare

And that happened because there wasn’t enough Hardware support. Even in Ubuntu derivatives like Linux Mint it came disabled.

What is hibernation?

Seriously? Forget it. I am not even going to look at you.

Alright Alright suit yourself: https://help.ubuntu.com/community/PowerManagement/Hibernate

Advantages of Hibernation:

  • You have an edge over “suspending”. It saves power.
  • The exact state of the computer is resumed.
  • Major use case for the people who leave their  PCs unattended (think: http://Torrentz.in)

How to enable it in Ubuntu:

Step#1 Check if hibernate works on your hardware.

  • Open Terminal (CTRL + ALT + T)
  • Save your work first and then type
 $ sudo pm-hibernate 
  • If everything goes smoothly, start your laptop and continue iff things look good.
  • If you see anything unexpected then please make sure that the size of SWAP is at least as large as the RAM or just 

Step#2 You can continue to use that command safely or make it permanent by enabling it on the menu (do it only if Step#1 above works)

Open terminal and type:

 $ sudo gedit /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla 

Enter the password

(instead of `gedit` you can use `vi` its awesome)

hit “i”; paste; hit “ESC”; hit “:”; hit “x”

Step#3 Paste the following lines in the blank file you created just now.

[Re-enable hibernate by default]

Hit Save and Quit.

Step#4 Reboot for the changes to take effect.

If upon restart you still cannot see the “Hibernate” item in the menu, then you need to Tweak the Grub but mostly it would not come to that.

And we’re back …

Also check http://nikunjlahoti.com/2012/04/29/ubuntu-12-04-fix-fn-brightness-keys/




Get your own website & WordPress++

Well… You can Blog!! (And the crowd cheers)

Frankly.. to cover everything would very exhausting. Lets just focus on the fancy stuff eh?!! (When I say fancy I just mean things that won’t make the ninja angry. You can totally keep living your life like you do)

So all you need is a credit-card and with absolutely no ado you can choose a custom domain and link your blog to it. You just have to THINK (of a name for your custom domain) and PAY ($18 per year; less than 1000INR). And WordPress takes care of everything.

Eg: https://nikunjlahoti.wordpress.com becomes http://nikunjlahoti.com

All your existing links etc get redirected to the new address. There are a lot of  TLDs like .ME, .COM etc that you can use.

For the rest of this post I am safely assuming that you have already bought the domain using WordPress. (Yes! There are ways to buy the domain yourself [think: http://godaddy.com] and then pay WordPress money to link it. Eventually you don’t get to save much. I would say as Tumblr.com does that for free so check that out today!)

Lets say your wordpress blog was: http://domain.wordpress.com

You got a brandnew custom domain name: http://mydomain.com

#2 (No! I wasn’t kidding before)

Get a http://blog.mydomain.com kind of URL for your Blog

I recently (5 minutes back) linked my Tumblr account [http://nikunjlahoti.tumblr.com] to my WordPress domain [http://nikunjlahoti.com]. Yeah that’s the place where I rant about topics not really related to technology or IT in general.

So as soon as you click on that Tumblr link above, it magically changes to [http://blog.nikunjlahoti.com]

I know it doesn’t make much sense to nest the blogs. But its a valid use-case.


Login to your Tumblr blog


Choose a CNAME (in this case “blog“)

CNAME record or Canonical Name record is a type of resource record in the Domain Name System (DNS) that specifies that the domain name is an alias of another, canonical domain name. This helps when running multiple services (like an FTP server and a webserver; each running on different ports) from a single IP address. Each service can then have its own entry in DNS (likeftp.example.com and www.example.com).



Go to: https://domain.wordpress.com/wp-admin/paid-upgrades.php?page=domains

Hit: “Edit DNS”

Add an entry: CNAME blog domains.tumblr.com



Get a http://mail.mydomain.com kind of URL for your Email


I mean how chic is that right?


Its powered by Gmail. Called Google Apps for business! You get an inbox of 10Gb. And there is Calendar, Docs and Sites.

In a free package you can create upto 10 email ids like that on your domain.

Btw, if you want an iamafan@nikunjlahoti.com email id then please let me know. I will be happy (wink) to do that. First lucky 5 people!! Ha!

How to:

Step1: Go to http://google.com/apps and Sign up Free Trial. Use a domain name I have already purchased (mydomain.com)

Step2: Verify site ownership. Use Add a <meta> tag to your home page

Go to: https://domain.wordpress.com/wp-admin/tools.php and paste that code. Save!

Come back and verify again. It will work!

Step3: Route the emails using Google servers


“Edit DNS”

put in the following entries (as told by Google)

CNAME mail ghs.googlehosted.com.

(refer to the first image)

It can take upto 48 hours for this to work but generally just takes less than 1 hour.

And we are done!

and as we wrap up, let me throw in a Productivity tip:

[sourcecode language=”css”]
your code here


your code here

Honorary mention to Java:

class MyClass {
 public static void main(String arr[]) {
 System.out.println("Wordpress Code Highlights");


Also, please notice the Doomsday Clock to the left!

Funny right? It would have been so much fun to see the countdown running. I guess it will eventually come!

Talking of which, I have written stuff on my Tumblr log — my non technical blog 😀 (almost non technical). Feel free to check it out.

Happy Hacking!

Save HTML webpage to a PDF Document


You get to access it offline. Its more readable. You can annotate, leave comments, etc from a PDF Client (Adobe Acrobat Reader anyone?). You can even track your progress inside the document. If your client is really friendly it can even reopen the document from where you left it.

Well for me its merely a matter of convenience. I always prefer a PDF manual instead of an HTML/CHM one for some reason (think: http://docs.python.org/download.html); Does it really matter if PDF is three times the size of the HTML archive? Storage isn’t really a pushing concern these days. Is it?


Multiple HTML pages to a Single PDF.

There are a lot of websites which offer to convert an HTML document to PDF on the fly. Doesn’t serve the purpose and I not very big on registering everywhere!

For our little experiment lets pick a URL. I suggest http://www.catb.org/~esr/writings/homesteading/cathedral-bazaar/index.html.

(for further reading go to https://en.wikipedia.org/wiki/The_Cathedral_and_the_Bazaar by Eric S. Raymond).

#1 Download web pages recursively using wget

# create a directory under home; Think: less clutter
$ mkdir ~/our_little_experiment; cd ~/our_little_experiment;

# download the webpage and recursively download all those webpages which are linked from this page in the current directory.
$ wget -v -r http://www.catb.org/~esr/writings/homesteading/cathedral-bazaar/index.html

FINISHED –2012-10-07 20:15:47–
Total wall clock time: 2m 51s
Downloaded: 16 files, 164K in 1.9s (88.7 KB/s)

A little later …

# lets look at the files generated by wget (an awesome tool btw!)
$ cd ~/our_little_experiment/www.catb.org/~esr/writings/homesteading/cathedral-bazaar

$ ls -1

# index.html is actually chapter 1 so renaming it to ar01s01.html
$ mv index.html ar01s01.html

#2 install htmldoc

$ sudo apt-get install htmldoc

#3 create the PDF document

$ htmldoc --webpage -t pdf14 -v -f catb_cathedral_bazaar.pdf *.html

Output: catb_cathedral_bazaar.pdf


All the links work perfectly.

I’d be happy to guide anyone doing it on w32.

Please don’t use “win” as an abbreviation for Microsoft Windows in GNU software or
documentation. In hacker terminology, calling something a “win” is a form of praise. If you
wish to praise Microsoft Windows when speaking on your own, by all means do so, but not
in GNU software. Usually we write the name “Windows” in full, but when brevity is very
important (as in file names and sometimes symbol names), we abbreviate it to “w”. For
instance, the files and functions in Emacs that deal with Windows start with ‘w32’.

— GNU Standards



Happy Hacking!