Posts

Trade Me API OAuth Java example

Image
Overview Trade Me is the most popular online auction e-commerce website in New Zealand, which features things very much like eBay. As an e-commerce platform, Trade Me provides APIs for third-parties vendors to spark their own ideas on top of Trade Me platform powerhouse. The API reference manual is as follows:  http://developer.trademe.co.nz/ , in the reference, among others, the authentication way on basis of OAuth is very complicated, check the following link for details:  http://developer.trademe.co.nz/api-overview/authentication/example-oauth-flow/ , unfortunately, Trade Me API manual doesn't contain vivid code examples to simplify the understanding. In this article, I will list all of steps with code snippets for Trade Me OAuth flow to make it vigorous in force, therefore, projects which lies on Trade Me API are easy to get started, especially for Java. Please be aware, trade me adopts OAuth 1.0 as authentication mechanism which is not compatible with OAuth...

How to develop Tomcat-based WebSocket application on Heroku

Image
Overview When we want to develop WebSocket application based on Java, Tomcat is a good fit because Tomcat 7 and onwards support WebSocket in default. Nevertheless, Tomcat deployed on Heroku Cloud PaaS needs slight tweaks. There are two existing solutions: Embedded Tomcat :  https://devcenter.heroku.com/articles/create-a-java-web-application-using-embedded-tomcat Webapp Runner :  https://devcenter.heroku.com/articles/java-webapp-runner Unfortunately, those two solutions don't work for WebSocket applications that work under standard tomcat. The Reason why exisiting solutions don't work The critical part makes WebSocket up and running in Tomcat is two jars under lib directory --  websocket-api.jar and  tomcat7-websocket.jar , they are the implementation of JSR 356 , Java API for WebSocket, the link tells the details,  http://www.oracle.com/technetwork/articles/java/jsr356-1937161.html . If we can find those two or stuff like that with regard t...

How to implement board games by Swing

Image
Overview Programming games could be super complicated, just imagine how fancy the scenes you can see in the Counter-Strike are, how sophisticated the weapon facilities are available in the Warcraft. However, on the flip side, building a game based on computer can also be reasonably easy and entertaining. Board games come into this category, in this article, I am going to use Java Swing to build a simple board game involved with board, layout and pieces, etc, which can serve as the entry level game programming that certainly paves the way to more advanced stages of game programming. Of note, Java Swing gains massive performance improvements in recent years due to the optimisations across multiple levels. The game rules and illustrations Game Board: There are two players, for each player there are three pieces. There are four borderlines forming square of the board; one horizontal line, one vertical line and two sloped lines are crossed at the centre point on the board. ...