This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title></title> | |
</head> | |
<body style="margin: 0;"> | |
<style> | |
@media only screen and (max-width: 600px) { | |
.main-table { | |
width: 100% !important; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
useEffect(() => { | |
console.log({ url: process.env.REACT_APP_SOCKET_ENDPOINT }); | |
function onConnect() { | |
console.log("Socket connected successfully"); | |
setIsConnected(true); | |
console.log(personId); // Check if personId is logged correctly | |
socket.emit("join", { person_id: personId }); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Custom hook for mutations | |
const useCustomMutation = <T = unknown>( | |
mutationFn: (...args: any[]) => Promise<T>, | |
options?: UseMutationOptions<T, unknown, unknown> | |
) => { | |
return useMutation(mutationFn, { | |
onSuccess: (data) => { | |
// Handle success case | |
console.log('Mutation successful:', data); | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function countRectangles(board) { | |
let count = 0; | |
let N = board.length; | |
let M = board[0].length; | |
for (let r = 0; r < N; r++) { | |
for (let c = 0; c < M; c++) { | |
for (let i = r; i < N; i++) { | |
for (let j = c; j < M; j++) { | |
let aCount = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function combineCustomNights(customNights) { | |
const result = []; | |
let currentRange = null; | |
customNights.sort((a, b) => new Date(a.date) - new Date(b.date)); | |
customNights.forEach((night) => { | |
if (!currentRange) { | |
currentRange = { start: night.date, end: night.date, rooms: { ...night } }; | |
delete currentRange.rooms.date; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function belongsToTriangle(x1, y1, x2, y2, x3, y3, xp, yp, xq, yq) { | |
// Calculate the length of the sides of the triangle | |
const lab = Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2); | |
const lac = Math.sqrt((x3 - x1) ** 2 + (y3 - y1) ** 2); | |
const lbc = Math.sqrt((x3 - x2) ** 2 + (y3 - y2) ** 2); | |
// Check if the triangle is non-degenerate | |
if (lab + lac <= lbc || lab + lbc <= lac || lac + lbc <= lab) { | |
return "o"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function palindromeChecker(s, startindex, endindex, subs) { | |
let result = ''; | |
for (let i = 0; i < startindex.length; i++) { | |
let sub = s.substring(startindex[i], endindex[i] + 1); | |
let count = new Array(26).fill(0); | |
for (let j = 0; j < sub.length; j++) { | |
count[sub.charCodeAt(j) - 97]++; | |
} | |
let oddCount = 0; | |
for (let j = 0; j < 26; j++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makePalindrome(s, startindex, endindex, subs) { | |
let result = ""; | |
for (let i = 0; i < startindex.length; i++) { | |
let substring = s.substring(startindex[i], endindex[i] + 1); | |
let count = 0; | |
let charMap = new Map(); | |
for (let j = 0; j < substring.length; j++) { | |
charMap.set(substring.charAt(j), charMap.get(substring.charAt(j)) + 1 || 1); | |
} | |
for (let [char, freq] of charMap) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Value types can be three, value1, value2, value3 | |
const items=[ | |
{ | |
"date": "2023-02-01", | |
"value1": 1, | |
"value2": 1 | |
}, | |
{ | |
"date": "2023-02-03", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable no-unused-expressions */ | |
import React, { useState, useEffect } from "react"; | |
import { | |
AppBar, | |
Button, | |
Card, | |
Dialog, | |
DialogActions, | |
DialogContent, |
NewerOlder