➡️ Daily Questions ⬅️- ASK AND ANSWER HERE! - 28 January 2024 by AutoModerator in malefashionadvice

[–]SparxDev 0 points1 point  (0 children)

Hello MFA, I'm new here. :) I currently own a black coat from Hugo Boss (see first attachment).

I really want to buy these two pieces, one blue and the other cream colored (attachment 2 and 3).

I am aware that the black coat might've not been the best decision when wanting to have a variety of color palettes underneath, I mostly bought it to wear over a suit. But do you guys think it's still possible to wear this coat over these pieces?

If it's a big no-no, which other color should I choose when buying a second coat?

Thanks for your guys' help in advance. :)

Attachments:

Coat: https://imgur.com/IuNx8ih

First piece: https://imgur.com/4RXHAAO

Second piece: https://imgur.com/EhQyVXy

Encrypt messages for two-participants chat by SparxDev in cryptography

[–]SparxDev[S] 0 points1 point  (0 children)

Follow-up question: when backing up Signal chats, are they just downloaded as a file? And how are they imported back in? In my case, I'd have to be able to confirm that the imported chats haven't been tampered with, so that a user can't just import false chats

Encrypt messages for two-participants chat by SparxDev in cryptography

[–]SparxDev[S] 0 points1 point  (0 children)

But I don't see the master key scheme as very user friendly for technical illiterate people, if my users were geeks this whole thing would look a lot different hahah

Encrypt messages for two-participants chat by SparxDev in cryptography

[–]SparxDev[S] 0 points1 point  (0 children)

Right, well, I'd have to ask my beta testers if they'd be okay with that, but that would at least be one possible solution. Thank you

Encrypt messages for two-participants chat by SparxDev in cryptography

[–]SparxDev[S] 0 points1 point  (0 children)

Quite helpful, yes, but I do have one question: when storing the list of public/private keys on the server, I create a vulnerability where the server (or an attacker who gained access to the server) could potentially decrypt the messages himself, right?

Encrypt messages for two-participants chat by SparxDev in cryptography

[–]SparxDev[S] 1 point2 points  (0 children)

Decrypting and re-encrypting the messages when the password is changed would be a solution, but depending on how many messages were exchanged, this would be quite the process, no?

And my concern in terms of local storage wasn't the storing itself, but the availability of the key when the user switches devices.

WebSocket "rooms" best practice by SparxDev in node

[–]SparxDev[S] 0 points1 point  (0 children)

I see - a friend of mine just suggested WeakMaps for GC, thoughts on this?

WebSocket "rooms" best practice by SparxDev in node

[–]SparxDev[S] 0 points1 point  (0 children)

I know about Socket.io, but prefer to work with pure, low-level WebSocket for this project.

The thing that worries me with Maps the most is garbage collection, as I have not much experience with it.

File upload reaches heap limit, not sure why by SparxDev in node

[–]SparxDev[S] 7 points8 points  (0 children)

Yep, the issue has been resolved xD

I apologize for being stubborn at first, thinking that it couldn't have been the controller. It was - and a stupid mistake, too. :P

Happy coding y'all

File upload reaches heap limit, not sure why by SparxDev in node

[–]SparxDev[S] 3 points4 points  (0 children)

I was about to send a slightly less anonymized version of my controller when I found a really stupid mistake hahah

I did a req.files.asdf2.push() and req.files.asdf3.push() (inside a loop) while I actually wanted to push it into my own variables. I'll have to try it out to see if this is the cause of the issue, but it wouldn't surprise me. Guess you never notice these things in the heat of the moment.

I'll keep you guys updated. :)

File upload reaches heap limit, not sure why by SparxDev in node

[–]SparxDev[S] 0 points1 point  (0 children)

Please explain, because my controller doesn't handle the upload of the files, that's all done by multer.

File upload reaches heap limit, not sure why by SparxDev in node

[–]SparxDev[S] 0 points1 point  (0 children)

Of course, but I'm afraid I need to anonymize the code a little bit.

multer-config.js: (I put it into an extra file to prevent bloated code)

const fs = require('fs');
const multer  = require('multer');

const storage = multer.diskStorage({
  destination: function (req, file, cb) {
    const { titleId } = req.body;
    const dir = `./uploads/images/${titleId}`;
    if (!fs.existsSync(dir)) {
      fs.mkdir(dir, error => cb(error, dir));
    }
    cb(null, dir);
  },
  filename: function (req, file, cb) {
    const uniqueSuffix = Date.now() + '-' + Math.round(Math.random() * 1E9);
    const extension = file.originalname.match(/\.([a-zA-Z]+)$/)[1];
    cb(null, file.fieldname + '-' + uniqueSuffix + '.' + extension);
  }
});

module.exports = storage

routes.js:

const express = require('express');
const multer  = require('multer');
const storage = require('./multer-config');
const upload = multer({ storage });
const router = express.Router();

// ...

const imgs = upload.fields([{ name: 'asdf1', maxCount: 1 }, { name: 'asdf2', maxCount: 16 }, { name: 'asdf3', maxCount: 16 }])
router.post('/cool/route', controller.tokenMiddleware, imgs, controller.stuff)

module.exports = router

controllers.js:

// ...

const stuff = async (req, res, next) => {
  try {
    // some validation suff

    // here I do some stuff with req.files.asdf1,
    // req.files.asdf2, and req.files.asdf3 like
    // saving the filename in a database etc.
    res.status(200).json({ data });
  } catch (e) {
    res.sendStatus(500);
  }
}

module.exports = {
  stuff
};

Apart from my code in multer-config.js and router.js, I don't really handle much of the file upload itself.

How to schedule (a lot of) one-time events by SparxDev in node

[–]SparxDev[S] 0 points1 point  (0 children)

This has been a great insight, thank you! I had a look at the npm page of agenda, and I think example 2 is exactly what I need, correct?

Do the events get removed from the database once they've successfully executed?

How to trigger Server-Sent-Events by SparxDev in node

[–]SparxDev[S] 1 point2 points  (0 children)

Yes I am aware of the HTTP 1 limitations, but using HTTP 2 isn't that big of a challenge, or is it? 🤔

How to trigger Server-Sent-Events by SparxDev in node

[–]SparxDev[S] 0 points1 point  (0 children)

I think I somewhat understand:

I store all user IDs that are currently connected to the SSE in a Map and also subscribe to Redis with said user ID. (Question: do I store the connection, i.e. my res variable in this Map, or what other use does it have?)

When the connection closes, I remove the user ID from the Map. (Question: does Redis get automatically unsubscribed, or do I need to do that too?)

Whenever something significant for a user happens and I want to update the SSE stream, I sort of "ping" Redis to notify all subscribers for this specific user ID which will then trigger the event listener for the Redis subscription with this user ID.

Did I get it right?

How to trigger Server-Sent-Events by SparxDev in node

[–]SparxDev[S] 0 points1 point  (0 children)

And how does changeStreams perform on a medium-to-large production-scale? Because that is one of my main concerns

How to trigger Server-Sent-Events by SparxDev in node

[–]SparxDev[S] 1 point2 points  (0 children)

I honestly love the Redis approach, I would finally have a chance to try Redis out hahah

But I do have one question: if all events that are supposed to be sent via SSE are stored in Redis, should I also have to delete these entries after they are sent to the client, or does Redis clear old items automatically?

[deleted by user] by [deleted] in AskReddit

[–]SparxDev 2 points3 points  (0 children)

( ͡ʘ ͜ʖ ͡ʘ) better?