How to Write Guard Macros

I recently discovered that it is possible to write custom guard macros for Elixir, provided that the macro expands to expressions that are supported in guards natively.

I used this to create an is_blank guard. Elixir doesn’t come with a blank? function, so you have to do it manually. Blank values are " ", "", and nil. To check blank? in Elixir, you can check if a given value is in this array of blank values.

[Read More]

Number Helpers For Elixir

Since I started working on a Phoenix app, I was frustrated by the lack of number conversion helpers in Elixir/Erlang. I didn’t want to have to rewrite number_to_currency every time I want to use it.

So, I created Number. It’s basically a shallow clone of NumberHelper from ActionView in Rails. Now, Elixir users can have number_to_currency too!

[Read More]

Useful Ecto Validators

Over the past week, I’ve created a couple custom validators for my Elixir projects which use Ecto. Since validators are just functions that take a changeset and return a changeset, they’re very easy to write.

[Read More]

Why a Static Blog is a Good Idea

Rather than use a popular blogging solution like Wordpress, Blogger, or even the new kid on the block, Ghost, I chose to use an old school method to write my blog: plain text.

This blog is a static site. My posts are written in plain text in a text editor on my computer, and are converted into simple HTML pages when I deploy. There is no admin panel. There is no pretty online editor. Just text.

[Read More]

On Keeping Your ETS Tables Alive

In my ongoing quest to make Elixir libraries that integrate with Twilio, I found that I needed a lookup table to store the state of ongoing calls in.

In Rails, this table would probably be a Postgres table or a list key in Redis. But before jumping to one of these familiar solutions, I thought, “What does Elixir/Erlang already have that would meet this need?”

[Read More]