Jay Taylor | programmer notes

Archive for March 2012

Recently, I went a little too far with my usage of Scala’s syntactic (very sugary and sweet!) ability to allow:

to be written as:
SomeObject someFunction param

This is cool. However, it is also possible to do something which I have decided is difficult to read and understand:

SomeObject anotherFunction (param1, param2, param3)

Regretful as the situaton is, I wrote a quick line of sed to fix it in the affected files:

The first step was to identify which files had this ugliness:
jay@secretcode:~$ grep ' *[a-z0-9_\.]\+ \+[a-z0-9_]\+ \+(.*,.*) *$' app/* -r -n

Then it was a matter of formulating the regular expression transform to be evaluated by sed:
jay@secretcode:~$ sed -i.bak -e 's/\( *[a-z0-9_\.]\{1,\}\) \{1,\}\([a-z0-9_]\{1,\}\) \{1,\}\((.*,.*) *\)$/\1.\2\3/g' Perk.scala
jay@secretcode:~$ diff Perk.scala.bak Perk.scala
< val ch = ContentHelper apply (false, content.jsonData)
> val ch = ContentHelper.apply(false, content.jsonData)
< val hashtag = ch get ("hashtag", "html")
> val hashtag = ch.get("hashtag", "html")

NB: The above sed expression is compatible with both the OS-X and Linux versions of sed

Whew, catastrophe averted!

No tags Hide

The Advanced PHP Debugger (apd) PHP script profiler worked wonderfully once the module was built and installed. However, getting to that point was quite painful.

Compilation initially wasn’t working the latest package code in the apd PECL repository. Initially, I thought the compilation problem was Ubuntu-specific, but after some googling I found this article by the apparently extremely capable jjf, in which the author dives into great detail about the exercise of tracking down and fixing the compilation problems with this package. This saved me a GREAT deal of time, and in the interest of making it even easier to obtain a working package I created an automated build system tool to automatically apply the changes that were required to “make it work.” The utility is available as “apdBuilder.sh” in the git repository.

Here are the full sources: https://github.com/jaytaylor/apd

No tags Hide

Find it!