Is there a effective framework that provide a listener to listen different types of the message queue?

One part of the project involve designing a listener or consumer which would listen for the different types and arbitrary numbers of message queues like rabbitMQ, Kafka, ActiveMQ etc. Also, the lister would be deployed as a micro-service and the same copy of it would be deployed on multiple machines. Is there any effective framework that would accomplish this task? And anyone have some good advice or points to notice for designing this distributed listener?

Thanks

How to retroactively make old files content types?

Is there a way to make files that are copied into a document library or that already exist in a library a certain content type?

For example, I have various content types based on the Document content type (e.g. contracts, letters, memos, etc.).. This is fine for all new content created by users… but what about old content that already exists in a document library? how do I migrate existing files to be mapped to those content types?

Thanks,

Possible to query a document library’s content types

We’ve noticed an issue in our SharePoint 2013 document libraries. When uploading documents to a document set in a document library, content types available to the root document library are available in the document set, even if that same content type isn’t available to the document set. This is particularly challenging as users aren’t seeing their documents in document sets as they’ve been erroneously tagged as the wrong content type as is the case when users drap/drop items into document sets.

I’d like to try to modify the new document pop up to strip out these invalid content types. Is there a way to query the document set’s properties to find valid content types?

Tks

Inheritance for 3 types of accounts

I’ve seen this code which is really helpful. I’m facing problems to inherit three diffent type of classes for saving, checking and business account. How can I do that with inheritance?

class SavingAccount(BankAccount):     """Class for a bank account"""     type = "Saving Account"      def __init__(self):         ##calls functions in the module filestore         self.username, self.userpassword, self.balance = filestore.cusaccountcheck()         print(             "Thank you %s, your account is set up and ready to use," % self.username)         time.sleep(2)         self.userfunctions() 

Is it possible to unhide specific file types that are normally hidden

I know that all the hidden files can be viewed in Finder by using the keyboard shortcut:

Command + Shift + .

or by running the following in Terminal:

defaults write com.apple.finder AppleShowAllFiles true

But, is it possible to change a specific file type who’s default behavior is hidden to always show in Finder? Specifically, I want my files with the extension .vscode to not be hidden, but I don’t want to show all hidden files, and I am trying to do this without having to use the shortcut or always run a command in the Terminal.

Is this at all possible?

Collect maximum fruits in two baskets of at most 2 types of fruits

The task

is taken from LeetCode

In a row of trees, the i-th tree produces fruit with type tree[i]. You start at any tree of your choice, then repeatedly perform the following steps:

  1. Add one piece of fruit from this tree to your baskets.  If you cannot, stop.
  2. Move to the next tree to the right of the current tree.  If there is no tree to the right, stop.

Note that you do not have any choice after the initial choice of starting tree: you must perform step 1, then step 2, then back to step 1, then step 2, and so on until you stop.

You have two baskets, and each basket can carry any quantity of fruit, but you want each basket to only carry one type of fruit each. What is the total amount of fruit you can collect with this procedure?  

Example 1:

Input: [1,2,1] Output: 3 // Explanation: We can collect [1,2,1]. 

Example 2:

Input: [0,1,2,2] Output: 3 // Explanation: We can collect [1,2,2]. // If we started at the first tree, we would only collect [0, 1]. 

Example 3:

Input: [1,2,3,2,2] Output: 4 // Explanation: We can collect [2,3,2,2]. // If we started at the first tree, we would only collect [1, 2]. 

Example 4:

Input: [3,3,3,1,2,1,1,2,3,3,4] Output: 5 // Explanation: We can collect [1,2,1,1,2]. // If we started at the first tree or the eighth tree, we would only collect 4 fruits. 

  Note:

  1. 1 <= tree.length <= 40000
  2. 0 <= tree[i] < tree.length

My solution:

has time and space complexity of O(n). At first I thought it was easy. But then, I got confused with the one of the test cases (i.e. I = [3,3,3,1,2,1,1,2,3,3,4];) and everything inside the else-block is a bit hacky afterwards. Maybe there is a more elegant solution to that.

/**  * @param {number[]} tree  * @return {number}  */ var totalFruit = function(tree) {     const set = new Set(tree);     if (set.size <= 2) {         return tree.length;             }      const fruits = new Set();     let i = 0;     let j = 0;     let max = 0;     let count = 0;     while (j < tree.length) {         if (fruits.size <= 2 && !fruits.has(tree[j])) {             fruits.add(tree[j]);         }          if (fruits.size <= 2) {             count++;             max = Math.max(max, count);             j++;         } else {             fruits.delete(tree[i]);             const lastIndex = tree.slice(i, j - 1).lastIndexOf(tree[i]);             i += lastIndex + 1;             count-= lastIndex + 1;         }     }     return max; };  let I = [1,2,1]; I = [0,1,2,2]; I = [3,3,3,1,2,1,1,2,3,3,4]; console.log(totalFruit(I)); 

Handling different error types from diffierent libraries with express

Most of the express error handling documentation and tutorials I’ve read suggest using Express middleware to throw errors up to, and to handle the errors there.

eg. From the Express documentation:

app.get('/', function (req, res, next) {   fs.readFile('/file-does-not-exist', function (err, data) {     if (err) {       next(err) // Pass errors to Express.     } else {       res.send(data)     }   }) })  function errorHandler (err, req, res, next) {   if (res.headersSent) {     return next(err)   }   res.status(500)   res.render('error', { error: err }) } 

The question I have, is around the use of this when either using external SDKs (like Mongo or GCP) or Axios/Fetch calls to other microservices.

eg.

//GCP example  app.post('/items/:id', async function (req, res, next) {      try {        const id = req.params.id;         const data = req.body;         const snapshot =  await db.doc(`items/$  {id}`).create(data); //This will throw an error if that document already exists        res.send("Success");      } catch(err) {         next(err);      }  });  
//Microservice example app.get('/foo/:id', async function (req, res, next) {      try {        const id = req.params.id;         const response =  fetch(`/microservice/$  {id}`); //Say errors with a 404 status or a 500 status        res.send(response.body);      } catch(err) {         next(err);      }  });   

The question is – if we want to now return useful error responses, what’s the right way to do this?

For example – the errors throw from the fetch function are going to be a fetch Response object, while the GCP function is going to throw an error that looks like this (I couldn’t find documentation for the error object):

{ code: 6,   metadata: Metadata { _internal_repr: {} },   details: 'Document already exists: projects/project-id/...'  } 

So I could implement my error handling function to cater towards different types of error objects:

function errorHandler (err, req, res, next) {   if (res.headersSent) {     return next(err)   }    //Handle Response Objects   if (err.status) {      switch(err.status) {           case 404: return res.status(404).send("Item not found");            // etc      }   }    //Handle GCP errors   if (err.code && err.details) {      switch(err.code) {         return res.status(409).send("Item already exists");       }   } } 

But this seems like a brittle solution – for example what if another library I was using included ‘status’ on their error object.

So then, the alternative approach would be to standardise the errors myself at the of the library.

I can throw objects as errors like

   throw {          status: 404,           message: "Item not found'    };   

And implement my code like:

formatGcpError(err) {    switch(err.code) {        case 6: return {            status: 409,             message: "Item already exists",         }    } }   app.post('/items/:id', async function (req, res, next) {      try {        const id = req.params.id;         const data = req.body;         const snapshot =  await db.doc(`items/$  {id}`).create(data); //This will throw an error if that document already exists        res.send("Success");      } catch(err) {         next(formatGcpError(err));      }  });  

Am wondering – what’s the standard approach here?

What types of Google Cloud application should I consider for something running as a continually available service that subscribes to a pub/sub?

I want to create an application that will run as a service that subscribes to a Google Cloud pub/sub topic, and delivers emails based on ‘alerts’ that it receives through the pub/sub subscription. It will read from Cloud DataStore to determine the email addresses to mail to, and it will probably use some type of 3rd party service and API to do the actual mailing. In future, there will be a requirement to send other types of notification, for example SMS alerts.

What types of Google Cloud application should I consider for this? I’m not sure what type of application would be appropriate for something that effectively acts as a constantly available ‘service’. Could I just create a normal Java application that subscribes to the topic in its ‘main’ method, and deploy this as an AppEngine app? Or are there more complex considerations I need to bear in mind? I’ve previously used DataFlow, which handles parallel processing of data very well, when subscribed to a pub/sub topic, however it’s really designed for processing Big Data and I don’t think would be appropriate.

Apologies for the noob question – I’m still learning to think in terms of Cloud architectures as opposed to traditionally running services. I’d really appreciate some basic guidance on what type of application I should be looking at creating.

What do the different data types in C++ classes do? (Private, public, and protected)

I have been trying to learn about classes and objects in C++, but every tutorial I have found is quite complex, at least to my standards, and I really would like a really simple and straight forward explanation explaining this. Like yeah, “private members are not accessible outside the class”, but how do I use them then. “The public members form an interface to the class and are accessible outside the class,” so can I just call them like [insert Class Name].[insert class instance], or insert object Name].[insert class instance]. These questions are probably pretty dumb, and my formatting is probably really bad, but I really wanna learn this language and I am new here.

Thanks for your help 🙂