Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
fuf
Sep 12, 2004

haha

go play outside Skyler posted:

if you put HandleChange in a callback context, "this" will refer to the callback context with version 2. With version 1, "this" will be implicitly captured and refer to whatever it was when the function was defined.

Thanks, I just about get this.


MrMoo posted:

usually the same people believe https://standardjs.com/ is actually real.

This looks kind of good? What's the issue?

Adbot
ADBOT LOVES YOU

necrotic
Aug 2, 2005
I owe my brother big time for this!

fuf posted:

Thanks, I just about get this.

This looks kind of good? What's the issue?

No semicolons alone is enough to throw that out. “Just memorize all the stupid automatic semicolon insertion rules~” no I’ll just tell it what I intend by using semicolons.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

necrotic posted:

No semicolons alone is enough to throw that out. “Just memorize all the stupid automatic semicolon insertion rules~” no I’ll just tell it what I intend by using semicolons.

:same:

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Semicolons should be required I don't understand this whole "write it like a caveman and it'll still work" attitude. Make the syntax strict! I'm so tired of opening popular repositories on github and realizing I don't want to use it.

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself

Nolgthorn posted:

Semicolons should be required I don't understand this whole "write it like a caveman and it'll still work" attitude. Make the syntax strict! I'm so tired of opening popular repositories on github and realizing I don't want to use it.

are you saying you won't use a library if the author doesn't use semicolons?

what the gently caress? weren't you the guy that was complaining about typescript absolutists a page ago?

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Typescript does have a benefit in that it'll format the code when you compile it.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

teen phone cutie posted:

are you saying you won't use a library if the author doesn't use semicolons?

i don't know if you're trying to accuse Nolgthorn of hypocrisy or something but if I saw a library, looked through the github, and saw that it was written in semicolon-less javascript, I'd nope the gently caress out pretty much independent of any other merit the library has.

Roadie
Jun 30, 2013

Bruegels Fuckbooks posted:

i don't know if you're trying to accuse Nolgthorn of hypocrisy or something but if I saw a library, looked through the github, and saw that it was written in semicolon-less javascript, I'd nope the gently caress out pretty much independent of any other merit the library has.

Wow, that's stupid.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I think you start to become more wary of what's in your node_modules directory with age, as it causes increasingly large headaches over the course of your career. So I end up assuming people who don't care just aren't very experienced yet. Which is fine there's nothing wrong with that but I'm not going to argue about it. When I see poorly written code in a repository I second guess how badly I need it.

Those libraries are going to be the first to stop being supported by their repository owner. Maybe they decide to rewrite it, which if the repository is popular means they'll branch off to a different library entirely. Which will involve either a migration task in the future or I'll have to babysit what node version it supports. I'll have to see warnings from npm saying there's security vulnerabilities in my dependencies.

All of this says nothing about how many dependencies the dependencies have, each of which has the same problem. And code that's written poorly tends to be written by people who don't care about what's in their node_modules directory. So, it is all part of the same pile.

smackfu
Jun 7, 2004

Wasn’t there a big todo over a library that wasn’t using semicolons in their doc examples and it caused a lot of angst?

fsif
Jul 18, 2003

Recently collaborated with a developer that used no semicolons. It was fine. Code readability is exactly the same.

lunar detritus
May 6, 2009


I don't care if they use semicolons or not, as long as they are using some sort of linter. Standard may not be what I like but if a library is using it the fact that they are obeying a strict guide-style is a big plus.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!
This is a great example of why the language should just require semicolons (or require no unnecessary semicolons I suppose). If consistency is enforced then nobody needs to argue opinions about it.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

fsif posted:

Recently collaborated with a developer that used no semicolons. It was fine. Code readability is exactly the same.

semicolonless javascript is fine except when it's not. the problem is there are edge cases and they suck - like https://stackoverflow.com/questions/2846283/what-are-the-rules-for-javascripts-automatic-semicolon-insertion-asi. i don't want to have to learn these rules when people can just put the loving semicolons where they ought to go.

MrMoo
Sep 14, 2000

fsif posted:

Code readability is exactly the same.

It’s not when you see a line with a semicolon at the start, it’s like “you typoed here bud.”

fsif
Jul 18, 2003

Bruegels Fuckbooks posted:

semicolonless javascript is fine except when it's not. the problem is there are edge cases and they suck - like https://stackoverflow.com/questions/2846283/what-are-the-rules-for-javascripts-automatic-semicolon-insertion-asi. i don't want to have to learn these rules when people can just put the loving semicolons where they ought to go.

This never came up and we have a linter that formats on save anyway.

MrMoo posted:

It’s not when you see a line with a semicolon at the start, it’s like “you typoed here bud.”

I don't know what this sentence means.

MrMoo
Sep 14, 2000

fsif posted:

I don't know what this sentence means.

code:
const TEST_USER_CREDENTIALS: AgentAuthManager.UserCredentials = {
  userName: 'testUser1',
  password: 'cheese!',
}
;(
  window as unknown as Window & { gLoggingAgentHandle: WorkerHandle }
).gLoggingAgentHandle.authManager = new AgentAuthManager(
  TEST_POOL_CONFIG,
  TEST_USER_CREDENTIALS,
)
Spot the semicolon.

worms butthole guy
Jan 29, 2021

by Fluffdaddy
Hey everyone,

I'm not sure the best way to word this question but hoping someone can decipher what i'm asking lmao.

I have a system of timestamps in C#:

code:
"beatTime": "00:00:05.0840000"
which gets converted to a TimeSpan via JSONDeserializer.

I am trying to make a way of capturing times in a React app using javascript, which captures time from the audio player like this:

code:
"beatTime": 226.539319
besides the obviously stringification, i'm wondering if anyone knows the format of either the C# or javascript one so I can convert it? I tried :

code:
      let minutes = Math.floor(timeSong / 60)
        let seconds = Math.floor(timeSong - (minutes * 60))

but it wasn't entirely accurate to the time stamp

Thanks...hope this kinda made sense

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

worms butthole guy posted:

code:
      let minutes = Math.floor(timeSong / 60)
        let seconds = Math.floor(timeSong - (minutes * 60))

but it wasn't entirely accurate to the time stamp
Do you just mean you lost the fractions-of-seconds? You're getting the rounded down whole numbers of seconds there, because Math.floor. Do you get what you want if you do
code:
      let minutes = Math.floor(timeSong / 60)
      let seconds = timeSong - (minutes * 60)

worms butthole guy
Jan 29, 2021

by Fluffdaddy
That did it, I was overthinking it. Thank you!

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I'm in node_modules heck

So, as with every company I've ever worked for I was given a bug ticket. It says that puppeteer which opens our html assets server side is taking screenshots and the images in the screenshot are blurry. I track it down to our version of Chrome running on the server needing to be updated.

Well this means the version of puppeteer needs to be updated since every version of puppeteer is only suitable for one version of chrome. However when I update the version of puppeteer and I update the version of Chrome now I get the following error. Because why would it work? What possible scenario could I ever expect the updating of a module to ever work? The whole point of node_modules is to break the second you have to touch anything in there.

code:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './internal/node/install.js' is not defined by "exports"
Of course, Package subpath is not defined by exports what the heck does that mean? Apparently there's several schools of knowledge about this error. One is that you should delete your node_modules and .lock file, then install everything again. Another is to npm update, and another is to npm audit fix. None of which solves my problem so if I just dig a little bit deeper maybe I'll come up with a solution.

Thankfully I found the rogue dev who posts their findings, usually this happens on mailing list archives. There were more than one, I tried all of them but one got me closer than the others. They say that the new version of puppeteer doesn't throw this error as long as it's below a certain version. So I downgrade puppeteer and go through the effort of figuring out what version of Chrome that version supports, and find a copy of that too.

Now, I get a little bit further, now it's a totally different error.

code:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './internal/common/DeviceDescriptors.js' is not defined by "exports"
Oh great. I forgot why I love node_modules so much, and why maybe an entire industry shouldn't depend on a handful of dipsticks who were responsible for nuking a bunch of servers a year or two ago because of a `rm -rf` bug they included in a patch release.

I have spent an entire day on this now. It's pretty unbelievable. I just want the dang version of Chrome to update.

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
i have no idea what the error could possibly be, but if there's truly some broken code in the module itself, patch package is always a good tool to rely on.

https://github.com/ds300/patch-package#readme

basically you can make a diff to node_module code and it'll apply your new change on the postinstall hook

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Sounds interesting, thanks

ThePopeOfFun
Feb 15, 2010

Whats the VS Code Typescript shortcut for jumping out of brackets/parenthesis like Tab does in C#? I don’t know what the setting is called to change the keybind

bigperm
Jul 10, 2001
some obscure reference

ThePopeOfFun posted:

Whats the VS Code Typescript shortcut for jumping out of brackets/parenthesis like Tab does in C#? I don’t know what the setting is called to change the keybind

I don't know if there is a keybind for that but I use Tab Out and have never had a problem with it.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

Nolgthorn posted:

ERR_PACKAGE_PATH_NOT_EXPORTED

The solution to this was to update node to a compatible version inside of the docker instance. Now instead npm is telling me dotenv is not installed, it certainly absolutely is. I've deleted node_modules and .lock again, re-installed, force installed, cleared cache, audit fix on and on and on.

Npm is impossibly bad.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Ever feel like "is this honestly what they pay me for?"

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
well deleting your .lock is usually a bad idea because it's going to update almost all your packages and just cause more problems.

e; maybe if you post a github repo with the issue happening we could help better?

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I'm at a company that enforces strict versions in the package json file, like most companies are these days. You can't rely on third party developers to use semvar properly, which is why the lock file was introduced. But then when you look up just about any npm related issue half the suggestions are to delete the lock file. So, it's worthless. I can't imagine depending on it.

It's not the cause of this issue anyway.

camoseven
Dec 30, 2005

RODOLPHONE RINGIN'
Works on my machine :shrug:

ThePopeOfFun
Feb 15, 2010

bigperm posted:

I don't know if there is a keybind for that but I use Tab Out and have never had a problem with it.

Excellent, thank you.

necrotic
Aug 2, 2005
I owe my brother big time for this!

Nolgthorn posted:

The solution to this was to update node to a compatible version inside of the docker instance. Now instead npm is telling me dotenv is not installed, it certainly absolutely is. I've deleted node_modules and .lock again, re-installed, force installed, cleared cache, audit fix on and on and on.

Npm is impossibly bad.

Er , if docker is in the picture and you “update node … in a docker instance”…. Might that be your issue? I mean, docker? Have you tried rebuilding the container?

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Yes.

The problem was that I need separately to run `npm install` inside each docker container that wants to use this specific library, after navigating to the directory where it is used, because of the way that library is being triggered, which is inside of a postinstall hook or something like that. I've forgotten the details because when it comes to problems like this I hate them so much I erase the solution from my brain.

That way if they ever come up again I can re-experience solving the problem from scratch.

Separately updating node broke many libraries in node_modules and so on. And then every so often I'll be browsing the web and someone shows up and is like "I don't know why anyone would care what's in their node_modules directory that seems silly to me."

So anyway, all I wanted to do a few days ago was update chrome.

Sab669
Sep 24, 2009

Quick question: what's the easiest way to call a function when a div scrolls into view?


End users want a giant single-scrolling app, "like the Word document we use that this app is based off of", so I implemented a single accordion style menu that they can click on and it'll scroll them to the appropriate section of the page using this code:

code:
<span role="button" (click)="updateSelectedChildTab(section.index, subSection.index)">
	{{subSection.sectionHeader}}
</span>

updateSelectedChildTab(parentTabIndex: number, childTabIndex: number): void
{
	if (parentTabIndex != null && childTabIndex != null && this.isDataLoaded)
		document.getElementById('div' + parentTabIndex + childTabIndex).scrollIntoView();
}
When the user clicks on an item from the menu, I apply a style to shade it -- but I'd also like for this styling to get applied as the user manually scrolls through the app, highlighting the appropriate nav menu items as they scroll in & out of each. All I need is to basically just pass in the div name of the one coming into view as that would have the "coordinates" for me to find the correct accordion item to highlight.

Sab669 fucked around with this message at 18:30 on Dec 15, 2022

Obfuscation
Jan 1, 2008
Good luck to you, I know you believe in hell
Check the position of the screen after scrolling and compare it to element positions, something like this.

Sab669
Sep 24, 2009

Obfuscation posted:

Check the position of the screen after scrolling and compare it to element positions, something like this.

:toot: Thanks!

necrotic
Aug 2, 2005
I owe my brother big time for this!
Using an Intersection Observer is the preferred approach these days

https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#a_simple_example

fuf
Sep 12, 2004

haha
I have some Christmas blues reflecting on my current (non Javascript) dev job.

Are there any Javascript / React learning resources that people would particularly recommend? Something that will make me feel less like an impostor and possibly set me up for applying for some jobs?

There's a million different "courses" out there so any kind of "this helped me" endorsement would be appreciated.

Armauk
Jun 23, 2021


fuf posted:

I have some Christmas blues reflecting on my current (non Javascript) dev job.
What are you using at your current job?

Adbot
ADBOT LOVES YOU

fuf
Sep 12, 2004

haha

Armauk posted:

What are you using at your current job?

Uhhh an incredibly obscure platform / language that's only used by Universities called SITS ("Strategic Information Technology Systems"). It's a weird niche I fell into by accident that means a secure job but development that is straight out of the 90s.

I have a fair bit of web dev experience though so I'm definitely not starting from scratch with JS or anything. I'm firmly in 'intermediate' territory, just with a strong sense that I'm missing fundamentals and need to update my skills.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply