Grails – The pinnacle of Spring MVC

December 21st, 2012 by admin No comments »

Here is an example demonstrating how light, easy, straight-forward Grails could implement MVC web application that list location address.

  • Data model layer – Location.groovy
class Location implements Serializable {

    Long id
    String street
    String suburb
    String state
    String postCode

    static mapping = {
        id generator: 'sequence', params: [sequence: 'seq_location_id']
    }

    static constraints = {
        street(nullable: false, blank: false, maxSize: 80)
        suburb(nullable: false, blank: false, maxSize: 50)
        state(nullable: false, blank: false, size: 2..3, inList: Constants.STATES)
        postCode(nullable: false, blank: false, size: 4, matches: '\\d+')
    }

With Grails’ Object Relational Mapping (ORM) solution – GORM, after run “grails run-app“, database will be initialised, table “LOCATION”, table column created and constrained in an automatic fashion.

Have a look database Location table in SQL:

» Read more: Grails – The pinnacle of Spring MVC

General knowledge – Absurd Trivia

December 19th, 2012 by Terrence Miao 5 comments »

November 19th is World Toilet Day. In 2001 the Singapore based WTO — that is, the World Toilet Organisation — chose a day to mark the plight of the world’s loo-less 2.5 billion. Its slogan this year was “I give a shit, do you?”

Google+: View post on Google+

For Apple, it's ALL downhill from here

December 18th, 2012 by Terrence Miao 5 comments »

Apple's stock price closed just above $702 in September 2012, and finished at $518 on Dec 17 2012.

Google+: View post on Google+

Stock up before this Friday, when the Mayans predict the world will end

December 18th, 2012 by Terrence Miao 8 comments »

A friendly remind that you should prepare for the worst on Dec 21st 2012 which is only two days away:

• Stockpiking enough food, bulk buying water at least for a month when Aldi and Coles are on heavy discount right now.

• Fullfilling your run away car tank as petrol price in Melbourne is only 135.9 cent per liter today.

• Selling all your stocks, redeeming all your managed fund when Aussie market hits 2012 high right now.

• Kindly stop making phone call, SMS, sending email, posting on G+, Facebook on Dec 21st which would scare people's shit out …

Fingers acrossed. Hopefylly world could survive the Armageddon. Everyone could safely back to work on next Monday. Amen.

Google+: View post on Google+

Pro Spring development mostly choose Tomcat as the web container

December 17th, 2012 by Terrence Miao 3 comments »

Tomcat is lighter and more agile if developers try to avoid huge, heavier, full blow version JEE server. However, one thing missing in Tomcat, and I really miss a lot in big O's OC4J and Weblogic is the management and monitor tools. 

Admin interface in Tomcat is shambolic and useless. You have to tail and trace the log to understand exact problem where is. So more hardcore developers go for the low maintenance, less configuration, easily clustered Jetty instead. Anyway, this is another debate or a new war Tomcat vs. Jetty.

Now, turn to Java Melody, an easily setup and integrated with your existing Java web application tool, let you monitor application's performance, configuration, JVM inside, SQL connection, cache, application error and warning …

Java Melody is the tool web application development must have.

Read more on pictures: http://code.google.com/p/javamelody/wiki/Screenshots

Embedded Link

» Read more: Pro Spring development mostly choose Tomcat as the web container

Step by step to setup Java app monitoring tool – Java Melody

December 17th, 2012 by admin No comments »
  • In $CATALINA_BASE/webapps/myapp/WEB-INF/web.xml, add filter and listener at the beginning of filter and listener section of file:
<filter>
    <filter-name>monitoring</filter-name>
    <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>monitoring</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
...

<listener>
    <listener-class>net.bull.javamelody.SessionListener</listener-class>
</listener>
  • copy following two jars files under $CATALINA_BASE/webapps/myapp/WEB-INF/ lib directory, add:

javamelody-1.42.0.jar
jrobin-1.5.9.jar

Visit URL: http://localhost:8080/myapp/monitoring

A hacker's guide to Telstra mobile phone service

December 16th, 2012 by Terrence Miao 9 comments »

Marriage seems unexplainable complicated these days. After two years with my Samsung Galaxy Tab, the first ever generation tablet 7", both of us are tired. The tablet is getting older, slower and grumpy, refusing to be mature like, still staying in Android 2.2 and committing suicide (self-reboot) several times a day. 

Now younger and sexier mail-ordered bride – Samsung Galaxy Note 2 arrived after one week long journey from Hong Kong on Friday. However, the new life just starts with a big bang.

All the preparation work for the wedding look good. Bridal clothing, shoes and accessories for the big formal occasion are making the day even more special. Connecting Note 2 to home WiFi, Android 4.1.1 guides you step by step, downloading all the latest applications you installed on Tablet 7 before to Note 2, saving your tons of time install them one by one. After two hours without any argument, about 1GB data, all original applications downloaded and installed. The new bride dresses up like old bride in the gown.

Then disharmony starts. 

New bride refuses to wear the engagement ring which taken off from old bride's finger. The mini SIM card from Tablet 7 can't put on Note 2's micro SIM finger. Thank you, you bloody over regulated European Telecommunications Standards, and Apple made it even popular. No SIM, no internet, no wedding, and can't get to anywhere.

Quickly I jump on Google to find out any peace deal solving engagement ring's crisis. No surprise, a few married people on internet teach their experience how to solve the crisis – with a bit help of scissors, paper template, tape. You can D.I.Y., cutting min SIM into micro SIM. Unfortunately, no one of them offer any kind of warranty what if failed. Hmmm, too risky, most probably make the SIM not functional working after the cut if you don't give any practice. But fortunately, at the end of day, find on the Telstra forum, some more experienced married people talk about back to the jewellery store – Telstra shop, you could ask exchange service – replacing mini SIM with micro SIM. And it's totally FREE.

Exuberated with the possible peace deal on the crisis. I head to the nearest Telstra shop on Saturday morning. A Telstra sale representative almost hands me the new ring – a new micro SIM card, then suddenly he asks who is the new bride. I tell him it's Samsung Galaxy Note 2, he starts shaking his head – "Telstra can't move your plan from a tablet to mobile phone. You need buy a new mobile phone plan. Here is a plan for you type people taste – a minimal $60 per month plan, you get SAME 1GB data, but $600 phone call and unlimited messages".

I want to tell this sale person stop bullshitting me and please bugger off. Tablet and smartphone are the SAME. The size doesn't matter. Only Telstra makes people life difficulty matter. I don't want to change my current $29 plan. And I'm a human beings hater. I don't have friends. I don't need to make phone call or SMS to anyone at all.

» Read more: A hacker's guide to Telstra mobile phone service

Thinking to setup Android screen unlock pattern like this

December 15th, 2012 by Terrence Miao No comments »

Then give up because it's too perverted, even to a geek's view.

Google+: View post on Google+