Elixir and Unicode: Two Blog Posts

You’ve heard that Elixir has great Unicode support. But how? I’ve written two posts on the Big Nerd Ranch blog explaining what Unicode is, how UTF-8 encoding works, and how Elixir’s string implementation helps it do things correctly that many languages do wrong.

TermSize: Reliably get the terminal window size

TermSize

https://github.com/sotojuan/termsize

ExChalk: Easier terminal styling

ExChalk is a simple way to style terminal text with a piping syntax.

ExChalk

ElixirWeekly: The Elixir Community Newsletter, covering community news you easily miss, shared on ElixirStatus and the web, in one email every Thursday.

Authorization with Policy Wonk Tutorial

Policy Wonk is a lightweight authorization and resource loading library for any Plug or Phoenix application.

I wrote a tutorial walking through how to set it up and use it. Read it here.

Policy Wonk provides three main plugs.

  • PolicyWonk.LoadResource loads resources into the conn’s assigns map.
  • PolicyWonk.Enforce evaluates a specified policy. It either continues or halts the plug chain depending on the policy result.
  • PolicyWonk.EnforceAction evaluates a policy for each incoming controller action in Phoenix.

Decisions are made before controller actions are called, isolating authorization logic, encouraging policy re-use, and reducing the odds of messing Auth-Z up as you develop your controllers.

Check it out here:

Ecto Shortcuts - Common shortcut operations in ecto © (see license)

https://github.com/MishaConway/ecto_shortcuts

Lightweight Elixir extension to simplify common use cases in Ecto. It even has auto preloads!

MyApp.Users.insert name: "Bob"
MyApp.Users.get_by! [name: "Sally", age: 30],  preload: "*"
MyApp.Users.where [status: 3],  limit: 10, order_by: [desc: :inserted_at], preload: [:posts]
defmodule MyApp.Users do
  ...
  use EctoShortcuts, repo: MyApp.Repo,
                     model: MyApp.User,
                     default_preload: "*"
  ...
end

Generating a stream using Stream.resource

Stream.resource is a powerful function that can be a bit confusing to use. See some examples from generating prime numbers to executing a long-running function on each item in a enum in parallel.

Elixir ETS/DETS/Mnesia/BEAM vs Redis

Learning Elixir has a way of challenging everything you know about programming. Redis is becoming an assumed part of many web stacks, in the same breath as your database. But with Elixir, do you need it? Do you even need a database?

https://blog.codeship.com/elixir-ets-vs-redis/

Elixir Users' Survey 2016

I’ve just launched the Elixir Users’ Survey 2016

I do these every year. Here are 2014 and 2015:

I’d love it if you’d share it around with other elixir users you know :) The more data we have, the more data the core team and the library authors will have.

This isn’t in any way an official thing, but I think I have a decent track record of doing a bunch of work to gather and collate this data and share it with interested parties :)

I also posted this on reddit’s /r/elixir and the orange website if you felt like promoting it there :taco:

plug: https://www.dailydrip.com is my full-time thing now, making elixir and elm screencasts, if that’s your cup’o. I’m also still updating ElixirSips, but with DailyDrip I have full control of the platform and a chance to make this into something bigger.

Entity Component Systems

Entity-Component-System is a design pattern that is mostly used in game development. In this post, discover how we can use both ECS and Elixir in a novel approach to structure our programs beyond the traditional OO/inheritance paradigm.

Read Entity Component Systems (in Elixir).

ElixirWeekly: The Elixir Community Newsletter, covering community news you easily miss, shared on ElixirStatus and the web, in one email every Thursday.

Pairs.One has been open-sourced

The multiplayer online Memory game written in Elixir/Elm and named Pairs One (http://pairs.one) has been open-sourced during a lightning talk at EuRuKo: https://github.com/mxgrn/pairs.one

The slides for the talk can be found here: http://www.slideshare.net/netzke/making-multiplayer-game-with-elixir-and-elm

Ecto.Rut - Ecto Shortcuts to make your life easier!

Ecto.Rut gives you simple wrapper methods that let you directly call CRUD methods from your Module, so you can do this:

Post.all
Post.get(id)
Post.delete(post)
Post.insert(title: "Name", category: "Elixir")

Alchemist v1.8.1 is OUT - Elixir Tooling Emacs Integration

Thanks for all the feedback and issue reports. <3

https://github.com/tonini/alchemist.el/releases/tag/v1.8.1

Elixir Application teardown - User Profile API for the Rio 2016 Olympics

https://medium.com/software-sandwich/elixir-video-user-profile-service-for-the-olympics-application-teardown-56ac3e103d1a#.qn00776rr

In this article, I wrote the teardown for the first article version of Elixir Video User Profile Service for the Rio 2016 Olympics

Exgen: A templating library for reusable Elixir apps

Do you have certain classes of applications you frequently create, or have a bunch of standard setup you automatically include in every new project? Exgen was built to address this need - a way to quickly generate projects from a base template.

https://github.com/rwdaigle/exgen

Commensurate with Exgen is the hope that the community will share their templates, their approaches to solving common problems, so that others can benefit and quickly get up and running themselves.

Exgen is in early development, so all feedback is welcome.

PlugRest is a new library for hypermedia web apps

PlugRest is an Elixir port of Cowboy’s REST sub-protocol for Plug and Phoenix applications. It features router macros, a resource behaviour, and a REST state machine.

PlugRest is perfect for creating well-behaved and semantically correct hypermedia web applications in Elixir.

https://github.com/christopheradams/plug_rest

IoT with Elixir and CoAP part 2: How to easily prototype and build an IoT platform

We are back with the second part of our IoT development series where we use Elixir to create a simple IoT setup talking over the Constrained Application Protocol (CoAP).

http://monterail.com/blog/2016/iot-with-elixir-and-coap-part-2-example-on-how-to-easily-prototype-and-build-an-iot-platform/

Requiring Sign In in Phoenix

Coming from Rails, there are a lot of little things to learn about Phoenix to write a fully functional app. To help others make the same transition, I wrote a blog post explaining how to use plug in a Phoenix application to require a user be signed in for certain actions.

Building a Digital Goods Shop & Blog in Elixir

I have just open sourced my first Elixir/Phoenix application. It is a simple CMS to manage my online shop and blog - Authentic Pixels.

This project has been a great learning experience for me. Coming from Ruby on Rails, there are a lot of things that are done differently in Elixir/Phoenix and building this app has helped me understand the “Elixir way” of doing things.

Some of the things that this project helped me wrap my head around are -

  • Nested records & associations (e.g: Product has many variants)
  • Handling many-to-many associations and validating them
  • Uploading images
  • Testing
  • Switching to Webpack from Brunch
  • Creating Sitemaps and running a cron task to regularly run the sitemap generation task
  • Deploying (to a Digital Ocean box using Dokku)
  • Sending HTML emails.
  • Separating admin area from frontend using differnt layouts and scopes in router.ex

I will be writing about this is a lot more detail on my blog soon.

Do review the code and let me know your thoughts/critiques - https://github.com/authentic-pixels/ex-shop

Building a Casino in Elixir

So obviously we can’t build an actual working Casino in a single tutorial. Instead we’re going to focus on building out a supervision tree using the components of Elixir.

First up we need a way to register new players in the casino. Each player should have a name, a balance, and the ability to deposit money and make bets. We will need to supervise the players to keep the register up-to-date as players come and go.

Second we will build out the blackjack tables of the casino. We need a way of automatically generating the initial tables when the casino first opens, but we also need to add and remove tables as the demand fluctuates.

And of course, we need to build this Elixir application to deal with failure. If something goes wrong in one of the branches or leaves of the tree, we should be able to recover without disrupting the rest of the application.

http://culttt.com/2016/09/21/building-casino-elixir

LDAP authentication with Phoenix

LDAP is mostly used by medium-to-large organi­zations to have one centralized place to store users and groups and to allow others internal systems to authenticate the users. If you want to build Phoenix applications that will work within an enterprise you will likely have to integrate with an existing LDAP server.

In this article I’m going to show you how you can authenticate and synchronize users to your Phoenix application.

http://rny.io/elixir/phoenix/ldap/2016/09/20/ldap-authenication-with-phoenix.html