Elixir’s Getting Started guides go over the &Module.function/arity and &(…) anonymous function shorthand, but there are a couple neat tricks that are not immediately apparent about this shorthand. For example, you can do something like &”…”. iex> hello_fun = &”Hello, #{&1}” iex> hello_fun.(“Keita”) “Hello, Keita” Let’s have some more fun. iex> fun = &~r/hello #{&1}/… Continue reading Elixir anonymous function shorthand
Category: Elixir
Elixir: A year (and a few months) in
In the beginning of 2015, I wrote a blog post about how my then-current programming language of choice (Ruby) was showing itself to not be as future-proof as I would have liked it to be. A lot has changed since then, but a lot has remained the same. First: I have started a few open-source… Continue reading Elixir: A year (and a few months) in
tokyo.ex #1
I attended my first Elixir-related meetup yesterday, tokyo.ex #1. (If the slides don’t work here, I have also uploaded them to YouTube.) In my 5-minute lightning talk, I talked about the basics of using Exfile. Exfile is a file upload persistence and processing library for Elixir with integrations for Ecto and Phoenix.
JavaScript Unit Tests in a Phoenix Application
There’s a guide to writing browser acceptance tests for Phoenix. Acceptance tests are nice, but sometimes you want to have unit tests. This is very easy to do with your Elixir code, but what about your JavaScript code that lives inside your Phoenix application? I couldn’t find a good guide on this, so I’ll go… Continue reading JavaScript Unit Tests in a Phoenix Application
Elixir’s StringIO may not be what you think it is
In Ruby, there is a very handy class called StringIO. Basically, it allows you to treat a string like you would an IO object, such as an open file, etc. Very useful for in-memory “files” that you may not want to write to a temporary file. In Elixir, there is a module called StringIO in… Continue reading Elixir’s StringIO may not be what you think it is
Elixir Pattern Matching in Anonymous Funs
filter_zed_by = “1” list = [ %{“a” => “1”, “b” => “2”}, %{“a” => “1”, “b” => “5”}, %{“a” => “2”, “b” => “5”}, %{“z” => “1”, “x” => “2”} ] Enum.filter list, fn %{“z” => ^filter_zed_by} -> true _ -> false end # => [%{“z” => “1”, “x” => “2”}] case in a fun… Continue reading Elixir Pattern Matching in Anonymous Funs
Link Unroller Service
As a small side project, I recently launched a “link unroller” service. This is a very simple service. You give it a URI, and it follows any redirect chain for you. Then it spits out the final URI via a friendly JSON API. Give it a spin: https://unroll.kbys.me/unroll?uri=http://bit.ly/1QZ6acT Basically, all you do is send a… Continue reading Link Unroller Service
My Great Language Hunt — Elixir
Edit 2016/4/29 I have written a follow-up piece to this blog post. As many of you probably know, I am a professional programmer. I started my professional career with WordPress and PHP development, and now I find myself doing a lot of Ruby work. I am still in the very early stages of my professional… Continue reading My Great Language Hunt — Elixir