Stack Overflow » Elixir
1 FOLLOWERS
Elixir is an open-source, dynamic, compiled, general-purpose functional programming language. It was designed to be fully compatible with the Erlang platform and is well suited to writing fault-tolerant, distributed applications with soft real-time guarantees and the ability for hot-code-swapping. In the Stack Overflow Forum, you can ask questions and find out everything you need to know about..
Stack Overflow » Elixir
10M ago
I create a simple Elixir app without Phoenix, I am able to run it without Docker.
When I want to dockerize the app using multi-stage build, I got an issue
/app/_build/prod/rel/todo_app/releases/0.1.0/../../erts-14.0.2/bin/erl: exec: line 12: /app/_build/prod/rel/todo_app/erts-14.0.2/bin/erlexec: not found
Here is the dockerfile
FROM elixir:1.15.1 as build
ENV MIX_ENV=prod
COPY lib ./lib
COPY mix.exs .
COPY mix.lock .
RUN mix local.hex --force && \
mix local.rebar --force && \
mix deps.get && \
mix release
# Copy the production.env.exs file to the cont ..read more
Stack Overflow » Elixir
10M ago
The ErlPort docs for making calls to Erlang functions in Python requires importing erlport.erlang and using the call function. It seems that in erlport 0.6 (the version that pip3 install) there is no erlport.erlang module.
I've searched around a bit and am not sure how to go about this, as most of the erlport docs/issues are pretty outdated. The repo and package themselves haven't gotten me anywhere. I am attempting to make calls to erlang functions from a Flask app. Erlport seems to be the best tool for this as recommended by this answer and quite a few others ..read more
Stack Overflow » Elixir
10M ago
I have table Orders and Table TRDs. each order can have multiple TRDs, and every trd has an account_id. What I am trying to do is: to get all the orders, with trds but TRD grouped by account id. I am using Scrivener for pagination
base_query =
from(order in Order,
left_join: trd in TradingRestrictionsDiscrepancy,
on: trd.order_id == order.id,
left_join: account in Account,
on: trd.account_id == account.id,
group_by: [
order.id,
trd.account_id,
trd.event_time
],
select: %{
order_id: order.id,
account_id: trd.account_id,
trd_even ..read more
Stack Overflow » Elixir
11M ago
I'm trying to create a unique index with an ecto migration for a PostgresDB.
def change do
create table(:categories) do
add(:name, :string)
add(:parent_id, references(:categories), null: true)
timestamps()
end
create(index(:categories, [:parent_id]))
create(
unique_index(:categories, [:name, :parent_id], name: :unique_categories_name_parent_id)
)
end
However, this does not work when the parent_id is NULL. I know that PostgresSQL 15 supports NULLS NOT DISTINCT but my db is on v13. This there a way to ensure unique name field with NULL parent_id here ..read more
Stack Overflow » Elixir
11M ago
Is there a good way to convert floats to strings in Erlang/Elixir, without scientific notation, and without specifying how many decimal digits I want?
Neither of these do what I need.
:erlang.float_to_binary(decimals: 10): gives trailing zero decimals
float_to_binary(100000000000.0, [short]).: prints scientific notation ..read more
Stack Overflow » Elixir
11M ago
Every time I try to run a Repo.insert with this particular table, I get an error about the id being null (null value in column "id" of relation table_name), but the id isn't supposed to be set manually anyway, so why would I need to set it explicitly ..read more
Stack Overflow » Elixir
11M ago
I'm building several worker with GenServer and I would like to implement both unit and integration tests on each worker.
For the first worker I built, this is the implementation code
defmodule CotacoesETL.Workers.Pesagro.BoletinsFetcher do
@moduledoc """
Todos os dias esse Worker visita a página da `Pesagro` e
busca novos boletins do Mercado Agrícola, a fim de atualizar
nossa base de dados.
"""
use GenServer
alias Cotacoes.Handlers.CotacaoHandler
alias CotacoesETL.Adapters.Pesagro.Boletim
alias CotacoesETL.Integrations
alias CotacoesETL.Integrations.PesagroAPI
require ..read more
Stack Overflow » Elixir
11M ago
The code below lets a user click on a list item (called a testbed.note) and as a result a modal pops up whereby they can either preview or edit the content.
The problem is if the user keeps the editor open and the modal closes, the next time the modal is opened it does so in the "edit" state.
In the code, the user should NEVER be able to open the modal and have it default to the edit state. In other words, each time the modal launches it should always be in preview mode.
I tried placing %JS{} code to toggle the class when the user clicks the submit button. It didn't work.
I have linked a video ..read more
Stack Overflow » Elixir
11M ago
My function takes a string and I need to check each individual character is either "0" or "1".
How to do that?
I have tried this:
defguard is_bit_string(str)
when is_binary(str) and
byte_size(str) == 1 and
binary_part(str, 0, 1) in ["0", "1"]
defguard is_bit_string(str)
# byte_size(str) == 1 and
when is_binary(str) and
binary_part(str, 0, 1) in ["0", "1"] and
is_bit_string(binary_part(str, 1, byte_size(str) - 1))
But turns out gaurd can't be recursive(ig as i get following error:
(C ..read more
Stack Overflow » Elixir
11M ago
I have a gRPC API and want to add Otel based tracing to it. Every request to this API contains trace/span ID, but I am struggling to properly emit child span.
Here is an example from iex:
require OpenTelemetry.Tracer
alias OpenTelemetry.Tracer
:otel_propagator_text_map.extract([{"traceparent", "00-00000000000000001f28325aa9c79b59-37ab46991f7a64e1-00"}])
_parent = :otel_tracer.current_span_ctx()
span_ctx = Tracer.start_span("otel-test")
Tracer.set_current_span(span_ctx)
# start doing some work
:timer.sleep(100)
# work done
Tracer.end_span(span_ctx)
Not sure what is wrong here but I don't s ..read more