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 ...
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 ...
3
votes
Accepted
Using Elixir pipeline to transform a string into a map
You can do this with an anonymous function
...
3
votes
Elixir/Ecto find_or_create with custom error
I think it is a perfect fit for with. It will be something like:
...
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 ...
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 ...
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 ...
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 ...
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:
...
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 ...
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 ...
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.
<...
2
votes
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)
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....
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:
...
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 <...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
elixir × 50beginner × 8
functional-programming × 6
strings × 3
recursion × 3
datetime × 3
error-handling × 3
phoenix-framework × 3
performance × 2
algorithm × 2
unit-testing × 2
validation × 2
javascript × 1
programming-challenge × 1
sql × 1
parsing × 1
reinventing-the-wheel × 1
comparative-review × 1
tree × 1
security × 1
matrix × 1
formatting × 1
database × 1
template × 1
cryptography × 1