13 July 2009

Export your contacts from your Google Apps account automatically as a vcard file

10/10/2009: edited as Google now requires a field called GALX to be posted too.
08/01/2011: edited as Google now requires a field called tok to be posted too.
16/05/2012: this solution nolonger works, looks like google have modified their authentication mechanism.

To export your contacts from your Google Apps account automatically as a vcard file:

google apps domain: acme.com
user: doej
password: mypassword

wget "https://www.google.com/a/acme.com/ServiceLogin" --no-check-certificate --save-cookies="/tmp/gcookie" --keep-session-cookies --output-document=/dev/null

GALX=`grep "GALX" /tmp/gcookie | cut -f 7`

wget "https://www.google.com/a/acme.com/LoginAction2" --post-data="service=contacts&Email=doej&Passwd=mypassword&GALX=${GALX}&PersistentCookie=yes&continue=http://www.google.com/contacts/a/acme.com" --no-check-certificate --load-cookies="/tmp/gcookie" --save-cookies="/tmp/gcookie" --keep-session-cookies --output-document=/dev/null

wget "https://www.google.com/contacts/a/c/acme.com/ui/ContactManager?titleBar=true&hl=en&dc=true#" --no-check-certificate --load-cookies="/tmp/gcookie" --save-cookies="/tmp/gcookie" --keep-session-cookies --output-document=/tmp/gtoken

TOKEN=`grep "var tok" /tmp/gtoken | cut -c 16-72`

wget "http://www.google.com/contacts/a/c/acme.com/data/export?exportType=GROUP&groupToExport=%5EMine&out=VCARD" --no-check-certificate --load-cookies="/tmp/gcookie" --output-document="/tmp/addressbook.vcf"

Note: In the first wget, by continuing to mail.google.com and specifying keep-session-cookies, the cookie file, /tmp/gcookie, will contain entries for the mail.google.com. This is required for the second wget.

12 July 2009

Alex Miller - Hibernate query cache considered harmful?

Using Netcat to test ports

Yesterday I needed to quickly test if two machines could communicate over tcp/ip across a firewall. You can use netcat to quickly open a service that is listening on a port.

To listen on port 8888 on host server1:

server1$ nc -l 8888

On the other end (host server2), connect to server1 with the following:

server2$ nc server1 8888

Anything you type on server1 or server2 is now transferred to the other host and you have successfully tested connectivity.


Reuse: Is the Dream Dead? | Javalobby

Reuse: Is the Dream Dead? | Javalobby An interesting analysis, the conclusion is copied below:
"The challenge we run into when attempting to create a highly reusable component is to manage the tension between reusability and useability. In our example above, breaking out the coarse-grained component into fine-grained components makes it more difficult to use each of the resulting fine-grained components. Likewise, creating a lightweight components makes using the component more difficult since the component must be configured each time the component is used.

Fine-grained components have more component dependencies and lightweight components have more context dependencies. Each makes a component more reusable, but also more difficult to use. The key is to strike a balance, and that is a topic for another day not too far away."

08 July 2009

How Hotspot Decides to Clear SoftReferences

How Hotspot Decides to Clear SoftReferences, interesting quotes too:
...IMHO using Softreferences in an application server is evil, because of this very coarse grained way to configure their behaviour. Note also that the mechanism implies that Softreferences will (in low memory situations) only be reclaimed after more than one full GC.
...This is precisely the problem that my colleagues encountered. They really want an LRU cache for what they are trying to do, and they tried to achieve it cheaply using SoftReferences.

06 July 2009

James Strachan gives Scala the thumbs up

James Strachan's Blog: Scala as the long term replacement for java/javac?
I can honestly say if someone had shown me the Programming Scala book by by Martin Odersky, Lex Spoon & Bill Venners back in 2003 I'd probably have never created Groovy.

Database Shards

Shard (database architecture) - Wikipedia, the free encyclopedia
Horizontal partitioning is a design principle whereby rows of a database table are held separately, rather than splitting by columns (as for normalization). Each partition forms part of a shard, which may in turn be located on a separate database server or physical location. The advantage is the number of rows in each table is reduced (this reduces index size, thus improves search performance). If the sharding is based on some real-world aspect of the data (e.g. European customers vs. American customers) then it may be possible to infer the appropriate shard membership easily and automatically, and query only the relevant shard. [1]

Sharding is in practice far more difficult than this. Although it has been done for a long time by hand-coding (especially where rows have an obvious grouping, as per the example above), this is often inflexible. There is a desire to support sharding automatically, both in terms of adding code support for it, and for identifying candidates to be sharded separately.

Where distributed computing is used to separate load between multiple servers (either for performance or reliability reasons) a shard approach may also be useful here.

Lifehacker - Clean Your Keyboard with a Hair Dryer

04 July 2009

Caught Between Two IDEs

In "Caught Between Two IDEs" the author seems to highlight some of the problems that I also share. IntelliJ IDEA has great features and has been responsible for high levels of productivity in software development. However, operating on a project that contains a large amount of source code it seems to be incredibily slow and prone to being unresponsive for long periods. I've tried optimising its memory and gc settings but it hasn't helped much. Maybe it is time to give Eclipse a try... I'll hold out a little bit longer but am nearly there.

01 July 2009

Lifehacker - Best of the Best: Hive Five Winners, March through June 2009

StackProbe - a new Java profiler

StackProbe - a new Java profiler
StackProbe can connect to local or remote applications through JMX without causing too much overhead, while giving accurate results. It periodically takes snapshots of threads stacktraces and analyzes them in real time. The main advantages of this technique are:

* You can control overhead by dynamically adjusting the sampling rate.
* There is no risk of breaking the production system - no code is ever modified.
* The slight slowdown caused by sampling is distributed evenly between all methods in the code, so the relative values reported by the profiler are very accurate.
* StackProbe is able to estimate the statistical error of reported results. This is actually the first profiler to do this.
* The profiler is ready to work just after establishing a JMX connection.
* No special agents are required to be installed on the remote side.
* You can observe first results very early, just when the first few samples arrive.

StackProbe is free for open-source projects. More information and an online demo can be found at http://www.stackprobe.com/.