this post was submitted on 15 Nov 2023
1012 points (95.7% liked)

Programmer Humor

19572 readers
2063 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 312 points 1 year ago (10 children)

Ok. This covers every ipv6 and ipv4 address.

"^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:)))(%.+)?\s*$"

[–] [email protected] 105 points 1 year ago

Lord have mercy

[–] [email protected] 83 points 1 year ago* (last edited 1 year ago) (1 children)

Please don't. Use regex to find something that looks like an IP then build a real parser. This is madness, its's extremely hard to read and a mistake is almost impossible to spot. Not to mention that it's slow.

Just parse [0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3} using regex (for v4) and then have some code check that all the octets are valid (and store the IP as a u32).

[–] [email protected] 11 points 1 year ago (8 children)

And dupe check. 0.0.0.0 and 000.000.000.000 may both be valid, but they resolve the same

load more comments (8 replies)
[–] [email protected] 51 points 1 year ago (5 children)

IPv6 was a mistake. We should have just added an addition octet

[–] [email protected] 75 points 1 year ago (5 children)

That would allow for like, 2 trillion devices? Feels like a bandaid, my dude. Next you’re gonna suggest a giant ice cube in the ocean once a year to stop global warming.

[–] [email protected] 13 points 1 year ago (1 children)

So add two more octets:

Moat companies will still just use something like 10.0.13.37.0.1

[–] [email protected] 11 points 1 year ago (5 children)

IPv6 is not made with internal networks in mind lol

load more comments (5 replies)
[–] [email protected] 9 points 1 year ago (2 children)
load more comments (2 replies)
load more comments (3 replies)
[–] [email protected] 17 points 1 year ago (2 children)

Oh yeah, great, let's change the fundamental protocol on which all the networks in the world are based. Now two third of the devices in the world crashed because you tried to ping 192.168.0.0.1

[–] [email protected] 12 points 1 year ago

that WOULD be quite funny for the first second or 2....

load more comments (1 replies)
load more comments (3 replies)
[–] [email protected] 37 points 1 year ago (1 children)
[–] [email protected] 20 points 1 year ago* (last edited 1 year ago) (5 children)

Made that joke in an interview once.

They didn't think it was funny. They truly thought Regex was the solution to, but never the cause of, all problems.

They wanted to make a Regex to verify every single address in the world. Dodged a bullet

load more comments (5 replies)
[–] [email protected] 31 points 1 year ago

It's always a treat to debug a regex of that size.

[–] [email protected] 29 points 1 year ago

I knew there would be someone with the regex.

[–] [email protected] 18 points 1 year ago* (last edited 1 year ago)

You're more of a perl programmer than network engineer :P

load more comments (3 replies)
[–] [email protected] 177 points 1 year ago (3 children)

0.0.0.0/0 0::0/0

You didn't specify it couldn't be in CIDR block notation...

[–] [email protected] 27 points 1 year ago
load more comments (2 replies)
[–] [email protected] 91 points 1 year ago (4 children)

0.0.0.0 /0 ::/0

SUCK MY DICK, GRU!

load more comments (4 replies)
[–] [email protected] 81 points 1 year ago* (last edited 1 year ago) (1 children)

:00 - :ff

Edit: Just learnt this can be also noted as:

:: - ::f

load more comments (1 replies)
[–] [email protected] 68 points 1 year ago (2 children)
[–] [email protected] 21 points 1 year ago (1 children)

Better hope the goon hasn't heard of IPv6 either, or you're toast

[–] [email protected] 21 points 1 year ago
load more comments (1 replies)
[–] [email protected] 65 points 1 year ago* (last edited 1 year ago)

This is gonna take a while...

0.0.0.0

0.0.0.1

0.0.0.2

0.0.0.3

...

[–] [email protected] 42 points 1 year ago* (last edited 1 year ago) (2 children)
load more comments (2 replies)
[–] [email protected] 40 points 1 year ago
[–] [email protected] 27 points 1 year ago* (last edited 1 year ago) (3 children)

This reminds me of something I saw online maybe 20 years ago now. Someone created a torrent with a name like "every IP address ever (hacking tool)" and uploaded it to Suprnova, which ended up having thousands of people seeding it. It was just a text file with every IPv4 from 0.0.0.0 to 255.255.255.255 😂

load more comments (3 replies)
[–] [email protected] 23 points 1 year ago

127.0.0.1, I'm an introvert

[–] [email protected] 22 points 1 year ago (1 children)

one of them has a 7 I’m pretty sure

load more comments (1 replies)
[–] [email protected] 22 points 1 year ago
[–] [email protected] 21 points 1 year ago
[–] [email protected] 20 points 1 year ago (1 children)
[–] [email protected] 22 points 1 year ago

That's only 1 ip (single host)

[–] [email protected] 17 points 1 year ago

I mean if I name them do I have to own the domain or…

[–] [email protected] 16 points 1 year ago (1 children)

1 and 0. Some assembly required.

load more comments (1 replies)
[–] [email protected] 15 points 1 year ago
[–] [email protected] 15 points 1 year ago* (last edited 1 year ago)

My PC's is now Bob, My router's Billy...

[–] [email protected] 13 points 1 year ago (4 children)

I'll start.

0.0.0.1: Sophie

Your turn.

load more comments (4 replies)
[–] [email protected] 12 points 1 year ago* (last edited 1 year ago)

0.0.0.0/0

::

[–] [email protected] 11 points 1 year ago
[–] [email protected] 10 points 1 year ago (1 children)
[–] [email protected] 10 points 1 year ago (1 children)
[–] [email protected] 13 points 1 year ago (1 children)

UDP

I'd love to tell you a joke about UDP but I'll never know if you get it.

load more comments (1 replies)
[–] [email protected] 10 points 1 year ago (1 children)
load more comments (1 replies)
load more comments
view more: next ›