Lately, I am exploring the use of OCR in Expendere (my expense tracking application) and came across Tesseract OCR. At the time of writing this blog post, there is no native binding of Tesseract OCR in Elixir. However, there are two Elixir wrapper available on GitHub: tesseract-ocr-elixir tesseract-elixir Both wrapper use System.

Read More

TLDR: Use Phoenix.Controller.send_download/3 to send binary as download to your users. In Phoenix, there are a couple ways of to send file to your users. The most straightforward one is to programmatically create a file and send it to user using Plug.Conn.send_file/5. For example: def export(conn, _params) do # Create file filename = "test.

Read More

If you are like me, having countless side projects and jumping from one to another from time to time, you might also experience ending up losing track of what you should do on each side projects. Keeping track of tasks in all of your side projects isn’t easy without using any project management software.

Read More

Oracle database does not index a row if all the indexed columns are NULL For instance, let say we have a users table where we index role column to improve the query performance. SELECT * from users WHERE role IS NULL The index does not work for such query in Oracle database.

Read More

In the previous post, we had briefly discuss about the solution of Part 1. It is fairly straightforward. I thought Part 2 is going to be easy too. But man, I was wrong. It is a bit tricky. My initial solution takes around 17 seconds to compute the answer. I made it 34x faster by changing the data structure.

Read More

Advent of Code (AOC) 2018 has finally arrived. This is the first time I participate in AOC. Last year, when I first heard of AOC, I wanted to participate in it. But due to heavy workload from university, I just give up on doing it. This year, it’s different, I had graduated and working remotely.

Read More

Markdown is great for formatting our writing to be publish as HTML. If you’re a developer, you probably used Markdown before. README of GitHub repositories are mostly written in Markdown. While developing web applications, there will be static pages such as about page and FAQ page. Most of the time, we have to write it in HTML, which can be unpleasant.

Read More

It is interesting to learn things from scratch. Coming from Ruby background, I was curious what is the equivalent of Sinatra in Elixir. It’s called Plug. It is what Phoenix build on top of. Using Sinatra, we can write a quick and simple web server with the following code:

Read More

Starting from Elixir 1.4, we don’t need to specify our application lists in application. It is automatically inferred from our dependencies. (Check the release notes here) Do note that it only automatically infer the application lists if the :applications key is empty. If you had already declared your it in your mix.

Read More

Recently, I have been using jekyll to make notes. I use jekyll-compose gem to create post using command line. However, the auto open generated file features isn’t working in my machine after the setup. After a few times on manually opening the generated files in vim, I decided to write a quick shell script to solve this issue.

Read More

Another story about fixing bug. This story is related to the native web API fetch, which is used to make request. Backstory After serveral days of having my first production application online, my client inform me that, the application has a bug, again. The button was not working as expected for one of the users.

Read More

While I was refactoring the code base of my client application, I came accross a code block, similar to this: arr = [] data.each do |d| status = d['status'] next if IGNORED_STATUS.include? status arr << d['value'] end I think, “Ha, I can replace each with map here.” I go ahead, and make the changes.

Read More

Ruby fetch

Today, when I am refactoring a CLI I wrote, I came across a code block where I check whether an index exists in an array (turns out I don’t actually need it, I can just access the array and check if the value is nil). I went to search of Ruby Array documentation to see if such method exists.

Read More

Register in Vim

For the past months, I have started to use vim in some occasions. One day, I came across a vim video, “Let Vim Do the Typing”{:target=”_blank”}, and discover the use of register in vim. Basically, the concept of register in vim is very similar to the register in our computer.

Read More

I have been working on a project which uses Vue.js for front end. I came across a scenario where we need to allow user to add more entry in their form. Initial Approach The first thought that come to my mind will be get the div#id of the element and append it dynamically through javascript

Read More

Ruby .() notation

In Ruby, .() is a syntatic sugar for call method. class Person def call "Hello World" end end Person.new.() #=> Hello World In this example, we declare a Person class and call method in the class. With this, we can later execute Person.new.() to call the call method. Note that, we need to initialize the Person object first by calling new, since the call is a instance method.

Read More