What's on the blog?

“mix release” and missing dependencies

When you use Elixir releases to deploy your application, you may find yourself in a situation where not all of the compile-time dependencies are included in the release.

The misunderstanding of “let it crash”

If you are programming in Erlang, Elixir or any other of growing number of languages that run on top of BEAM VM, you probably heard about “let it crash” philosophy.

Refactoring Phoenix controllers

Phoenix framework is a web framework for Elixir programming language, which became the go-to set of libraries when we start new project for our clients. It’s performant and robust, flexible and has sane defaults - we enjoy working with Phoenix a lot.

Composing Ecto queries: filters and preloads

Let’s say you have a simple blog system. It’s written in Elixir, uses Ecto (v3.x) and you have the following schemas: Post, Author, Comment, Tag and Tagging.

React Hooks

Ever since the release of React 0.14 in October 2015, developers have the ability to choose between the two types of components: functional and class ones.

Polish Up your JavaScript #02: Adding React

In the previous post we have set up working development environment with Babel 7 and Webpack 4. Look there if you haven’t set it up just yet, and download our example repository for code examples.

How to configure and deploy an Elixir app to a VPS, part 2

Some reasonable DevOps to keep your Elixir app running. This is a follow up to deploying an elixir app to a VPS.

Polish Up your JavaScript #01: Setting up development project with Webpack

I have been doing programming, both front-end and back-end for a good while (over a decade), but recently I realized I need to pay more attention to what I am doing, and what I should be doing on the front-end side of things. It’s not the same JavaScript I started writing in 2006 anymore, and things are moving super fast. I am taking some notes for myself and others like me. I hope you find this series useful!

Elixir: Runtime vs. compile time configuration

Elixir is a compiled language, but when you work with it - it behaves like interpreted language. The whole development workflow of typical Elixir project is very similar to the workflow employed in Ruby projects. You write some code and you run it.

When web requests fail in Elixir and Phoenix

I love Elixir language and Phoenix framework. It is so good, that we switched our consultancy entirely from writing Ruby on Rails to Elixir (and Phoenix), and we recommend it to our customers in majority of the cases for both: traditional applications and signle-page app back-ends (we love GraphQL too!).

Executing raw SQL queries in Elixir

Ecto is pretty awesome. It will do just fine for majority of db-related tasks in Elixir applications. Sometimes, however, you want to - or need to - use SQL directly. If you use PostgreSQL, you can use underlying driver for Elixir: postgrex. This will come in handy when something you want to achieve in Ecto turns out to be difficult or unsupported. Examples that come to my mind are: connecting to databases on the fly as application is running, enforcing use of single connection to perform series of queries or using some more exotic SQL features implemented using PostgreSQL, that are not generic enough to find it’s support in Ecto. The same applies to MySQL/Mariadb. From time to time you will want to directly use mariaex.

When to use Elixir language?

Major part of my job is what you would call business development. I reach out to customers, but I also receive e-mails and inquiries about projects. Since we switched from Ruby to Elixir as our tool of choice a couple of years ago, I have been asked many times “Is Elixir the right tool for the job?”, “Should I use Elixir over Ruby/Node.js/.Net/Java?” or “What types of projects Elixir is a good fit for?”. Over two years ago, I tried answering some of these questions in a blog post already published on this web site, but that is a long time in evolving world of Elixir and things did change a lot, including our experience with Elixir in production. Let’s re-evaluate these questions and see when Elixir is a good fit in 2018.

Elixir, Phoenix, CSRF tokens and gloomy foreteller

Let’s pretend you want to write a really simple foreteller in Phoenix/Elixir. You don’t want to use any helpers to write a form. It could look something like this:

(Ab)using Ecto as Elixir data casting and validation library

How do you create a “tableless form” in Elixir & Phoenix? The kind of form that is not backed by a database table, think contact form. Or maybe it’s backed by multiple database tables - think registration form.

Structuring Elixir projects

The way you organize source code in your projects has significant impact on the ergonomics of working with it. This is especially true as the project grows bigger in size and functionality. Properly structured project will make refactoring and changing functionality easier. A big ball of mud - will make your job more difficult.

Connecting Ecto to PostgreSQL with SSL

PostgreSQL has native support for secure SSL connections, and - if available - it’s a good idea to use this feature. Moreover, some hosted PostgreSQL providers, such as Google’s Cloud SQL do require that you establish your connections not only with SSL enabled, but also in a way that verifies identity of both: client and server during the process.

Trying out upcoming Elixir releases

There are really cool upcoming features in next Elixir release. This sentence is true no matter which one is the upcoming release, in my experience ;). It would be awesome to - on occasion - try some of these out. The upcoming v1.6 release has an Elixir code formatter built in, and you will need it if you want to cut the code formatting discussion now with mix format.

Elixir :applications vs :extra_applications - a guide

I have seen many people (myself included) being confused about the usage of :applications vs :extra_applications in their mix.exs files. Why both these options are present? When to use one and when another? Do I really need to specify any of my dependencies? Let’s clarify it.

Why you should not build your start-up as Single-Page Application?

The year is almost 2018, and you are thinking about building your start-up. You want it to be modern, snappy, an app that your clients will love to use and use because they love it. You want to build a Single-Page Application (SPA) that will make it all better - for you and the user. It’s almost 2018 in the end, right? Not so fast, there are things you need to know first.

Time zones in PostgreSQL, Elixir and Phoenix

Handling time zones is hard in any environment I worked with. Part of the problem is that time zones are political construct rather than geographical one, and as such - they change whenever authorities make such decision. This is happening more often than you think.

How learning Elixr made me a better Ruby developer

I write more functional code, avoid mutating data and side effects in methods, do not shy away from (modern) concurrency primitives, I explored alternative deployment options.

How to configure and deploy an Elixir app to a VPS

In this guide we’ll go through a process of preparing our Virtual Private Server for a production package of our web application, building a release package using Distillery, deploying, and exposing it to the world via nginx web server. Some common troubleshooting is included too.

AmberCasts #3: TDD Elixir command-line application with ExUnit

Watch the screencast directly on YouTube

AmberCasts #2: Deploying Ruby on Rails application to Heroku using Docker

Watch the screencast directly on YouTube

AmberCasts #1 Ruby on Rails development environment with Docker and docker-compose

In this very first screencast (yay!) I will show you how to set up your local web development environment with Docker and docker-compose.

Elixir - different kind of promises

When I started using Rails, somewhere around version 1.2 in autumn 2006, I was attracted by many promises it made. Web development was supposed to be easier, faster and more fun - something a young Java & PHP developer like me instantly desired.

Continuous delivery with Git (hotfix by default)

Recently there has been shift in the way we organize code and do releases in one of our Ruby on Rails web projects. Previously, when we were introducing new major feature, we were going with pretty standard git-flow.

Redux Overview

A while ago I wrote a blog post comparing two approaches to the all new and shiny Flux architecture The comparison included reference implementation as described by its authors at Facebook and one of the many alternatives - the Reflux, created by Mikael Brassman. At the time, new implementations of the Flux pattern were springing up at an astonishing pace: Flummox, alt, Fluxxor, to name just a few of countless examples. At some point, one of the libraries started getting a lot of traction in the community and gained the status of a de facto standard. The library I have in mind is of course Redux, created by Dan Abramov. While many of the alternative libraries are still developed and can be a a great option to use in your application, there’s no doubt that Redux has become a weapon of choice for most of the React developers in need of a state management solution. In this post we’ll take a look at features that made Redux stand out from the crowd. We’ll also build a simple app to demonstrate how it differs from the alternatives. We’ll also learn about some good patterns that are not mandatory but can be very helpful for writing maintainable code.

Elixir vs. Ruby: catching method/function call errors

Elixir and Ruby look alike. This is very much understandable, since José Valim was involved in Ruby ecosystem before he switched to become a language designer and maintainer. Both languages are strongly and dynamically typed, share similar method/function/module definition syntax, and overall layout of source files is similar.

Rails Girls Bialystok 2016

In May, we had a pleasure to organize already 2nd edition of Rails Girls programming workshop in Bialystok. This year we decided to double the number of participants. We invited 44 women and 1 man who together with 15 mentors formed 15 groups (3 mentees and 1 mentor in each team).

Process name registration in Elixir

In Erlang and Elixir, process is something entirely different than operating system process. In simplest words: it is a hybrid between thread and and object. Ok, maybe that’s not that simple, let’s have a look at example of simple process:

Creating Elixir libraries as OTP applications

There have been good posts written about creating Elixir libraries already. One awesome recent post can be found here. It will walk you throught the process of writing, documenting and publishing your first Elixir library really well.

On migrations, JSONB and databases in general

This post was started as a polemic against some views presented by Rob Conery in his latest blog post, but grown a bit. Sorry. These things happen with blog posts!

How Elixir’s Ecto differs from Ruby’s ActiveRecord

At AmberBit we still mostly develop Ruby on Rails applications for our clients. For about a year now, however, we have been looking at Elixir programming language and it’s ecosystem, to help us solve problems that Ruby (and Rails) fail to address. We used Elixir with client’s projects already, and the experience was generally positive.

Translating existing Rails applications made easier

In the lifetime of most successfull Rails applications, comes a moment, when it will have to speak many languages. If a developer did not thought of such possibility at the very beginning of the project, that will cause some trouble and manual work. There are so many places where it was just easy and convenient to use static texts (most likely in English), that at this point this will imply digging through the source code and manually searching for strings. The most tedious part of whole translation process is ealing with dozens of views, controllers and mailers. That’s where most of the strings presented to the user live.

When to choose Elixir over Ruby for 2016 projects?

You are planning to build something in 2016, aren’t you? Some decisions have to be made, team to be hired. For a few years now you have been relying on Ruby (and Rails) for all your work and you have been reasonably happy. You have been hearing a lot about this new Elixir thing and considering giving it a shot? Let me tell you a bit more about it and help you make a good decision.

Using Repository pattern to migrate Rails app from MongoDB to PostgreSQL

At Amberbit, we have a legacy project which uses MongoDB. We’ve been working on it for few years now. Through this time it obviously grow and changed a lot and at some point we started focusing more on it’s performance. The biggest issue we had was that we were using mongoid and mongoid/moped, which not only caused memory leaks (rack mini profiler) but also had an impact on performance as we needed to run really complicated queries that non-relational database couldn’t handle well. That’s why we agreed on switching to PostgreSQL.

State Machines

When you’re working on an application you deal with many types of objects. For some of these objects it feels natural to think of them as being in one of a few possible states.

How to deploy Rails App on a VPS

As Ruby on Rails developers we get used to hosting our apps on platforms such as Heroku, which make configuration and deployment fairly easy. Sometimes, however, we want to have more control over server configuration and all of the steps of deployment, backup or monitoring. VPS providers like AWS EC2 or DigitalOcean droplets come in handy in such cases. Maintaining those may be not as simple as in case of Heroku, but there are few automation tools written in ruby (e.g. Capistrano, Chef) that make this task easier.

Rails Girls Bialystok 2015

Few months ago I had the opportunity to be a part of the team that organized the very first Rails Girls Bialystok. The idea was to encourage women to become part of the IT community by organizing one of worldwide Rails Girls events.

Rails mountable engines

What is an engine? And a mountable one? In Rails world it’s just a piece of code, which plugged to existing application, extends its basic functionality. Good examples would be: ActiveAdmin, AmberBit’s Translator or Devise. Also Rails application is example of an engine.

Hold on, I know where it leads…

Just read it this time.

Flux vs. Reflux

The JavaScript community has been seeing a huge number of new technologies and tools in recent years. One of the current hottest topics is React, a library for building user interfaces, created and open-sourced by Facebook.

Sorcery + Google Calendar for multiple users

Recently I’ve been working on a Ruby on Rails project, which requires access to Google Calendars of multiple users. I decided to use Sorcery for registering users via Google and receiving access to their calendars. Unfortunately, it turned out that synchronizing calendars’ data was slightly more complicated than I initially anticipated. Here’s how I did it.

Closures: Elixir vs. Ruby vs. JavaScript

Closures in Elixir prevent nasty side-effects. Closures in JavaScript are the worst of the three (suprirse, surprise!). Ruby is slightly better thanks to functional elements in the language, but not perfect.

SEO basics for Rails developers

Search engine optimization (SEO) is the process of optimization of a website, which main purpose is to make it more visible among results from search engines (such as Google). There are tons of practices, tricks and tips that can be applied to improve a website in terms of SEO. Lets start with some basics.

Why Rails 5 / Turbolinks 3.0 / Action Cable matter, and why @dhh was right all along

Rails won the hearts of developers and entrepreneurs because it made creation of shiny web apps easy and fast. This is not the same experience you have when you build Single Page Apps using JavaScript frameworks (it tends to be way slower, and you end up with bunch of new problems to solve). Rails 5 might be good enough for you as it is.

5 Cool AngularJS libraries

At AmberBit we use AngularJS, and it is slowly becoming our second framework of choice after Rails. We won’t run away from Ember either, but Angular is significantly easier to pick up, and to introduce incrementally in existing projects. Oh, and there are some awesome libraries out there that make it even more productive.

10 skills that will make you a better Rubyist

So you are a Ruby developer? You write Rails code for living? That’s cool. But you know what, you can do much better if you learn at least some of these 10 skills.

Splitting monolithic Rails applications

At AmberBit we not only work on small MVPs or prototypes for emerging start ups. We have a solid base of long-term customers, and we have to support their application not for months, but for years. All applications tend to grow in time, and issues such as technical debt and bad architectural decisions can arise, and bide you after many months the mistake was made. There has been a lot of talk recently about making the applications more modular, to tackle this as well as other problems, such as performance. But how would one do that? I’ll explain you my approach.

Ruby - the bad parts

Some time ago I wrote a post highlighting some the Ruby features that I find to be its strong points. The list was by no means exhaustive. Such list would be really long, as I believe there are many things that Ruby got right.

Calling C/C++ from Ruby

We often come to the point, when we have to write enormously huge module in Ruby. But we simply don’t want to. Maybe because we’re too lazy/smart, or we do know that such library already exists written in C/C++. Implementing pthread or crypt library in pure Ruby sounds like reinventing the wheel. The other thing is well-written C code most likely will perform much better than any higher-level implementation. It takes advantage of pre compilation, better garbage collection or static typing.

Ruby - the good parts

Ruby is a programming language designed by Yukihiro “Matz” Matsumoto, with a focus on programmers productivity and fun. The author stated it himself many times in interviews and talks, such as Google Tech Talk in 2008: “I hope to see Ruby help every programmer in the world to be productive, and to enjoy programming, and to be happy. That is the primary purpose of Ruby language.”

Building and documenting API in Rails

These are really exciting times for web developers. New JavaScript frameworks emerge constantly, completely changing the way we think about building web applications. With libraries such as AngularJS, Ember.js or Backbone.js, the server is no longer responsible for generating complete pages. Its role is often reduced to serving as a backend for client-side application. This approach has many advantages. To name a few:

Putting Ruby on Rails on a diet

Ruby on Rails is our usual framework of choice to build web applications at AmberBit. It is good and easy to use, but let’s face it: it’s massive compared to more lightweight frameworks, such as Sinatra. Why is it bad? There are a few reasons and slow start-up time and high resources usage are just two most common concerns. Slimming down Ruby on Rails applications can allow you to use different components (say Sequel instead of ActiveRecord) and improve system security. Remember the last year’s security dramas related to JSON parameters parsing? It would be largely irrelevant for most applications if everyone who does not use it, disabled it.

Automate tasks on the web with Ruby and Capybara

Capybara is a tool that Ruby on Rails developers mostly use for testing their web applications. This tool, however, can be also used to automate boring/repeating/long running tasks on the web or scraping information from web sites that were not kind enough to provide API.

PostgreSQL awesomeness for Rails developers

PostgreSQL is the true awesome SQL database, that you should probably be using for your relational data in your Ruby on Rails applications. In fact, if you are using Heroku, you are quite likely using PostgreSQL already. If you are not using PostgreSQL, or just starting, you have no idea how awesome it is. In this post, I will walk you through some basics that all Ruby on Rails developers who use PostgeSQL should know about.

Torquebox 3, Rails 4 - zero downtime deployments on Ubuntu 12.04

Torquebox is JRuby application server based on JBoss. What’s an application server? It’s a bundle of web server, messaging queue, JRuby runtime and websocket infrastructure. It is pretty cool and we use it in AmberBit to deploy a few hight-traffic web applications we developed for our clients.

AngularJS templates and Ruby on Rails assets pipeline

Developing AngularJS and Rails applications is our favorite way to build web applications at AmberBit. Why Angular? Because it allows us to finally separate user interface from Rails back-end. The promise of building an API along with your application is also much easier to meet when combining both frameworks. Learn how to integrate views in those two.

Similar images detection in Ruby - Part 1

At AmberBit we develop Ruby on Rails web applications for clients that are start-ups in different areas. One of the clients required detection of near-duplicate images, which allowed us to explore the area of content-based image retrieval systems, existing commercial solutions, advanced algorithms such as SURF and computer vision libraries. We’re more than happy to share the knowledge in this multi-part blog posts series, but we’ll start small with simple solutions that might be just fine for you and Ruby on Rails application that you develop.

Building small sites with LocomotiveCMS and deploying to Heroku and GridFS

So you have a small site to build and host cheaply. Let’s user Rails. Let’s deploy to Heroku. Let’s build around Locomotive CMS. Let’s see how.

Render views and partials outside controllers in Rails 3

You probably heard that rendering views outside controllers is pure evil. That’s true, but there are cases where it is very handy to render partials or views defined in your Rails application in different places. Think about generating newsletter templates and saving them to database, or generating bits of static HTML that need to be saved to filesystem. You will learn how to do it from this article.

Ruby FLV pseudostreaming implemented with Sinatra and Rack::Evil

There are many ways you could implement FLV video streaming. The most “proper” way to do it is to use RTMP (Flash Media) Server, which you can purchase directly from Adobe. A few cheaper/free/open source alternatives exist. For me, most promissing one is Mammoth, but it’s still in early stage of development. However, most popular alternative is Red5, however I didn’t find it either easy to configure or being reliable at serving files. Some big guys are using it, but it takes time and experience to set it up and maintain properly.

Measuring complexity of Ruby 1.9 code with metric_abc

metric_abc is a tool that can help you find bad code in your Ruby 1.9 projects. It is much simplier cousin of Flog, but does the job in absence of Flog in Ruby 1.9 world.

GoTranslateYourself - Rails engine for managing web site translations

This gem has been replaced with translator. Please use instead!

Social networks application development with Rails and OpenSocial (part 1 - introduction)

Open Social is a standard for developing applications for social network sites that was introduced by Google. The standard was not welcomed with ecstatic applause, however more and more social networks started to embrace it. It evolved over time and today, Open Social is supported by such big players as MySpace, Orkut or VZ network. It’s basic competitor is framework used on Facebook, currently the biggest player on the market, and they share the same basic concepts and quite similar APIs, however not compatible.

Geospatial search with Ruby and Sphinx

Geolocation and geospatial search are hot topics and a lot of people start building web or mobile applications that use it. Companies like Qype are building up databases of points of interest (POIs), which include shops, restaurants etc. With the upcoming HTML5 standard additions, building such applications will be even easier. From this article you will learn:

Introduction to Rack middleware

Rack middleware is hot topic these days and anyone who is reading Ruby-related blog sites must have heard about it already. However, if you didn’t, here’s short quote from Rack site:

Want to get in touch about a project? Drop us a line!

When submitting the form, you are sending your personal information (including your name and e-mail as entered above) to contact@amberbit.com. AmberBit Sp. z o. o. is the receiving party, and a data controller, and will use the information you provided for the purpose of establishing relationship leading to possibly signing a services contract, and fulfillment of such contract only. We will not subscribe you to marketing lists, newsletters etc. You can read more about it in our Privacy Policy.