Monday, November 28, 2011

How to eject an usb storage device like kindle from command line

If you are working with a kindle, trying to convert some books into kindle format, it's frequent to plug and unplug the device to check if the file is rendered correctly.
Doing this with the graphical interface is of course annoying.
Luckily you can easily use the command line (and maybe automate the conversion and copy with a command line application).
First of all you have to find the name of your device using
sudo fdisk -l
You will see an output like this one
Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c83e7
Device Boot      Start         End      Blocks   Id  System
/dev/sda2               1       29179   234374145    5  Extended 
...
Partition table entries are not in disk order
Disk /dev/sdb: 3282 MB, 3282272256 bytes
4 heads, 16 sectors/track, 100167 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      100167     3205336    b  W95 FAT32
Of course the device is sdb1: now you can eject typing
sudo eject /dev/sdb
 to "uneject" a trick is to use the command
sudo eject -t /dev/sdb
which sends a tray close cdrom command, that actually reconnects the kindle. 

Monday, November 14, 2011

How to bypass the hp smart pin

Some Hp laptops have a strange connector, with 3 poles:
  • pwr
  • gnd
  • smart pin
Of course the smart pin is so smart that without it the computer won't turn on.
If you want to bypass it you can simply add a resistor between voltage and the smart pin.
430k will be good.



NOTE: Without the resistor, connecting the smart pin to pwr directly, the computer will turn on but it will be extremely slow

How to create an ebook from a website

If you want to put a webpage on your kindle the best idea is to convert that page into an ebook.
You can do this simply by saving the page and converting it with Calibre.
What if the document is divided into different pages?
With calibre is very simple:
  • Download all the pages
  • Download also the first page with the links to the chapters
  • edit the first page so that the links are local (remove http://www.site/foo/bar... leave only chapterX.html)
  • Open calibre and import the first page
  • Convert it to mobi or whatever format you like
The book will be complete with all chapters