Phoenix and Elm, a real use case (pt. 4)
Here is part 4 of my Phoenix and Elm series, in which we cover better states with union types, search resetting, and keyed nodes.
http://codeloveandboards.com/blog/2017/02/23/phoenix-and-elm-a-real-use-case-pt-4/
Focus - lightweight, pure Elixir lenses
Focus is a lens library that helps you get, set, and apply functions to values at any level of a data structure.
https://travispoulsen.com/blog/posts/2017-02-19-Focus-and-Functional-Lenses.html
person = %{name: "Homer"}
nameLens = Lens.make_lens(:name)
# Extract a value from a map
Focus.view(nameLens, person)
# "Homer"
# Replace a value in a map
Focus.set(nameLens, person, "Bart")
# %{name: "Bart"}
# Apply a function to a value in a map
Focus.over(nameLens, person, &String.upcase/1)
# %{name: "HOMER"}
Provide up-to-date information in an email sent hours ago with Elixir/Phoenix
JayPads are build for live and asynchronous collaboration and communication so it’s vital you stay up-to-date about what’s happening.
In this blog post I explain how we managed to provide up-to-date information in an email you received some time ago with the help of dynamic images and a supervised GenServer.
New Pluralsight Course: Getting Started With Phoenix
My new Pluralsight course walks through building an application delivered over the web with Phoenix. It covers Models, Views, Templates, Controllers, Plugs, Sockets, and Deployment. At the end, you’ll have a working application that you can extend.
Searching, Sorting and Pagination in Ecto & Phoenix
Rummage.Ecto and Rummage.Phoenix provide ways to perform Searching, Sorting and Pagination over Ecto queries and Phoenix collections.
For more details visit this blog
Here’s a little demo:
ExStub provides an easy way to stub a module and record the function calls executed on it.
ExStub provides an easy way to stub a module and record the function calls on it.
If you have a module in your original application like:
defmodule OriginalModule do
def process(param), do: :original_process
def another_method, do: :original_method
end
You can quickly create a stub copy of this module using defstub
use ExStub
defstub MyStub, for: OriginalModule do
def process(true), do: :stubbed1
def process(false), do: :stubbed2
def process(1), do: :stubbed3
end
All the functions called on the defstub
created module will be recorded.
You can later use assert_called
to check if the function was called on the stub
assert_called ModuleName.function_name
Rebuilding Phoenix
As part of my book on Phoenix 1.3, I have published a code repo demonstrating a minimal rebuild of Phoenix to understand various components of Phoenix, Plug, Cowboy.
For details visit Building a Slim Phoenix
Direct link to GitHub repo Slim Phoenix
The repo doesn’t have a lot of code explanations (that comes in the book). However, any curious mind can quickly go through the commit history and see what is happening.
As always, feedbacks are more than welcome
love, Shankardevy
Mix Task Creation in Elixir Project
Article on how to create mix
tasks in elixir projects.
Highlights:
- Live demo
- Explanation with screenshots
https://medium.com/@blackode/mix-task-creation-in-elixir-project-d89e49267fe3#.49cfru6ql
Decorating Elixir
Acutar.io blog post about how they dealed with previously calculated model fields by creating Decoratex, a library that allows to easily decorate virtual fields in Ecto models. https://medium.com/acutario/decorating-elixir-af08bd46b2fc
Domainatrex: properly parse TLDs/Domains in Elixir
Domainatrex is a TLD parsing library for Elixir, using the Public Suffix list :)
10 Killer Elixir Tips #2
Thanks for the great response for #1.
Here is another 10 Killer Elixir Tips #2
Happy Coding !!
https://medium.com/blackode/10-killer-elixir-tips-2-c5f87f8a70c8#.50k3xf52z
Flowex 0.2.0 with 'cast' and 'error_pipe'
My talk Flowex - Flow-Based Programming with Elixir GenStage on Elixir Club 5 meetup and following discussions lead me to some significant improvements of the project.
A cast
function was added to run calculation asynchronously. And an error handling mechanism was added. Since “0.2.0” each pipeline has error_pipe
- separate GenStage for handling errors.
More details here: https://github.com/antonmi/flowex
Railway Oriented Programming in Elixir with Pattern Matching on Function Level and Pipelining
Coding seems cool without error checks, does not it? When if/else checks effect the next execution behaviors, then the code becomes a mess. Luckily, there is a pattern called ‘Railway Oriented Programming’ for error handling.
A different approach to elixir test doubles
A proof of concept of a different approach to testing modules in isolation.
http://teamon.eu/2017/different-approach-to-elixir-mocks-doubles/
Create an Elixir web app using Cowboy
This post describes in detail the process of setting up Cowboy server to display a Hello World message.
https://shankardevy.github.io/code/create-elixir-web-app-using-cowboy/
Calculate Execution Time of Your Functions
Like with Ruby lang, the Elixir allows you to code magic without pain. Sometimes, you might need to run a snippet of code before and after execution of a block of code on several function calls. For instance, you need to measure the time elapsed in a function call or multiple function calls.
https://medium.com/@mustafaturan/implement-a-basic-block-yield-with-elixir-d00f313831f7
Enjoyable XML parsing with Elixir and SweetXml - Elixir Hex package showcase
SweetXml is an awesome hex package which makes parsing xml enjoyable :) Don’t beleive that anything to do with XML can be enjoyable? Checkout https://github.com/awetzel/sweet_xml
Source code of demo can be found at: https://github.com/rawcodehq/sweet_xml_hex_package_showcase
Fast Import and Export with Elixir and Postgrex - Elixir Hex package showcase
https://www.youtube.com/watch?v=YQyKRXCtq4s
Watch us cut the import time from 4 minutes to 1 minute to 1 second and then back to 1.7 seconds :)Watch us cut the import time from 4 minutes to 1 minute to 1 second and then back to 1.7 seconds :)
Building & Publishing Elixir Package from scratch.
This video is about the step by step guide to build packages with clear explanation of package files and registration procees to hex.pm
Highlights of Video:
- Each File Explanation
- Auto Documentation
- User Registration - https://hex.pm
- Build and Publishing.
Code School's Free 'Try Elixir' Course
Begin learning the basics of Elixir and take your first steps into the world of functional programming.