Developing a Slack Bot in Elixir Phoenix

Developing Slack Bot in Elixir Phoenix.

Generating Image Thumbnail In Elixir Phoenix With ImageMagick

Thumbnails becomes inevitable part of the process when dealing with images. They provide us a way to give a peek through the original image which helps in building rich user experience in modern applications. In an internal productivity tool while building this experience, Our whole attachments feature was ready and we had found the only available option in Elixir/Phoenix ecosystem Thumbnex for generating thumbnails. Once we started integrating this library, we almost immediately got hit by following error: ** (ErlangError) Erlang error: :enoent (elixir) lib/system.ex:622: System.cmd("ffprobe", ["-show_format", "/var/folders/

Elixir - How to run Ecto queries from within a custom mix task

Reading Time: 4 mins While writing a custom Mix task in Elixir, I ran into minor challenges for running / executing an Ecto query to update a database table column from within my mix task. It was not straightforward initially thus I thought to share here. In this short article, we will also see how to pass arguments to our mix task to run dynamic query. First, what is Mix? Elixir documentation says: Mix is a build tool that ships with Elixir that provides tasks for creating, compiling, testing your application, managing its dependencies and much more. Mix build tool is

"Lambda" Behind Functional Programming

I have been writing code in Imperative programming languages for many years. Writing code in functional programming is a big shift and change in thinking. As I recently started with Elixir and when I was reading about Functional Programming, I keep reading mention of Lambda Calculus every time. That ignited my curiosity to brush up my computer science knowledge. As Functional programming languages implement Lambda Calculus(λ-calculus). If we understand how Lambda Calculus notation works from Computer Science perspective it will be easier to understand Functional programming. As nowadays most of the languages have implementation of lambda calculus may it

Upload files on S3 with Elixir/Phoenix using ex_aws

In one of our Rails 4 app, we decided to move file and image uploads to another microservice so that the load on server is reduced when a big file is uploaded. We decided to do this in Phoenix. In Phoenix, we have ex_aws package which makes file uploads to S3 very simple just like Rails. So lets get started. Add ex_aws Update mix.exs to include following dependencies. defp deps do [ ..., {:ex_aws, "~> 1.0"}, {:poison, "~> 2.0"}, {:hackney, "~> 1.6"}, {:sweet_xml, "~> 0.6"

Scaling Enterprise SaaS Platform with Microservices

Spoiler Alert: This article is not about Microservices architecture or how microservices works. In this article, I will share what we have learned in scaling one of the large SaaS platform, our ongoing improvements and how Microservices architecture is playing a key role in scaling this SaaS platform. This SaaS Platform has experienced tremendous growth in the past 18 months. It has now become one of the leading CRMs in North America. Everyone’s definition of “scale” and “growth” can differ based on specific numbers or metric a company is targeting i.e. revenue, user base, or others. We are

Heroku like Elixir deployment on Digital ocean.

Recently building few microservices and apps in Elixir and deploying it to heroku, we realised that heroku was not very cost effective for us and also we can't get into every nuts and bolt of how heroku manages our app. As a part of learning things related to deploying to our own server and to save some bucks we decided to look for other options and we decided to experiment deploying one of our app to Digital ocean. One thing we were worried about, was whether we can make deployment as easy as heroku makes it for us. After some

Understanding changesets in Ecto

Note: This article requires basic knowledge of elixir. If you are not familiar with I will encourage you to check the link Ecto is a database abstraction layer for elixir. It provides a domain specific language to interacting with your database. It is also intended for relational database much like Active record. But it share more traits with LINQ in how it generate queries. Ecto in many ways different from ORMs like Active record. Unlike Active record, which uses model as a direct interface to interact with database, Ecto has separate concern for querying (using Query module) and actually perform

Interesting feature of Elixir: Documentation as Tests

One of the coolest feature I came across in Elixir - our code documentation becomes our unit tests. I was amazed by its simplicity when I saw it in action in sample app I was writing. I feel this is one of the most incredibly and helpful feature I saw in any modern programming language in recent times. (Python has similar functionality using Python’s doctest.) Let me explain this by giving a quick demo using few simple examples: Math functions sum and multiply. Lets say this is our Maths module defmodule Maths do def sum(num1, num2) do num1

Constant in Elixir

Recently I was looking at various ways to create a constants in Elixir. I come from ruby background, where it is very easy to create and think of constant. You can create constant by assigning a value to constant name. Constant name should begin with capital letter in ruby. Concept of constant is bit twisted in ruby as we can reassign constant to different value. I_AM_CONSTANT = "though i can be reassigned :)" Ohh! Just remembered this is a post about Elixir and not Ruby. Being in love with Ruby, I can't stop talking about it. I guess