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
Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I've always understood mocking in tests to be that you mock the `require` as opposed to any global variable. You can mock a global variable as easily as reassigning it before use, otherwise you're overriding node's require statement. So if you wanted to mock `node-fetch` you'd mock `node-fetch`, the resource you are requiring, as opposed to the `fetch` variable that's being created inside your script.

You can encapsulate the fetch in another file and then mock that file, too if that makes it easier.

Adbot
ADBOT LOVES YOU

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

Doom Mathematic posted:

Well, since we're here. What's the technique if you're using ES modules? There's no such thing a require and imported values are immutable.

I'd suggest Node doesn't know what it's doing and it's a miracle native Javascript imports work at all. But from what I understand in order to make import work it uses require behind the scenes and it should ultimately work the same way with regard to import. Pretend import is require.

Nolgthorn fucked around with this message at 12:07 on Nov 15, 2021

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

uncle blog posted:

This feels dumb:
What's the cleanest way to set the body font-size to 16px, and yet give the site a globally applied size of 0.875 rem?

Rem only applies in relation to the root font size so if you want one that is specific you can just define it directly instead of using rem again.

Nolgthorn fucked around with this message at 00:33 on Nov 10, 2021

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Can someone help me figure out http2, it looks like an interesting technology and I want to write my next app using it. I understand there's a "compatibility layer" so that you can use it while continuing to write apps "the old way" but I'm interested in the new way.

https://www.sohamkamani.com/nodejs/http2/

The above guide is one of the only resources I've found on the topic that doesn't say "use express and bastardize the framework even more." My intent would be to write an app in node with an accompanying client side app. My understanding of one of the primary benefits of http2 is that it's a persistent connection between the client and server. So I want to load my html and have that act as a persistent connection.

But that doesn't seem to be right.

It seems like I need to load the html the "old way", then from within my client side code create a persistent http2 connection from which I can make any further requests. But then, I don't understand what I'm supposed to do such that all of my resources like css or js or images are loaded through it. It seems like first page load along with whatever is on the page is all still loaded "the old way."

Like, how can I create a http2 connection, without having my javascript file loaded for example. Isn't the browser supposed to handle a lot of this?

Additionally, server side. I got pretty comfortable with the fact I could set and then change headers at will using `setHeader()` before they'd all be sent out at once after I was ready to start writing the body of the response. But with the new implementation, whenever I get my hands on a stream instance, it seems like my only option is to write a header or not. I can't overwrite it, for example. It just sends it out right away. Am I not getting it?

Additionally, now that http2 is all binary does that mean I need to do a bunch of manual stuff with the responses once it gets client side? The old way always expected text. So now I need to convert everything, like JSON for example, before I can parse it?

I feel like I've confused myself more than I've helped myself over the last week trying to get to the bottom of all this.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
After a bit more experimentation I was confusing the client side implementation that you would put in the browser with a client side implementation on the server. In fact because http2 requires use of ssl, the pre-flight handshake informs the browser that it's http2 and it does in fact handle a lot of this stuff after that. So you can basically build a web app without thinking too much about it.

The structure of your server side code is quite different as long as you aren't using the compatibility layer. But it also looks a lot easier too, working with binary all the time for example makes things much clearer.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I prefer to use

code:
return (
  {condition ? ( 
    <div>
      <p>This will render if condition is true. Otherwise null isn't rendered in jsx.</p>
    </div>
  ) : null}
)
It's not much different just really like explicit null syntax in jsx.

prom candy posted:

I'd like to stop using Chrome but my efforts to switch to anything else never end well.
Brave to escape Google creepiness while also developing for Chrome.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

camoseven posted:

What does the null syntax gain you? Or what could NOT using it cause?

It's just explicit. Returning null from a component is also a convenient way not to render it, if you ever need to do that.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Hello fine people of the internet. I have a CSS question! I know you're all dying to see it.

https://jsfiddle.net/df0g4rek/1/

I've extracted this simplified example from an existing code base! Div `container` is whatever, it's just somewhere on the page. Div `outer` and div `inner` are both thanks to this 3rd party library that replaces native scrollbars with custom ones. I've removed the javascript code from the example, because it's not relevant.

Other than the fact they exist and my client wants to use that library. They are customizable so if those are the cause of the problem by all means tell me.

Within this scrollable area, there's div `background` which has to be there and is the focus of the issue. And div `square` which acts as placeholder content. Ideally when you scroll to the right, div `background` would extend all the way across. But it does not.

It's like the browser stops bothering to render it, "oh nobody will ever scroll to the right." it says.

Nolgthorn fucked around with this message at 16:28 on Jan 27, 2022

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Oh my god. I've been coming back to this problem for days thank you.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

kedo posted:

CSS will never catch on! Javascript is just a dumb gimmick for making text follow a mouse cursor, nothing more!

I heard javascript is picking up adoption rates at an alarming speed, god help us

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I don't think this is advertising since it's free and there's no money, there's never any money. :arghfist:

https://www.npmjs.com/package/kequapp

A while ago I wrote a app framework that had basic functionality.

Just recently I performed a full rewrite to make it do what I actually want. It's modular and written in TypeScript so that you can define individual parts of your application like routes, handles, branches, renderers wherever all in separate files if you want.

The core idea being that you can write a good web app without a lot of configuration or boilerplate.

I'm looking for advice around the documentation (it's only the readme file), missing features, how you would want to use a web framework, what you want a web framework to do. What you like about the 10-20 other solutions that are available.

The readme says that it is "fast" but I just ran it through fastify's benchmark turns out it's only about 50% faster than express, and slower than most of the other heavy hitters. We're talking about ms but that adds up when you have a million requests. I'm not sure if I need to work on that, or if it's important since generally with this type of thing the real processing time is going to be taken up by the developer's code.

Fastify is somehow barely slower than no framework at all which to me means they're cheating. Do you think the speed is important, what else would you look for?

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
How does it decide where the first wedge starts, none of those lines seem to be perfectly vertical or anything.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Shouldn't the PR firm be talking to the product owner? Or are you the product owner, in that case it's deffo your job to talk to the PR firm.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

America Inc. posted:

Why does there seem to be a trend to move away from client-based single page apps towards server-side rendering that returns static html to the client, for example with Next.js?

I think if I wasn't writing another spa thank you God, I'd probably absolutely just use mustache and love my life again.

Why would anyone think server side rendering of a react app sounds good. That is nonsense I refuse to take part in the madness. Even on Halloween.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

LifeLynx posted:

Is there a chat bot that doesn't suck? Clients always have them but they're all a massive drain on page speed and insert so much render-blocking code that PageSpeed Insights throws a fit. Sometimes all the red in every area is the chat bot and the site would score a 90+ otherwise.

Maybe this is why websites never load those in right away. There's always 30 seconds or a minute before the chat bot loads in.

Likely helps with speed ranking.

As far as why they all suck I don't know. Seems if I wanted to build one I'd just need to connect to a websockets endpoint. Perhaps after it's js css html load from a script. Wouldn't need to be too intensive.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

Boba Pearl posted:

If anyone was wondering I gave up on Drupal, Hugo, Jekyll, and Wordpress, and now I'm just running pure html and js

https://bobapearlessence.com

I hate how much I had over complicated this process.

Heck yes, now if only "GitHub Pages" would do this.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

It used to be there were huge swings in the market, entire ecosystems would grow die and be replaced within 5 years. That doesn't really seem to happen anymore, it has more or less been decided event based languages are what's up. Therefore Javascript owns. Python is used for calculations and things like c++ or rust is used for anything that needs a lot of performance. That's basically the entire industry and it's stagnating.

It's no longer necessary to always be exploring new technologies to stay ahead of the curve, there isn't one anymore. I think that's more or less what was being discussed earlier.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

FlowerRhythmREMIX posted:

Did Vue just vanish? That was supposed to be the next big thing like five years ago.

It feels like they got self conscious and started to pivot instead of holding onto a good thing. Now you can write Vue with jsx if you want which is totally unnecessary for example. They needed to provide something better than react not duplicate it.

They also ditched their bundler agnosticism and now it basically doesn't function without stupid goddamn webpack. Exactly what I want to get away from.

Nolgthorn fucked around with this message at 02:35 on Mar 3, 2023

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Is there a way to fight back against the time wasters? Like, if someone contacts you and you respond with interest that's a half contract that they will ask you a follow up of some sort. This is basic social stuff. Can we reprimand whichever agency is hiring these people?

Or, get off LinkedIn which is a spam network. I did ages ago, people just pay to be able to send out mass messages. Take them less seriously I suppose..

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I guess when I'm looking for work I scour job boards and send applications. I never took anything seriously that I received from linkedin, it was always just tentatively related to what I was doing now. Almost always something I did 5 years ago.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

Last Chance posted:

I love OO programming. Has it fallen out of favor in some areas? I hear a lot of talk about procedural and functional programming these days

Oh man. Ohh man, you are trying to rile people up.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I'll bite though.

OOP is really good if you've got a lot of different objects that interact with one another in dynamic and unexpected ways. Game development for example. But in professional applications, unexpected things happening is the last thing anyone wants. Something that always outputs the same thing when given the same inputs. Something that's easy to test and predict. Dependable.

If you're using OOP just because it's what you're used to using then I recommend looking at alternate methodologies and structures. It is absolutely not the right tool for anything that matters, in my opinion. You wouldn't write bank software in Java for example that would be insane. No bank would ever do that rite?

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
https://forums.somethingawful.com/showthread.php?threadid=4013930

https://www.npmjs.com/package/kequapp

I've been posting about development of a node web framework. It gets a few downloads but doesn't currently have any attention. Which is good, more it less, because I'm an introvert. But if I wanted more attention what would make the library more palatable to it's beginners? Maybe I could improve the presentation somehow.

I heard somewhere that open source frameworks and modules compete with each other like a marketplace even though they're free. It is fascinated me how much effort goes into the marketing for these things. Super professional websites with pretty images and seemingly trips to tech fairs.

So, does it need a website? Does it need a code review? What could improve the package image? It would be a tremendous curiosity for me, as I use it for all of my personal projects, lonely though.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
422 might also be correct keeping in mind that nobody cares about any status code. As opposed to 400 Bad Request, 422 Unpossessable Entity says that while the request was interpreted and understood the server still isn't going to process the request due to something about the content of the request. Like yeah you gave me a cat name, but the cat name was too short so try again.

I guess 400 Bad Request is more like the whole request is fubar. But I've definitely seen it used more.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I've been running my ts code in production without building it. I've read you're not supposed to do that because of the overhead of typescript but so far it hasn't mattered. I'm sure I could compile it as es code using vite or similar if we ever needed to squeeze performance.

Adbot
ADBOT LOVES YOU

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
They'll pick the bad option 50% of the time though.

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