subscribe observable (as subject)

i have following example code which returns id+1 of it’s elements: EntitiesService: public create(model: Model): Observable<number> { var subject = new Subject<number>(); this.GetAll().subscribe(result => { if (result.find(x => x.name == model.name)) { return; } model.id = result[result.length – 1].id + 1; EntitiesService.mock.push(model); subject.next(model.id); }) return subject.asObservable(); } and i would like to subscribe it to… Read More subscribe observable (as subject)

Is there a cleaner way to extract a substring from a string in PHP using RegEx?

I have a function that is getting a string of "lead time" in WooCommerce. An example would be:Available! Estimated Lead Time: 2-3 Weeks. I want to get the 2-3 Weeks. So far, I’ve been able to do it with the following function: function display_lead_time_notice_card() { global $product; //Get Stock Status $in_stock = $product->get_availability()[‘class’]; //If In… Read More Is there a cleaner way to extract a substring from a string in PHP using RegEx?

Adding multipart file as an attachment to an email in Spring Boot

I want to send an email from Spring Boot with a pdf attachment. I have received the pdf file as a multipart file from a POST call. Here’s my controller class so far (sendEmails method is included in emailService service): @PostMapping("/email") public ResponseEntity<?> sendEmail(@RequestParam("file") MultipartFile pdfFile, @RequestParam("email") String email) { boolean result = this.emailService.sendEmails(email, pdfFile);… Read More Adding multipart file as an attachment to an email in Spring Boot

How to select only first non NA value of each group in R?

I have a data frame like mydata <- data.frame(Id=c(01,01,01,01,01,01,02,02,02,02), VISIT=c("Screeing","Baseline","Baseline","Baseline","Week 9","Week 9","Baseline","Week 2", "Week 2","Week 2"), Score=c(1,2,4,5,78,9,5,NA,3,4)) > mydata Id VISIT Score 1 1 Screeing 1 2 1 Baseline 2 3 1 Baseline 4 4 1 Baseline 5 5 1 Week 9 78 6 1 Week 9 9 7 2 Baseline 5 8 2 Week… Read More How to select only first non NA value of each group in R?