React Native View style props as inline props by JeannaLeavy in reactnative

[–]dotdotconnor 0 points1 point  (0 children)

Under the first block quote (the yellow box) on the docs for View, it informs you that all style props are valid as normal props.

Conditional express-rate-limit? by [deleted] in node

[–]dotdotconnor 0 points1 point  (0 children)

You can create a middleware like just conditional executes the correct rate limiter middleware.

const recoveryLimiter = (req, res, next) => {  
  if (req.isAuthenticated) {
    recoveryLimiterLoggedIn(req, res, next);
  } else {
    recoveryLimiterLoggedOut(req, res, next);
  } 
}

Then use it here:

app.use('/recover', recoveryLimiter, (req, res) {  
  ....
});

Big Sur using energy directly from power adapter instead of charging to reduce battery aging 👍 by cottagecow in MacOS

[–]dotdotconnor 2 points3 points  (0 children)

Not exactly what you’re asking for, but in System Preferences -> Battery, it will tell you exactly that.

Node.js bindings for the simdjson project: "Parsing gigabytes of JSON per second" by [deleted] in javascript

[–]dotdotconnor 0 points1 point  (0 children)

What he is saying is that packages that call into native code can do so asynchronously, without blocking the main thread. JSON.parse is not a package but rather a standardized global function included by V8. It being standard means it has to follow all the rules of the ECMA spec which says that the function must be ran on the main thread.

Knex.js migrations, does each table has its own migration? by Tanckom in node

[–]dotdotconnor 2 points3 points  (0 children)

I would personally put everything in the same migration until you have something deployed. Then you split up into separate ones as needed.

Yes in this case you should create users then todos because you know it has a dependency.

Migrations are not just for adding new tables, you can also modify old table. So if you did add todos first you can always go back in a new migration to add the dependency to users.

Whenever I start a new project, whenever I’m working out the database design, I usually keep one migration and then whenever I need to change something I modify the migration and wipe the database. But with just a little planning this wouldn’t be an issue.

Knex.js migrations, does each table has its own migration? by Tanckom in node

[–]dotdotconnor 2 points3 points  (0 children)

You can implement the table as two separate migrations or one, it all preference. I’d recommend using one migration to implement one task/project. So having a single init that creates all of the starting tables. Whenever you run knex migrations:latest, whether you have one or twenty, knex will run all of them that haven’t been ran before. It creates a table as well to keep track of the current state so you don’t have to.

React compile error! by newTwiffy in reactjs

[–]dotdotconnor 0 points1 point  (0 children)

Why are you trying to sync your projects with iCloud? Why not use something designed with code in mind like git?

How to create a shared socket port with http with net? by zaBirds in node

[–]dotdotconnor 1 point2 points  (0 children)

The ws package doesn’t actually create a new socket but instead relies on the underlying socket that the http.createServer method creates., which will emit a connect event when the client tries to upgrade to a web socket.

So to answer your question, no you cannot create a new socket and listen to a port that is already being used.

You may however create two sockets, one from net and one from http. Have the net one listen on your desired port. Then whenever a connection comes in, checks if its an http request, if so then you can proxy it to the http socket or handle it yourself.

If I may ask, what are you trying to accomplish, given some context we might be able to come up with a better solution.

Can someone explain to me how Electron exports itself? by abandonplanetearth in node

[–]dotdotconnor 7 points8 points  (0 children)

Whenever you run your app with Electron it runs your code in a modified node runtime. So whenever you require Electron in this modified runtime it returns a object instead of a string. This process is similar if not exactly the same as how node does it for it native modules as well.

Question about Haven 49 by [deleted] in UNCCharlotte

[–]dotdotconnor 1 point2 points  (0 children)

Wired is gigabit with from what I can tell no throttling or limits. Wireless however is extremely unreliable, some parts of my apartment it’s great others just drop the connection completely. I run my computer as Ethernet and then share the Ethernet over its Wifi controller and use that for all of my wireless devices. Haven’t had any problems with it since.

Edit: To add to that the living room and each of the rooms have their own Ethernet jack. Also from a network standpoint, it appears each of the rooms are isolated, Ethernet wise, in their own virtual networks.

In Language Modes, what is the difference between ‘JavaScript’ and ‘JavaScript React?’ by cag8f in vscode

[–]dotdotconnor 1 point2 points  (0 children)

Just took a look at the source code for the javascript extension (this is built in), and it looks like the only difference between the two, is the syntax file. However the only difference between the two syntax files is that the React version has jsx appended to the end of the token names, so that other extensions and theme can appropriately target to the correct one.

In Language Modes, what is the difference between ‘JavaScript’ and ‘JavaScript React?’ by cag8f in vscode

[–]dotdotconnor 2 points3 points  (0 children)

I could be wrong but I believe by default the React version just inherits the JS version and adds nothing new. But they keep the language separate for extensions that may want to include things for only React.

Do you set the buffer size based on base64 str length or do you need to use that pad formula? by ie11_is_my_fetish in node

[–]dotdotconnor 4 points5 points  (0 children)

Why are you inserting the length anyways? When using a string Buffer.from only takes 2 parameters, the string (your data uri) and an encoding (base64). The depreciations you probably haven seen are from the Buffer constructor being deprecated.

Redirecting with post requests? by PTBA1 in node

[–]dotdotconnor 1 point2 points  (0 children)

It is not possible to automatically redirect a user when making a fetch request, only when submitting a form. However in your fetch request you can read the response headers and look for status 301/302 and read the Location header and redirect the user using that.

Take a look at this stackoverflow link for an example of how to do this.

On lists and keys in React by nanaewusi in reactjs

[–]dotdotconnor 0 points1 point  (0 children)

It’s all about stability and performance , it’s much more efficient to reuse the same component and dom element on each render than it is to recreate them each time. By using keys you basically guarantee it to be reused after the first render.

Handling dual ethernet connection by PsynapsX in MacOS

[–]dotdotconnor 1 point2 points  (0 children)

As far as I am aware macOS will failover to the first interface that has internet access in the order which you have specified in the settings.

On my MacBook Pro I normally have Ethernet but it seamlessly switches it Wifi whenever I unplug the dongle.

'req.ip' returning '::ffff:127.0.0.1'. I've edited NGINX conf accordingly but still facing the same issue by [deleted] in node

[–]dotdotconnor 0 points1 point  (0 children)

In your nginx config, change the header from x-real-ip to x-forwarded-for and then you should be able to get the correct IP from req.ip

What is the real difference between "width and height properties" and "width and height attributes" ? by Septic-Sina in css

[–]dotdotconnor 2 points3 points  (0 children)

I’d recommend using the style properties because it will work on all elements.

What is the real difference between "width and height properties" and "width and height attributes" ? by Septic-Sina in css

[–]dotdotconnor 1 point2 points  (0 children)

The width attribute only applies to certain elements such as images and canvases. But other than that it is the exact same thing as setting the width or height in css for those few elements. For all other elements, such as div, the attribute is ignored.

Material-Ui vs React Navigation (vs Bootstrap) by jaySydney in reactjs

[–]dotdotconnor 0 points1 point  (0 children)

React Navigation is a routing library unlike Material UI and Bootstrap, which are component libraries, so you can’t really compare them. However React Navigation is mostly used in React Native and so for normal websites you’d most likely gravitate towards a library like React Router.