Thursday, April 4, 2019

Did you know? JDK comes with HttpServer since 1.6

Did you know? JDK comes with a HttpServer since 1.6

And it is not a secret, do not use API under sun.*. It is under com.sun.*. Just tried it out and still works on JDK 11.

Thursday, August 10, 2017

Intellij SLF4J live template - psfl

In Settings > Editor > Live Templates
Under "others" section

Add the following with abbreviation: psfl and description: Insert slf4j logger

private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger($CLASS_NAME$.class);

And "Edit Variable" where CLASS_NAME = className()

Sunday, May 31, 2015

Bitcoin Faucet - And I actually got paid by one of them

In the past weekend, there was a Bitcoin-themed hackathon in Hong Kong. Although I didn't participate, it did bring my attention to bitcoin again and I did a little bit of research about it.

While I was doing my research, I learn about these little sites called "Bitcoin faucet". For those of us old enough to know about those get-paid-to-surf-the-net-schemes back in the 90s (e.g. AllAdvantage, are the still around?), are they back?

At first I was skeptical, but I figure I will give them a try. Of the 7-ish Bitcoin faucets I tried over the week, one of them actually did payout. The faucet that paid out is http://freebitco.in/


And here is a screenshot of the transaction receiving the bitcoin!


That's right. A Grand Total of $0.14 USD. Is it worth the time? Probably not. But at the end of the day, what intrigues me is the ability to enable micro-transactions. After all, paying out $0.14 USD by any other means, the transaction cost is probably more than the actual amount transferred.

Like it or not, Bitcoin or some other crypto-currency technologies like this will open a whole new world for us.

P.S. Wanna try out the bitcoin faucet? Here is the link to it again.


Saturday, March 28, 2015

Javascript oddities #1

var func = function() {}
console.log(func.prototype.constructor == func); // return true

Thursday, March 12, 2015

JHipster: A code generator with a truck load of tech for AngularJS and Spring Boot based projects

I recently came across a JHipster - a Yeoman-based generator, which generates a based project which includes a truck load of technologies (taken directly from JHipster's Technology Stack page):

Technology stack on the client side

Single Web page application:

  • Responsive Web Design
  • HTML5 Boilerplate
  • Twitter Bootstrap
  • AngularJS
  • Full internationalization support with Angular Translate
  • Optional Compass / Sass support for CSS design
  • Optional WebSocket support with Spring Websocket

With the great Yeoman development workflow:

  • Easy installation of new JavaScript libraries with Bower
  • Build, optimization and live reload with Grunt or Gulp.js
  • Testing with Karma and PhantomJS

And what if a single Web page application isn't enough for your needs?

  • Support for the Thymeleaf template engine, to generate Web pages on the server side

Technology stack on the server side

A complete Spring application:

  • Spring Boot for easy application configuration
  • Maven or Gradle configuration for building, testing and running the application
  • "development" and "production" profiles (both for Maven and Gradle)
  • Spring Security
  • Spring MVC REST + Jackson
  • Optional WebSocket support with Spring Websocket
  • Spring Data JPA + Bean Validation
  • Database updates with Liquibase
  • MongoDB support if you'd rather use a document-oriented NoSQL database instead of JPA
  • Cassandra support if you'd rather use a column-oriented NoSQL database instead of JPA

Ready to go into production:

  • Monitoring with Metrics
  • Caching with ehcache (local cache) or hazelcast (distributed cache)
  • Optional HTTP session clustering with hazelcast
  • Optimized static resources (gzip filter, HTTP cache headers)
  • Log management with Logback, configurable at runtime
  • Connection pooling with HikariCP for optimum performance
  • Builds a standard WAR file or an executable JAR file
Although I did not use it for any of my projects (yet), it is a great reference to see how to setup a project which truly separate the front and back development. What I meant by that is the project is setup where the front-end can be served via 'grunt serve', i.e. NodeJS, decoupled from the back-end Spring Boot server. Yet, we all these goodies, you can still easily call 'mvn package' to build a complete Spring Boot powered executable JAR.

It is a great project to get a glimpse of all these technologies and how they can integrate together. More importantly, it set up a viable project which separates but integrated workflow for front-end and back-end. After working with it for a bit, I do have some reservations and comments, but that for another post.

Have you used JHipster in your projects? In a production setting? If so, I love to hear your comments.

Wednesday, December 17, 2014

SLF4J Template for Eclipse

In Preference > Java > Editor > Templates

Insert the following template:
${l:import(org.slf4j.Logger)}
${f:import(org.slf4j.LoggerFactory)}
private static final Logger LOG = LoggerFactory.getLogger(${enclosing_type}.class);

Monday, December 15, 2014

SOAPUI 5.0.0 hangs after upgrading OS X to Yosemite

After upgrading to the company's Mac OS X to Yosemite, SOAPUI 5.0.0 refuse to load properly. It will start, and the UI will come up, but it just hang with the spinning wheel right away.

I was able to resolve this issue by uncommenting the line #53 in $SOAP_HOME/bin/soapui.sh

#   JAVA_OPTS="$JAVA_OPTS -Dsoapui.browser.disabled=true"

I hope this help someone else out there who has the same problem, and also for myself to reference again if face with the same problem in the future.