Skip to main content

Posts

This blog has moved

This blog is now located at http://blog.cyclopsgroup.org. You will be automatically redirected in 30 seconds, or you may click here . For feed subscribers, please update your feed subscriptions to http://blog.cyclopsgroup.org.

RESTful service with JAX-RS is so easy, a caveman could do it

A recent project requires me to build a RESTful service that supports supports stream input, output and JAXB binding. After a quick research, I was amazed when I found how easy it is to build RESTful service using JAX-WS(JSR-311) and Apache CXF . Cut the chase, let the code talk. import javax.xml.ws.rs.*; @Path( "/hello" ) public interface Greeter { @GET @Path( "/{user}") @Produces( "text/plain" ) public String sayHelloTo( @PathParam( "user" )String userName ); } It seems the annotations in the interface above provides everything client needs to know, and that's exactly right. Following CXF class returns an implementation of Greeter that knows to send HTTP request to http://helloworld.com/hello/jiaqi and return the HTML response as a String. There's zero coding work involved to create fully functional client. import org.apache.cxf.jaxrs.client.JAXRSClientFactory; ... Greeter greeter = JAXRSClientFactory.create( "http://hel...

Amazon PayPhrase, a secure way to pay

I've been hearing about Amazon PayPhrase for a while, and finally received official news letter in last month. Here I'll skip the part about what is PayPhrase and how does it work, I'm sure the official website describes it with words thousands times more accurate and understandable than what I can do. Rest of this article talks about why I think PayPhrase is a secure way to pay. "Secure" is a very mirky word. This morning I went to a website of my favourite croissant store, picked a yummy cranberry cream cheese croissant and checked out. A little PHP page pops up, "select credit card XXXX-XXXX-XXXX-8841 or input a new card". This small page made me nervous for the rest of the day. To improve customer experience of buying a 2$ croissant, this shaky little home-made PHP website decided to keep my credit card information in their tiny MySQL database, probably running on a windows machine in store owner's house, a machine where an 9-year-old boy plays ...

Project Euler problem 220 - Heighway Dragon

This document goes through a Java solution for Project Euler problem 220 . If you want to achieve the pleasure of solving the unfamiliarity and you don't have a solution yet, PLEASE STOP READING UNTIL YOU FIND A SOLUTION. Problem 220 is to tell the coordinate after a given large number of steps in a Dragon Curve . The first thing came to my mind, is to DFS traverse a 50 level tree by 10^12 steps, during which it keeps track of a direction and a coordinate. Roughly estimate, this solution takes a 50 level recursion, which isn't horrible, and 10^12 switch/case calls. Written by a lazy and irresponsible Java engineer, this solution vaguely looks like: Traveler traveler = new Traveler(new Coordinate(0, 0), Direction.UP); void main() { try { traverse("Fa", 0); } catch (TerminationSignal signal) { print signal; } } void traverse(String plan, int level) { foreach(char c:plan) { switch(c) { case 'F': traveler.stepForward(); break; ca...

Yilin Guo, the coolest girl on the planet

The biggest project that I ever do, for now and ever, just started on September 22nd 13:00 EST 2009, in Memorial Hospital in South Bend, Indiana. This project will take 18 years of development and my lifetime to support. She is my daughter, Yilin Guo. There are way too many reasons why Yilin is the coolest girl on the planet. I can't explain them quickly in a simple article, therefore I created blog THE COOLEST GIRL ON THE PLANET to post these reasons whenever I find one. The following photo starts the argument with the fact that, Yilin is a better performer than Steven Seagal .