Adventures in programming and data.

  • Get database version in Rails

    For one of my applications, I recently created a status report page which shows crucial information for debugging, including software versions, service connectivity and filesystem path writability. One of the items was a database version string, and the standard ActiveRecord interface does not support this concept. While version methods usually exist in the connection adapters,…

  • Combining DataTable’s Ajax and Javascript sources

    I often use DataTables as it provides a lot of out-of-the-box functionality for searching, ordering, paginating and use of Ajax data sources. However, using the server-side processing example means the HTML page will load, and then there is a short wait until DataTables fetches the data from the server using Ajax. This can make an…

  • Optimising index view performance

    I recently came across a scenario where my index views in Rails were taking a long time to render when there were large data sets. The problem stemmed having a lot of data presented that were from models/tables other than the primary model/table of interest. For example, an “asset” index view may have the following…

  • Calling a SOAP 1.1 Web Service using WS-Security and HTTPS

    I recently had to update an .NET application to enable support for calling SOAP 1.1 Web Services using the WS-Security UsernameToken support over HTTPS with a self-signed TLS certificate. In the end, I had to use a custom binding, since there wasn’t a built in one that suited my requirements; for example, basicHttpBinding supports SOAP…

  • Apache2 configuration for Rails

    I recently had to stand up a Rails production server that used Apache2 as a reverse proxy. While it was relatively easy proxying requests to the Thin server using ProxyPass, assets would not show up, even with a DocumentRoot specified. It seems that ProxyPass proxies all requests, and the configuration needs to specifically ignore proxying…

  • HTML5 presentation with motion background

    I was recently looking for a way to present our church’s worship lyrics on top of a motion background. I naturally turned to PowerPoint, but quickly found out that the only way to achieve a seamless transition between slides is to combine all the lyrics on a single slide and use animations to show and…

  • Selecting string literals in Rails 4 using PostgreSQL

    I recently ran into an issue with Rails 4 using the PostgreSQL adapter (MRI) where selecting a string literal in a query would return a warning about an unknown OID. This can be reproduced by running the following in Rails Console: This occurs both with and without column aliases. 705 is PostgreSQL’s code for an…

  • Nokogiri XML schema validation with multiple schema files

    When using Nokogiri to validate an XML document against multiple XML Schema files using import declarations, ensure that you use File.open rather than File.read as shown in the Nokogiri::XML::Schema documentation. This will allow Nokogiri to navigate to and read these imported schemas. Thanks to this StackOverflow post. a.xsd b.xsd example.xml validate.rb

  • Financial Comparison of Air Conditioners

    I’ve been looking to get ducted AC installed at my residence and have had a few quotes come in. As the AC units, zoning and controls came with a similar set of features, I investigate the decision from an objective financial standpoint by ranking the offerings by comparing both the capital and operating costs. The…

  • Selecting by Option Value using Capybara

    Capybara’s select command allows searching a HTML select field and selecting an option that matches the supplied value by name, id or label text. Additionally, the match option allows the user to indicate the behaviour if more than one option is found. For example, match: :first will select the first item out of multiple matches,…