You're reading a blog by Arkency , a Ruby on Rails development shop.

Gulp - a modern approach to asset pipeline for Rails developers

Rails asset pipeline is one of things that makes Rails great for creating simple applications fast. It solves a big problem of serving our assets efficiently in both development and production environment.

While being very useful, Sprockets has its age. There is a rapid growth of technologies around JavaScript. A growth which often cannot be used in an easy way by Rails developers. There are good technologies for code modularization, languages transpiled to JS, CSS preprocessors and much, much more. Those technologies are easy to use in Node.js-based stacks, but not in Rails.

Rails asset pipeline has a big advantage of being painless to use. We do not need to configure anything to have our assets served or precompiled. There is a built-in file require system to help us split our code into files. In bigger frontend codebases we’d live happier with more sophisticated solutions - and we cannot throw away a legacy that Sprockets have. How to live with both CommonJS and Sprockets require system? How to optimize our compilation steps? Sprockets is implicitly doing its job - and that’s great until you want to have something more.

Fortunately, asset serving is a low-hanging fruit when it comes to decoupling parts from Rails. You can easily remove all asset serving responsibilities from Rails and use a modern build system like Gulp to compile your assets.

In this blogpost I’d like to show you how to replicate major part of Sprockets responsibilities in 82 lines of JavaScript code, with ability to use CommonJS and modern technologies straight from npm. As a bonus this 82 lines will also generate source maps for your CoffeeScript and Sass.

continue reading →

Stream pagination in Greg's Event Store

Every stream in Event Store is represented as a paged feed. This is because reading from streams based on an AtomPub protocol. A paged feed is a set of feed documents where each document contains some part of a whole data. This is very useful solution when the number of information is very large. So basically in the ES reading a stream is a process of collecting events in small portions. You can find some information about this feature in main Event Store’s documentation but in my opinion It is described very briefly. So this is why I decided to write this blog post.

continue reading →

Tracking down unused templates

Few days ago, my colleague raised #sci-fi idea. Maybe we could somehow track templates rendered in application to track down which ones aren’t used? Maybe we could have metrics how often they’re used? Metrics? That sounds like gathering data using We have already installed Chillout gem in other project I work at.

continue reading →

Explaining Greg's Event Store

Event Store is a domain specific database for people who use the Event Sourcing pattern in their apps. It is a functional database which based on a publish-subscribe messages pattern. Why functional? It uses a functional language as its query language. In ES It is the Javascript. I will say something more about this later. The lead architect and designer of Event Store is Greg Young who provides commercial support for the database. I decided to create this two-part tutorial to bring the idea closer to you. I will describe issues related to Event Store in the first part and I will present some simple examples of the ES usage in the second one.

continue reading →

Why use Event Sourcing

Event Sourcing relies on not storing current state. All of application state is first level derivative out of facts. That opens completely new ways of architecting our applications.

But why?

There is a lot of reasons to use Event Sourcing. When you browse through Greg Young’s and other articles & talks you will find most of them. Usually they mention:

  • It is not a new concept, a lot of domains in real word works like that. Check out your bank statement. It’s not the current state - it is log of domain events. Or if you are not still convinced talk to your accountant ;)
  • By replaying an event we could get a state of an object (or let’s use correct term here: aggregate) for any moment in time. That could greatly help us to understand our domain, why things changed and debug really nasty errors.
  • There is no coupling between the representation of current state in the domain and in storage.
  • Append-only model storing events is a far easier model to scale. And by having a read model we could have best of both worlds. Read side optimised for fast queries and write side highly optimised for writes (and since there is no delete here, it could really be fast writes).
  • Beside the “hard” data we also store user’s intentions. The order of events stored could be used to analyse what user was really doing.
  • We are avoiding impedance mismatch between object oriented and relational world.
  • Audit log for free. And this time the audit log really has all the changes (remember there is no change of state if there is an event for that).

Every database on a planet sucks. And they all suck it their own unique original ways.

Greg Young, Polyglot Data talk

For me the biggest advantage is that I could have different data models generated based on domain events stored in Event Store. Having an event log allows us to define new models, appropriate for the new business requirements. That could be not only tables in relational database. That could be anything. That could be a graph data model to store relations between contractors in your system with easy way to find how the are connected to each other. That could be a document database. That could be a static HTML page if you are building newest and fastest (or of course most popular) blogging platform :)

As the events represent every action the system has undertaken any possible model describing the system can be built from the events.

Event Sourcing Basics at Event Store documentation

You might not know future requirements for your application but having an event log you could build a new model that hopefully will satisfy emerging business requirements. And one more thing… that won’t be that hard, no long migrations, no trying to guess when something has changed. Just replay all your events and build new model based on the data stored in them.

If you are interested in pros and cons of Event Sourcing and another point of view on why to use it read Greg’s post from 2010 (I’ve said Event Sourcing is not a new thing):

Fast introduction to Event Sourcing for Ruby programmers

Many applications store a current state in these days. Although there are situations where we want to see something more than a current information about our domain model. If you feel that need Event Sourcing will help you here.

The Event Sourcing is an architectural pattern which allows as to keep information about object’s state as a collection of events. These events represent modifications of our model. If we want to recreate current state we have to apply events on our „clean” object.

continue reading →

Configurable dependencies in Angular.js

Photo available thanks to the courtesy of streetmatt. CC BY 2.0

Angular.js is often a technology of choice when it comes to creating dynamic frontends for Rails applications. As every framework, Angular has it’s flaws - but one of the most interesting features it has is built-in powerful dependency injection mechanism. Compared to Rails, it is a great advantage - to achieve similar results you would need to use external gems like dependor. Here you have this mechanism out of the box.

In my recent work I needed to learn Angular from scratch. After learning about providers mechanism, my first question was: Can I have a dependency and configure which implementation I can choose? Apparently, with a little knowledge about JavaScript and Angular it was possible to come with a very elegant solution of this problem.

continue reading →

You don't need to wait for your backend: Decisions and Consequences

Photo remix available thanks to the courtesy of mripp. CC BY 2.0

As front-end developer your part is often to provide the best possible experience for your application’s end-users. In standard Rails application everything is rather easy - user clicks on the submit button and waits for an update. User then sees fully updated data. Due to async nature of dynamic front-ends it is often missed what happens in the ‘mid-time’ of your user’s transaction - button is clicked and user waits for some kind of notification that his task is completed. What should be displayed? What if a failure occurs? There are at least two decisions you can take to answer those questions.

continue reading →

Use your gettext translations in your React components

Photo remix available thanks to the courtesy of miguelb. CC BY 2.0

In one of our projects, we are using gettext for i18n. We were putting Handlebars x-handlebars-template templates directly in Haml templates to provide translated views for frontend part - all translations were made on backend. Recently we have rewritten our frontend to React and decided not to use ruby for translations anymore.

continue reading →

How to split routes.rb into smaller parts?

Each application created using Ruby on Rails framework has a routing engine and config/routes.rb file where we define routes paths. That file very often becomes very large in the proces of development. Each additional line makes the routing file harder to maintain. Also, searching for specific paths during the development phase becomes increasingly difficult. Currently, I work on an application in which the routing file contains about 500LOC. Quite a lot, isn’t it? The solution is very simple. All you need to do is split the file into a couple of smaller ones.

continue reading →

The Beginners Guide to jQuery.Deferred and Promises for Ruby programmers

Working with asynchronous code is the bread and butter for frontend developers. You can find it hard when working with it at first - as a Rails developer, you live with code which is usually synchronous. Luckily, promises were something which allowed us to get a huge step forward to deal with callbacks in a sane way. While widely adopted by backend JavaScript developers, Promises and their tooling is something often missed by Rails devs.

It can be different - and you have all important libraries bundled by default in our Rails app. Let’s see what jQuery can offer you here - and I’ll discuss how I managed to solve typical async problem with features that jQuery provides.

continue reading →

Ruby Exceptions Equality

Few days ago my colleague was stuck for a moment when testing one service object. The service object was responsible for a batch operation. Basically operating on multiple objects and collecting the status of the action. Either it was successful or failed with an exception. We couldn’t get our equality assertion to work even though at first glance everything looked ok. We had to dig deeper.

continue reading →

It's easy to miss a higher level concept in an app

Just yesterday, I finished reading Understanding the Four Rules of Simple Design written by Corey Haines. I definitely enjoyed reading it. The examples are small, understandable and a good starting point for the small refactorings that follow. It’s a short, inexpensive book, but dense with compressed knowledge, and I can only recommend buying it. You can read it in a few hours, and contemplate it for much longer.

One of the examples inspired me to write this blogpost about higher level concepts. What does that even mean? Especially in terms of programming?

continue reading →

The categories of validations

There are many reasons why rails changed the landscape of web development when it was released. I think one of the aspects was how easy it was to communicate mistakes (errors) to the user. Validations is a very nice convention for CRUD applications. Over time however, many of our active record objects tend to grow in terms of validations. I think they fit at least into a few categories (probably more).

continue reading →

Don't forget about eager_load when extending autoload paths

I am sure you know about config.autoload_paths. A setting which allows you to add aditional directories (besides app/* which works out of box) that can be used for placing your .rb files. The documentation mentions a config.autoload_paths += %W(#{config.root}/extras) example. But the most common way to use it is probably to add lib directory (especially after the transition from rails 2 to rails 3).

Another (maybe not that common) usecase is to have some components (such as notification_center for example) in top-level directory. To make it possible for them to work with your app people are usually using:

config.autoload_paths += %W( #{config.root}/notification_center )


config.autoload_paths += %W( #{config.root}/notification_center/lib )

And it is all cool except for one thing they might have forgotten to mention to you. How it all works in production and what you can do to make it work better.

continue reading →

Frontend performance tips for web developers

Optimization has always been a tough topic. Donald Knuth said that premature optimization is the root of all evil. Performance is something that always causes emotions in web community. When we need it, we tune up our applications, try different and new servers, use load balancers, speed up our applications by playing with threads and processes, but sometimes we forget about frontend at all. Server side is important too, how if we need to provide fast-responding websites, we have to optimize them in our browsers as well. In this article I’d like to focus on client side and how to efficiently deliver content to end user.

continue reading →

How to start using Arrays in Rails with PostgreSQL

So far we covered a lot of PostgreSQL goodness. We’ve already talked about using uuid or storing hashes in our Rails applications with PostgreSQL database. Now is the time to do something in the middle of these topics (more complex than uuid, but easier than hstore) - we want to store list of simple values under one attribute. How can we do that? You may think “arrays” right now and you are correct. Let’s see how we can achieve that.

continue reading →

React.js and Dynamic Children - Why the Keys are Important

Recently I’ve been building a pretty dynamic interface based on google analytics data for one of our customers. There was a bug that I couldn’t quite figure out because of my wrong understanding of how react works. In the end it turned out to be a very easy fix and very important lesson on understanding react.js.

It is even pretty accurately described in react documentation however without showing what will go wrong and what kind of bugs you can expect if you don’t adhere to it. In other words, the documentation explains the right way but without going much into details about why.

continue reading →

Adapters 101

Sometimes people get confused as to what is the roles of adapters, how to use them, how to test them and how to configure them. Misunderstanging often comes from lack of examples so let’s see some of them.

continue reading →

Concurrency patterns in RubyMotion

The more we dive into RubyMotion, the more advanced topics we face with. Currently, in one of our RubyMotion applications we are implementing QR code scanning feature. Although it may seem already as a good topic for blogpost, this time we will focus on concurrency patterns in RubyMotion, because they are a good start for any advanced features in iOS like this 2D code recognition.

continue reading →

Burnout - do you need to change your job?

I’ve been reading recently a story on Hacker News about a programmer who (depending on who you ask for a diagnose in the thread) was suffering from burnout. Some commenters even suggested depression. There were many advices recommended (unfortunatelly I can’t find a link to the discussion right now) but one certainly spot my attention.

continue reading →

Truncating UTF8 Input For Apple Push Notifications (APNS) in Ruby

When sending push notifications (APNS) to apple devices such iPhone or iPad there is a constraint that makes implementing it a bit challenging:

The maximum size allowed for a notification payload is 256 bytes; Apple Push Notification Service refuses any notification that exceeds this limit

This wouldn’t be a problem itself unless you want to put user input into the notification. This also wouldn’t be that hard unless the input can be international and contain non-ascii character. Which still would not be so hard, but the payload is in JSON and things get a little more complicated sometimes. Who said that formatting push notification is easy?

continue reading →

SSH authentication in 4 flavors

We are connecting with remote servers every day. Sometimes we explicitly provide passwords, sometimes it just happens without it. A lot of developers don’t care how it works internally, they just get access, so why to bother at all. There are a couple ways of authentication, which are worth to know and I’d like to present you them briefly.

continue reading →

Using ruby Range with custom classes

I am a huge fan of Ruby classes, their API and overall design. It’s still sometimes that something surprises me a little bit. I raise my eyebrow and need to find answers. What surprised me this time was Range class. But let’s start from the beginning (even though it is a long digression from the main topic).

continue reading →

Hidden features of Ruby you may not know about

How well do you know the language you’re using? What if I tell you that even you use it the whole day and every day it still can hide some tricks that you might not be aware of? I’d like to reveal some less or more known, but certainly interesting parts of Ruby to make you sure that you don’t miss anything.

continue reading →

6 front-end techniques for Rails developers. Part I: From big ball of mud to separated concerns

Photo remix available thanks to the courtesy of Clever Cupcakes. CC BY 2.0

Current trends in web development forces us to write more and more front-end code in our applications. Single Page Applications, content changes without refreshing, rich user experience using custom controls - all those requirements needs you to write code. And this code, as any other code, can quickly turn into a big ball of mud. It can happen when you lack proper tools in your toolbox to design it correctly.

In this course I want to share with you techniques and tools we’re using in our day-to-day work. Some of those allow you to create easier, more testable code. Some of those allow you to develop it faster, without losing quality. I believe it’s really worth to try these techniques and choose which suits you most.

In the part one, I want to present you a simple case of refactoring of a badly written front-end code to a stand-alone micro-app with proper encapsulation.

continue reading →

Why we use React.js in our Rails projects

Source: Subramanya Prasad

Programming interactive user interfaces using JavaScript might be a tough task. User calls some action and we need to update his view - manipulating DOM using tool like jQuery. It just doesn’t feel good enough to modify document’s elements by hand. It is also really hard to re-use already written parts of UI and compose them with each other.

Imagine if there was one tool, that would solve all these problems and help you deliver your front-end much faster. What if you didn’t have to worry about this whole DOM stuff when you just want to update the view?

How would you feel being as efficient as when developing your Rails backend, when it comes to user interface?

Here comes React.js!

continue reading →

4 ways to early return from a rails controller

When refactoring rails controllers you can stumble upon one gottcha. It’s hard to easily extract code into methods when it escapes flow from the controller method (usually after redirecting and sometimes after rendering). Here is an example:

1. redirect_to and return (classic)

class Controller
  def show
    unless @order.awaiting_payment? || @order.failed?
      redirect_to edit_order_path(@order) and return

    if invalid_order?
      redirect_to tickets_path(@order) and return

    # even more code over there ...

So that was our first classic redirect_to and return way.

Let’s not think for a moment what we are going to do later with this code, whether some of it should landed in models or services. Let’s just tackle the problem of extracting it into a controller method.

continue reading →

Code style matters

Have you ever wondered how your code looks? Exactly - no what it does or even how it is organized, but actually how it looks. One may think here “oh screw it”, but I want to present that it can matter and show you my various thoughts about that topic.

continue reading →

Developer matters

Have you ever wondered what does your regular workday look like? Do you have the same daily habits? So how is it going? Breakfast, coffee, daily standup, reading mails, some work, off-topic talk with coworkers, dinner, some work and the day is over? If you follow these chain (not necessary in the same order) it is important signal that things must change. Not tomorrow, but right now.

continue reading →

RubyMine basic navigation features (that make you move around code fast)

  • jump to callback definition
  • jump to field from schema
  • jump to accessor definition
  • jump to association declaration
  • select jump destination from multiple implementations of methods
  • jump to method defined in ruby gem

Microservices - 72 resources

Microservices - everyone talks about them nowadays. There’s no common understanding however what they are. I’ve been researching this topic for a while, gathering and evaluating articles, presentations and conference videos.

continue reading →

Service objects as a way of testing Rails apps (without factory_girl)

There’s been recently an interesting discussion about setting up the initial state of your tests. Some are in favor of using built-in Rails fixtures (because of speed and simplicity). Others are in favor of using factory_girl or similar gems. I can’t provide definite numbers but judging based on the apps that we review, in terms of adoption, factory_girl seems to have won.

I would like to present you a third alternative “Setting up tests with services” (the same ones you use in your production code, not ones crafted specifically for tests) and compare it to factory_girl to show where it might be beneficial to go with such approach.

continue reading →

From Rails to RubyMotion: basic toolkit

Have you noticed the tendency that development is moving strongly towards mobile? There are more and more projects with mobile companion, there are a lot of just-mobile software houses, and there are even only-mobile projects. What if a company has only web developers specialized in Ruby, but want to be really full-stack? Doesn’t matter, with Ruby, it can still goes mobile!

continue reading →

Real-time Web Apps

From the very beginning web pages were just static. Internet browsers received some HTML code to render and displayed it to user. When someone wanted to check if there are any news on our page, he had to refresh it and then some new data might appeared. Time to change it.

continue reading →

Effective async communication

What we mean by working asynchronously is not to always work async, to avoid meetings and video calls at all cost. But to rather prefer async way of communicating when it is favorable, when you are sure that sync discussion wouldn’t bring you much more. At first you might think that it is almost never but if you keep pushing yourself a little bit you will soon start to realize that you are getting better at it. In fact now we have much more async discussions than sync discussions.

continue reading →

Async & remote - toolbox

I’ve been speaking recently at a local IT entrepreneur meetup about remote work and about the ways a company can transition towards being more remote.

The part of the talk that seemed to be most interesting was the toolset that we’re using at the moment. I thought I’d share this list here, as well.

Remember, that tools should just support your process and not replace it. If your goals are clear to you and your team, then the tools are just implementation details.

continue reading →

Mastering Rails Validations: Contexts

Many times Rails programmers ask How can I skip one (or more) validations in Rails. The common usecase for it is that users with higher permissions are granted less strict validation rules. After all, what’s the point of being admin if admin cannot do more than normal user, right? With great power comes great responsibility and all of that yada yada yada. But back to the topic. Let’s start with something simple and refactor it a little bit to show Rails feature that I rerly see in use in the real world.

continue reading →

The biggest obstacle to start with Continuous Deployment - database migrations

Photo remix available thanks to the courtesy of Mark Engelbrecht. CC BY 2.0

There are still companies which disable the website during deploys with database migrations and believe that db migrations prevent them from going fully with CD. They even have time window for triggering such activities (usually early in the morning or late at night).

If you are working in a place like that, and you would deeply want in your heart to adopt Continuous Deployment but you can’t find a way to convince your boss, this is a step by step guide for you. Instead of going from zero to warp nine, you can go towards your goal with small steps that can be part of your current, normal tasks that you are doing for the client.

continue reading →

Zero uptime deploy

Photo remix available thanks to the courtesy of Rob Boudon. CC BY 2.0

Unicorn has a nice feature that bought it a lot of popularity and set standards for other Ruby web servers: The ability to do Zero Downtime Deploy, also known by the name rolling deploy or rolling restart aka hot restart. You start it by issuing USR2 signal. But here is something that most websites won’t tell you. It can fail and you won’t even notice. You will be thinking that everything went ok, living in Wonderland, whereas in reality your deploy achieved uptime of exactly 0 seconds.

So what you need is a small verification procedure that everything worked as expected. This article will demonstrate simple solution for achieving it in case you are using capistrano for deploying the app. However you can use very similar procedure if you deploy your app with other tools.

continue reading →

Don't call controller from background job, please. Do it differently!

Photo remix available thanks to the courtesy of francescomucio. CC BY 2.0

Some time ago while doing Code Review for one of our clients I stumbled on a very unexpected piece of code. Background job calling a controller.

class OrderPdfJob
  def self.perform(order_id, locale)
    controller =
    pdf = controller.generate_pdf_for_order(order_id, locale)
    OrderPdf.create file: pdf, order: order
    # ...

class PdfController < ApplicationController
  skip_before_filter :authenticate_user!

  def generate_pdf_for_order(order_id, locale)
    # ...

I was a bit speechless. Calling controller out of HTTP request/response loop sounds like an odd thing to do. I had to investigate and refactor.

continue reading →

2 ways to deal with big and complicated features

Photo remix available thanks to the courtesy of EladeManu. CC BY 2.0

From feature vision to stories

One of the challenges of managing software projects is delivering big features. We already told you that we prefer to work with small, prioritized and unassigned stories that anyone can take and finish. But how do any up there? Especially, if what the customer comes to you with, is a big document, describing the features that you must implement.

continue reading →

Sitemaps with a bit of Metal

Photo remix available thanks to the courtesy of tinkerbrad. CC BY 2.0

Sooner or later, you will probably start taking care about your application’s SEO, especially if it provides a lot of content and you want to be discovered by users in search engines results. There are several ways to do this in your Ruby app. You can create sitemap.xml file manually if there aren’t very much urls, but it will become pretty ineffective when you have more than a dozen or so. There are some very neat tools which will do this for you out of the box, even if you need a lot of customization.

continue reading →

Pretty, short urls for every route in your Rails app

Photo remix available thanks to the courtesy of Moyan Brenn. CC BY 2.0

One of our recent project had the requirement so that admins are able to generate short top level urls (like /cool) for every page in our system. Basically a url shortening service inside our app. This might be especially usefull in your app if those urls are meant to appear in printed materials (like /productName or /awesomePromotion). Let’s see what choices we have in our Rails routing.

continue reading →

37 signals was not lying, you win by being remote

There is such moment in developer’s life when you start looking for a new job, sooner or later. You can observe that even in Poland, there are plenty of Ruby on Rails job offers, often in very perspective companies. I probably could find interesting job in Poznań, where I live, but there were some presumptions which pushed me to apply to Arkency.

continue reading →

Rails and SOA: Do I really need to have this big app?

Developing complex web applications (not particularly Rails apps) is a tricky task. You write your models, controllers, services and optimize application architecture iteratively. But even with the great architecture when your application starts to be huge, bad things happen. Every little feature you’ll add will cost you precious time - tests must pass on your CI and workers needs to be reloaded every time you deploy. In addition, you begin to realize that mental overhead with keeping modules separated is huge - you have to remember a lot of things to keep it in right fashion. Ultimately, working on a project is hard, TDD technique is inefficient to use and you’re not happy at all with your code.

Have something gone wrong? No. You just didn’t notice that you need more applications than just one.

continue reading →

CoffeeScript acceptance tests

You’ve already learned how to implement simple model and view tests, so as I promised now I’ll show you how you can introduce acceptance tests on client-side. We’re not too far from this goal - you know how to write test cases, make assertions and “click through DOM”. Let’s apply some abstraction then - to look at our app like the end user.

continue reading →

3 ways to do eager loading (preloading) in Rails 3 & 4

You are probably already familiar with the method #includes for eager loading data from database if you are using Rails and ActiveRecord. But do you know why you someties get few small and nice SQL queries and sometimes one giant query with every table and column renamed? And do you know about #preload and #eager_load which can help you achieve the same goal? Are you aware of what changed in Rails 4 in that matter? If not, sit down and listen. This lesson won’t take long and will help you clarify some aspects of eager loading that you might not be yet familiar with.

continue reading →

Developers oriented project management: Leave tasks unassigned

As with software, improving your company is an ongoing process consisting of multiple small steps. If you want your company to be more remote-friendly it is also not all-or-nothing decision. You can gradually start using techniques that will bring you closer to your goal. This series of blogposts is not about why you should go remote, but rather how. Also, we belive that those techniques will help you even if you are not planning to work remotely.

The first part was about having very small stories and how it helps everyone track progress and provides closure. Today we are going to talk about leaving tasks unassigned instead of delegating them to particular developers at the beginning of an iteration.

continue reading →

Services - what are they and why we need them?

Model-View-Controller is a design pattern which absolutely dominated web frameworks. On the first look it provides a great and logical separation between our application components. When we apply some basic principles (like ‘fat models, slim controllers’) to our application, we can live happily very long with this basic fragmentation.

However, when our application grows, our skinny controllers become not so skinny over time. We can’t test in isolation, because we’re highly coupled with the framework. To fix this problem, we can use service objects as a new layer in our design.

continue reading →

Throw away Sprockets, use UNIX!

The Sprockets gem is the standard way to combine asset files in Rails, but it wasn’t very straightforward to use in stand-alone projects, like Single Page Applications without backend, before the sprockets command was added.

Few weeks ago I realized that Sprockets solve the problem that has been already solved, but in a different language and in different era of computing.

Later I wanted to check whether my idea would actually work and started hacking. You can see the results below.

continue reading →

Developers oriented project management

Working remotely is still a relatively new thing compared to going to an office, which has centuries long tradition. Despite its tremendous growth recently (especially in IT industry), there is not a lot of literature about best practices and working solutions. We still miss patterns for remote collaboration.

Many companies try remote working, but fail at doing it effectively.

They go with the conclusion that it is a broken model. But the truth is, that working remotely is just different, and expecting it to be the same as stationary work, with just people in different places, is the biggest mistake that one can made about it. To fully benefit from it, one must learn how to get most out of it.

You need to learn how to embrace remote work, instead of working around it.

On the other hand, some companies are already there, when it comes to remote working. Or at least they think they are. But is there something more that we can strive for? More ideas that we can try and benefit from? Many of them.

continue reading →

CoffeeScript tests for Rails apps

You may know this pain too well - you’ve created rich client-side in you Rails app and when your try to test CoffeeScript features it consumes much time to run all test scenarios with capybara and any of browser drivers (selenium, webkit, phantomjs). Let’s apply painkiller then - move responsibility of testing front-end to… front-end.

continue reading →

Ruby and AOP: Decouple your code even more

We, programmers, care for our applications’ design greatly. We can spend hours arguing about solutions that we dislike and refactoring our code to loose coupling and weaken dependencies between our objects.

Unfortunately, there are Dark Parts in our apps - persistence, networking, logging, notifications… these parts are scattered in our code - we have to specify explicit dependencies between them and domain objects.

Is there anything that can be done about it or is the real world a nightmare for purists? Fortunately, a solution exists. Ladies and gentlemen, we present aspect-oriented programming!

continue reading →

Implementing worker threads in Rails

If you care about your application performance you have to schedule extra tasks into background when handling requests. One of such tasks may be collecting performance or business metrics. In this post I’ll show you how to avoid potential problems with threaded background workers.

continue reading →

The A Team

I work in Arkency for almost 4 years and lately I’ve started to think how it influences me. Working together is not only about delivering some good as a bunch of people - team has own identity, own culture. These days I decided to write down what I found out about my team for two reasons. First is just to see some day how it evolved over years - but that’s a good reason to write it in “My sweet diary”, holden under a pillow. I’m also inspired by great blog series “We are principled” by 8th Light.

continue reading →

Is it cute or ugly?

Yesterday day I presented a small code snippet to my dear coworkers (who I of course always respect) and (as usually) they were not impressed, even though I liked my solution. So I wanted to know your opinion about this little piece of code. Let’s start with the beginning.

continue reading →

Naming in OOP

There is a well known cite on naming in our industry:

“There are only two hard things in Computer Science: cache invalidation and naming things.” Phil Karlton

To be honest it’s not Computer Science specific issue, but common problem for whole science. History of science is composed of discoveries and evolution of definitions. Every math theorem is based on some definitions - I would call it “theorem dictionary”. There is also huge branch of philosophy aiming to figure out how our language infleunce on our thoughts. So I asked myself - how naming can influence my design. What can I learn from bad names?

continue reading →

Black-box Ruby tests architecture is distributed - currently just as few processes on same production server. As professionals we decided to prepare integration tests for each of application (maybe in terms of their business we could call them acceptance tests), but that wasn’t enough - we wanted to expose business scenarios that we’re actually aiming in. We achieved that with fully black-box tests. Curious how we did that? Read on.

continue reading →

Rails API - my simple approach

I have seen people using very different techniques to build API around Rails applications. I wanted to show what I like to do in my projects. Mostly because it is a very simple solution and it does not make your models concerned with another responsibility.

continue reading →

You don't inject for tests

What is unit testing for? Is it a way to make sure that your code is correct and bugless? Or rather OOD tool, that expose most of places where you break object orientation principles? You may have your own answer (please comment though) but I would vote for the second one - of course it may assure me that I haven’t introduced some totally stupid bug, but that’s less interesting part.

continue reading →

Blogging for developers

There are many possible blogging platforms out there to be used, yet we decided not to use any of them. It was a controversial decision even inside our own, small team. Before we started blogging there was a heated discussion whether we should use something that can quickly get you running so that when you feel in a mood for a blog post, there are no obstacles preventing you from writing. Or the alternative was to build something custom and have more control. We ended up using existing tools but put a little effort to combine them together into something that we like.

continue reading →

Sending async data from Rails into the world

Exceptions and business metrics. These are two common use cases involving delivery of data from our Rails application (or any other web application) to external services that are not so crucial and probably we would like to send them asynchronously instead of waiting for the response, blocking the thread. We will try to balance speed and certainty here, which is always a hard thing to achieve.

This is a series of posts which describe what techniques can be used in such situation. The first solution that I would like to describe (or discredit) is ZMQ.

continue reading →

JavaScript objects philosophy

As a web programmer you use JS from time to time or on daily basis. You probably know how to create and use objects, but don’t feel that approach is natural. It’s awful JS, right? No, it’s you and your lack of knowledge. Let’s see what object orientation in JavaScript mean.

continue reading →

Filepicker and Aviary - Image uploading on steroids

We all have been using the same code for uploading images for years, but didn’t you always feel that there is something wrong with it? For every other task like writing texts, picking a date, selecting from lot of choices we have a good tool that can help in implementing such feature and improve the user experience, but file uploads almost always feel a little broken. There are some Flash tools that might help, but they are still not good enough.

continue reading →