###### Blog

This post gives the answer to last week’s Problem of the Week. First of all, I have to admit that this problem actually came from the Quicker Maths blog. This blog actually pulled the problem from IBM’s Ponder this section. First of all, in order to write the equation algebraicly, Read more…

## JavaScript – Sort An Array of Type

One thing that is not extremely obvious in JavaScript is how you sort arrays. Yes, of course I know that arrays have the native sort() function, but did you know that the following will incorrectly sort the array of numbers: How crazy is that? Even though the array is in Read more…

## JavaScript – Convert Function Arguments To An Array

At times, you will need to use the arguments object of a function as an array. In order to convert the arguments into an array, you can do the following: The following is an example of using this function: If you are not familiar with CDR, it is an operator Read more…

## POW Answer – Unnamed Function #2

This answers the Problem of the Week from May 8, 2012. The identity of this well-known computer science function is the binary search. The following is the same code from before with the variables more properly named: To tell you the truth, after using the real names in the function Read more…

## POW – Unnamed Function #2

This Problem of the Week involves determining the identity of a well-known computer science function and renaming the variables so that the definition makes more sense.  The following is the function definition (obfuscated by me): What I can tell you is that this function takes in a sorted array (in ascending order) as the Read more…

## PostgreSQL – Sum Of An Array

Something I had to do today was figure out how to find the SUM of an array in PostgreSQL. I went through many different ways, but this seemed to be the best: If you know of a shorter or better way to do this for a variable size array please Read more…

## OpenKM Scripting – Creating Folders

We recently had the need to create hundreds of folders but didn’t want to do so manually. Unfortunately, this wasn’t as easy as simply going into the database and adding them. Fortunately, it was as easy as using the following script: That script creates the following folders with the same Read more…

## PostgreSQL – Convert A String Into A Table

Recently at work we had the need to convert a string parameter (passed into an iReport) into a table. For many people, the first thing that may come to mind is either the STRING_TO_ARRAY(...) function combined with the UNNEST(...) function. The biggest issue with using just those two functions is Read more…

## PostgreSQL – Example Query As A Function

One of the things that I am not all that thrilled about is the fact that at times it is hard to find examples of PostgreSQL queries or plpgsql functions. For this reason, I want to help out anyone who would like to see an example of converting a query Read more…

## JavaScript – Binary Search

The following is an implementation of a binary search for arrays which gives you the ability to do fuzzy matches (default), exact matches, or specify your own comparison function: I used the following to test the normal execution of this binary function: