ityonemo
I’ve been internally using a library for IP and Mac addresses, and thought I’d open source the toolset. Some of the more interesting features include
- guard clauses
is_ip,is_ipv4,is_ipv6 - support for CIDR block notation and ease of generating ipv4 broadcast addresses
- sigil_i for IP addresses, ranges, and support for matching pinned variables (useful for /24 addresses)
Trending in Announcing
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries.
offset-based pagination with...
New
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
I released Doggo, a collection of unstyled Phoenix components.
https://github.com/woylie/doggo
Features
Unstyled Phoenix components....
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hello
Published a new library - ProcessHub!
ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
It’s not that it’s vocabulary is too advanced. It’s something worse.
I get lost trying to follow even a paragraph written by Claude. It’...
New
This showed up on my feed.. anyone heard of it? Just hype?
Ox Alpha is a reasoning model designed for coding, sustained ag...
New
Hey folks,
I just published a post about Hologram’s funding and where the project goes next - the short version:
Curiosum as Main Spons...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
dimitarvp
Pretty useful, thanks for that.
hauleth
I would only change
from_string/1toparse/1andparse!/1instead to match theIntegerandFloatAPI more closely.ityonemo
Parse returns a tuple that contains an extra binary useful for unit matching, no?
hauleth
Yes, but in general I would assume
IP.from_string/1(orIP.parse/1) to return error tuple instead of throwing on error. You can pick any naming, but I would expect to have “failure-safe” way to parse data.ityonemo
I think in elixir, .to_x and .from_x are designed to output naked values (String.to_integer/1 raises on a non-integer string), and be in pipelines, but your point about wanting something that outputs an error tuple on conversion is taken under advisement! function that returns an error tuple instead of raising on conversion · Issue #1 · ityonemo/net_address · GitHub
dimitarvp
While you are generally correct I believe that having a bang variant like
parse!signals even more clearly that the function might raise an exception which also implies thatparsewould return an ok/error tuple.As another anecdotal evidence data point, I would also naively believe that
from_stringwould not raise and would return an ok/error tuple as well (although this expectation might be severely misguided – I really don’t know).ityonemo
The standard library’s Map.from_struct/1 does not return an error tuple. But doing a more comprehensive look, I see that the datetime/time/naivedatetime modules have from_* functions which do emit error tuples. I guess network addresses seem more like datetimes than structs, so I’ll go ahead and make the from_ functions emit tuples and have the bang equivalents throw.
ityonemo
updated in 0.2.0 to have bang functions and tuple functions for from_* functions, and as a bonus I implemented random and IP.SockAddr module.
mbklein
I like how you used the
mmodifier onsigil_i. Nice touch.ityonemo
updated in 0.3.0 to have ranges and subnets work in each other’s
Kernel.in/2implementations; also implementsis_infunction to detect membership in ranges and subnets, in guards.