Here the how-to explaining how to interact with GoogleCalendar using iCal and the CalDAV support provided by Google.

Notes from a programmer's life.

class ImageComponent extends JPanel
{
public ImageComponent() {}
public ImageComponent (byte[] image)
{
ByteArrayInputStream bis = new ByteArrayInputStream (image);
try {
_image = ImageIO.read (bis);
}
catch (IOException ex){}
}
//This method replaces the image displayed by the component
//with a new one passed in the image byte array.
public void updateImage (byte[] image)
{
ByteArrayInputStream bis = new ByteArrayInputStream (image);
try {
_image = ImageIO.read (bis);
}
catch (IOException ex){}
repaint();
}
public void paint(Graphics g)
{
g.drawImage(_image, 0, 0, null);
}
public Dimension getPreferredSize()
{
if (_image == null) {
return new Dimension (320, 240);
} else {
return new Dimension (_image.getWidth (null), _image.getHeight (null));
}
}
BufferedImage _image;
}
//NetworkCamera class
import java.io.IOException;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
public class NetworkCamera
{
public NetworkCamera (String url)
{
log ("Registered network camera. Image url = " + url);
_method = new GetMethod(url);
//Create the HTTP client and set the parameters
_client = new HttpClient();
_client.getParams().setParameter ("http.useragent", "CustomizedJavaClient");
_client.getParams().setParameter ("http.connection.timeout", new Integer(5000));
_method.setFollowRedirects (true);
}
public byte[] getImage ()
{
log ("Getting image...");
byte[] image = null;
try {
int retCode = _client.executeMethod (_method);
if ( retCode != -1){
log ("getMethod succeed [HTTP-RESPONSE-CODE" + retCode + "]. Content lenght = " + _method.getResponseContentLength());
//The HTTP response body contain the bytes of the image
image = _method.getResponseBody();
System.out.println ("Bytes read: " + image.length);
}
}
catch (IOException ex) {
//Report error
System.out.println (ex.getMessage ());
}
return image;
}
private void log (String message)
{
if (DEBUG) {
System.out.println (message);
}
}
private GetMethod _method;
private HttpClient _client;
private static final boolean DEBUG = true;
}
//Main class (for test purpose)
import java.io.FileOutputStream;
public class Main
{
public static void main (String[] args) throws Exception
{
Camera cam = new NetworkCamera (CAMERA_IMAGE_URL);
byte[] image = cam.getImage();
FileOutputStream fos = new FileOutputStream (IMAGE_FILE_NAME);
fos.write(image);
fos.close();
}
private static final String CAMERA_IMAGE_URL = "http://xxx.yyy.www.zzz/cgi-bin/video.jpg?size=3";
private static final String IMAGE_FILE_NAME = "test.jpg";
}
private static final String CAMERA_IMAGE_URL = "http://www.google.com/intl/en_ALL/images/logo.gif"
public byte[] toByteArray (Object obj)
{
byte[] bytes = null;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(obj);
oos.flush();
oos.close();
bos.close();
bytes = bos.toByteArray ();
}
catch (IOException ex) {
//TODO: Handle the exception
}
return bytes;
}
public Object toObject (byte[] bytes)
{
Object obj = null;
try {
ByteArrayInputStream bis = new ByteArrayInputStream (bytes);
ObjectInputStream ois = new ObjectInputStream (bis);
obj = ois.readObject();
}
catch (IOException ex) {
//TODO: Handle the exception
}
catch (ClassNotFoundException ex) {
//TODO: Handle the exception
}
return obj;
}

#navbar-iframeThe !important keyword prevent the property from being overwritten from the rules inserted by the blogger engine.
{
display: none !important;
}
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.DatagramPacket;
public class SimpleUDPSSocket extends Thread
{
public SimpleUDPSSocket() throws Exception
{
_dSocket = new DatagramSocket(PORT);
_running = false;
}
public void run()
{
byte buf[] = new byte[MAX_SIZE];
DatagramPacket packet = new DatagramPacket (buf, buf.length);
String data;
_running = true;
while (_running) {
try {
_dSocket.receive (packet);
}
catch (Exception ex) {
_running = false;
break;
}
data = new String(packet.getData(), 0, packet.getLength());
System.out.println (data);
}
}
private DatagramSocket _dSocket;
private boolean _running;
private static final int PORT = 4444;
private static final int MAX_SIZE = 64;
}
#!/bin/bash
# Author: Massimiliano Marcon
# Description: this script resets the Microsoft Office 2008 for Mac licence number.
DEFAULT_OFFICE_PID_LOCATION="/Applications/Microsoft\ Office\ 2008/Office/OfficePID.plist"
DEFAULT_OFFICE_SETTING_LOCATION="~/Library/Preferences/Microsoft/Office\ 2008/"
function reset () {
mkdir /tmp/backup-office-licence
mv $DEFAULT_OFFICE_PID_LOCATION /tmp/backup-office-licence
mv $DEFAULT_OFFICE_SETTING_LOCATION/Microsoft\ Office\ 2008\ Settings.plist /tmp/backup-office-licence
mv $DEFAULT_OFFICE_SETTING_LOCATION/Office\ Registration\ Cache\ 2008 /tmp/backup-office-licence
echo "Done. Restart Microsoft Office and insert the new serial number."
}
function question () {
echo -n "Would you like to reset your Microsoft Office Licence Key now? (yes/no) "
read RESPONSE
case "$RESPONSE" in
yes)
#Reset process
reset
#End reset process
;;
no)
echo "Nothing to do, exiting."
;;
*)
echo "Please type \"yes\" or \"no\""
question
;;
esac
}
echo "[Resetting your Microsoft Office Licence Key...]"
echo "*** All the files will be moved in /tmp ***"
question
exit 0