Programming as a career

Message Bookmarked
Bookmark Removed
Not all messages are displayed: show all messages (802 of them)

var x = condition ? condition 2 ? a : b : c

yeah my reaction to this is mostly: if you think ternaries in python are bad, wait until you see how people use them in practice in js.

throw massive exception (argh!) if appropriate (oh...)

i get your point but fwiw you can't throw in a ternary.

š¯” š¯”˛š¯”¢š¯”Ø (caek), Wednesday, 15 June 2022 18:18 (one year ago) link

code review today (please excuse clumsy anonymising)


...
.withXXXXXXXXXXXXStartTime(OffsetDateTime.parse((somethingInfo.getXXXXXXXXXXXXStartTime() == null) ? XXXXXXXXXXXXX_START_TIME : DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'").withZone(ZoneId.of("UTC")).format(Instant.EPOCH.plus(somethingInfo.getXXXXXXXXXXXXStartTime()))))
...

kids today with their 300 character-wide monitors

koogs, Thursday, 16 June 2022 16:59 (one year ago) link

yeeeikes

š¯” š¯”˛š¯”¢š¯”Ø (caek), Thursday, 16 June 2022 17:27 (one year ago) link

> if you think ternaries in python are bad, wait until you see how people use them in practice in js.

or java...

koogs, Thursday, 16 June 2022 17:34 (one year ago) link

koogs, when did you start maintaining my old code from a decade ago

mh, Thursday, 16 June 2022 18:24 (one year ago) link

actually, more like fifteen years ago. me old

mh, Thursday, 16 June 2022 18:25 (one year ago) link

Is there a data science thread? Iā€™ve found myself managing some data scientist on a pretty cool project but I am completely out of my league. I work in geography (English major here!) and Iā€™ve been on the job for awhile so I can at least act as an SME but these kids are doing some insane stuff.

Heez, Thursday, 16 June 2022 20:25 (one year ago) link

we should start a real one. weā€™ve just been bouncing between this one and caekā€™s corner iirc

mh, Thursday, 16 June 2022 21:03 (one year ago) link

in my review i suggested moving the 300 character line of code into a separate method and calling that instead.

he duly copied the line verbatim into another method, so there's now a new method with a single 300 character line in it...

koogs, Friday, 17 June 2022 10:36 (one year ago) link

Programmers gonna literal.

Chewshabadoo, Friday, 17 June 2022 10:48 (one year ago) link

lmao

castanuts (DJP), Friday, 17 June 2022 14:52 (one year ago) link

Classic!

Jimmy Jimmy Loves Mary-Anne Mary-Anne (James Redd and the Blecchs), Friday, 17 June 2022 14:55 (one year ago) link

I don't think I've ever typed this out before but one thing I haven't forgotten over many years is someone once saying about someone else "he really is an automaton."

Jimmy Jimmy Loves Mary-Anne Mary-Anne (James Redd and the Blecchs), Friday, 17 June 2022 14:56 (one year ago) link

regexp help. need at least 1 of A B and C, in order

9A9B9C
9A9B
9A9C
9B9C
9A
9B
9C
are all ok (where 9 is any digit). blank is not

so far i have

/^(9A9B9C|9A9B|9A9C|9B9C|9A|9B|9C)$/

which reduces down to

/^(9A(9B9C|9B|9C|)|9B(9C|)|9C)$/

there's slightly more to it than this but this is the crux

koogs, Monday, 20 June 2022 16:08 (one year ago) link

no reason it has to be one line, of course.

koogs, Monday, 20 June 2022 16:30 (one year ago) link

since we got on Java 8 there's been like a competition to see who can make the most convoluted lambda expression possible, I hate it cuz these are so hard to debug

our transfer objects go like 6 layers deep. yeah a bunch of nested if loops looks like crap but you can at least step through it and easily make changes. we have a new developer on one of them now, I can only imagine how much he'd struggle if I did things the way everyone else was

frogbs, Monday, 20 June 2022 17:46 (one year ago) link

Koogs, Iā€™m not great at regex but I find the editor at regexr.com quite useful- lots of user submitted patterns too that can be lifted and adapted

she started dancing to that (Finefinemusic), Monday, 20 June 2022 18:31 (one year ago) link

i don't think we'll ever use more than one of A, B or C, so it'd just be 9b;ABCd; if i had my way.

(will that work?)

koogs, Monday, 20 June 2022 20:24 (one year ago) link

no.


9[ABC]

koogs, Monday, 20 June 2022 20:25 (one year ago) link

lol java 8, theyā€™re on 17 now bruv

(8 is fine, I crack up that they finally did a version release strategy but itā€™s a major number so often)

mh, Tuesday, 21 June 2022 01:30 (one year ago) link

last 3 components i worked on here were 2014 vintage and needed Java 8, wouldn't compile under (our default) Java 11. i didn't upgrade them.

Been downhill all the way with Java since they introduced lambdas.

koogs, Tuesday, 21 June 2022 01:37 (one year ago) link

beginners mindset, youā€™re worse than a weird .net bro now

mh, Tuesday, 21 June 2022 01:40 (one year ago) link

That sounds like a very difficult thing to do in regex, but fairly simple in regular code.

o. nate, Tuesday, 21 June 2022 17:29 (one year ago) link

lol java 8, theyā€™re on 17 now bruv

yea we recently upgraded to 11, idk when we'll ever get to 17. i mean what's the point

frogbs, Tuesday, 21 June 2022 17:47 (one year ago) link

I think I'd just do /^(9A)*(9B)*(9C)*$/ and check not empty/null separately tbh?

I'm assuming that checking for empty string is like one brief, readable line despite my suspicions about Java. I might not be understanding the requirements correctly though and my regexping is rusty.

(tbh I am rustier than ever at programming in general, which I was never good at, and I feel like my days at my current job are numbered because my brain seems to have died and we're implementing a new system I don't understand or care about understanding at all. Sort of feel I should completely give up on making a living doing anything tech-related but can't think of what else I might possibly do. I remember saying all this before, almost exactly half my lifetime ago at the start of my non-career, and probably on this thread several times since then...)

(Current job is in theory part scripting and part support, and the support part expands to fill 99.9% of the time. That's what support jobs are like, right? But also I let it do so, because I always put off any tasks which require
1. concentration/flow/clear-headed thought/forward planning
2. the perceptivity to think of all the possible disastrous problems and guard against them
3. the calmness not to stress yrself to death thinking about what examples of 2 you've forgotten and how much of the database it might delete and how your coworkers will hate you and the boss will thunder down the hall going "WHICH IDIOT LET THIS HAPPEN", again)

a passing spacecadet, Tuesday, 21 June 2022 18:31 (one year ago) link

I think I'd just do /^(9A)*(9B)*(9C)*$/ and check not empty/null separately tbh?

This works from what I can tell, and the only suggestion I'd make is to not bother with capturing them if that's needed:

/^(?:9A)*(?:9B)*(?:9C)*$/

Antifa Lockhart (Leee), Tuesday, 21 June 2022 18:43 (one year ago) link

it's ruby, but that doesn't matter.

i went with readability in the end, listed all the valid combinations in separate lines. you can golf these things but there's a point where concise becomes curt and that's everything i don't like.

but wouldn't /^(9A)*(9B)*(9C)*$/ allow 9A9A9A9A? i can only have at most one of each. replacing the *s (0 or more) with ?s (0 or 1) should do. then, yes, just need to catch "" separately

koogs, Tuesday, 21 June 2022 20:46 (one year ago) link

as for fuckups, we have two components, A (currently on version 367) and B (currently on version 317) and i managed to deploy version 317 of component A to LIVE and didn't notice for an ENTIRE DAY. this is public facing stuff, 10s of thousands of users and not a single bug report or alert. so either nothing important has happened in those last 50 versions or all the built-in redundancy works.

(i've added checks so it won't happen again - it'll now look up the version itself)

koogs, Tuesday, 21 June 2022 20:55 (one year ago) link

but wouldn't /^(9A)*(9B)*(9C)*$/ allow 9A9A9A9A? i can only have at most one of each.

Sorry, yes, it would - I misread "at least 1 of A, B and C" to mean that repeats were OK as long as A-B-C were still in order.

Probably something to be said with listing the valid combinations separately for readability, though. As long as it doesn't result in such a massive list nobody will ever read the whole thing...

a passing spacecadet, Tuesday, 21 June 2022 21:20 (one year ago) link

maybe i'm missing something but isn't it just A.*B.*C
haven't done regex in ages

adam t. (abanana), Friday, 24 June 2022 17:01 (one year ago) link

never mind

adam t. (abanana), Friday, 24 June 2022 17:04 (one year ago) link

two months pass...

maybe i should do more regex? tried for a programming job for the first time in over a decade, flubbed a coding task where it required a "\w" but I put in a "*". fun but stressful.

formerly abanana (dat), Wednesday, 24 August 2022 04:40 (one year ago) link

i love writing regexes--they're like a fun puzzle imo. regex101.com is a good tool for writing/debugging

diamonddave85ļ»æ (diamonddave85), Wednesday, 24 August 2022 14:46 (one year ago) link

but \w / \W seems designed to confuse

koogs, Wednesday, 24 August 2022 15:26 (one year ago) link

I enjoy writing regexes too, but I donā€™t think Iā€™ve ever written one without referring to a cheat sheet. They donā€™t seem like good material for interview questions because who can remember all those special characters.

o. nate, Wednesday, 24 August 2022 18:41 (one year ago) link

I have spent my entire career avoding using regex as much as I possibly can, the most unreadable abominations that they are.

Chewshabadoo, Wednesday, 24 August 2022 19:00 (one year ago) link

xp yeah it reminds me of the tests I got in college where you had to remember specific syntax which always felt dumb because in the real world you could just Google it. which I still do, often :)

in retrospect it was kind of funny how adamant they were about not sharing your code with your classmates, even calling it "plagiarism" over and over, when in reality like half of what I do is copy something and change it a bit

frogbs, Wednesday, 24 August 2022 19:04 (one year ago) link

lol, I was careful to specify that I enjoy writing regexes. Reading them, not so much.

o. nate, Wednesday, 24 August 2022 19:38 (one year ago) link

you bugger

the man with the chili in his eyes (ledge), Wednesday, 24 August 2022 19:58 (one year ago) link

(Google image search has the answer. i remember doing it at the time and getting less than half)

koogs, Wednesday, 24 August 2022 20:05 (one year ago) link

two months pass...

https://thetypingoftheregex.com/

ionjusit (P. Flick), Thursday, 27 October 2022 14:29 (one year ago) link

so,

"What have you done to his eyes?"

with "What" and "have" highlighted. what matches that? 4 letter words with a 'ha' in them? how do you write that as a reg exp? what am i missing?

koogs, Thursday, 27 October 2022 15:57 (one year ago) link

would it work to do everything in string before 'you'?

I have to google regex solutions rather than knuckling down and learning the syntax, so i don't share this as someone who can complete it. Admire anyone who can though!

ionjusit (P. Flick), Thursday, 27 October 2022 16:44 (one year ago) link

um, maybe, letters rather than words. it goes so quickly though it's hard to spot the patterns.

i had another that was two words starting with ex among other words.

koogs, Thursday, 27 October 2022 17:16 (one year ago) link

there's a video of the game on the guy's twitter feed, you use the global flag: /What|have/g

ledge, Thursday, 27 October 2022 17:49 (one year ago) link

I guess /[^\s]+ha[^\s]+/ would work, harder to type quickly though.

ledge, Thursday, 27 October 2022 17:52 (one year ago) link

Ugh so fussy, but I guess that's regex for you (I keep forgetting to match the punctuation when that's part of what it looks for).

Fartleby the Scrivener (Leee), Thursday, 27 October 2022 18:01 (one year ago) link

i've written my fair share of regexes and i have no idea how to do the exclusions... what's the syntax? also symbol ligatures (try typing !=) are for disgusting savages

diamonddave85ļ»æ (diamonddave85), Thursday, 27 October 2022 19:55 (one year ago) link

symbol ligatures and cursive italics or, as i call it, "frontend brain".

š¯” š¯”˛š¯”¢š¯”Ø (caek), Thursday, 27 October 2022 19:57 (one year ago) link


You must be logged in to post. Please either login here, or if you are not registered, you may register here.