Posts

How to define Mongoose Schema for delete method

I am not able to delete items of a list of MongoDB. Unfortunately, when axios.delete method is called in ExpensesListItem.tsx , the item of MongoDB list is not deleted (no error message gets printed to the console). What is wrong with the code (maybe mongoose schema)? ExpensesListItem.tsx import React from "react"; import { IconButton, ListItem, ListItemSecondaryAction, ListItemText } from "@material-ui/core"; import DeleteIcon from '@material-ui/icons/Delete'; import { ExpenseAndAmountObject } from '../ExpenseAndAmountObject'; import axios from 'axios'; interface Props { expenseTitle: string; expenseAmount: string; currencySymbol: string; item: ExpenseAndAmountObject; expenseAndAmountList: Array<ExpenseAndAmountObject>; setExpenseAndAmountList: (value: Array<ExpenseAndAmountObject>) => void; } const ExpensesListItem: React.FC<Props> = ( { expenseTitle, expenseAmount, ...

Is there way to sort *.md files according to publish date value with bash script?

I am writing a blog and I am saving these blog posts with markdown file format. The file contains the release date and the update date. I can call the information I need, for example, the release date with the help of the lowdown tool. So far everything is going fine. but I couldn't find a way to do this when I want to sort by publish date for my index page. Note : The date format i am using; YYYY-MM-DD As an example of the result I am trying to reach; (assuming we're looping through the directory containing the blog posts) for post in *.md; do title=$(lowdown -X title $post) date=$(lowdown -X date $post) <h1>$date</h1> <h1>$title</h1> done The output gives natural order(i think). 2021-10-02 2th Post 2021-10-04 Last Post ... My expectation is sort them with $date values. 2021-10-04 Last Post 2021-10-03 3th Post 2020-10-02 2th Post 2019-10-01 1th Post from Recent Questions - Stack Overflow https://ift.tt/3xXf59Z https://...

codes not execute when Socket.Receive return zero

I have a Function to handle requests and another to forward data. In ForwardToBrowser function when receivedBytes in hostSocket.Receive return zero the codes stopped working and my codes after it not executed. BUT The program resumes. For example, when receivedBytes return zero the "MessageBox1" not shown and the program still working. Without any error and without any Exception. I put my codes such as MessageBox after while loop (you can see it as "MessageBox2") and it doesn't execute. I'm using this ForwardToBrowser function in Handle function in the same class, Unfortunately the codes after it such as Shutdown and closing socket and Tools.Save and "MessageBox3" when receivedBytes become zero can't execute. private void ForwardToBrowser(Socket hostSocket) { byte[] buffer = new byte[10240]; int receivedBytes = 0; receivedBytes = hostSocket.Receive(buffer); while (receivedBytes ...

How to download file from website where the hyperlink shows as 'Javascript'

Things tried: Inspect the page, but the specific hyperlink does not show any file path. Tried with selenium to get the web element , but that does not have a submit/click option. The page under discussion is 'https://ift.tt/3h46ewc' and the element is > "<a href="javascript:;" onclick="downloadCSV('high')" class=""><img src="/assets/images/icon-xls.svg" alt="csv" title="csv" class=""> Download (.csv)</a>" from Recent Questions - Stack Overflow https://ift.tt/3jgFsn5 https://ift.tt/eA8V8J

Extract element of given subclass from list of superclass

Given this code class Animal{} class Dog extends Animal{} class Cat extends Animal{} class Pitbull extends Dog{} object MyClass { def main(args: Array[String]) { val animals: List[Animal] = List(new Dog(), new Cat(), new Pitbull(), new Dog(), new Cat()) getElementOftype(animals, PitBull) } def getElementOftype(list: List[Animal], givenType: ???): Animal = { } } I want to extract the first element of type Pitbull from this List, How should I proceed with this? from Recent Questions - Stack Overflow https://ift.tt/3vZpVeh https://ift.tt/eA8V8J

C# how to CC myself

I'm working on a VSTO project for Outlook. Very simple application with an icon on the ribbon. When user clicks on it, the selected email will be sent to the manager. It is working with the following code. But I want to add the sender as CC in the email. So whenever user clicks on it, the selected email will be sent to the manager and the user will be CC'd on it. So user will get a copy too. How can I CC the sender? here is the code: public partial class Ribbon1 { private void Ribbon1_Load(object sender, RibbonUIEventArgs e) { } private void button1_Click(object sender, RibbonControlEventArgs e) { Outlook.Application application = new Outlook.Application(); Outlook.NameSpace ns = application.GetNamespace("MAPI"); try { //get selected mail item Object selectedObject = application.ActiveExplorer().Selection[1]; Outlook.MailItem selectedMail = (Outlook.MailItem)selectedObject; ...

Alternatives To Global Variables in C++

I need to set a variable in the main function and access it from a different function in the same file. I can not pass it to the function because it means changing the entire code structure, which is not an option. To avoid declaring a global variable I crated a namespace and I want to check if this is a good programming practice or is there a cleaner way to do it. This is the code: namespace mylocalnamespace{ int myglobalvar; } static void myFunc() { ..... some code operationX(mylocalnamespace::myglobalvar); ..... some code } int main(int argc, char **argv) { ..... some code mylocalnamespace::myglobalvar = atoi(argv[0]); ..... some code } from Recent Questions - Stack Overflow https://ift.tt/3jfUycJ https://ift.tt/eA8V8J