There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

programmer_humor

This magazine is from a federated server and may be incomplete. Browse more on the original instance.

debil , in Merge then review

I dunno but xtreme programming sounds like something straight outta Musk’s wettest teenage day dreams.

Bakkoda ,

Imagine if you will: You have a red button and a green button. You are allowed 10 seconds to review the code before rejecting or accepting & merging. Think fast.

xav , in GoOn

I’ll start.

0.0.0.1: Sophie

Your turn.

starman2112 ,
@starman2112@sh.itjust.works avatar

0.0.0.2 is Bob

tamiya_tt02 ,

0.0.0.3 is Clarence

1847953620 ,

0.0.0.4 is Darryl

v81 ,

127.0.0.1 is you

irdc , in Welcome to the wonderful world of code obfuscation

<span style="color:#323232;">weekend = day_of_week in (“sat”, “sun”)
</span>

As a bonus this completely sidesteps the issue of what day is 0 or 1.

baseless_discourse ,

Until some idiot sends in “Sunday” as days of the week…

activ8r ,

/^(sun|sat)/i.test(day_of_week)

👍

snowe ,
@snowe@programming.dev avatar

Ah yes the ole sunweday. My favorite day of the weekend.

dbilitated ,
@dbilitated@aussie.zone avatar

yeah I like having an array of days that are weekend days then testing if the day is in the array. can change what days are considered weekend if we go to a three day weekend and it reads really well. I hate massive if statements

ISometimesAdmin , in Welcome to the wonderful world of code obfuscation
@ISometimesAdmin@the.coolest.zone avatar

Depending on whether this code is in a hotpath (and considering how "elementary" it is, I figure that's a possibility), this could very well be a significant speed improvement.

Though I'd say that only excuses it if it's truly an elementary function (and not one line as part of a larger function), as otherwise it's unreadable garbage. But on its own it:

  • has a clear purpose
  • (presumably) isn't reimplementing functionality
  • is easily tested
  • can be modified with no side effects (besides breaking your calendar, but that's beside the point)
DroneRights OP ,

It’s one line as part of a larger function. Also, it doesn’t actually say weekend, it just executes some other functionality if !(day % 6). I made it more readable so that everyone here could understand what it does

eluvatar , in Welcome to the wonderful world of code obfuscation

Honestly the first one is the only one that works when people define the first day of the week differently. On the other hand, it does make you wonder. If Sunday is the first day of the week (as it is in many places) then how is it also part of the weekend?

subignition ,
@subignition@kbin.social avatar

Yeah it's the front end of the week and Saturday is the rear end

Esca ,

But if you’re worried about locale, you can’t assume people use the string “Saturday” to describe Saturday either. That solution only works in English.

jonne ,

I assume this is in a language where the first day of the week is a fixed part of the language (like JS).

Halosheep ,

They’re the week’s ends, front and back.

Schrolli97 ,

Thats not really one weekend then though, is it? Its more like last week’s post-week weekend and this week’s pre-week weekend

dauerstaender , in Welcome to the wonderful world of code obfuscation

Why would you call it weekend and the start the week with half of it?!

DroneRights OP ,

A rope has two ends, and so does a week

DrunkenPirate ,

Sentences have both meanings and sound, yours have sound

subignition ,
@subignition@kbin.social avatar

Methinks your username is a little too relevant right now :p

Scrath ,

I like fancy insults

magic_lobster_party ,

Do you say weekend or weekends?

boredtortoise ,

Three-day workweek now

fl42v ,

So, where does it start then?

DroneRights OP ,

At the ends

Lysergid , in Welcome to the wonderful world of code obfuscation

weekend = dayOfWeek > 5

DroneRights OP , (edited )

Sunday is 1 0 and Saturday is 7 6. You just made Friday part of the weekend You forgot Sunday

JeffKerman1999 ,

On which planet? Monday is 1

DroneRights OP ,

I was off by one, but Sunday is 0 in javascript

Cralder ,

JavaScript is wrong

DroneRights OP ,

That’s nice, you can run weekend = dayOfWeek > 5 and then explain to the boss why clients are getting work texts on a sunday

JeffKerman1999 ,

Don’t use JavaScript on the backend ¯_(ツ)_/¯

DroneRights OP ,

I’ll be sure to tell my boss to throw away all the work he already paid for and start over in a different language. I’m sure he’ll be very understanding

emmanuel_car ,

Sunken cost fallacy

DroneRights OP ,

I don’t think you understand the concept of having a boss.

Earlier this week I proved to him that his new “more secure” password policy results in passwords that can be cracked in under a minute, and he didn’t care

xmunk ,

Sneak in a library that makes things more sane when nobody is looking…

Also, that isn’t “having a boss” it’s having a shit boss. As an engineering manager I am happy to go to bat and make excuses for time my reports spend paying down technical debt and making things more maintainable (within reason of course, and if shits really bad I can usually sneak a sustainability project into the timeline).

We’ll always need to make some compromises for our workplaces, the perfect job doesn’t exist, but what you described is a huge red flag. You deserve respect at work.

Cosmicomical ,

Yo nodejs is just plain amazing. We should just keep improving on js and replace all other languages. Js is already on all browsers, by adopting it on the server you get huge efficiency as you can move code AND coders between backend and frontend. Of course you must make the right choices of practices and frameworks for this to be possible

JeffKerman1999 ,

I agree! How many js frameworks spawned today? Which one is best?

oolio ,

Cron has clearly the superior numbering system, where sunday is both 0 and 7

kungen ,

Depending on how you’re counting your integers, Monday is 0, being the first day of the week.

Zagorath ,
@Zagorath@aussie.zone avatar

Both Monday and Sunday are used as the first day of the week with quite some regularity. It’s a completely arbitrary standard no different to "the tenth month is the one called “October”. Or dividing a day into 24 segments which are each broken into 60 smaller segments of 60 even smaller segments. You can’t say either is “wrong” per se.

Personally, I was brought up learning Sunday is the first day of the week, but at some point decided that was bullshit partly because it’s the week end. But also just from a practical standpoint when looking at a calendar, it’s useful to have the weekend days grouped together.

DroneRights OP ,

Yeah, that’s why my calendar starts the week on Saturday

Cosmicomical ,

Funny thing, september comes from the number 7, october from 8 and november and december from 9 and 10, as the year in ancient rome was starting around march. This problem is timeless.

Zagorath ,
@Zagorath@aussie.zone avatar

Huh. I knew about the problem (that’s why I used October as my example, rather than, say, February), but I was mistaken as to the cause. The way I had always heard it told, September–December don’t match their current place in the year because of the addition of July and August. But I just looked it up and it seems you’re right. Those months are merely renamings of Quintilis and Sextilis, and the numbering issue comes from moving the start of the year from March to January.

Cosmicomical ,

Phew luckily my random memory was correct this time!

theKalash ,

On planet America.

JeffKerman1999 ,

Ah the same place that uses feet and inches, and puts the month before the day, and cannot read a 24 hour clock?

4am ,

dayOfWeek is clearly represented by 1-7 in the example, with Sunday being 1.

So, I guess the answer is “depends on what date library you’re linking against”

blakeus12 , in GoOn
@blakeus12@hexbear.net avatar

s.w.x.y/z

plug it into a 5-dimensional graph and there you go.

MiddledAgedGuy , in GoOn
rez_doggie , in GoOn

0.0.0.0/0

LemmysMum , in GoOn

127.0.0.1

open_world ,
@open_world@lemmy.world avatar

Heh, you just doxxed yourself

ohlaph , in GoOn

Doug

doctorcrimson , (edited ) in GoOn

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 ,

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.

doctorcrimson ,

thanks, fixed

tabularasa ,

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.

nephs ,

I’ll leave the regex to validate an ipv6 address as an exercise to the reader.

doctorcrimson ,

Omg, that’s twice now I’ve messed it up. Fixed.

HiddenLayer5 , in GoOn

Name every protocol

QuazarOmega ,
  • TCP
  • UDP
stringere ,

UDP

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

QuazarOmega ,
  • TCP
  • UDP

(Yes, this is a TCP joke)

vox , in GoOn
@vox@sopuli.xyz avatar

ipv6

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines