Adam Niedzielski

Programming is about people

Using message queue in Rails

| Comments

This post describes the application architecture pattern which is (in general) nothing new, but (from my experience) rarely applied in the Rails world. I’m talking about the nice and simple abstraction – message queue. But let me start by describing the goals I want to achieve and some alternative solutions.

10 easy-to-fix Ruby / Ruby on Rails mistakes

| Comments

Programmers make mistakes. Some of them are just annoying (for others to read) and some are really dangerous. Here is my selection of 10 mistakes done by Ruby / Ruby on Rails developers. These tips are easy to follow and can save you much time of later debugging.

My take on services in Rails

| Comments

It’s been a while since my last post. I was writing my engineer’s thesis which caused general disgust towards writing at all. Anyway, these sad times are over and here comes the shiny new blogpost about introducing service layer in Rails applications. It does not contain any breakthrough thoughts, but is rather a mixture of ideas I learned from great Ruby developers.

Using Lineman.js with AngularJS

| Comments

I’ve recently started playing with AngularJS. Coming from the Rails world I expected a structure enforced by the framework, good default configuration and separation into development, test and production environments.

It seems that the way to start a new project suggested by the creators of AngularJS is to clone angular-seed project. While this seed project worked for me during development and testing, I was a bit lost when it came to deploying to production.

Black-box testing

| Comments

This time I want to share my thoughts concerning two approaches to testing – black-box testing and white-box testing. I gave a talk about it at Lodz Ruby User Group. You can find the slides here.

The presentation took place some time before DHH’s keynote at Railsconf 2014 and before #isTDDDead discussion began. However, there is a connection: DHH encourages to write “higher level system tests” and in this post I express slightly more balanced opinion on black-box testing.

wroclove.rb 2014

| Comments

Here you can find a couple of my personal opinions about talks at wroclove.rb 2014 which took place in March 14th – 16th in Wrocław. I tried to keep my feedback 100% positive in order not to upset anybody, but if you are – write a comment and we’ll discuss.

Learn Chef - it’s hard but worth it

| Comments

Recently I’ve been forced by the circumstances to learn Chef. It’s simply not possible to manage about 15 servers without any automation tool. I’m not a master of shell scripting (neither I like it), so using Ruby in this field sounds great to me.

JSON API with rails-api and active_model_serializers

| Comments

This post is based on my presentation given at Lodz Ruby Users Group. The slides are here (in Polish).

Rails and JSON

Dealing with JSON in Rails is pretty easy and straightforward. The support is built into the framework, request data is automatically available in params hash. Then we just have to say render :json and we are done.

This may be sufficient if JSON is one of the formats which we use. For instance, we can render both JSON and HTML in the same controller action. Or we may create an action intended for AJAX call which changes some model and returns JSON with status field.

On the other hand, we may use Ruby on Rails for building JSON API – app with the assumption that JSON is the only format we support. In such a case we know that the app won’t render HTML. There is no View layer (or you can say that JSON is your View layer). We probably won’t need cookies support and the code specific to handling browser requests.

Fighting Paperclip Errno::ENOMEM error

| Comments

We are using Paperclip to handle image uploads in one of our applications and after migrating from 4 GB instances to a number of really small 512 MB instances we started to experience an error which looked similar to this:

Errno::ENOMEM (Cannot allocate memory - identify -format %wx%h '/tmp/stream20130201-23766-d5htny-0.png[0]')

This was rather weird – we are running one app instance on each server, so the amount of free RAM memory is not critically low. In fact it should be enough to run identify.