Blog

  • Turning PostgreSQL rows into arrays

    The short version: To turn a set of PostgreSQL rows into an array, wrap a subselect in the ARRAY function: SELECT ARRAY(SELECT description FROM Appointments). It returns one row with one array, holding one element per input row. Wrap that in array_to_string(…, ‘, ‘) to get a comma-separated string, and use AS to give the…

    Read more

  • Looking in PostgreSQL arrays with ANY

    So far, this series has looked at how to create PostgreSQL arrays, how to retrieve data from them, and how to get the length of an array’s outer and inner dimensions. But one of the most common actions that we’ll want to do with an array is look inside to see if a particular value…

    Read more

  • The real questions to ask offshore developers

    Friends of mine, who are not software developers, have a small, retail Internet business.  The original developers created the application in Python, and my friends are looking for a full-stack Web/Python developer to help them.  Frustrated with their inability to find someone who can commit to their project, my friends have decided to hire offshore developers, which…

    Read more

  • PostgreSQL array indexes and length

    In my last blog post, I introduced the idea of a PostgreSQL array, and showed how we can insert data into a table using either the curly-brace {} syntax, or the ARRAY construction syntax.  In this post, I want to talk about PostgreSQL indexes and length — what happens when we retrieve from indexes that exist (and…

    Read more

  • Learning to love PostgreSQL arrays

    I’ll admit it: When arrays were added to PostgreSQL a number of years ago, I thought that this was a really bad idea.  I’m a firm believer in normalization when it comes to database design and storage; and the idea of putting multiple values inside of a single column struck me as particularly foolish.  Besides,…

    Read more

  • Control-R, my favorite Unix shell command

    If you use a modern, open-source Unix shell — and by that, I basically mean either bash or zsh — then you really should know this shortcut.  Control-R is probably the shell command (or keystroke, to be technical about it) that I use most often, since it lets me search through my command history. Let’s…

    Read more

  • Starting a new software project? Don’t start coding right away.

    It’s always fun to start a new project. I should know; I’ve been a consultant since 1995, and have started hundreds of projects of various shapes and sizes.  It’s tempting, when I first meet a new client and come to an agreement, to dive right into the code, and start trying to solve their problems.…

    Read more

  • Summary of my “reduce” series

    I teach Ruby and Python to a lot of people — in formal courses, and in one-on-one pairing sessions, both online and in person.  I’ve found that for many people, the whole notion of functional programming seems strange and difficult, as well as something of a waste of time.  After all, if you have objects,…

    Read more

  • Implementing “filter” with “reduce”, in Ruby and Python

    We’re nearly at the end of my tour of the “reduce” function in Ruby and Python.  Just as I showed in the previous installment how we can implement the “map” function using “reduce”, I want to show how we can implement another functional-programming standard, “filter”, using “reduce” as well.  As before, I’ll show examples in…

    Read more

  • Implementing “map” with “reduce”, in Ruby and Python

    This is another installment in my “reduce” series of posts, aimed at helping programmers understand this function, with examples in both Ruby and Python.  So far, we have seen how we can build a number of different types of data structures — integers, strings, arrays, and hashes — using “reduce”.  But the really interesting use…

    Read more