May 18, 2012

Yahoo! Mail Signatures With Pictures

Introduction

Do you use Yahoo! Mail?  Do you want to create a signature for you emails which includes images?  I wanted to create a signature with an image to go and view my LinkedIn account, but every time I tried to create the signature the image would never appear.  I finally figured out the trick.  Read on.

How To

To include an image in your Yahoo! Mail signature is actually very easy, however you need to do it in the right way otherwise it will not work.  This is what you need to do.
  1. Go to your Yahoo! Mail options and select Signature.
  2. Select "Show a rich text signature" from the dropdown box.
  3. Go to the website which has your image, right click the image on the website, and select "copy image". This is the trick!  You cannot simply copy an image from your desktop.  You must Go to the website which has your image, right click the image on the website, and select "copy image".  If the image you want is not on any website, see below for what to do about that...
  4. Go back to the Signature, put the cursor where you want to have the image, right-click and paste.
That's it.  Again, the trick is you must Go to the website which has your image, right click the image on the website, and select "copy image".  You cannot simply copy an image from your desktop!

Now when you send an email, your signature with the image will be included.  Some email clients will initially block the image, but right-clicking on the email and selecting something like "show images" will reveal it.

Image Not On A Website?

If the image you want on your Yahoo! Mail signature is not on a website, then you need to get it on one. How do you do this?  Easiest thing to do is to use Flickr. Create an account, and upload your image.  After the image is uploaded, click on the image in your photostream to view it.  Above the image select "Actions" then "View all sizes".  On the All Sizes page, click whatever sized image you want to have on your signature (typically will be a small image!), then right click the image and select "copy image".  Then go back to the Signature, put the cursor where you want to have the image, right-click and paste.

Do you have to use Flickr?  No, any photo sharing site should allow you to do the same thing.  You will have to try it out.

That's it, Enjoy!

February 15, 2012

Create Your Own Java URL Handlers

Introduction
Custom URL handlers are becoming more popular as desktop applications are interacting with Internet or Cloud sources.  For example, to subscribe to a iTunes podcast, a website will have a link which looks something like this:

itpc://www.company.com/public/get/podcast.rss

Where "itpc" is a custom protocol handler created by iTunes to handle URLs of this type.  The purpose of this article is to demonstrate how to create your own URL handler in Java.

Problem
Suppose there is need to create the "JTLC" protocol? If I were to create a URL object with this protocol...

public static void main(String[] args) throws Exception
{
  String urlStr 
    = "jtlc://www.mycompany.com/some/path/to/resource";
  URL url = new URL(urlStr);
}

I will get a nasty stack trace from Java...

Exception in thread "main" java.net.MalformedURLException: 
unknown protocol: jtlc
    at java.net.URL.<init>(URL.java:574)
    at java.net.URL.<init>(URL.java:464)
    at java.net.URL.<init>(URL.java:413)
    at jtlc.main.Main.main(Main.java:14)

This is because Java comes with a set of built in handlers to handle well known protocols like HTTP, but your JTLC protocol is unknown to Java so you get a stack trace.  However, before Java throws the stack trace, it attempts to locate a handler for the JTLC protocol.  If you provide the handler, Java will use it to handle JTLC.

Solution

Package

First (and easiest) thing to do is to create the following package in you application to hold the code for your JTLC protocol handler:

sun.net.www.protocol.jtlc

Java will automatically look in the root sun.net.www.protocol package for protocol handlers.  Furthermore, by adding the additional sub-package jtlc (making the full package name you should use sun.net.www.protocol.jtlc), you are telling Java the code in this package handles the JTLC protocol.  When you try to create a new URL object with the "jtlc" protocol, Java will look in the root sun.net.www.protocol package for a sub-package named jtlc to find the code to handle this protocol.

If you do not use this package, then you will have to set special system properties to tell Java what package holds the handlers for you JTLC protocol. 

URLConnection

Second, you need to create a class which extends java.net.URLConnection.

The name of this class can be whatever you want, but it is good convention to name it after the letters in the protocol.  The class for the JTLC protocol may look something like this:

package sun.net.www.protocol.jtlc;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

public class JtlcConnection extends URLConnection
{
    public JtlcConnection(URL u) {
        super(u);
    }

    @Override
    public void connect() 
    throws IOException {
      throw new UnsupportedOperationException(
        "The connect() method is not supported"
      );
    }
   
    @Override
    public Object getContent() 
    throws IOException {
      throw new UnsupportedOperationException(
        "The getContent() method is not supported"
      );
    }

    @Override
    public InputStream getInputStream() 
    throws IOException {
      throw new UnsupportedOperationException(
        "The getInputStream() method is not supported"
      );
    }
}

Of course you will want to provide a real implementations for these methods to handle connecting to your resource and getting a stream to the content.

URLStreamHandler

Finally, you will need to create a class with extends java.net.URLStreamHandler.

THE NAME OF THIS CLASS MUST BE "Handler".  Java will automatically look for a class named Handler inside the sun.net.www.protocol.jtlc package.  If you name this class something other than Handler, Java will not find it.

The purpose of Handler is to create an instance of URLConnection subclass.  An example may look like this:

package sun.net.www.protocol.jtlc;

import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;

public class Handler extends URLStreamHandler
{
    @Override
    protected URLConnection openConnection(URL u)
    throws IOException
    {
        return new JtlcConnection(u);
    }
}


Summary
Although there are more than one way to create your own Java protocol handlers, this is the quickest and easiest way I've found.

That's it.  Enjoy!

NetBeans and Public-Private SSH Key Access to CVS

Introduction
The purpose of this article is to document how to configure NetBeans to access a CVS repository over SSH using public-private keypairs.

Install "Putty" Applications
Putty is located at http://www.chiark.greenend.org.uk/~sgtatham/putty/.  The primary applications need are pageant.exe and plink.exe.

Run Pageant
Startup pageant.exe. It will be accessible via the system tray.





Right click on the pageant icon in the system tray to add the private key you use to access the CVS server.  Keep in mind that putty and all the putty related applications do not work with keys generated by the linux `ssh-keygen` command.  The private key generated by `ssh-keygen` needs to be opened with the puttygen.exe application and converted into a putty specific private key which can then be used in pageant.exe.

Configure NetBeans
Startup NetBeans.  Go to Team > Checkout.  For the CVS repository configuration, select the radio button to "Use External Shell".  In the "Shell Command" textbox, enter the fully qualified path to plink.exe. Click the "Next >" button and the CVS repository will be access via SSH using your public-private keypair.





























That's it.  Enjoy!