Questions tagged [elixir]

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.

0
votes
0answers
14 views

Elixir Phoenix not loading env variable at runtime

I am trying to load an API key as a system env from my mac when starting up the phoenix server. What am I getting wrong? these are my steps: On my mac terminal: export API_NOTIFICATION_KEY=1234 in ...
0
votes
0answers
13 views

erlang:odbc - cannot get correct query results in unicode from mssql

What i'am trying: - just make a select with erlang-odbc from elixir and dump all result to console. Enviroment: my side Red Hat Enterprise Linux Server release 7.6 (Maipo) unixODBC-devel ( yum) ...
0
votes
2answers
32 views

How to implement Date.add(date, n, :month) in Elixir

Would be nice to have this in the standard Elixir library, but we don't. Date.add(date, n, :month) # where n could be +/- How would you implement this? This looks like a good starting point: https:/...
0
votes
1answer
35 views

Is there a way to find out or control which process is running on which CPU core in Elixir?

I made a multi-process insertion sort program with Elixir. However, when run on a 32 core machine, it is slower than a single process insertion sort. If the processes sending messages are running on ...
0
votes
1answer
28 views

GenServer implementation of an event handler not handling casts

I am trying to use GenServer as an event handler for EventBus in my Phoenix application but for some reason I can't seem to figure out why the handle cast function isn't getting called. I checked that ...
0
votes
2answers
39 views

Understanding pattern matching in Elixir function parameters

In the book 'Elixir in Action', one of the examples has a function that is tripping up my understanding of pattern matching: def add_entry( %TodoList{entries: entries, auto_id: auto_id} = ...
0
votes
1answer
18 views

put_assoc complains of wrong type

I have Ecto schemas representing a directed graph -- there is a Node schema with a self-referential many-to-many relation through an intermediate NodeEdge schema. i.e. schema "nodes" do field :...
0
votes
1answer
22 views

IEx truncated Error stackstrace despite of config

My config ~/.iex.exs is : IEx.configure(inspect: [limit: :infinity, printable_limit: :infinity, pretty: true , safe: false] ) In IEx, strings, lists are not truncated, but despite the configuration ,...
-1
votes
1answer
37 views

Elixir socket duplicate STX and ETX in response

I have socket server with this method: @impl true def handle_call({:tcp, socket, packet}, state) do Logger.info("Received packet: \x02#{packet}\x03 and send response") {:reply, {:ok, packet}, ...
4
votes
3answers
62 views

how to get values basis on keys from a Struct Elixir

I have this value as %{is_public: true, discoverable: true} This could be anything not specifically is_public and discoverable, but all the keys which will come in above Map will be available in a ...
2
votes
1answer
40 views

Why does running local.phx downgrade the phoenix archive?

According to documentation, running mix local.phx should upgrade the phoenix project generator. Instead, it downgrades it. Is this expected behavior? Why? $ mix phx.new -v Phoenix v1....
1
vote
2answers
32 views

Elixir / Phoenix LiveView: How can I report exceptions to Rollbar?

I've had a lot of fun playing around with the still-beta Phoenix LiveView library. One thing that I'm confused about is how to ensure that my LiveViews will behave in a predictable and transparent way ...
0
votes
1answer
42 views

Inserting foreign key from building association with given schema in single transaction

I have a schema exchange_accounts and user_profile user_profile has a foreign_key column exchange_accounts_id which is referenced from exchange_accounts schema. I want to insert data in user_profile ...
0
votes
2answers
50 views

replacing null values from in map with some other value

I have a map exchange_accounts = %{"BSE" => "yes", "MCX" => "", "NSE" => ""} I need to check for only empty values in this given map. if I find any key with empty value/null it should be ...
0
votes
1answer
26 views

How to use ANY operator with array field with Ecto?

How to find all posts with a tag 'apple' ? schema "posts" do field :title, :string field :content, :string field :tags, {:array, :string} timestamps() end With postgresql it ...
1
vote
1answer
38 views

Configuring and running a Phoenix Framework application

I can run my application from the terminal using mix phx.server. I decided to create an Elixir project in IntelliJ and move the project files there. My configuration of the Elixir Plugin can be seen ...
0
votes
2answers
46 views

Credential changeset not inserted into database

When I create a new user I go through the following process, accounts.ex def register_user(attrs \\ %{}) do %User{} |> User.registration_changeset(attrs) |> Repo.insert() end user....
2
votes
1answer
66 views

Elixir / Phoenix: Why do route helpers require @conn?

When writing Phoenix apps I've gotten used to writing links using a syntax like this: link "My profile", to: Routes.user_url(@conn, :show, user). Recently when working with LiveView I realized that ...
0
votes
2answers
76 views

Using Cowboy Websocket Client for Testing with Elixir

First of all, there is a genuine lack of documentation for Cowboy altogether and Websockets in particular but in general it is excellent to use once it is decyphered. Then getting that info from ...
1
vote
1answer
42 views

Elixir: How can I hookup a logger to a specific logger backend

I have a situation like this: In a Phoenix application, I have some protected information, and want to log those information in different ways to different places. For example: EncryptedLogger => ...
0
votes
2answers
73 views

How to get html page in wallaby

I try to run fin function but for some reason I get back nil. The item I search for have to be there, how can I get the html to see what went wrong?
1
vote
2answers
62 views

What is (k)ill for in the iex break menu?

I access the Break Menu of eix 1.8.2 by pressing CTRL + C. It looks like this: BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded (v)ersion (k)ill (D)b-tables (d)istribution At first I ...
0
votes
1answer
19 views

Phoenix Elixir : cannot escape function in elixir compiler

From this tutorial, I have some elegant: get("/old-path", Redirector, to: "/new-path") get("/old-path/:id", Redirector, to: "/new-path?object=:id") in my router.ex. But I now have a more complex ...
0
votes
2answers
28 views

Passing information from resolver to post-resolution middleware

Im trying to pass from information from my resolver function to my middleware such that I can set a cookie in the response. The use-case is I want to generate an Oauth2 authorization link which ...
0
votes
1answer
30 views

Could not compile dependency :jiffy

I'm trying to run a mix server: ... Compiling c_src/decoder.c sh: 1: exec: cc: not found ===> Hook for compile failed! ** (Mix) Could not compile dependency :jiffy, "/home/user/.mix/rebar3 bare ...
0
votes
1answer
36 views

Weird error which shows up *sometimes* in tests in Elixir using Ecto

Error: 14:18:04.259 [error] GenServer MyApp.Receiver.Handlers terminating ** (Ecto.Query.CastError) deps/ecto/lib/ecto/repo/queryable.ex:382: value `1234` in `where` cannot be cast to type :string ...
1
vote
0answers
46 views

could not compile dependency :salty, “mix compile” failed

I am compiling my application with mix compile and there an error is occurring for the dependency salty. I have already added the dependency salty and libsodium. But still error is not resolved. ...
1
vote
0answers
27 views

Interpolating list of UUIDs into a raw SQL query (can't use fragment)

I'm having issues interpolating a list of UUIDs to perform an in query. Ecto.Adapters.SQL.query!(Repo, " WHERE some_id IN ($1) ", [some_list_of_ids]) This gives me an error ** (ArgumentError) ...
2
votes
1answer
69 views

Does Erlang (and Elixir by extension) provide a way to remove atoms? [duplicate]

Can atoms be removed from a running Erlang/Elixir system? Specifically, I am interested in how I would create an application server where modules, representing applications, can be loaded and run on ...
0
votes
0answers
38 views

Elixir App runs with iex but not when releasing

I'm facing the following issue in an Elixir project and I would appreciate any kind of help. my_service/mix.exs def application do [ extra_applications: [:foo_lib], mod: {My....
0
votes
0answers
23 views

Emmet for <%= %> in EEX files with Phoenix Framework

I'd like to know if there is an emmet to generate <%= %> into eex html files with Phoenix. I have the Elixir Extension with VS Code.
1
vote
2answers
71 views

Deep level recursion with Elixir

I am working on a file system seaweedfs. and we have saved files on it with proper directory structures as server/camera_id/snapshots/recordings/year I am trying to delete the empty folders beneath ...
1
vote
0answers
23 views

For Distillery 2.x, how to fetch runtime configuration values in a release task?

So basically I need some Ecto repository information (call it "Sample.Repo") to start the repo in a release task for Ecto 3. It's configured in a runtime config with a custom json config provider as ...
1
vote
3answers
43 views

Elixir best data structure for testing comparison

I have two array outputs where I need to iterate over each struct, and compare the counts where the source's match. The comparison needs to be less than or equal to. My output sources look like this: ...
1
vote
1answer
26 views

Ecto - how to asynchronously update a batch of records from one table with respect to another table

I have two tables: assignments and reports. A report is made to keep stats on assignments. So, every time an assignment is created or updated, all reports must be indiscriminately updated. I do ...
0
votes
1answer
61 views

Dialyzer emits Type specification is a subtype of the success typing for multiple functions with same name

I have the following two functions and I am receiving this dialyzer warning on them: "Type specification 'Elixir.MyModule':calculate(arg1::'Elixir.String':t(),arg2::'Elixir.CustomType':t(),arg3::'...
0
votes
2answers
46 views

how to change a list from one format to another

I'm trying to change the format of a list using enum function. The original list looks like this myInitialList = [ {1, [ ["A3", "Teddy"], ["B3", "[email protected]"], ["C3", "56123456"...
0
votes
1answer
43 views

Using List Comprehensions to generate potential combinations

I need to generate sets of series data with some already-determined values to test against an algorithm. The data sample data looks like ["apple", "orange", "apple", nil, "pineapple", nil] and I need ...
1
vote
1answer
60 views

Why does Elixir's group_by use a reverse function in the implementation?

Here is Elixir's Enum.group_by/3 implementation from Github: def group_by(enumerable, key_fun, value_fun \\ fn x -> x end) def group_by(enumerable, key_fun, value_fun) when is_function(key_fun) ...
-1
votes
0answers
31 views

Supposedly missing Content-Range in the Access-Control-Expose-Headers

I am trying to integrate react-admin with an API I previously developed in Elixir. Despite the request returning a 200 status code, I am not able to access the payload. It seems supposedly there is ...
0
votes
1answer
45 views

how to write this where clause in Ecto

I have to filter an index that could accept in some cases comma separated values. Im working with Ecto, without phoenix (with cowboy). my index will support some search like this /users?ids=1,2,3&...
0
votes
1answer
39 views

Build series of datetimes with exclusions in Elixir

I would like to generate a list of available time slots between two dates whilst removing time slots that are booked. Firstly, there is a list of time_slots which are tuples of {start_time, end_time}...
1
vote
1answer
36 views

Elixir requests slow in docker with phoenix code reloader on

I currently use docker-sync but it crashes a lot when changing branches when lots of files change. I am trying to find a way to get everything working without it just using volumes, but I am running ...
1
vote
1answer
15 views

Elixir / Phoenix / Ecto: How to customize SQL query log format?

In my Phoenix/Ecto apps, when I set log level to :debug, I see helpful log entries for each SQL query issued by Ecto, like this: [debug] QUERY OK source="users" db=1.9ms SELECT u0."id", u0."full_name"...
0
votes
1answer
18 views

Elixir / Phoenix: How to customize HTTP request log format?

By default, my Phoenix apps log basic information about each HTTP request across ~ 5 lines of log output. As long as I've set my log level to :debug, I can see each request's method, path, controller &...
1
vote
0answers
46 views

Ecto put_assoc changeset is correct, but Repo.update gives StaleEntryError exception

I am trying to update some data in the mysql table. I am using Ecto to perform database operations. The User table has an association with ItemsPurchased, the has_many association and belongs_to are ...
0
votes
2answers
54 views

How to remove quotes around a list in Elixir

One of the operation in Elixir is returning me "[some_data1, some_data2]" And I want to remove the quotes around the list i.e. I want my end result to look like this [some_data1, some_data2]
1
vote
1answer
43 views

Storing calculated column to use in order_by and select

So I'm doing a PostGis calculation. I have a User and a Place model. Each have a :geom, and Place has a virtual distance field. I want to order by distance, as well as select it. I have it working ...
0
votes
3answers
72 views

Compare two lists to find date and time overlaps in Elixir

As part of some code that runs a booking system, we have a list of time_slots, which are tuples containing {start_time, end_time}. These are the available time slots that can be booked: time_slots = [...
1
vote
1answer
35 views

Convert Enum into Flow with elixir

I have 2 million data file to process. Following code takes 2 hours to work done. out_file = "./output.tsv" result = "./input.tsv" |> File.stream! |> CSV.decode(separator: ?\t,...