Skip to main content
5 votes
Accepted

Get The Base Name of an Elixir Template File

Since you seem to know what the file extension is, you can use Path.basename/2. "foo.html.eex" |> Path.basename(".eex") |> IO.puts If you don’t know ...
RubberDuck's user avatar
  • 30.9k
3 votes
Accepted

Codewars kata : reverse and rotate

So, the only major comment I'd have on your code is that it's a bit hard to understand what's going on. It becomes a lot easier when you have the Kata text to help, but ideally the code itself should ...
obmarg's user avatar
  • 678
3 votes
Accepted

Using Elixir pipeline to transform a string into a map

You can do this with an anonymous function ...
noscreenname's user avatar
3 votes

Elixir/Ecto find_or_create with custom error

I think it is a perfect fit for with. It will be something like: ...
iacobSon's user avatar
2 votes
Accepted

SMTP client module

First of all I'd question what's the purpose of a process (Agent) here. There could be multiple reasons for a process: Sharing the same instance of SMTP client with multiple processes, controlling ...
Dmitry Belyaev's user avatar
2 votes

Retrieving first non-private ip for local system in elixir

There is few problems there: There is no :inet.getif/0 function listed in inet module docs, which mean that if such function ...
Hauleth's user avatar
  • 143
2 votes
Accepted

Naive SCP module in Elixir

I have never used Elixir in my life until seeing this question, so my feedback is very limited and I probably shouldn't be putting an answer on here. However, there are a few ways it could be ...
alexyorke's user avatar
  • 1,181
2 votes

Emulating the pipe operator in javascript in a readable way

It works by using the output of each of the functions as the first argument to the next function. The given args are bound to the second argument and up. Just running by this description, one could ...
Joseph's user avatar
  • 25.2k
2 votes

Find the sum of Fibonacci sequence

I'd improve two things: take advantage of ability to specify multiple clauses for anonymous function, use underscore for big numbers to improve code readability. My take on your code: ...
oldhomemovie's user avatar
2 votes

Expose encrypted serial ID in Elixir

I don't understand why encryption would be "hard" - the code above looks straightforward enough although I'm not sure you need the padding (never tried the new crypto APIs). Do note that if you want ...
cdegroot's user avatar
  • 176
2 votes
Accepted

Storing temporary data in ETS - for example, using ETS in a web wizard

Yes, using ETS for this sort of temporary data is totally fine, as long as you realize of course that all that intermediate state is lost whenever you restart your server. In fact, if you dig into ...
cdegroot's user avatar
  • 176
2 votes

String contains non-overlapping letter pairs

You could use a map to store the pairs with their first occurrence while iterating over the pairs. Break if the current pair was already found at a position less than the current position minus 1. <...
aventurin's user avatar
  • 520
2 votes

Extract and divide algorithm implementation in Elixir

(untested) ...
cdegroot's user avatar
  • 176
2 votes

Using Elixir pipeline to transform a string into a map

This would also be solvable with a map instead of a reduce lines |> Enum.map(&String.split(&1, ": ")) |> Map.new(&List.to_tuple/1)
succcubbus's user avatar
1 vote
Accepted

Elixir - Points bot using Ecto

Here are a few suggestions... You could DRY up your code in add_me by returning the string and then making the API call in one place. Also, you should call Repo....
Steve Pallen's user avatar
1 vote

Scoring Ping Pong in Elixir

There's a few things you could do to improve this code: Don't assign inside a case statement. You assign a value to leader inside this case statement: ...
obmarg's user avatar
  • 678
1 vote
Accepted

Extract and divide algorithm implementation in Elixir

I do not have much to say about the pipe operator. It looks fine to me, although maybe some else has something to say... As for the if-else clause, you can use <...
Dair's user avatar
  • 6,008

Only top scored, non community-wiki answers of a minimum length are eligible