this post was submitted on 15 Nov 2023
972 points (95.6% liked)

Programmer Humor

19817 readers
58 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 2 years ago
MODERATORS
 
top 50 comments
sorted by: hot top controversial new old
[–] FauxPseudo@lemmy.world 310 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*$"

[–] YIj54yALOJxEsY20eU@lemm.ee 105 points 1 year ago

Lord have mercy

[–] dannym@lemmy.escapebigtech.info 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).

[–] Emma_Gold_Man@lemmy.dbzer0.com 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)
[–] MsPenguinette@lemmy.world 50 points 1 year ago (4 children)

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

[–] Nalivai@discuss.tchncs.de 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

[–] tilcica@lemm.ee 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)
[–] rob64@startrek.website 37 points 1 year ago (1 children)
[–] Patches@sh.itjust.works 19 points 1 year ago* (last edited 1 year ago) (1 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

[–] rob64@startrek.website 9 points 1 year ago* (last edited 1 year ago) (2 children)

Holy hell yeah you did. How would you go about doing that in a single expression? A bunch of back references to figure out the country? What if that's not included? Oy.

[–] Patches@sh.itjust.works 15 points 1 year ago* (last edited 1 year ago) (2 children)

You wouldn't. It's not possible. Which is what I told them.

And why would you want to? Legally if you change the given address, and it fails to get delivered - that is on you. Not them.

Some countries have addresses that are literally 'Last house on the left by the Big Tree. Bumban(Neighborhood). NN (Country)'. Any US Centric validation would fail this but I assure you - mail gets delivered just fine.

load more comments (2 replies)
load more comments (1 replies)
[–] BeigeAgenda@lemmy.ca 31 points 1 year ago

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

[–] SchizoDenji@lemm.ee 29 points 1 year ago

I knew there would be someone with the regex.

[–] takeda@lemmy.world 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)
[–] Static_Rocket@lemmy.world 173 points 1 year ago (2 children)

0.0.0.0/0 0::0/0

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

[–] Mr_Dr_Oink@lemmy.world 7 points 1 year ago (1 children)

Remember, when we abbreviate an ipv6 address all leading zeros are reduced to a single 0.

E.g

0003 would just become 03

When there are geoups of 4 zeros these can be represented as a single 0 or as a double colon ::

But we can only use the :: once so when summarizing an address containing multiple groups of 4 0s one after the other they can all be abbreviated to a single ::

Eg

fe80:0000:0000:0000:0210:5aff:feaa:20a2 would become fe80::210:5aff:feaa:20a2

Therefore it is perfectly valid to abbreviate an address of 0000:0000:0000:0000:0000:0000:0000:0000 /0 to just ::/0

load more comments (1 replies)
[–] Mr_Dr_Oink@lemmy.world 88 points 1 year ago (4 children)

0.0.0.0 /0 ::/0

SUCK MY DICK, GRU!

load more comments (4 replies)
[–] agilob@programming.dev 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)
[–] michaeljo94@discuss.tchncs.de 66 points 1 year ago (2 children)
[–] Emma_Gold_Man@lemmy.dbzer0.com 21 points 1 year ago (1 children)

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

load more comments (1 replies)
[–] Kolanaki@yiffit.net 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

...

[–] knobbysideup@lemm.ee 41 points 1 year ago* (last edited 1 year ago) (2 children)
load more comments (2 replies)
[–] rez_doggie@lemmy.world 40 points 1 year ago
[–] doctorcrimson@lemmy.today 26 points 1 year ago* (last edited 1 year ago) (2 children)

ipv4 [0,255].[0,255].[0,255].[0,255]

ipv6 [0000,ffff]:[0000,ffff]:[0000,ffff]:[0000,ffff]:[0000,ffff]:[0000,ffff]:[0000,ffff]:[0000,ffff]

[–] Hobo@lemmy.world 14 points 1 year ago* (last edited 1 year ago) (1 children)

This excludes all the ipv4 ips that have a 0 in the 2nd, 3rd, and 4th octets. Sorry but we're going to have to revoke your Network Engineering credentials.

load more comments (1 replies)
[–] tabularasa@lemmy.world 10 points 1 year ago (1 children)

Not to nitpick, but an IPv6 address is represented as eight groups of four hexadecimal digits separated by :. Like 2001:0db8:3333:4444:5555:6666:7777:8888.

load more comments (1 replies)
[–] dan@upvote.au 26 points 1 year ago* (last edited 1 year ago) (1 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 😂

[–] coloredgrayscale@programming.dev 6 points 1 year ago (2 children)

Heard about that too! Is there an updated version for ipv6?

[–] spuncertv@iusearchlinux.fyi 10 points 1 year ago* (last edited 1 year ago)

That file would be ungodly large. There are 2^128 possible addresses, each weighing in at 128 bits, 16 bytes. 16 bytes times 340 trillion trillion trillion. That puts us around 5.44 trillion Zettabytes. The estimates I've seen for worldwide data storage sit aroun 60-70 zettabytes.

load more comments (1 replies)
[–] Seasm0ke@lemmy.world 22 points 1 year ago
[–] shootwhatsmyname@lemm.ee 21 points 1 year ago

one of them has a 7 I’m pretty sure

[–] GammaGames@beehaw.org 20 points 1 year ago
[–] Napain@lemmy.ml 18 points 1 year ago (1 children)
[–] Z3k3@lemmy.world 22 points 1 year ago

That's only 1 ip (single host)

[–] spudwart@spudwart.com 16 points 1 year ago

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

[–] quinkin@lemmy.world 16 points 1 year ago (1 children)

1 and 0. Some assembly required.

load more comments (1 replies)
[–] 018118055@sopuli.xyz 15 points 1 year ago
[–] MonkderZweite@feddit.ch 15 points 1 year ago* (last edited 1 year ago)

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

[–] vox@sopuli.xyz 11 points 1 year ago
[–] xav@programming.dev 11 points 1 year ago (4 children)

I'll start.

0.0.0.1: Sophie

Your turn.

load more comments (4 replies)
[–] LemmysMum@lemmy.world 9 points 1 year ago (1 children)
load more comments (1 replies)
[–] HiddenLayer5@lemmy.ml 9 points 1 year ago (1 children)
[–] QuazarOmega@lemy.lol 10 points 1 year ago (1 children)
[–] stringere@reddthat.com 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)
[–] DaveedMee@beehaw.org 7 points 1 year ago
[–] RIP_Cheems@lemmy.world 6 points 1 year ago (1 children)
load more comments (1 replies)
load more comments
view more: next ›