How to mutate/write the property of an asset using Tandem API?

I am trying change the value of a property of an asset using tabdem api. I am using mutate method provided in the tandem api but I’m unable to find how to change property value. It is asking key and value as argument for query param but I don’t what yo give and from to fetch that values.

Please guide me as how to change the properties values using this method.

[enter image description here](https://i.stack.imgur.com/DYOqw.jpg)

I tried to find the values in the facility but I am not sure from I should get the property value in the facility.

How to use Jolt to get attribute when the structure of the JSON data is different between objects

Does anyone how to write a JOLT Transform with this situation:
Input:

[
{
    "id": "65cf06b62fadc0122dc30f29",
    "code": "H34.23.9-240216-0003",
    "applicant": {
      "eformId": "60d990f88e6893001e5a7b42",
      "userId": "6186433deee4513fe0d86efc",
      "data": {
        "birthday": "",
        "address": "Thôn Kon Năng Treang",
        "gender": 2,
        "nation": {
          "label": "Việt Nam",
          "value": "5f39f4a95224cf235e134c5c"
        },
        "ghiChu": "",
        "identityDate": "",
        "noiDung": "",
        "phoneNumber": "",
        "province": {
          "label": "Tỉnh Kon Tum",
          "value": "5def47c5f47614018c000062"
        },
        "identityNumber": "062195002130",
        "soBoHoSo": "1",
        "organization": "Y Thảo",
        "district": {
          "label": "Huyện Đắk Hà",
          "value": "5def47c5f47614018c001615"
        },
        "identityAgency": {},
        "fullname": "Y Thảo",
        "fax": "",
        "village": {
          "label": "Xã Đắk Ui",
          "value": "5def47c5f47614018c123509"
        },
        "email": ""
      }
    }
  },
{
    "id": "65cf24e3f21075472fe549c7",
    "code": "H34.6-240216-0032",
    "nationCode": "G22.99-240216-030023-H34",
    "applicant": {
      "eformId": "624bb547cdb7f7ec092bee16",
      "data": {
        "fullname": "CÔNG TY CỔ PHẦN VIEON",
        "province": {
          "label": "Thành phố Hồ Chí Minh",
          "value": "5def47c5f47614018c000079"
        },
        "district": {
          "label": "Quận 3",
          "value": "5def47c5f47614018c001770"
        },
        "village": {
          "label": "Phường Võ Thị Sáu",
          "value": "5def47c5f47614018c127139"
        },
        "phoneNumber": "02838241919",
        "fax": "02838241919",
        "mail": "[email protected]",
        "taxCode": "0314415573",
        "contact": "Hoàng Lê Huế An ",
        "contactPhoneNumber": "0385792805",
        "chonDoiTuong": 2,
        "hinhThucNop": 2,
        "ownerFullname": "CÔNG TY CỔ PHẦN VIEON",
        "identityNumber": "0314415573",
        "ownerIdentityNumber": "0314415573",
        "isOwnerDossier": true
      }
    }
  }
]

Expected output:
[
{
“id”: “65cf06b62fadc0122dc30f29”,
“eformId”: “60d990f88e6893001e5a7b42”,
“gender”: 2,
“fullname”: “Y Thảo”,
“ownerFullname”: “”,
“province_label”: “Tỉnh Kon Tum”
},
{
“id”: “65cf24e3f21075472fe549c7”,
“eformId”: “624bb547cdb7f7ec092bee16”,
“gender”: null,
“fullname”: “CÔNG TY CỔ PHẦN VIEON”,
“ownerFullname”: “CÔNG TY CỔ PHẦN VIEON”,
“province_label”: “Thành phố Hồ Chí Minh”
}
]

Set Image Size in jsPDF while converting HTML to PDF

I’m using jsPDF to convert HTML to PDF. Text and Images are being converted but there are issues coming with image sizes. I’m using the jsPDF version ^1.3.4. I’ attaching the following code for reference.

 const tempElement = document.createElement("div");
tempElement.innerHTML = HTMLdataString;

   var pdf = new jsPDF("p", "mm");
pdf.fromHTML(
  tempElement,
  10,
  10,
  {
    putOnlyUsedFonts: true,
    margin: [10, 10, 10, 10],
    autoPaging: "text",
    x: 0,
    y: 0,
    width: 190, //target width in the PDF document
    windowWidth: 675, //window width in CSS pixels
    pageSplit: true,
    image: { type: "jpeg", quality: 0.98, width: 100 },
  },
  function (bla) {
    const pdfBlob = pdf.output("blob");

    // Create URL for the Blob
    const pdfUrl = URL.createObjectURL(pdfBlob);

    // Open the PDF in a new tab
    window.open(pdfUrl, "_blank", "text.pdf");
  }
  //options
);

Futher, I’m attaching the data coming from React-Quill which is referenced as HtmlDataString above.
HTML Data String Consoled

PS: I don’t want to use html2canvas as it captures the document. The issue with capturing data is it attached as image in the pdf and user can’t select the data from pdf. If there’s any method or library that helps to convert the html to pdf, will be appreciated.

React Native WARN `new NativeEventEmitter()` was called with a non-null argument without the required `addListener` method

WARN new NativeEventEmitter() was called with a non-null argument without the required addListener method.
WARN new NativeEventEmitter() was called with a non-null argument without the required removeListeners method.

whenever i build my react native project getting this warning :

WARN new NativeEventEmitter() was called with a non-null argument without the required addListener method.
WARN new NativeEventEmitter() was called with a non-null argument without the required removeListeners method.

can we apply date range filter on date if date data type or dtype is text or str?

models-
`class RocCharge(models.Model):`
`charge_id = models.IntegerField(blank=True, null=True)`
`chname = models.CharField(max_length=100, blank=True, null=True, db_index=True)`
`date_of_creation = models.TextField(default=date.today)`

views-
`from_date = request.GET.get('fromdate')`
`to_date = request.GET.get('Todate')`
`if from_date and to_date:
    combined_data = combined_data.filter(date_of_creation__gte=from_date, date_of_creation__lte=to_date)`

my date of creation in mysql as well as in models in text format , but i want to perform date range filter from to range without changing date data type , my date in mysql like-21-12-2019

Joint Plus CBD Gummies Reviews (Warning Exposed 2024) Joint Plus CBD Gummies Review Natural Ingredients

What is Joint Plus CBD Gummies?

Joint Plus CBD Gummies are the most advanced health-boosting gummies which simply help in solving all the different health issues at the same time and give you better stamina and energy levels. This formula helps enhance your immunity and digestion power and you will become healthy from the inside and make you healthy and strong from the inside. This formula will never leave any side effects on your body and you will find only natural ingredients in its making which are tested by experts and will surely give you the desired results in a short period.

This formula is designed for every male and female and will solve the problem of depression, stress, and anxiety at the same time and makes you fit from the inside and you must try this formula without thinking excess as it will surely give you the results that you always wanted and you must try it now.

Official Website:- https://www.onlymyhealth.com/new-joint-plus-cbd-gummies-reviews-1708695168

Move object inside an array to another another array in react and remove the object from the initial array

I have two objects in my react component as follows

cosnt [Selected, setSelected] = React.useState([]);
cosnt [NonSelected, setNonSelected] = React.useState([]);
const Tmp_Selected = [
   { "Metric": "AAA", "Weight": 10, "Value": "xxx" },
   { "Metric": "BBB", "Weight": 20, "Value": "xx1" },
   { "Metric": "CCC", "Weight": 30, "Value": "xx2" },
];
const Tmp_NonSelected = [
   { "Metric": "DDD", "Weight": 5, "Value": "yy" },
   { "Metric": "EEE", "Weight": 15, "Value": "zz" },
   { "Metric": "FFF", "Weight": 25, "Value": "cc" },
];
React.useEffect(() => {
  setSelected(Tmp_Selected);
  setNonSelected(Tmp_NonSelected);
}, [location]);

I have a function in my code where I will be getting only the Metric and Weight values of NonSelected object value based on that, I need to move that whole object from NonSelected object to Selected object

const MoveValues = (Metric='DDD', Weight=5) => {
  
}

So I need an something similar to this

const Tmp_Selected = [
   { "Metric": "AAA", "Weight": 10, "Value": "xxx" },
   { "Metric": "BBB", "Weight": 20, "Value": "xx1" },
   { "Metric": "CCC", "Weight": 30, "Value": "xx2" },
   { "Metric": "DDD", "Weight": 5, "Value": "yy" },
];

const Tmp_NonSelected = [
   { "Metric": "EEE", "Weight": 15, "Value": "zz" },
   { "Metric": "FFF", "Weight": 25, "Value": "cc" },
];

Any help is much appreciated

Thanks,

Find every path through a 4×4 matrix starting from 0,0 that touches every cell once and doesn’t revisit any?

I’m trying to generate all the paths through an NxN matrix that touch every cell once without revisiting any, starting from (0,0). Each path in a 4×4 matrix would thus be 16 steps long. Each step of the path can only move 1 cell in any direction, including diagonal. I have tried to write this for a couple hours in different ways using DFS- or BFS-based approaches, so far unsuccessfully. I am working in Typescript. Could anyone with a better grasp of their graph algorithms lend me a hand?

This is what I have so far but someone else might probably be better off starting from scratch because this is pretty non-functional. It currently just hangs, and most likely my logic is wrong anyway. I tried consulting with an LLM and it was unable to solve this problem either nor was its code any better than mine.

I guess this is kind of a variant of the longest-path problem – I want to find every possible longest path for a given acyclic graph, which I suppose is what a matrix equates to if you can’t revisit any cells.

type Position = [number, number];

// Define the directions for moving (including diagonals)
const directions: Position[] = [
    [-1, -1], [-1, 0], [-1, 1],
    [0, -1],           [0, 1],
    [1, -1],  [1, 0],  [1, 1]
];

// Checks if a given position is valid within an NxN matrix
function isValid(n: number, x: number, y: number, visited: boolean[][]): boolean {
  return x >= 0 && y >= 0 && x < n && y < n && !visited[x][y];
}

function bfs(n: number): void {
    let visited: boolean[][] = Array(4).fill(false).map(
      () => Array(4).fill(false)
    );

    let queue: { path: Position[], visited: boolean[][] }[] = [];
    queue.push({ path: [[0, 0]], visited: visited }); // Start with the top-left corner

    while (queue.length > 0) {
      let current = queue.shift()!; // Dequeue current position
      let [x, y] = current.path[current.path.length - 1];

      if (current.path.length === 16) {
        // We have visited all nodes, print the path
        console.log(current.path);
        continue;
      }

      for (let [dx, dy] of directions) {
        let newX = x + dx;
        let newY = y + dy;

        if (isValid(n, newX, newY, current.visited)) {
          let newPath: Position[] = [...current.path, [newX, newY]]; // Extend the path
          let newVisited: boolean[][] = current.visited.map(row => row.slice()); // Copy visited array
          newVisited[newX][newY] = true; // Mark the new position as visited
          queue.push({ path: newPath, visited: newVisited }); // Enqueue new path
        }
      }
    }
}

bfs(4);

Tabulator dropdown disappear its own instantly in Tablet/mobile view

Its work fine on PC, but on a tablet, when I click on the dropdown, it opens along with the virtual keyboard, and the dropdown and virtual keyboard disappear instantly. I think the problem would be solved if the virtual keyboard didn’t open/close on its own.

I want to open the dropdown and ensure that it remains open until I take any action. It should not close on its own.

I would like to make the below code to execute synchronous [duplicate]

Below is the code I want to make synchronous

subtractBtn.addEventListener("click",  (e) => {

    console.log("executing");
    readDatafromDB();
    console.log("executing after read");

});



function readDatafromDB() {

    const db_store = createTransaction("readwrite");
    const data = db_store.get(79);

    console.log("executing 2");
    
    data.onsuccess =  function(e) {       
        var data = e.target.result;
        console.log("data is: ", data);
    };

    data.onerror = function(e) {

    };
    console.log("executing 4");
}

Since reading data from indexedDB is async the following the being printed:

executing
executing 2
executing 4
executing after read
data is: 

However, I would want the code to execute in the below way synchronously

executing
executing 2
data is: 
executing 4
executing after read

I tried in all possible, and seems impossible

How to implement user consent in applications multitenant registered with Azure AD B2 with microsoft graph to access Microsoft Calendar API?

I have tried registering the application on Azure AD B2C by selecting the option “Accounts in any identity provider or organizational directory (for authenticating users with user flows)”. I chose this option so that all personal accounts or work accounts from any tenant can log in.

However, selecting this option creates Delegated permissions on Microsoft Graph when adding API permissions only has the option for openid, as in the image below:

Request API Permissions – Microsoft Graph – Delegated permissions type

therefore, I added calendars.read with application permissions type
Request API Permissions – Microsoft Graph – Application permissions type

The API permission has also been granted admin permission
Grant admin consent

the dependencies I use are “@azure/msal-browser”: “^2.16.1”

and here’s how I implemented it into my javascript code:

const msalConfig = {
  auth: {
    clientId: envconfig.REACT_APP_MICROSOFT, //Application (client) ID
    redirectUri: envconfig.REACT_APP_BASE_URL,
    postLogoutRedirectUri: envconfig.REACT_APP_BASE_URL,
  },
  cache: {
    cacheLocation: "localStorage",
  },
};

const msalRequest = { scopes: ["user.read", "calendars.read"] };
const msalClient = new msal.PublicClientApplication(msalConfig);

async function MsalLogin() {
  try {
    const authResult = await msalClient.loginPopup({
      scopes: msalRequest.scopes,
      prompt: "select_account",
    });

    localStorage.setItem("_microsoftAccount", authResult.account.username);

    return authResult;
  } catch (error) {
    console.error("MsalLogin error:", error);
    throw error;
  }
}`

with the configuration above, when I as a user who is a member of a different tenant (Azure AD) tries to enter the application, and displays Need admin approval in the popup:
Need admin approval – error

Question:

What configurations are appropriate to do in an Azure AD B2C environment and how to implement them in JavaScript coding, so that users with work or personal accounts from any tenant can connect their calendars to my application with consent by the user or if possible without requiring approval from any party . So that admins from the user’s organization don’t have to approve logging into my app?

If anyone understands this, please help. Let me know if there is any other information I should share.

What i have tried:

  • I have tried registering a new application by selecting “Accounts in any organizational directory (Any Microsoft Entra ID tenant – Multitenant)”. With this option, delegated permissions have the option to add more api permissions, including calendars.read. After I apply it, it still displays Need admin approval.
  • I have tried to find out about verified publisher to solve this problem, but I am not sure because Azure AD B2C does not have this feature
  • i have tried adding a user flow with type signupsignin, but i don’t understand how to implement it, and whether this way will solve my problem.
    -I have tried changing the Admin consent settings by changing to Yes in the Users can request admin consent to apps they are unable to consent to option, but it doesn’t work

What i expected :

I want my application to be accessible by any tenant and with personal Microsoft accounts or work accounts. And also I want to use the graph API to access the calendars.read API with delegated permission. I don’t understand how delegated permissions work, but what I want is that permissions must be approved from the user’s side, so that the admin doesn’t need to give permission first so that the popup doesn’t appear Need admin approval.

How to generate a random path that touches every square in a matrix?

In my case it’s a 4×4 matrix, but I would imagine we would write this to accept the dimensions as a parameter. I am trying to generate a path that:

  1. always starts in a random corner
  2. touches every cell once
  3. never revisits an already-visited cell
  4. only moves 1 cell per step in any direction (including diagonals)
  5. outputs the result as an array of cell coordinates charting the path through the matrix e.g. [ [0,0], [0,1], etc… ]

So the result for a 4×4 array should always be an array of 16 smaller arrays.

I have been trying to do this for a couple hours now and not quite gotten there. I was trying to use DFS, but I cannot get the logic right. I tried using ChatGPT to help and it was unable to solve this problem either.

Here is my current code, but it’s in-progress and critically flawed and does not function. Everything from the DFS declaration down is in a halfway-state that I just kind of gave up on, honestly. It might be better to start from scratch lol.

export const generateRandomPath = () => {
    const matrixSize = 4;
    const visited = Array.from({ length: matrixSize }, () => Array(matrixSize).fill(false));

    // start in corner
    const startRow = Math.floor(Math.random() * 4); // 0 or 3
    const startCol = Math.floor(Math.random() * 4); // 0 or 3

    function isValidMove(row: number, col: number): boolean {
      return (row >= 0 && row < matrixSize)
      && (col >= 0 && col < matrixSize)
      && !visited[row][col];
    }

    function getValidNeighbors(row: number, col: number): [number, number][] {
      const neighbors: [number, number][] = [];
      const directions = [-1, 0, 1];
      for (const dx of directions) {
        for (const dy of directions) {
          if ((dx !== 0 || dy !== 0) && isValidMove(row + dx, col + dy)) {
            neighbors.push([row + dx, col + dy]);
          }
        }
      }
      return neighbors;
    }

    function shuffleArray(array: any[]): void {
      for (let i = array.length - 1; i > 0; i--) {
        const j = Math.floor(Math.random() * (i + 1));
        [array[i], array[j]] = [array[j], array[i]];
      }
    }

    function dfs(row: number, col: number): boolean {
      const neighbors = getValidNeighbors(row, col);
      if (neighbors.length === 0) {
        return false; // Dead end, need to backtrack
      }

      shuffleArray(neighbors); // Randomly shuffle neighbors

      visited[row][col] = true;
      for (const [nextRow, nextCol] of neighbors) {
        if (dfs(nextRow, nextCol)) {
          return true;
        }
      }
      visited[row][col] = false; // Unmark current cell
      return false;
    }

    let success = false;
    while (!success) {
      success = dfs(startRow, startCol);
      // Reset visited array for the next attempt
      visited.forEach(row => row.fill(false));
    }

    return path;
};

Javascript : How can I find a specific value among arrays, then get the array of the value? [duplicate]

I cannot find a way to find a specific way to find a value among multiple arrays and get the whole value of the array.

An example is I would want to get the array with the number “5”

{
  [1,2,3],
  [4,5,6],
  [7,8,9]
};

Code output:
[4,5,6];

I cannot provide code that I have tried because I am still new to JavaScript. Is the code that I am thinking of possible?

Incoming file from post is “fakepath”

Brand new to react. My file is sending as a fakepath. I know this is for browser sercurity but I expected it to be different in my view. When I deserialize the request.body with json.loads I get this FileNotFound error.

fitz.FileNotFoundError: no such file: 'C:fakepathHW 3 CPSC 332.pdf'

When I deserialize the body with my own serializer it returns that the object is not valid. I am assuming this is due to the same issue with the fake file path.

request.body

b'{"title":"sdfg","content":"","file":"C:\\fakepath\\HW 3 CPSC 332.pdf"}'

views.py

@api_view(['POST'])
def createPost(request):
    serializer = SinglePostSerializer(data=request.body)
    
    if serializer.is_valid():
        serializer.save()
        return Response({'message': 'File uploaded successfully'}, status=status.HTTP_201_CREATED)
    else:
        return Response({'errors': serializer.errors}, status=status.HTTP_400_BAD_REQUEST)

serializers.py

class SinglePostSerializer(ModelSerializer):
    class Meta:
        model = Post
        fields = '__all__'

models.py

# Create your models here.
class Post(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    title = models.CharField(max_length=50)

    likes = models.IntegerField(default=0)
    comment_count = models.IntegerField(default=0)

    pdf_file = models.FileField(upload_to='media/pdfs/')
    images = models.ManyToManyField(SheetMusicImage)
    
    comments = models.ManyToManyField('Comment', blank=True)
    date_created = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.pdf_file.name

CreatePostPage.js

import React, { useState, useEffect} from 'react'

const CreatePostPage = () => {


    const [formData, setFormData] = useState({
        // Initialize form fields here
        // For example:
        title: '',
        content: '',
    });

    const handleChange = (e) => {
        setFormData({
          ...formData,
          [e.target.name]: e.target.value,
        });
      };

    const handleSubmit = async (e) => {
        e.preventDefault();

        try {
            console.log(JSON.stringify(formData))
            const response = await fetch('posts/createPost', {
            method: 'POST',
            headers: {
            'Content-Type': 'application/json',
            },
            body: JSON.stringify(formData),
        });

        if (response.ok) {
            // Handle successful submission, e.g., redirect or show a success message
            console.log('Post created successfully');
        } else {
            // Handle error cases
            console.error('Failed to create post');
        }
        } catch (error) {
        console.error('Error:', error);
        }
    };

    return(
        <div>
            <form onSubmit={handleSubmit}>
                <input type="text" id="title" name="title" placeholder="Title" onChange={handleChange}/>
                <input type="file" id="file" name="file"  accept="application/pdf" onChange={handleChange}/>
                <button type="submit">Submit</button>
            </form>
        </div>
    );
}

export default CreatePostPage

Best way to render the children twice in Next.js

To make an infinite slider I needed to use the same data twice.

The data is just an array within component with max 20 items, each one with image. The slider is working perfectly.

Yeah, its unusual, but needed on a simple application… what is the best or prettier way/practice to render this data without problems or performance loss if it exists?

function Page() {
  const data = [
  {
    src: "ObjectA"
  },
  {
    src: "ObjectB"
  },
  {
    src: "ObjectC"
  }
  ...
 ]

return (
  <Slider>
   {
     data.map((item, i) => {
      return (
        <Component key={i}>
          <Child src={item.src}/>
        </Component>
      )
     })
   }
  </Slider>
 )
}
export default function Component(props: {children: ReactNode}) {
  return (
   {props.children}
  )
}
export default function Child(props: {src: string | StaticImport}) {
  return (
   <Image src={props.src} alt="..."/>
  )
}

Some different approaches that work:

export default function Component(props: {children: ReactNode}) {
  return (
   {props.children}
   {props.children}
  )
}

export default function Component(props: {children: ReactNode}) {
  const [childrenCopy] = useState(props.children) // really necessary?
  return (
   {props.children}
   {childrenCopy}
  )
}
function Page() {
  const data = [
  {
    src: "ObjectA"
  },
  {
    src: "ObjectB"
  },
  {
    src: "ObjectC"
  }
 ]

// no savings for code
return (
  <Slider>
   {
     data.map((item, i) => {
      return (
        <Component key={i}>
          <Child src={item.src}/>
        </Component>
      )
     })
   }
   {
     data.map((item, i) => {
      return (
        <Component key={i}>
          <Child src={item.src}/>
        </Component>
      )
     })
    }
  </Slider>
 )
}