Sunday, March 9, 2008

How do i convert my email account(with a lot of storage space :-P ) as a filesystem like the GMail Drive?

Well,many people thought about doing this from the very day they saw the below line at the gmail homepage
"Lots of space Over 2757.272164 megabytes (and counting) of free storage so you'll never need to delete another message."
Now that the gmail storage has multiplied( 6501.217310 ...),the interest of people has also grown towards the concept.Many competitors also started providing huge email storage. One significant point to note is that you can convert any email account into a file system.Think about it for a while...Think about SMTP,MIME,IMAP & POP3 ..if you are familiar with those,you got the answer!!!.

Wait,think about what happens when you send an email to your self with a file as an attachment.
of course i agree that there will be an attachment size limitation.Suppose if a software automatically splits your file and sends multiple mails to your own account and retrieves them in a nice fashion and displays it to you in an explorer like window or like a FS mounted to your *nix box ???gotcha..cool idea!!!

It all started when Richard Jones thought about a Gmail Filesystem and implemented it in Python.It is a mountable Linux filesystem which uses your Gmail account as its storage medium. it uses the FUSE userland filesystem infrastructure to help provide the filesystem, and libgmail to communicate with Gmail.
A lot of other libraries and applications also came up on similar lines.Let me list out a few of them here.It will definitely benefit you if you are a developer.

libgmail - A Python based API for Gmail Access
gmail.py - A Python API for Gmail Access.
libgmailer - A Php-based API for the Gmail Access. Requires the php CURL extension.
Gmail API - A .Net Library for Gmail Access
jGmail API - A Java based Library for Gmail Access

The discussion wont be complete with out mentioning GMail Drive Shell Extension by bjarke.
It creates a virtual filesystem on top of your Google Gmail account and enables you to save and retrieve files stored on your Gmail account directly from inside Windows Explorer. GMail Drive literally adds a new drive to your computer under the My Computer folder, where you can create new folders, copy and drag'n'drop files to it.
If you are a windows C++ developer,he has some C++ source code and code snippets for various programming libraries for you.Have a look at http://www.viksoe.dk/
It is also nice to have a look at the gVault,a java implementation of a Gmail based cryptographic network file system.It was designed by a few guys from University of California, Irviney, Brigham Young Universityz, University of Bologna, Italy.They have also provided a nice pdf explaining their design & implemenation http://www.ics.uci.edu/~rjammala/gVault.pdf
Even i have come up with a generalized design & implementation of a mail file system utilizing any email account that supports IMAP & SMTP.It is basically is a windows shell name space extension allowing the users to have a virtual drive. It appears as a local hard disk drive & enables the user to use the standard Windows desktop file copy and paste commands to transfer files.When the user creates a new file inside the Virtual Drive(when he does a copy & paste), it generates an e-mail and sends it to the users inbox. The e-mail appears in the normal Inbox folder when using the normal webmail interface, and the file is attached as an e-mail attachment. The subject line will be having a special keyword "[MAILDRIVE]" for optimizing search. It periodically checks the mail account to see if new files have arrived and to rebuild the virtual drive's directory structures.It also provides access to the virtual drive from multiple systems simultaneously providing functionalities of a fileserver.The meta data about each file is also maintained inside the email.

Friday, March 7, 2008

how do i combine multiple pdf files into one?

Well,for combining multiple pdf files into one,as usual there are two approaches that i can suggest
1.The easy way in which you don't have to worry about too much of internal details
There is a nice little utility called pdftk (the pdf toolkit) which allows you to manipulate pdf files in a variety of ways(like merging files,repairing corrupted pdfs,update pdf meta data etc).
You can download the utility from the url http://www.pdfhacks.com/pdftk/#packages
download is available for windows also.For ubuntu,you can also use apt to get it installed
from your terminal,type sudo apt-get install gs pdftk.Once it is installed you can issue the command as shown in the below example
jobinwl@jobinwl-laptop:/media/sda1/videooutput/pscan$ pdftk 1.pdf 2.pdf 3.pdf 4. pdf 5.pdf 6.pdf 7.pdf 8.pdf 9.pdf 10.pdf 11.pdf 12.pdf 13.pdf 14.pdf 15.pdf 16.p df 17.pdf 18.pdf 19.pdf 20.pdf 21.pdf cat output /home/jobinwl/Desktop/full.pdf
it will combine all the pdfs into one single file called full.pdf

2.The programmatic way in which you have a full control over the process
Let us see how to make a little utility program to get this done.Since pdf files are involved,we will be using the iText java library(assuming we are making it in java,there is also a .Net implementation of the same called iTextSharp). i am sure you must have heard about iText...it is an awesome java library that helps you to do a lot of pdf related operations like dynamic pdf creation or manipulation
source code is available here :http://docs.google.com/Doc?id=dr47ftb_2gsmgm5zs

Thursday, March 6, 2008

How do i reduce the size of my executable?

One of my firends asked this question to me over email.I thought it would be great to answer it here so that it will help many others with similar queries.
The size of an executable depends on a lot of factors like the compiler,linker & libraries that you use,the operating system on which these tools run,the format of the binary(say exe,dll or PE (Portable Executable) in general for windows,ELF for *nix etc).Most compilers provide you "compiler switches" which helps you to specify a lot of settings like even howmuch debugging info you want to keep in the final executable. The structure of PE & ELF binaries are described here Now let us deal with some scenareos
1.Imagine you want an "easy solution" to compress the executable with out worrying much about the internal structure of an executable. Great,have a look UPX (Ultimate Packer for eXecutables).A great opensource tool avilable at http://upx.sourceforge.net/ .It helps to compress many executable formats.(works with windows,linux etc).Just download the utility & run it along with your executable name and approptiate switches.I will give you an example below. Assume you have a 32 bit exe called myprog.exe on a windows machine & you have UPX,run it as shown below C:\Jobin\Personal\setups\upx302w\upx302w>upx- 9 -o Compressed.exe myprog.exe
Ultimate Packer for eXecutables
Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007
UPX 3.02w Markus Oberhumer, Laszlo Molnar & John Reiser Dec 16th 2007
File size Ratio Format Name
-------------------- ------ ----------- -----------
2720039 -> 2565927 94.33% win32/pe Compressed.exe
Packed 1 file.

2. Imagine your compiler is VC++ 6.0, and you want to use appropriate compiler switches and libraries to get your executable size less.
Well, this is the programmers way...great to know you are interested in reading this.If you remember those good old days when you worked on Turbo C/C++, you had something called as memory models(Tiny,Small,Medium etc).Also think about those 64K segments(CS,DS etc)...those near, far & huge pointers??? Remembering them?If you remember them, then you know how to play around with the compiler switches & memory models. otherwise let me take you to a crisp document which explains it step by step. Just have a look at http://www.hailstorm.net/papers/smallwin32.htm#smallapps

3.I want to still reduce the size of my executable verymuch,can you tell me any other way?
Well,As i mentioned earlier,your executable size is dependent on your compiler,linker,libraries etc.so to have the least size,you need to stay more closer to the CPU :-P
Imagine you wanted to print out the letter "A" from your program..you write the code as below
#include "stdio.h"
int main(void)
{
printf("A");
return 0;
}
Compile it & look at its size..huge??? that is exactly what I was telling you
insted,go to your command prompt and do as shown below
H:\>debug-a 100
138C:0100 mov ah,02
138C:0102 mov dl,41
138C:0104 int 21
138C:0106 int 20
138C:0108
-g
A
Program terminated normally
-r cx
CX 0000:08
-n out.com
-w
Writing 00008 bytes
-q
H:\>dir *.com
Volume in drive H is users Volume Serial Number is 0002-6F60
Directory of H:\
03/07/2008 12:32 PM 8 OUT.COM
1 File(s) 8 bytes 0 Dir(s) 881,819,648 bytes free
H:\>out
A
H:\>
Got it? Just in 8 bytes you printed out "A"...gr8!!! so if you want smaller sized exe,write your code in Assembly. I am sure it can be a debatable suggestion .You may ask me who the hell writes code in asm today??? all I have to say is that any someone might ,depending on their needs. If you decided to try your hands on assembly, you may find NASM handy and open source .Have more queries???shoot a mail to me or post a comment,i will be happy to help you out..have a good day!!!

Inaugural post...walking backwards in space-time

Destiny, If such a thing exists, takes us to where ever we are destined to be!!!

In this little space down here, I am going to write on what ever that i am interested in, aspiring for and working on. I love to colaborate and share thoughts and ideas to the very community which inspired me and motivated me to work on making these digital creatures do amazing things...I am dedicating this blog to all those great minds ,who had spent their entire life for transforming computing into what it is today .I still remember those days when I sat in front of a green monitor with a blinking A:\> after to booting DOS from a 5.25" floppy & putting another working disk to do some GW BASIC programs. Kudos to all of you and your great efforts because of which I have ubuntu running on my PC and i am able to publish this post now...