Check out my book
on server deployment

Running wkhtmltopdf in Vagrant (without X server)

Chances are you might need to run wkhtmltopdf on your server or in Vagrant environment (e.g. to overcome compatibility issue such as Cannot mix incompatible Qt library (version 0x50700) with this library (version 0x50701)). That way you need to be able to run it without an actual X server. Continue reading “Running wkhtmltopdf in Vagrant (without X server)”

Specifying parameters encoding by action in Rails

At work I needed to accept a Windows-1250 encoding in URL parameters on some actions in one of our Rails API endpoint. The problem is that Rails will scream at you since everything needs to come as UTF-8. Future! Unfortunately some 3rd party Windows software might be still in the past… at that time I was trying to find a way how to write a middleware or patch Rails’ ActionPack to handle this request and what I found was actually a commit that adds this to Rails in master. Continue reading “Specifying parameters encoding by action in Rails”

Using Ruby gems in Java/Gradle projects with JRuby

Let’s have a quick look on how to reuse our Ruby code and gems in Java leveraging the awesome work of JRuby guys. What we need is Java, Gradle and JRuby installed and we are ready to rock. Continue reading “Using Ruby gems in Java/Gradle projects with JRuby”

Comparing wkhtmltopdf to Prawn for generating PDF in terms of speed, memory and usability

HTML-to-PDF or Prawn? Let’s look how these compare by generating an invoice using PDFKit and InvoicePrinter and examine performance, memory and usability. Continue reading “Comparing wkhtmltopdf to Prawn for generating PDF in terms of speed, memory and usability”

Creating staging and other environments in Rails

Ruby on Rails come with three environments by default – development, testing and production. But sooner or later one has a need for staging environment. And don’t get me wrong, you can (or should?) use the production settings there, but if you run it locally or on the same server as production, chances are you need a different database. And while you are at it, it may be handy to allow logging to console or change any other of Rails settings for that matter. In fact you can create as many other environments as you want and since it’s really easy I encourage you to do so. Continue reading “Creating staging and other environments in Rails”

InvoicePrinter: generate PDF invoices and receipts in seconds with pure Ruby

They are many options how to generate PDF versions of your invoices in Ruby and the ones that do not come with system dependencies are often built on top of Prawn library. InvoicePrinter is no different. Here is a short announcement on what it is (and aims to be) and what not. Continue reading “InvoicePrinter: generate PDF invoices and receipts in seconds with pure Ruby”

Building and consuming JSON API with Crystal

When I firstly heard about Crystal language, I got really exited. It fixes exactly four problems I sometimes have with Ruby; types, speed, memory consumption and compilation to machine code. After many months silently following its development I decided to try it out for a simple program I need — a simple server standing between Google Maps API and my application to catch the geocoding responses in local Redis instance not to hit the limit imposed on using the service (plus, Google suggests you to do it anyway). Continue reading “Building and consuming JSON API with Crystal”

Allowing Nginx to use a Puma/Unicorn UNIX socket with SELinux

If you are deploying Ruby web application on Fedora with Puma (or other) application server and Nginx web server as a proxy, you might encounter SELinux forbidding Nginx to use the Puma socket. Here is how to create a SELinux policy module that you can use during your server provisioning.
Continue reading “Allowing Nginx to use a Puma/Unicorn UNIX socket with SELinux”