How to Never Lose Your Email Again [SSL Added]

Posted by Prolific Programmer Fri, 09 Jan 2009 08:49:00 GMT

As earlier today, I have added SSL support to EmailS3. It has also been tested with gmail and my S3 information and it works like a charm. Leave a comment here if you have any problems whatever and I'll be happy to work with you to fix them.

How to Never Lose Your Email Again

Posted by Prolific Programmer Thu, 08 Jan 2009 22:51:00 GMT

A little while ago, I outlined how to achieve limitless gmail using Amazon's S3 service. Well, over a year later, I finally have code ready, prompted by Doc Searls' report of data corruption with his email. You'll need javamail, JetS3t, and their associated dependencies, in order to run the class below. Tomorrow, I'll probably add SSL support, as most email providers are moving in that direction today.

import java.io.ByteArrayOutputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.Session;
import org.jets3t.service.S3Bucket;
import org.jets3t.service.S3Service;
import org.jets3t.service.security.AWSCredentials;

public class EmailS3 {
    Folder folder;
    String user,hostname;
    String AWSACCESSKEYPROPERTY = "com.amazon.aws.ACCESS_KEY";
    String AWSSECRETKEYPROPERTY = "com.amazon.aws.SECRET_KEY";
    public EmailS3 (String username, String password, String hostname) {
	this.user = username;
	this.hostname = hostname;
	Session session = Session.getDefaultInstance(System.getProperties(),null);
	// assume pop3 as imap is probably already backed up
	store = session.getStore("pop3"); 
	folder = store.getDefaultFolder();
    }

    private ArrayList messages() {
	ArrayList ret  = new ArrayList();
	folder.getFolder("INBOX");
	folder.open(Folder.READ_ONLY);
	Message[] content = folder.getMessages();
	for (int i = 0; i != content.length;i++) {
	    ret.add(content[i]);
	}
	return ret;
    }

    public void toS3() throws Exception {
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	ObjectOutputStream oos = new ObjectOutputStream(baos);
	oos.writeObject(messages);
        String bucketContents = baos.toString();
	AWSCredentials creds = new AWSCredentials(System.getProperty(AWSACCESSKEYPROPERTY), System.getPropety(AWSSECRETKEYPROPERTY));
	S3Service service = new S3Service(creds);
	byte[] bucketBytes = bucketContents.getBytes();
	int i  = 0;
	while (bucketContents.length() > (5 * 1024 * 1024)) {
	    S3Bucket bucket = new S3Bucket(this.user+'@'+this.hostname+new Integer(i).toString());
	    bucketContents = bucketContents.substring(i*(5*1024*1024), (i+1)*(5*1024*1024));
	    i++;
	    bucket.putObject(bucketContents);
	}
	S3Bucket bucket = new S3Bucket(this.user+'@'+this.hostname);
	bucket.putObject(bucketContents);
    }
    public static void main (String[] args) {
       EmailS3 e = new EmailS3(args[0], args[1], args[2]);
       try {
           e.toS3(); 
       } catch (Exception e1) {
           System.err.println(e1.getMessage());
       }
    }
}

Ride Like The Wind

Posted by Prolific Programmer Thu, 08 Jan 2009 19:44:00 GMT

Another Opposition MP Arrested Under Anti-terror Legislation

Posted by Prolific Programmer Thu, 08 Jan 2009 18:53:00 GMT

Thomas Hawk writes about Croydon Central MP, the Rt. Hon. Anthony Peeling being arrested for photographing a bicycle path. While I'm no fan of the Tories, this runs counter to the spirit of the anti-terror legislation in Britain, it should not be used by Number ten to arrest shadow immigration ministers for wanting to release information embarrassing to it, nor should it be used to arrest opposition MPs for taking photos of neglected bike paths, also slightly embarrassing to a third-term Labour government keen to shore up its base ahead of next year's general election.

An Israeli Patriot

Posted by Prolific Programmer Thu, 08 Jan 2009 18:26:00 GMT

This former IDF captain ought to be beyond reproach, but as the BBC presenter notes, he is being slighted by the right wing for being anti-Semitic. Never mind that the right has not once looked up semite in the dictionary or anything like that. Dog forbid, they read anything other than the Bible. Patriotism is not, my country, right or wrong. There are a set of principles, codified in the Universal Declaration of Human Rights which may not be compromised. Holding these principles uniformly and calling for their enforcement universally is the definition of a patriot.

Top 5 Time Management Tips from Penelope

Posted by Prolific Programmer Thu, 08 Jan 2009 18:08:00 GMT

That Brazen Careerist is at it again. Penelope Trunk makes no secret on how she hates Tim Ferris, author of The Four Hour Workweek. However, in a magnanimous gesture, Trunk does admit to learning time management tips through interacting with him. Some of us would do well to learn some time management skills as it does reduce stress and emotional psychosis (meant to attract one person, and she damn well knows who she is).

Router Saga Over

Posted by Prolific Programmer Thu, 08 Jan 2009 07:32:00 GMT

I've been having loads of trouble with my Internet connection recently. It seems things are sorted now. FCKeditor had to be disabled to get the blog to work and I had to put DD-WRT on my router and configure it.

Solutions Needed

Posted by Prolific Programmer Mon, 05 Jan 2009 02:57:00 GMT

Mish claims that everyone is jumping on the Keynesian bandwagon. Want to know why this is, Mish? It's because there is no credible solution from the other side. That's right, I have yet to see anything remotely resembling a solution to the crisis from anyone aside from Keynesian economists. Sure, there are Libretarians like Ron Paul, but their views represent the extreme of the present condition.

If the definition of insanity is repeating the same thing, while expecting different results, then prescribing less regulation is falling off the deep end.

Dress you up in Adsense

Posted by Prolific Programmer Mon, 05 Jan 2009 00:45:00 GMT

Sang to the tune of Madonna's Dress you up.

You got clicks, that's what all our logs say
Satin sheets and stock options so fine
Your router is custom-made by Cisco
But I got something that you'd really like

Gonna dress you up in adsense
All over, all over
Gonna dress you up in adsense
All over your site

Feel the silky touch of our textads
They will keep your SEO fresh
Let me cover you in adsense
I'll create one that's made for you

Gonna dress you up in adsense
All over your site
From your frontpage to your sitemap

Interesting Parallel for Israel-Palestine

Posted by Prolific Programmer Sat, 03 Jan 2009 22:55:00 GMT

Dr Cole, perhaps unintentionally, brings up an interesting parallel in his peace entitled Isrel Invades Gaza:

what "we" would do if militant European refugees landed at Newport Beach, took over Virginia, expelled its population, and then kept the refugees from McLean huddling over in West Virginia in camps for decades with no reparations, recently denying them sufficient food and fuel to avoid a humanitarian crisis. But of course that would never happen to the Granges, so why bother to even mention any point of view but the hawks'?
Except that this did happen. European refugees did land in this country 400-odd years ago. They created the United States of America and, in doing so, massacred or forced the native population onto reservations. I'm very glad Dr. Cole brought this up, even if unintentionally.