GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Livebook
  • Integrations
  • Badges
  • Docs
  • What’s new?

This view

  • Original page
  • New address

GeezerVison is showing livebook.dev — Elixir integration - Livebook.dev

Use Elixir directly in Livebook

Livebook has an interactive environment to code in Elixir. You can use it to learn Elixir, explore Elixir packages, prototypes, scripts, and interactive data apps.
Install LivebookLocally or on the cloud
Learn moreElixir & Livebook
Reevaluate
# Start the GenServer process
MyApp.Queue.start_link([])

MyApp.Queue.len() |> IO.inspect(label: "Initial length")

# Add some data to the queue
for idx <- 4..6, do: MyApp.Queue.push(idx)

MyApp.Queue.len() |> IO.inspect(label: "Length after adding elements")

:sys.get_state(MyApp.Queue) |> IO.inspect(label: "Introspection with :sys module")

GenServer.stop(MyApp.Queue)
Evaluated
Initial length: 0 Length after adding elements: 3 Introspection with :sys module: %{len: 3, queue: {[6, 5], [4]}}
:ok

Elixir Code Editor

Livebook's Elixir code editor supports autocompletion, inline documentation, code formatting, and more.
Evaluate
defmodule Formulas do
  import Nx.Defn

  defn softm

  defn sigmoid(x) do
    1 / (1 + Nx.exp(-x))
  end

  defn relu(x) do
    Nx.m
  end
end
Stale*
Amy
Jake
ƒmap/2
ƒmap/3
ƒmax/2Nx.max(left, right)
ƒmean/1
ƒmean/2
ƒmin/2
ƒmultiply/2
{:module, Formulas, <<70, 79, 82, 49, ...>>, {:relu, 1}}

Visual Representation of the running system

Livebook can render visual representations of supervision trees and message-passing between Elixir processes. Learn how to do this.
Kino.Process.render_seq_trace(fn ->
  parent = self()

  child =
    spawn(fn ->
      receive do
        :ping -> send(parent, :pong)
      end
    end)

  send(child, :ping)

  receive do
    :pong -> :ponged!
  end
end)
Evaluated

Interactive UI to visualize, debug and edit Elixir pipelines

Livebook has an interactive widget that lets you see the result of an Elixir pipeline, enable/disable pipeline steps, and re-order them through drag and drop. Learn how to do this.
"Elixir is cool!"
|> String.trim_trailing("!")
|> String.split()
|> List.first()
|> dbg()
Evaluated
dbg:5
Copy new pipeline
"Elixir is cool!"
String.trim_trailing("!")
String.split()
List.first()
Output:
["Elixir", "is", "cool"]
"Elixir"

Run a notebook within the context of a Mix project

It's super easy to run code of a Mix project inside Livebook. This can be useful for interactive development or for experimenting with your project's code.
my_app_root = Path.join(__DIR__, "..")

Mix.install(
  [
    {:my_app, path: my_app_root, env: :dev}
  ],
  config_path: Path.join(my_app_root, "config/config.exs"),
  lockfile: Path.join(my_app_root, "mix.lock")
)
Evaluated
:ok
MyApp.Repo.aggregate(MyApp.Orders.Order, :count)
Evaluated
1274

Add Hex packages as dependencies of your notebook

Livebook makes it easy to use Hex packages inside your notebooks. The integrated package management also makes your notebooks easier to be used and reproduced by others.

Search packages

Find external packages for your notebook

kino
kino 0.19.0
Interactive widgets for Livebook
Add
kino_vega_lite 0.1.13
Vega-Lite integration with Livebook
Add
kino_db 0.3.1
Databases integration with Livebook
Add
kino_maplibre 0.1.13
MapLibre integration with Livebook
Add
kino_bumblebee 0.5.1
Bumblebee integration with Livebook
Add

Connect to a running Elixir system directly in Livebook

You can easily connect to a running Elixir node. Useful for production environment diagnostics, remote debugging, and automation.

Runtime settings

Elixir standalone
Attached node

Connect the session to an already running node and evaluate code in the context of that node. Make sure to give the node a name and a cookie, for example:

iex --name [email protected] --cookie mycookie -S mix

Then enter the connection information below:

Name
[email protected]
Cookie
mycookie
Connect

Develop on embedded devices with Livebook and Nerves

Nerves Livebook enables you to try out Nerves on real hardware without needing to build anything. You'll be able to run code in Livebook and work through Nerves tutorials from the comfort of your browser.
led_pin = 20
Evaluated

Now that we've selected a pin, connect the LED to led_pin through a 220Ω resistor, then to ground.

PLATINUM SPONSORS
Flyio Logo
SPONSORS
Tigris logo
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.