ElixirMix Podcast 049 - Standard Library Treasures
Introduction to Testing
I put together an episode for anyone looking to get started writing tests with Elixir.
There is no magic in Elixir!
When I got into Elixir, I was admiring all the awesome shiny magic it had ready for me to build things. But there’s actually less to it than you might think! - In a good way! https://medium.com/@svengehring/there-is-no-magic-in-elixir-9f61c1ec6ea4
Event Sourcing With Elixir - Part 4
In Part 4 of this series on Event Sourcing we’ll introduce middleware and improve our test coverage.
Organising Absithe GraphQL and Ecto errors
https://medium.com/@imanhodjaev/organising-absithe-and-ecto-errors-2a2257ccdff6
I’ve been using Absinthe in my own project for some time now and wanted to share my thoughts on the topic of organising and working with errors in general and particularly with Ecto.Changeset errors. In my opinion this topic is poorly covered though there are some guidance in the official documentation and numerous other places which I tried to unify them. Also as it is quite hard to figure out the exact common shape of possible API errors at the beginning and it comes over time once you have something in place.
Free ebook about Elixir
Syncfusion has just published a short but dense book about Elixir and OTP. You can download it here: https://www.syncfusion.com/ebooks/elixir-succinctly
Pi Zero using Nerves sending USB keypresses triggered by GPIO
First milestone achieved: a Pi Zero running Nerves sending USB keypresses triggered by GPIO. Next: setup a keyboard matrix! https://www.youtube.com/watch?v=pTK-UYxU-YQ
IntelliJ Elixir 10.5.0
-
The correct home path for
kiex
is~/.kiex/elixirs/elixir-VERSION/lib/elixir
as that contains the truelib
andbin
directory, but users may select other directories by mistake, so doing the following adjustments: -
Adjust
bin
home path tolib/elixir
. -
Adjust
elixirs/elixir-VERSION
home path toelixirs/elixir-VERSION/lib/elixir
. -
In RubyMine, attach OTP applications as separate projects with Elixir facets instead of directly creating
ELIXIR_MODULE
modules inDirectoryConfigurator
. This matches the manual steps of opening the OTP apps as separate directories after opening the root of the project.- Mark directories when adding facet
- Sync libraries when adding facet or attaching to root project. Ensures External Libraries show up for all OTP applications.
-
Convert Small IDE projects with
ELIXIR_MODULE
s:-
Remove
ELIXIR_MODULE
*.iml
files -
Remove
ELIXIR_MODULE
entries root project’smodules.xml
file. -
Lack of modules in project in
doOpenProject
will triggerDirectoryProjectConfigurator
s to be run, which will setup the project and runDirectoryConfigurator
to attach theapps
OTP apps and Elixir facets.- Only support automatic attaching multiple OTP apps as separate projects in Rubymine. In IntelliJ normal support for multiple Modules in one Project still works.
-
Remove
-
Increase suspect
nameSet
size to15
to supportgeo
.geo
has 13String.Chars
implementations. -
Check that HomePath has
ebin
paths when validation. Prevents selecting false HomePaths forkiex
. -
Adding missing ESpec template. When reviewing #1410 I missed that the template wasn’t in
resources
. 🤦♂️ -
Ignore
targets
when calculatingDep
path. -
Ignore
organization
when calculatingDep
path. -
Get view provider document in read action.
-
Support
rebar.config
deps that are name only. -
Always use
containingFile
forQualifiableAlias
maxScope
forgetReference
. Prevents cache capturingmaxScope
, which can vary based on invocation. -
Create new project before attaching it in Small IDEs. When attaching a directory to a project during startup, saving is disallowed, so the attached directory only has a
workspace.xml
in its.idea
when the attach is attempted. Attaching requires the.idea/*.iml
Module file, so the attaching fails, saying the directory is an unsupported format.Experimentation showed that manually attaching the directory also did not work, but opening the directory in a separate window, then opening and attaching it again would make the directory have the full project files. To mimic this manual process:
-
The internals of
doOpenProject
are copied - A save of the project files is forced, bypassing the normal “startup” save blocker
- The project is attached to the root project. Tested to work when upgrading from 10.4.0 to 10.5.0-pre in Rubymine when no project was already open.
-
The internals of
-
Check if project can be attached instead of if RubyMine Although GoLand supports attaching projects, it doesn’t work for non-Go projects, so it is also excluded. How the support appears in each non-IntelliJ IDEA is shown below:
IDE Works? Android Studio YES Android Studio is built on top of IntelliJ, so it has full multi-Module support. It is not Small IDE. CLion NO No Attach to Project support to multiple module support. DataGrip No DataGrip doesn’t have a Project View and doesn’t support Attach to Project. You can still run tests if you directly open the file. GoLand NO Modules show up, but independent projects are not attached as in other Small IDEs, so disabled. In general, the Go settings, like Test Runners always win, so it is recommended to not use GoLand at all for Elixir development. PHPStorm YES The projects are listed in Directories. The Languages & Frameworks > Elixir shows all 3 projects. Right-clicking on the marked Test directory will not show the Elixir Run Configuration, Python ones win, but subdirectories and *_test.exs
will show up in the context menu.PyCharm YES The root project is listed in Project. app/*
projects are listed listed as Project Dependencies of the root Project. The Languages & Frameworks > Elixir shows all 3 projects. Right-clicking on the marked Test directory will not show the Elixir Run Configuration, Python ones win, but subdirectories and*_test.exs
will show up in the context menu.Rider No Solution system is separate from Project system. Rubymine YES The projects are listed in Project Structure. The Languages & Frameworks > Elixir shows all 3 projects. Right-clicking on the marked Test directory will not show the Elixir Run Configuration, Python ones win, but subdirectories and *_test.exs
will show up in the context menu.WebStorm NO No Attach to Project support or multiple module support. -
Don’t count Android Studio as a Small IDE. It includes Project Structure menu with multiple-language, multiple-Module per Project support from IntelliJ.
Version 1.0.4 of external_state released
ExternalState: for when your GenServers have long running functions but other processes need to ask them quick questions. At [https://hexdocs.pm/external_state and https://github.com/sampscl/external_state
Easy introduction to recursive functions
A very simple tutorial on how recursive functions work, to help those unfamiliar with them understand the concept. https://medium.com/@damonvjanis/recursive-functions-in-elixir-93a118c69db7
New library Uribe
I just published Uribe. This is a new library to manipulate URI struct in Elixir. PRs are welcome
Serving static assets on a subpath in Phoenix
Phoenix serves static files with a Plug.Static defined in the endpoint. But what if we want to serve additional static files from subpaths? https://medium.com/@svengehring/serving-static-assets-on-a-subpath-in-phoenix-758f9ecb9921
Using libgraph for graph data structures in Elixir
I just published a new post ‘Native graph data in Elixir: Using libgraph for graph data structures‘.
This post looks at the Elixir libgraph package from Paul Schoenfelder.
After a brief introduction to building graphs using libgraph I take a quick look at how to serialize and visualize these graphs with Graphviz tools.
I then show how to create a libgraph graph from CSV data, and explore some basic graph structures.
Lastly a couple naive conversions from graph database formats (both property and RDF graphs) into native libgraph formats is attempted.
NimbleETS → KV-Store For Zero Cost
The very simple :ets
wrapper simplifying
cross-process :ets
handling
(like Agent
,
but :ets
.)
https://hexdocs.pm/nimble_ets / https://github.com/am-kantox/nimble_ets
You may not need GenServers and Supervision Trees
It seems to me that GenServers and supervision trees are emphasized a bit too much - we can build great applications without writing them ourselves: You may not need GenServers and Supervision Trees
Latest ElixirOutlaws - implicit vs. explicit
This week the elixir outlaws discuss implicit vs. explicit api design.
Caveats storing large amounts of data in Elixir Agents
Recently when working on an Elixir project I ran into an interesting gotcha with Agents that caused massive amounts of resource usage. In this post I’m describing how using Agents can lead to high memory usage and how you can solve it by using a worker pool.
https://www.theguild.nl/caveats-storing-large-amounts-of-data-in-elixir-agents/
KeywordValidator - Get a Handle on Your Options
Just released KeywordValidator
This is a tiny library that validates keyword lists against a schema. Provides detailed error feedback when something is not right. Helps prevent code repetition and cryptic errors stemming from function options! Enjoy.
How to Create a Todo List with Phoenix LiveView
In my latest Phoenix LiveView tutorial we go over how to create a real-time updating todo list with Phoenix LiveView and Phoenix PubSub. Check it out and let me know what you think!
https://dennisbeatty.com/2019/04/24/how-to-create-a-todo-list-with-phoenix-liveview.html
Git Book for Killer Elixir Tips
checkout new public GitBook for Killer Elixir Books https://extips.blackode.in/