Category Archives: Technology

[rails] improving the performance of a query involving date-ranges

I have an audit-log table with +300M rows and while most messages are just confirming we performed some very repetitive action, I was thinking of an easy way to compress the data: when a month is over, instead of adding 1000 lines per day with the message “CHECKED IT”, replace them with 1 line saying […]

[mac osx] extracting photos from photos library

Before, with iPhotos it was pretty easy to extract files: just drag and drop and they would have the exact same date and time as when they were imported/taken. Now, with the Photos app, this is no longer the case. WTF. A dropped file gets the current date and time. While I can understand why […]

Using render-anywhere gem with partials

Normally in rails, you can only render views inside of the controller. But what if you want to render a view somewhere else? For instance we wanted to generate xml-files using views. Haml can be used to describe xml just as well as plain html. There is a gem called render_anywhere that allows just that. […]

[ruby] hate private methods? use protected instead

I started out writing something like the following: If I could change just one thing in ruby, I would change how private works. Aaarrgghh. For instance, I am trying to implement an equality of bounding boxes in ruby. I would presume I could write something like: class BoundingBox attr_accessor :xmin, :ymin, :xmax, :ymax def initialize(xmin, […]

[rails] store your settings in a model

Most of the times I use a config.yml to store application settings, that I want to be able to change quickly between environments, servers, deployments. But what with settings that need to be changed on the fly, by a user? I create a small model, with three fields. rails g model Setting name:string description:string value:string […]

Run rails 2.3.18 using ruby 1.8.7 on windows server 2012

For my current job we have two 2.3.5 rails sites, of which I already succesfully upgraded one to rails 4. For the other we still need to start the migration, and we were asked to install new windows servers to run the rails servers on in the meantime (let’s not digress why they choose windows, […]

max osx: computer does not go to sleep anymore?

I had this weird thing: it seemed, since my update to mavericks, that my macbook pro did not go to sleep anymore. Well, when on power supply, my computer never goes to sleep, but my display does. I know that some applications, like full screen video, make sure that the screen does not go to […]

complete coverage with SimpleCov

When using SimpleCov in a very ill-covered project, I got amazingly good results: SimpleCov just did not count not-covered files. So files that were never used in our test-suite, were just simply being ignored. While I understand that approach, it did not feel good. I want to measure absolute progress, and I want to know […]

tuning Geoserver on windows for production

I develop my website using a MacBook Pro retina, and deploy on windows. And I noticed that my Macbook Pro is a lot faster than the standard GeoServer install. I use Geoserver only to serve the WMS layers, vector data which is stored in postgis. So I needed to tune GeoServer on Windows for optimal […]

automatically handle StaleObjectError in rails 3.x

There are different reasons why a ActiveRecord::StaleObjectError would occur. Sometimes it is caused because rails does not have a stable identity map yet. This means that if the same object would be retrieved via different associations, your rails process would not know they point to the same object, would keep different copies of the same […]