{"id":1453,"date":"2013-11-29T20:05:18","date_gmt":"2013-11-29T19:05:18","guid":{"rendered":"http:\/\/www.xenonique.co.uk\/blog\/?p=1453"},"modified":"2013-11-29T20:07:48","modified_gmt":"2013-11-29T19:07:48","slug":"the-competition-winners-of-the-java-ee-7-developer-handbook","status":"publish","type":"post","link":"https:\/\/www.xenonique.co.uk\/blog\/2013\/11\/29\/the-competition-winners-of-the-java-ee-7-developer-handbook\/","title":{"rendered":"The Competition Winners of the Java EE 7 Developer Handbook"},"content":{"rendered":"<p>There are 3 lucky winners of the <a title=\"Win A E-Copy of My Java EE 7 Book Competiton\" href=\"https:\/\/www.xenonique.co.uk\/blog\/?p=1391\">Java EE 7 Developer Handbook competition<\/a>.<\/p>\n<p>Congratulations to <span style=\"color: #008080;\"><strong>Cathy White<\/strong><\/span>, the special selected winner, who wrote the best comment and wins first prize!<\/p>\n<p>The next two winners in second and third place, respectively, are <span style=\"color: #008080;\"><strong>Rui Morais<\/strong><\/span> and <span style=\"color: #008080;\"><strong>Seb Rose<\/strong><\/span>. They were chosen by this following <a title=\"Groovy programming language, Baby! \" href=\"https:\/\/groovy.codehaus.org\/\">Groovy<\/a> program that randomly shuffles a list collection of elements:<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n\/\/ LICENCE is GPL 3.0 (GNU PUBLIC LICENSE 3.0)\r\n\/\/ Peter Pilgrim, Xenonique.co.uk\r\npackage uk.co.xenonique.je7hb.competition\r\n\r\nimport java.security.SecureRandom\r\n\r\n\/**\r\n * The type JE7HBLottoTest\r\n *\r\n * @author Peter Pilgrim\r\n *\/\r\nclass JE7HBLottoTest extends GroovyTestCase {\r\n\r\n    List entrants = [\r\n    \/* SPECIALLY SELECTED WINNER FOR BEST REPLY COMMENT\r\n     &quot;Cathy White, @athyC, 21 Nov, Learning Java EE7\r\n    so I can use existing Java code to build a robust, scalable,\r\n    modern system with a great web UI #javaee7handbook&quot;, *\/\r\n\r\n    &quot;Himadri Pant ,?@himadripant, 21 Nov, JEE 7 packs a powerpunch of &quot; +\r\n            &quot;Project Coin and other features of Java 7. Hopeful of &quot; +\r\n            &quot;getting this master guide into JEE 7 #javaee7handbook.&quot;,\r\n\r\n    &quot;IanonP, ?@iPolding, 20 Nov, Being so new to development, the &quot; +\r\n            &quot;#javaee7handbook sounds like just what I need to &quot; +\r\n            &quot;kickstart my new career&quot;,\r\n\r\n    &quot;Seb Rose, , 14 Nov, It has been a long time since I immersed &quot; +\r\n            &quot;myself in EE Java. This book will give me the information &quot; +\r\n            &quot;I need in a format I can use. I know this because I am a &quot; +\r\n            &quot;long time reader of Peter's work. &quot; +\r\n            &quot;If I don't win this book, I'll buy it anyway!&quot;,\r\n\r\n    &quot;Mohan Radhakrishnan, , 14 Nov, I have been following your blog for &quot; +\r\n            &quot;several years.The stress on communication and &quot; +\r\n            &quot;presentation skills is what attracts me most.&quot;,\r\n\r\n    &quot;Harmeet Singh, , 10 Nov, #javaee7handbook I am new in JavaEE &quot; +\r\n            &quot;and so, i want to learn JavaEE new technologies and &quot; +\r\n            &quot;i am still wait for Java 8. The future plan for &quot; +\r\n            &quot;JavaEE 8 is really good. The Arun Gupta Articles &quot; +\r\n            &quot;are amazing for J2EE 7.&quot;,\r\n\r\n    &quot;Andrew Bell, ,  17 Nov, I'm a recent college graduate &quot; +\r\n            &quot;(read poor) and new Java developer trying to suck up &quot; +\r\n            &quot;all the information I can!&quot;,\r\n\r\n    &quot;Jos\u00e9 antonio, , 18 Nov, IMHO JEE 7 brings new fantastic &quot; +\r\n            &quot;features like Websockets and JSON to just name a few &quot; +\r\n            &quot;and I'd like to learn it to be a java top developer&quot;,\r\n\r\n    &quot;Vivek Krishnan, , 19 Nov, #javaee7handbook Make it my birthday gift :D&quot;,\r\n\r\n    &quot;Mariano Eloy Fern\u00e1ndez Osca , , 19 Nov, JEE has been moving forward &quot; +\r\n            &quot;so fast the last couples of years ... curated information &quot; +\r\n            &quot;is so valuable when there's so much ground to &quot; +\r\n            &quot;cover. Hail #javaee7handbook.&quot;,\r\n\r\n    &quot;suresh, , 19 Nov, very much interested in understanding the&quot; +\r\n            &quot; support for PAAS in Java EE 7. Its inclusive support &quot; +\r\n            &quot;for jpa 2.1 and JAX-RS 2.0.&quot;,\r\n\r\n    &quot;Rui Morais, , 19 Nov, This would be perfect to revamp my Java &quot; +\r\n            &quot;EE knowledge!!&quot;,\r\n\r\n    &quot;Daniela, , 19 Nov, what a nice book to read! (my bday is on friday... :P )&quot;,\r\n\r\n    &quot;Carsten Cerny, , 19 Nov, Hallo, ich kann leider nicht zur &quot; +\r\n            &quot;Konferenz kommen. W\u00fcrde das Buch aber trotzdem gerne lesen.&quot;\r\n\r\n    \/* (Duplicate) &quot;Himadri Pant, , 19 Nov, JEE 7 packs a power punch of\r\n    Project Coin and other features of Java 7 into the enterprise edition.\r\n    I am hopeful of getting this master guide into JEE 7.&quot; *\/\r\n    ]\r\n\r\n    void testPickRandomWinners() {\r\n\r\n        warmUpTheJVM();\r\n        def N = entrants.size()\r\n\r\n        SecureRandom secureRandom = new SecureRandom();\r\n        for ( int j=0; j&lt;Math.abs(secureRandom.nextDouble()) * 32678 + 16384; ++j ) {\r\n            Collections.shuffle(entrants)\r\n            assertEquals( N, entrants.size() )\r\n        }\r\n\r\n        println( &quot;First winner is ${entrants[0]}\\n&quot;)\r\n\r\n        println( &quot;Second winner is ${entrants[1]}\\n&quot;)\r\n\r\n        println( &quot;Third winner is ${entrants[2]}\\n&quot;)\r\n        println( &quot;Fourth winner is ${entrants[3]}\\n&quot;)\r\n        println( &quot;Fifth winner is ${entrants[4]}\\n&quot;)\r\n    }\r\n\r\n    final private static int MIN_NUM = 12;\r\n    final private static int MAX_NUM = 25;\r\n\r\n    private static void warmUpTheJVM() {\r\n        SecureRandom secureRandom = new SecureRandom();\r\n        Random rnd = new Random(System.currentTimeMillis());\r\n        for (int j=0; j&lt;Math.abs(secureRandom.nextDouble()) * 1048576 + 524288; ++j ) {\r\n            calcFibonacci((int)(Math.abs(secureRandom.nextDouble()) * (MAX_NUM - MIN_NUM)) + MIN_NUM);\r\n        }\r\n    }\r\n\r\n    private static int calcFibonacci(int n) {\r\n        int result = 1;\r\n        int previous = -1;\r\n        int sum = 0;\r\n        for(int i = 0; i &lt;= n; i++) {\r\n            sum = previous + result;\r\n            previous = result;\r\n            result = sum;\r\n        }\r\n        return result;\r\n    }\r\n\r\n}\r\n<\/pre>\n<p>But it doesn&#8217;t just shuffle a list, I \u00a0copied the blog comments and the Twitter <em>#javaee7handbooks<\/em> tag entries into a Groovy list. The tricky part was being fair and smart. I wanted to be fair and generate a good random selection of winners. When the program first runs, it warms up the JVM. I also used a <code>javax.secure.SecureRandom<\/code> object instead of the mathematically crackable PRG implementation <code>java.util.Random<\/code>.<\/p>\n<p>After ensure the program actually did what it was supposed to, I ran a few iterations , capture a definitive sample to the standard output:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nFirst winner is Rui Morais, , 19 Nov, This would be perfect to revamp my Java EE knowledge!!\r\n\r\nSecond winner is Seb Rose, , 14 Nov, It has been a long time since I immersed myself in EE Java. This book will give me the information I need in a format I can use. I know this because I am a long time reader of Peter's work. If I don't win this book, I'll buy it anyway!\r\n\r\nThird winner is Carsten Cerny, , 19 Nov, Hallo, ich kann leider nicht zur Konferenz kommen. W\u00fcrde das Buch aber trotzdem gerne lesen.\r\n\r\nFourth winner is Vivek Krishnan, , 19 Nov, #javaee7handbook Make it my birthday gift :D\r\n\r\nFifth winner is Daniela, , 19 Nov, what a nice book to read! (my bday is on friday... :P )\r\n<\/pre>\n<p>From output, Cathy White was already excluded from the list collection.<\/p>\n<p>Congratulations to all the winners, enjoy your e-book, and to the other contestants, thanks for entering the competition.<\/p>\n<p>+PP+<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are 3 lucky winners of the Java EE 7 Developer Handbook competition. Congratulations to Cathy White, the special selected winner, who wrote the best comment and wins first prize! The next two winners in second and third place, respectively, are Rui Morais and Seb Rose. They were chosen by this following Groovy program that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[158,118,59,110,143,169],"tags":[],"_links":{"self":[{"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/posts\/1453"}],"collection":[{"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=1453"}],"version-history":[{"count":11,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/posts\/1453\/revisions"}],"predecessor-version":[{"id":1463,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/posts\/1453\/revisions\/1463"}],"wp:attachment":[{"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=1453"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=1453"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=1453"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}