Skip to content

Instantly share code, notes, and snippets.


Aaron Tinio aptinio

  • Angeles City, Philippines
View GitHub Profile
evancz /
Last active Dec 8, 2020
Why do I have to write JSON decoders in Elm?

A vision for data interchange in Elm

How do you send information between clients and servers? What format should that information be in? What happens when the server changes the format, but the client has not been updated yet? What happens when the server changes the format, but the database cannot be updated?

These are difficult questions. It is not just about picking a format, but rather picking a format that can evolve as your application evolves.

Literature Review

By now there are many approaches to communicating between client and server. These approaches tend to be known within specific companies and language communities, but the techniques do not cross borders. I will outline JSON, ProtoBuf, and GraphQL here so we can learn from them all.

jessejanderson /
Last active Oct 24, 2020
Don't Write Macros (but do learn how they work)
timriley / _pagination.slim
Created Jan 12, 2016
Rodakase/ROM pagination
View _pagination.slim
- unless first_page?
a href=url_for_page(1)
| « First
a href=url_for_page(prev_page) rel="prev"
| ‹ Prev
- if prev_gap?
View enum.rb
# for use by collection_select and friends, to link a human-readable label with a db-friendly symbolic value
# todo: ActiveRecord macros for setters (for allowing multiple values or just one)
# Usage:
# Table name: snacks
# id :integer
# ice_cream :string
# class Snack < ActiveRecord::Base
# [:vanilla, "Vanilla"],
# [:chocolate, "Chocolate"],
timruffles /
Last active Jun 11, 2020
Approaches to dependency-injection/dynamic dispatch in elixir

In many production systems you'll want to have one module capable of talking to many potential implementations of a collaborator module (e.g a in memory cache, a redis-based cache etc). While testing it's useful to control which module the module under test is talking to.

Here are the approaches I can see. The two points that seem to divide the approaches are their tool-ability (dialyzer) and their ability to handle stateful implementations (which need a pid).

Passing modules

Modules are first class, so you can pass them in. Used in EEx, where passed module must implement a behaviour.