{"id":890,"date":"2012-10-26T10:01:47","date_gmt":"2012-10-26T09:01:47","guid":{"rendered":"http:\/\/www.xenonique.co.uk\/blog\/?p=890"},"modified":"2012-10-26T12:41:18","modified_gmt":"2012-10-26T11:41:18","slug":"a-groovy-script-to-keep-the-internet-cafes-wifi-alive","status":"publish","type":"post","link":"https:\/\/www.xenonique.co.uk\/blog\/2012\/10\/26\/a-groovy-script-to-keep-the-internet-cafes-wifi-alive\/","title":{"rendered":"A Groovy Script to Keep The Internet Cafe&#8217;s WIFI Alive"},"content":{"rendered":"<p>Have you ever been to an Internet Cafe and connected to the free WIFI? Have you found that after five minutes of activity the connection has been dropped and you have go through the License and Terms of Agreement again and again and again? Annoying isn&#8217;t. <\/p>\n<p>Well after expiring this at Charlotte Airport in the USA recently, I re-concocted the script that I wrote for the half-dozenth time. This time I going to blog it and save it for all time.<br \/>\nHere is a simple Groovy script to keep the Internet alive.<\/p>\n<pre class=\"brush: groovy; title: ; notranslate\" title=\"\">\r\n\/\/ Hang-up to Internet Connection Groovy Script\r\n\/\/ Useful for Internet Cafe that drop WIFI connectivity through\r\n\/\/ perceived lack of activity e.g. Starbucks \/ Hotels\r\n\/\/ Peter Pilgrim\r\n\/\/ 28 September 2012\r\n\r\ndef maxTimeout = 30000\r\ndef minTimeout = 15000\r\n\r\ndef domainList = [\r\n    'gmail.com', 'google.co.uk', 'google.com', 'bbc.co.uk', 'cnn.com', 'java.oracle.com',\r\n    'facebook.com', 'twitter.com', 'oracle.com', 'zen.co.uk', 'java.net', 'www.scala-lang.org',\r\n    'plus.google.com', 'guardian.co.uk', 'linkedin.com', 'www.typesafe.com', 'www.yahoo.com',\r\n    'www.ibm.com', 'www.apache.org', 'www.adobe.com', 'www.microsoft.com', 'www.stackoverflow.com',\r\n    'www.apple.com', 'groovy.codehaus.org', 'java.oracle.com', 'www.telegraph.co.uk', 'www.jroller.com',\r\n    'www.dell.com', 'www.samsung.com', 'www.amazon.co.uk', 'docs.oracle.com', 'www.infoq.com',\r\n    'www.devoxx.com', 'www.qconlondon.com', 'www.smashingmagazine.com', 'en.wikipedia.com' ]\r\n\r\ndef count = 1\r\nwhile (true) {\r\n    int idx = (int)( Math.random() * domainList.size )    \r\n    println &quot;[$count]  nslookup ${domainList[idx]}&quot;\r\n    def process = &quot;nslookup ${domainList[idx]}&quot;.execute()\r\n    println &quot;Found text ${process.text}&quot;\r\n    \r\n    def sleepTime = (int)( minTimeout + Math.random() * ( maxTimeout  - minTimeout))\r\n    Thread.sleep( sleepTime );\r\n    \r\n    ++count\r\n}\r\n\r\n\/\/ done\r\n<\/pre>\n<p>The script can be improved with a much larger set of domain names, perhaps I could machine generate the domain names from the Chrome Browser history, or something like this. That is about all I would do, except to parameterise the command line arguments. On Mac or Linux I just hit the terminal and type with auto completion of course <code>groovy ~\/hangon-to-internet.groovy <\/code><\/p>\n<p>Now, the only thing to write is a similar script to keep the WIFI connection to the both mobile phone and tablet alive. Answers on a post card please.<\/p>\n<p>+PP+<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever been to an Internet Cafe and connected to the free WIFI? Have you found that after five minutes of activity the connection has been dropped and you have go through the License and Terms of Agreement again and again and again? Annoying isn&#8217;t. Well after expiring this at Charlotte Airport in the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7,44,40,153],"tags":[],"_links":{"self":[{"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/posts\/890"}],"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=890"}],"version-history":[{"count":3,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/posts\/890\/revisions"}],"predecessor-version":[{"id":894,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/posts\/890\/revisions\/894"}],"wp:attachment":[{"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=890"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=890"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}