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 →
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 →
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 →
We've tried almost everything for our Rails frontends - typical Rails views, Backbone, Angular and others. What we settled with is React.js. In this post we're showing you, how we structure a typical React.js app when it comes to the files structure.continue reading →
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 →
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 →
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 →
This will be short, simple, but painless and useful. We'll show you how to integrate Facebook SDK with RubyMotion application.continue reading →
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).
Recently, my colleague at Arkency Paweł Pacana wanted to manage application process with upstart. He started with the previous article about upstart and finished with robust deployment configuration with reliable setup using… runit. He summarised upstart briefly: “so sudo” so I decided to extend my latest blogpost with some information about upstart user jobs.continue reading →
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 →
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 →
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 →
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:
class Controller def show unless @order.awaiting_payment? || @order.failed? redirect_to edit_order_path(@order) and return end if invalid_order? redirect_to tickets_path(@order) and return end # even more code over there ... end end
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 →
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 →
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 →
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 →
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 →
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 →
Have you ever wanted to run some of your ruby program as a background service? There are a couple ways to do that starting from simple
runit to complex services.
This tutorial is intended to give you a quick overview of
upstart, which is one of the possible solutions to run and manage your background processes.
Do you feel the need for a change?continue reading →
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 →
When you work remotely, you want to have some kind of a standup meeting regularly. In our team, after experimenting with many different approaches, we settled with text-based, asynchronous standups every day. Additionally, every project has a weekly 'sync' meeting.continue reading →
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 →
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 →
We are Arkency and we have been working remotely since the very beginning of our company in 2007. Remoteness is a core value for us. If you opened the email, I hope you are at least curios as to why and how to work remotely. I think it all starts with dream and vision.continue reading →
In my previous blogpost I showed you how Rails validations might become context dependent and a few ways how to handle such situation. However none of them were perfect because our object had to become context-aware. The alternative solution that I would like to show you now is to extract the validations rules outside, making our validated object lighter.continue reading →
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 →
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 →
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.
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 = PdfController.new pdf = controller.generate_pdf_for_order(order_id, locale) OrderPdf.create file: pdf, order: order # ... end end class PdfController < ApplicationController skip_before_filter :authenticate_user! def generate_pdf_for_order(order_id, locale) # ... end end
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 →
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 →
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.
Have you ever been stuck with some code? Looking at it for minutes, hours, feeling the code smells, but not being able to fix it?continue reading →
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
/awesomePromotion). Let's see what choices we have in our Rails routing.
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 →
Many times I have seen people including
Enumerable module into their
classes. But I cannot stop thinking that in many cases having methods
minmax and many others
that are available in
Enumerable are not
core responsibility of the class that is including them itself.
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 →
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 →
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
#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.
When working on any project (personal or professional) we are always confrontend with tremendous amount of tasks that bring us closer to the goal or let us finish the project (many, many times there is no such a thing as the end of a project, just years of long, ongoing, constant improvement of the process and code). There are two ways you can look at it…continue reading →
We recently talked how small and unassigned tasks can help you manage the risk in the project. In short: they help to guarantee that despite the obstacles people keep working on the most important things.
But to take most from such approach we need one more rule. Let's talk a little about it.continue reading →
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 →
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 →
In one of our projects we decided to try a lot of new things in the area of project management. One of the most beneficial change that I noticed was using very, very small task as the primary tool to assign and track work.continue reading →
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 →
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 →
As a consulting agency we are often asked to help with projects which embrace lots of typical Rails conventions. One of the most common of them is the usage of STI (Single Table Inheritance). It is even considered best practice by some people for some use cases [YMMV]. I would like to show some typical problems related to STI usage and propose different solutions and perhaps workarounds.continue reading →
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 →
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 →
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 →
If you're really serious about your application you have to collect and analyze its statistics. You can use Google Analytics or any other tool to track visits and basic events, or you can send specific events on demand. There's also a way to automatically track ActiveRecord model creations and in this post I'll show you how easy it is.continue reading →
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 →
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 →
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 →
In the old times everything was simple. You received a request, did some computation (or not in case of static page) and sent a reply. However what we do now is no longer that easy.continue reading →
Chillout.io 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 →
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 →
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 →
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 →
Yes, we have to be honest - we're doing content marketing for our product for Rails developers, but we want that content to be meaty and very useful. So today I'm gonna focus on basic functions of Google Analytics you could not know and how we use them on our blog and landing page.continue reading →
So today I started my day with reading recent posts on rails-core group and one post looked interesting to me: Add support for multiple, concurrent, connection pools. ActiveRecord and threads and multiple databases. What could possibly go wrong?continue reading →
There are many ways to install and manage ruby installation in your
infrastructure. Some people like
rvm, others prefer
rbenv, some pack
their ruby installation into
deb packages. We like nothing.
In this series of blog posts we discuss possible implementation options for sending data asynchronously from Rails applications. The two common use cases involve delivering exceptions and business metrics to external services.
The second part describes another two solutions: using Thin and classic threads. Read the first part if you have not done it yet.continue reading →
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 →
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 →