explorers' club

explorations in dev, science, sci-fi, games, and other fun stuff!

Leave a comment

JSON: underscore camelCase (keys only)

A function for parsing JSON data and changing any keys that contain “property_name” to/from “propertyName”.


Leave a comment

Problem Solving: Random Rules & Regexp (JavaScript)

My intent is not to provide an answer per se, rather it’s to provide insight into the way I think and to foster discussion.  Copy & paste at your own risk.

This is one of 3 tests that I recently took in applying for a developer position.  Due to copyright restrictions I cannot post the problem here verbatim.  I’ve substituted certain values and names.  I can give you the gist (both 🙂 here:

the problem


  • the input string P can have a length of 0 – 50000
  • the input string P will only consist of the characters X, Y and/or Z


Keep in mind that this is my interpretation of the task at hand.  While it’s unfortunate that I can’t recreate the test verbatim here, I can say it was very explicit, but did leave room for interpretation.  Without further ado…

Write a function

function solveIt(S);

..such that, if any transformation applies, pick one at random, transform the string, and continue the process until no transformations are applicable.  Now where there is some room for interpretation is in the transformation rules.  An example of a transformation rule looks like this:

substitute some occurrences of “XY” with “XX”

As you can see, the word “some” could be interpreted differently.  Rather than overthink that part of the test, I assumed they meant to apply the transformation to any & all occurrences.  I think the coding difference is rather trivial at this point.


  • XY -> XX
  • YX -> XX
  • YZ -> ZZ
  • ZY -> ZZ
  • XX -> X
  • ZZ -> Z

the solution

Leave a comment

Quick find and replace using Regular Expressions in Eclipse + Flex

Note to self:

I had the tedious task of removing explicit widths from nearly 150 data grid columns as we had implemented an internal sizing mechanism based on maxChars and headerText.  After manually deleting about 10 of these, I decided to find out how to use Regex in Eclipse to remove them all for me.

This is specific for width but you could do this with nearly any property:

Basically you see the “width” property.  The next set of specialized characters are the following in oct char codes (note: in order for these to properly show I had to add a space between \ and the number):

  • \ 0075 = =
  • \ 0042 = “
  • \ 0173 = {
  • \ 0175 = }
  • [a-zA-Z0-9. _]* = any alphanumeric character of any case, ., (space) or _ for an indeterminate length.

If somebody else has a better formula for this, please let me know so that I can update this post.  Thanks.