Wi-Fizzle.com - Putting the fizzle in Wi-Fi since 2005 .. (yes, this was a poor choice for a domain name)

March 22, 2012 - September 01, 2012

< Previous Articles >< Next Articles >
Posted by dandriff on Saturday September 01, 2012@03:18PM

Here is the code fragment:

 trait ElasticSearchIndexed[T] {
     private val _containsIdPattern = """^.*[^\]"id" *:.*$""".r
     private val _idIntegralPattern = """^[1-9][0-9]*$""".r
      * NB: If search hit result `id' field not present in json, then one will be inferred and inserted.
     implicit def searchHitToT(hit: SearchHit)(implicit manifest: Manifest[T]): T = {
         val source = hit.sourceAsString
         val cleanedSource: String = source match {
             case _containsIdPattern(p) =>
                 println("P=" + p)
             case _ => hit.id.toString match {
                 case _idIntegralPattern(p) => source.replaceFirst("\{", """{"id":""" + hit.id.toLong + ",")
                 case _ => source.replaceFirst("\{", """{"id":"""" + hit.id.replaceAll("\"", "\\\"") + """",""")
         println("A: " + source)
         println("B: " + cleanedSource)

The runtime JVM exception was like this:

 play.api.Application$$anon$1: Execution exception [[AbstractMethodError: com.company.models.Group$.com$company$models$ElasticSearchIndexed$_setter_$com$company$models$ElasticSearchIndexed$$_containsIdPattern_$eq(Lscala/util/matching/Regex;)V]]
     at play.api.Application.handleError(Application.scala:144) ~[play_2.9.1-2.1-07132012.jar:2.1-07132012]
     at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:121) [play_2.9.1-2.1-07132012.jar:2.1-07132012]
     at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:108) [play_2.9.1-2.1-07132012.jar:2.1-07132012]
     at akka.actor.Actor$class.apply(Actor.scala:318) [akka-actor.jar:2.0.2]
     at play.core.ActionInvoker.apply(Invoker.scala:106) [play_2.9.1-2.1-07132012.jar:2.1-07132012]
     at akka.actor.ActorCell.invoke(ActorCell.scala:626) [akka-actor.jar:2.0.2]
 Caused by: java.lang.AbstractMethodError: com.company.models.Group$.com$company$models$ElasticSearchIndexed$_setter_$com$company$models$ElasticSearchIndexed$$_containsIdPattern_$eq(Lscala/util/matching/Regex;)V
     at com.company.models.ElasticSearchIndexed$class.$init$(ElasticSearchIndexed.scala:18) ~[classes/:na]
     at com.company.models.Group$.<init>(Group.scala:70) ~[classes/:na]
     at com.company.models.Group$.<clinit>(Group.scala) ~[classes/:na]
     at com.company.services.impl.GroupSearchService$$anonfun$4.apply(GroupSearchService.scala:79) ~[classes/:na]
     at com.company.services.impl.GroupSearchService$$anonfun$4.apply(GroupSearchService.scala:79) ~[classes/:na]
     at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194) ~[scala-library.jar:0.11.3]

Solution: Clean and recompile your play-framework project

 play clean
 play compile


  • AbstractMethodError
  • scala/util/matching/Regex
  • Execution exception
  • Execution exception [[AbstractMethodError "scala/util/matching/Regex"
  • Play-framework 2.0.3
  • Play-framework 2.0.x
  • Play-framework 2.x
  • SBT
  • Simple Build Tool
  • Scala
  • Regex
  • Regular expressions
  • JVM
  • Play

Posted by dandriff on Thursday August 30, 2012@01:13PM

HOWTO: Command-line test for whether or not a TCP port is open

Usually I just use `telnet <host_or_ip> <port>' to see if a port is open, but this doesn't lend itself to automation. One way to accomplish this automatically is

 nc -z <host_or_ip> <port> 1>/dev/null 2>&1; result=$?;
 if [ $result -eq 0 ]; then
     echo 'the port is open for tcp connections'
     echo 'the port was closed'

If the port is open, the exit status will be `0', otherwise it will be `1'.

Reference: How to test if remote TCP port is opened from Shell script?

Posted by dandriff on Wednesday August 29, 2012@04:18PM

I started off with a basic ProxyCommand configuration, like this:

     ProxyCommand ssh nc %h %p
     IdentityFile ~/.ssh/id_rsa

But I kept getting the following error:

 $ ssh
 Permission denied (publickey).

 $ ssh -v
 OpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011
 debug1: Reading configuration data /Users/wi-fi/.ssh/config
 debug1: Applying options for *
 debug1: Applying options for api1b
 debug1: Reading configuration data /etc/ssh_config
 debug1: Applying options for *
 debug1: Executing proxy command: exec ssh -C nc 22
 debug1: permanently_drop_suid: 501
 debug1: identity file /Users/wi-fi/.ssh/id_rsa type 1
 debug1: identity file /Users/wi-fi/.ssh/id_rsa.pub type -1
 debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1
 debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1 pat OpenSSH*
 debug1: Enabling compatibility mode for protocol 2.0
 debug1: Local version string SSH-2.0-OpenSSH_5.6
 debug1: SSH2_MSG_KEXINIT sent
 debug1: SSH2_MSG_KEXINIT received
 debug1: kex: server->client aes128-ctr hmac-md5 zlib@openssh.com
 debug1: kex: client->server aes128-ctr hmac-md5 zlib@openssh.com
 debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
 debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
 debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
 debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
 debug1: Host '' is known and matches the RSA host key.
 debug1: Found key in /Users/wi-fi/.ssh/known_hosts:89637
 debug1: ssh_rsa_verify: signature correct
 debug1: SSH2_MSG_NEWKEYS sent
 debug1: expecting SSH2_MSG_NEWKEYS
 debug1: SSH2_MSG_NEWKEYS received
 debug1: Roaming not allowed by server
 debug1: SSH2_MSG_SERVICE_ACCEPT received
 debug1: Authentications that can continue: publickey
 debug1: Next authentication method: publickey
 debug1: Offering RSA public key: /Users/wi-fi/.ssh/id_rsa
 debug1: Authentications that can continue: publickey
 debug1: No more authentication methods to try.
 Permission denied (publickey).

These wonderful articles all ended up not helping me solve this problem _at all_:

But what each of these publications fails to mention as a possible problem is that if your username doesn't match on both the intermediate and destination hosts, the ProxyCommand won't work until you specify the usernames in your ~/.ssh/config like this:

     User wi-fizzle
     ProxyCommand ssh nc %h %p
     IdentityFile ~/.ssh/id_rsa

Along the way, I found a cool trick to reuse tcp connections:

Reusing Connections

The transparent multi-hop connections can be very useful but you may find that it takes a second or two to establish each connection. This delay can become annoying if it happens a lot (e.g.: every time you save a file from the text editor).

The good news is that if you can configure SSH to reuse an existing connection. This means that for example if you have an SSH shell session running then a new connection for SCP can skip the connection setup phase. Two steps are required:

First, you must create a directory (or 'folder') which SSH will use to keep track of established connections:

 mkdir ~/.ssh/tmp

Next, add these two lines at the start of your ~/.ssh/config (make sure to use your username in place of 'YOUR-NAME'):

 ControlMaster auto
 ControlPath   /home/YOUR-NAME/.ssh/tmp/%h_%p_%r

As you can see, a small investment in time setting up your SSH configuration can pay back dividends in convenience.

Posted by dandriff on Tuesday August 28, 2012@05:34PM

With play 2.0.3 I kept getting "Cannot find any HTTP Request here" with the following Action composition:

 def foo[A](i: Int)(implicit request: Request[A]): Baz = {

I found the Play Request docs, which list the class annotations as:
 @implicitNotFound( "Cannot find any HTTP Request here" )

But this ended up not being useful information.

Ultimately StackOverflow helped me find a solution to this problem. This error was fixed by changing 'Request[A]' to instead use the type 'RequestHeader'.


 import play.api.mvc.RequestHeader


 def foo(i: Int)(implicit request: RequestHeader): Baz = {

  • Scala
  • Implicit parameters
  • Play-framework
  • Play-framework 2
  • Play-framework 2.0
  • Play-framework 2.0.x
  • Play-framework 2.0.3
  • Cannot find any HTTP Request here

Posted by dandriff on Friday August 24, 2012@05:07PM

All it takes are a few special flags to `curl`:

 curl -o /dev/null -s -w %{time_connect}:%{time_starttransfer}:%{time_total} 'http://google.com/'


Posted by dandriff on Wednesday August 22, 2012@05:29PM

            import Global
            Global registerCancellable cancellable

 ContactsIndexer.scala:173: _root_ cannot be imported
 [error]             import _root_.Global
 [error]                    ^
 [error] indexers/impl/ContactsIndexer.scala:174: not found: value Global
 [error]             Global registerCancellable cancellable
 [error]             ^
 [error] two errors found
 [error] application - 
 ! Internal server error, for request [POST /contact.json] ->
 sbt.PlayExceptions$CompilationException: Compilation error [_root_ cannot be imported]
     at sbt.PlayReloader$$anon$2$$anonfun$reload$3$$anonfun$4$$anonfun$apply$12$$anonfun$apply$13.apply(PlayReloader.scala:223) ~[na:na]
     at sbt.PlayReloader$$anon$2$$anonfun$reload$3$$anonfun$4$$anonfun$apply$12$$anonfun$apply$13.apply(PlayReloader.scala:223) ~[na:na]
     at scala.Option.map(Option.scala:133) ~[scala-library.jar:0.11.3]
     at sbt.PlayReloader$$anon$2$$anonfun$reload$3$$anonfun$4$$anonfun$apply$12.apply(PlayReloader.scala:223) ~[na:na]
     at sbt.PlayReloader$$anon$2$$anonfun$reload$3$$anonfun$4$$anonfun$apply$12.apply(PlayReloader.scala:220) ~[na:na]
      at scala.Option.map(Option.scala:133) ~[scala-library.jar:0.11.3]

It turns out that in newer versions of the JVM, referencing the root package has been deprecated, see:

Posted by dandriff on Tuesday August 21, 2012@03:29PM

 play -Dconfig.file=conf/prod.conf run
 heroku PSQLException: FATAL: no pg_hba.conf entry for host

The fix for this is to connect to postgresql using SSL, which in play framework 2.0.x can be achieved by appending everything after the "?" to your jdbc url, e.g.:

  • Heroku
  • Postgres
  • Postgresql
  • Play-Framework 2.0
  • SSL
  • Connection error

Posted by dandriff on Thursday August 16, 2012@12:25PM


a·lac·ri·ty /&#601;&#712;lakrit&#275;/
Noun: Brisk and cheerful readiness.


quick and eager; "an alacritous response to the invitation".

Posted by dandriff on Thursday August 16, 2012@12:24PM

define: egress

e·gress/&#712;&#275;gres/ Noun: The action of going out of or leaving a place: "direct means of access and egress".

Posted by dandriff on Saturday May 05, 2012@09:16PM

INVESTIGATED: windows 7 + cygwin + postgresql + python psycopg2

Posted by dandriff on Monday April 30, 2012@01:44PM

HOWTO work around Cygwin error messages like:

 address space needed by SOME_DLL is already occupied


 .. resource unavailable ..


 Running setup.py egg_info for package redis
      0 [main] python2.6 8384 child_info_fork::abort: address space needed by 'cygcrypto-0.9.8.dll' (0x780000) is already occupied
    Error [Errno 11] Resource temporarily unavailable while executing command python setup.py egg_info

A quick search led me to unhelpful pages like http://cygwin.com/ml/cygwin/2012-02/msg00667.html. Bummer.

It turns out that this problem can happen after installing new packages. This includes setup.exe-based Cygwin packages as well as Python packages and/or libraries.

The solution to this problem is to run the `rebaseall` command for Cygwin. This cannot be done from within Cygwin, so shut down all instances of cygwin and start up a windows command prompt. type the following commands:


Wait for the rebase all operation completes, then fire up a new instance of cygwin terminal and you should be all set!

If the problem still happens, then this didn't work.. :/

  • address space needed by .. is already occupied
  • "address space needed by"
  • "is already occupied" cygwin

Posted by dandriff on Monday April 16, 2012@11:18AM

Today I found the cool Windows terminal emulator Poderosa, but after installing it on Windows 7 I was getting registry key missing errors when I tried to connect to my local cygwin with it.

I found the fix here: http://thelongestblogurlicouldthinkof.blogspot.com/2011/03/cygwin-window-in-poderosa.html

Here are the registry modifications I performed (not perfect, but they'll get the job done):

    Windows Registry Editor Version 5.00
    [HKEY_LOCAL_MACHINESOFTWARECygnus SolutionsCygwin]
    [HKEY_LOCAL_MACHINESOFTWARECygnus SolutionsCygwinmounts v2]
    "cygdrive prefix"="/mnt"
    "cygdrive flags"="dword:0000002a"
    [HKEY_LOCAL_MACHINESOFTWARECygnus SolutionsCygwinmounts v2/]
    [HKEY_LOCAL_MACHINESOFTWARECygnus SolutionsCygwinmounts v2/]

  • poderosa
  • windows 7
  • registry
  • cygnus solutions mounts v2
  • mounts v2/

Posted by dandriff on Thursday March 22, 2012@10:58AM

F.Lux is a program to make your display easier on your eyes. It is kind of trippy, too!

< Previous Articles >< Next Articles >