livebook-connect script, new in Legendary 6.6.0
I just added script/livebook-connect to Legendary. It lets you connect Livebook to your running server with a single command! https://gitlab.com/mythic-insight/legendary
EctoCellar has been releasedđStore changes to your models, for auditing or versioning.
Store changes to your models, for auditing or versioning. Inspired by paper_trail.
Links
- github: https://github.com/tashirosota/ecto_cellar
-
hex: https://hex.pm/packages/ecto_cellar
Usage
1. Configuration.
Add ecto_cellar congigure to your config.exs.
config :ecto_cellar, :repo, YourApp.Repo
2. Creates versions table.
You can generate migration file for EctoCeller.
Letâs type mix ecto_cellar.gen
.
And migrate by mix ecto.migrate
.
3. Stores changes to model.
Stores after a model is changed or created. These are stored as recoverable versions for the versions table
iex> with {:ok, post} <- %Post{title: "title", views: 0} |> @repo.insert(),
iex> {:ok, _post} <- EctoCellar.store(post) do # or store!/2
iex> # do something
iex> end
4. Gets versions and can restore it.
Uses EctoCellar.all/2
and EctoCellar.one/3
, you can get past changes versions.
And use it, you can restore.
iex> post = Post.find(id)
%Post{id: 1, body: "body3"...etc}
iex> post_versions = EctoCellar.all(post) # Can get all versions.
[%Post{id: 1, body: "body3"...etc}, %Post{id: 1, body: "body2"...etc}, %Post{id: 1, body: "body1"...etc}]
iex> version_1_inserted_at = ~N[2022/12/12 12:00:12]
iex> post_version1 = EctoCellar.one(post, version_1_inserted_at)
%Post{id: 1, body: "body1", inserted_at: ~N[2022/12/12 12:00:12]...etc}
iex> post_version1
iex> |> Post.changeset([])
iex> |> Repo.update() # RestoredïŒïŒïŒ
Bugs and Feature requests
Feel free to open an issues or a PR to contribute to the project.
Speed up your daily work with Elixir console tricks
I would like to present some useful tricks to speed up your work.
Elixirâs interactive shell is a great tool to make your work comfortable. You donât need to use a browser to check function errors. You have everything available in the console!
More on: https://bartoszgorka.com/speed-up-your-daily-work-with-elixir-console-tricks
ThinkingElixir 091: Reviewing Elixir with José Valim - Part 3
In episode 91 of Thinking Elixir, José Valim returns to continue with part 3 of our 5 part series as we count down to the 10 year anniversary of the Elixir project we know and love. In Part 3, we talk through the Elixir releases of 1.7, 1.8, and 1.9. We talk about the unification efforts between Elixir and Erlang. These came through changes to error stacktraces, how documentation is stored, a unified logger, and more. We learn how features like Mix.target made a big difference for the Nerves project. We also hear the call for contributors to help bring a few remaining date/time features to Elixir. The big feature in Elixir 1.9 was the addition of deployment releases and the early efforts at managing config for releases. We thought this would be a short episode but found there was a lot to talk about and learn!
flop 0.16.0
Flop 0.16.0 was released with improved compile time validation, operator validation, custom count queries and more.
Using Ecto.Multi and Phoenix.PubSub to update Phoenix Liveview
Keep your Liveviews in sync with your database by adding pubsub to your Ecto contexts.
Dependency Inversion with Elixir Protocols
Iâve always liked the Dependency Inversion Principle (DIP). Once understood, it helps us decouple code in surprising ways. Letâs take a look at how Elixir protocols decouple code through DIP.
âïž https://www.germanvelasco.com/blog/dependency-inversion-with-elixir-protocols
Fundamentals & Deployment
A recent podcast episode with Kelsey Hightower got me thinking about my deployments.
Is LiveView Overhyped?
A good while back I saw discussion of this and this is my late attempt to put some nuanced into my typically very enthusiastic writing on this tech. (spoiler: I still like it) https://underjord.io/is-liveview-overhyped.html
ExLicense - License header injection
First release of ExLicense, the utility to inject license header in Elixir files .
Check out the release post
TIL: wrapping an execution in a tuple
One of the advantages of Elixir is its openness. You can get more readable code with the command wrapped in tuple. You donât need to modify the response from functions itself.
https://bartoszgorka.com/til-wrapping-an-execution-in-a-tuple
Zanzibar Goes Elixir, Pt. 1: Setup and Relation Tuples
Zanzibar is a unified, planet-scale authorization system used by Google. While none of my side projects are quite at planet scale yet, the idea of a general purpose authorization engine is intriguing. In this article series, Iâll attempt to write a naive implementation of the system using Elixir and PostgreSQL. https://www.mathiaspolligkeit.com/dev/zanzibar-goes-elixir-pt-1/
ThinkingElixir 090: Elixir Cards with Tetiana Dushenkivska
In episode 90 of Thinking Elixir, we talk with Tetiana Dushenkivska, the creator of Elixir Cards, a series of Elixir flashcards with multiple ways to use them. We talk about why she created the cards, how they helped her, and how others have used them. We talk about learning models and the importance of repetition for memorizing things. Tetiana shares how LiveView is used in the creation of the cards and more! David shares how he used the cards for fun drills at meetups and Tetiana fondly recalls a tournament held at a previous Elixir conf. She also shares what sheâs working on now for a future online learning system.
A Guide to Secure Elixir Package Updates
This article explores how you can use Hex dependencies for safer package updates in Elixir.
https://blog.appsignal.com/2022/03/15/a-guide-to-secure-elixir-package-updates.html
Using mix aliases to improve your workflow
I wrote a bit about using mix aliases to improve your workflow. I always use them and augment them. But I never thought about writing about them til now. Hope itâs helpful to others!
https://www.germanvelasco.com/blog/using-mix-aliases-to-improve-your-workflow
Build Simple Reusable Widgets Using Slots
A new feature in LiveView called âslotsâ can help make your components more composable and reusable. This post is about getting started with slots to build a simple component.
I took notes from what I learned while creating my first custom LiveView component using slots. If youâve been wanting to play with slots, hopefully this can help you skip the snags that slowed me down.
https://fly.io/phoenix-files/build-simple-reusable-widgets-using-slots/
Scholarship tickets for The Big Elixir
NewAperio is sponsoring The Big Elixir conference in New Orleans this year and weâre giving away scholarship tickets for students/professionals from underrepresented groups. Learn more and apply here.
Benchee 1.1.0 released + why did it take so long
After quite some time you can finally enjoy a new Benchee version with a bugfix (finally!), reduction counting and profiler after benchmarking (yay!). Check out the Changelog or go all in on the release blog post including some musings on Open Source and why it took so long.
ThinkingElixir 089: Reducing the Friction in Your Flow
In episode 89 of Thinking Elixir, we talk about how designing applications with lower friction points is a valuable goal. LiveView plays a powerful role in that mission. Mark pitches why he thinks itâs time to take another look at LiveView if you havenât lately. We talk over some of the business benefits, efficiencies gained and we address some common reasons given for âwhy it canât work.â We also cover some remaining areas of improvement for LiveView. Then we talk about how moving your servers closer to users removes additional friction both for deployment and application design. Mark shares how the fly_postgres library works and how it enables people to build ânormalâ Phoenix applications using Postgres read-replicas across multiple regions. A fun discussion!