Given any weighted graph G=(V,E) and vertices s,t∈V , multiplying each of the edge weights in the graph by 2 does not change which edges are in the shortest path from s to t .
true or false
Freelance Projects, Design and Programming Tutorials
Given any weighted graph G=(V,E) and vertices s,t∈V , multiplying each of the edge weights in the graph by 2 does not change which edges are in the shortest path from s to t .
true or false
useEffect(() => {
//for duration
if (
filtering?.durationInMinutes &&
selectedFilterItems.find((item) => item.type === 'durationInMinutes')
?.code !==
`${filtering?.durationInMinutes?.from || '-'}${
filtering?.durationInMinutes?.to
}`
) {
setSelectedFilterItems((prev) => {
prev = prev.filter((items) => items.type !== 'durationInMinutes');
return [
...prev,
{
displayItem: (
<span className="flex items-center gap-2">
{!!filtering?.durationInMinutes?.from && (
<span className="flex items-center gap-2">
from{' '}
<strong>
{convertDuration(filtering?.durationInMinutes?.from)}
</strong>
</span>
)}{' '}
{!!filtering?.durationInMinutes?.to && (
<span className="flex items-center gap-2">
{!!filtering?.durationInMinutes?.from ? 'to ' : 'upto '}
<strong>
{convertDuration(filtering?.durationInMinutes?.to)}
</strong>
</span>
)}
</span>
),
type: 'durationInMinutes',
code: `${filtering?.durationInMinutes?.from || '-'}${
filtering?.durationInMinutes?.to
}`,
},
];
});
} else if (!filtering?.durationInMinutes) {
setSelectedFilterItems(
(prev) =>
(prev = prev.filter((items) => items.type !== 'durationInMinutes'))
);
}
if (
(sortType.sort !== 'DEFAULT' &&
selectedFilterItems.find((item) => item.type === 'sort')?.code !==
sortType.sort) ||
selectedFilterItems.find((item) => item.type === 'sort')?.code ===
sortType.sort
) {
setSelectedFilterItems((prev) => {
prev = prev.filter((items) => items.type !== 'sort');
return [
...prev,
{
displayItem: (
<span className="flex items-center gap-2">
Sort by <strong>{sortType.name}</strong>
</span>
),
type: 'sort',
code: sortType.sort,
},
];
});
} else if (sortType.sort === 'DEFAULT') {
setSelectedFilterItems(
(prev) => (prev = prev.filter((items) => items.type !== 'sort'))
);
}
i expected this to works both on low to high and high and low
Im upgrading from SST 3.2 to 3.11 but as soon as I use the deploy command, I get the following error: Your sst.config.ts has top level imports - this is not allowed. Move imports inside the function they are used and do a dynamic import: const mod = await import("./mod")
This is my old .config file:
import { settings } from 'path/to/settings';
const type = 'test';
export default $config(settings(type));
I have tried to change the config file like this:
const type = 'test';
export default $config(async () => {
const { settings } = await import('path/to/settings');
return settings(type);
});
But I get this error Unexpected error occurred. Please run with --print-logs or check .sst/log/sst.log if available. with an empty log folder.
I have tried to search for documentation on this but I have not been able to find anything. Has anyone experienced something similar when upgrading?
I’m working with Angular and using the DevExtreme dx-tree-list and dx-select-box components. I want to show the dx-select-box dynamically based on a condition (showAdjustmentBudgetBases), but when I do this, the data in my dx-tree-list no longer displays any data.
Here is the relevant portion of my HTML:
<dxi-item itemType="group">
<dx-tree-list height="400" #budgetLock id="departmentListBudgetLocking"
[dataSource]="departmentList"
dataStructure="tree" itemsExpr="items" parentIdExpr="worD_CODE"
[showRowLines]="true"
[showBorders]="true" [columnAutoWidth]="true" [(selectedRowKeys)]="selectedRowKeys">
<dxo-selection mode="multiple" [recursive]="true"></dxo-selection>
<dxo-filter-row [visible]="true"></dxo-filter-row>
<dxi-column dataField="text" [allowFiltering]="true" caption="Select All"></dxi-column>
</dx-tree-list>
</dxi-item>
<dxi-item *ngIf="showAdjustmentBudgetBases" itemType="group">
<dxi-item dataField="adjustmentBudgetBaseId"
editorType="dxSelectBox"
[editorOptions]="{dataSource: finyearAdjustmentBudgetBases, displayExpr: 'finyearAdjustmentBudgetBase', valueExpr: 'id', onValueChanged: adjustmentBudgetBaseEvent}">
<dxi-validation-rule type="required"></dxi-validation-rule>
<dxo-label [text]="finyearAdjustmentBudgetBaseLabel"></dxo-label>
</dxi-item>
</dxi-item>
Problem:
When I set showAdjustmentBudgetBases to true, the dxSelectBox is rendered as expected, but the dx-tree-list no longer displays any data (departmentList is empty). If I set showAdjustmentBudgetBases to false, the dx-tree-list shows its data again.
What I’ve tried:
Ensured that departmentList contains data.
Verified that showAdjustmentBudgetBases is set correctly in the component.
Tried changing the order of elements in the HTML.
Used ChangeDetectorRef to manually trigger change detection when the condition changes, but it didn’t resolve the issue.
My Guess:
I suspect the issue is related to how *ngIf is causing Angular to re-render the dx-tree-list when the condition for the dx-select-box changes. This might be disrupting the dx-tree-list’s data binding, but I’m not sure how to prevent this.
Can anyone help me figure out why the dx-tree-list data is not displaying when showAdjustmentBudgetBases is true? How can I conditionally show the dx-select-box without affecting the rendering of the dx-tree-list?
I’m wondering why I can exit full screen when I have a flag that should prevent the user from pressing F11 twice. Please don’t tell me to use once I just need to know the reason. Fyi this is just an experiment
this.input.keyboard.on('keydown-F11', (event) => {
event.preventDefault();
console.log("isTogglingFullScreen: ", isTogglingFullScreen);
if (!isTogglingFullScreen){
console.log("toggleFullScreen called");
isTogglingFullScreen = true;
this.scale.isFullscreen ? this.scale.stopFullscreen() :
this.scale.startFullscreen();
}
});
I am making a website which is predominantly for data visualisation, data is selected by the user (who also selects a chart type) and returned with PHP and I’m using Chart.js on the client side to generate the graphs. I’m trying to use as modular an approach as possible for reusability so that I can make different types of graphs with different data with this code.
The problem I have is that whilst most charts, such as line and bubble charts, work just fine pie and doughnut charts do not, instead it just outputs a series of rectangular blocks with numbers.
I apologise using an image of the chart output, I simply don’t know how else to show the chart output and I’ve tried to explain it above – the graph output on the webpage.
This is the code responsible for generating the graph:
function makeChart(ctx, response, selectedColumn) {
if (myChart) {
myChart.destroy();
}
const chartTypeValue = chartTypeSelect.value;
const labels = response.map(item => item['Hour']);
const data = response.map(item => {
const value = item[selectedColumn];
return isNaN(value) ? value : parseFloat(value);
});
myChart = new Chart(ctx, {
type: chartTypeValue,
data: {
labels: labels,
datasets: [{
label: `Data for ${selectedColumn}`,
data: data,
backgroundColor: [
'rgb(255, 99, 132)',
'rgb(255, 159, 64)',
'rgb(255, 205, 86)',
'rgb(75, 192, 192)',
'rgb(54, 162, 235)',
'rgb(153, 102, 255)',
'rgb(201, 203, 207)'
],
}]
}
}
);
return myChart;
}
So I’d like to know how I might go about addressing this.
Thanks for your time and help.
Background: This problem statement provides the high-level design of the project that has to be implemented as part of the hands-on assessment in order to complete the course Spring Basics.
InfyGo is an airline booking application that provides services to its customers to search for flight details. InfyGo wants a lightweight, loosely coupled application to be implemented using Spring.
Let us start with basic implementation using Spring core concepts for the following functionalities
Add Flight
Search Flight
As part of the Spring Basics course, let us develop the business tier of this application.
I am using Playwright and trying to drag & drop the list at this site into the right order. These locators work as expected, and the drag & drop does work every so often. I have tried dragTo(), a combination of mouse up, down, and hover, and a lot of different selectors. Nothing works consistently. I am urgently preparing for a test, so any help would be appreciated, please don’t mind the sloppy code.
// launch browser and open a new page
const { context } = await launch();
const page = await context.newPage();
// go to sortable list site
await page.goto('https://qaplayground.dev/apps/sortable-list/');
// order list
const correctOrder = [
'Jeff Bezos',
'Bill Gates',
'Warren Buffett',
'Bernard Arnault',
'Carlos Slim Helu',
'Amancio Ortega',
'Larry Ellison',
'Mark Zuckerberg',
'Michael Bloomberg',
'Larry Page'
];
async function swapItemToIndex(textIndex, listIndex) {
const correctItem = `div.draggable:has-text('${correctOrder[textIndex]}')`;
const targetItem = `li[data-index="${listIndex}"]`;
await page.dragAndDrop(correctItem, targetItem);
}
await swapItemToIndex(0, 0);
await swapItemToIndex(1, 1);
// the elements are not ordered as expected
I have a button inside a Shopify Liquid file, and when it’s clicked, I need it to trigger a click event on a chat div role=button elsewhere in the DOM.
<button class="my-button">open chat</button>
Chat Div role=button (Rendered in DOM):
<div class="chat-button" data-testid="launcher-button" role="button">
</div>
Issue:
I attempted to use JavaScript to trigger the .chat-button when .my-button is clicked:
document.querySelector(".my-button").addEventListener("click", function () {
document.querySelector(".chat-button")?.click();
});
However, the chat button is not always found or does not respond to the .click() event.
Questions:
Is .chat-button dynamically loaded after the page renders? If so, how can I ensure it’s ready before triggering .click()?
Is .click() the right approach for a , or should I use dispatchEvent(new Event(“click”))?
If .chat-button is inside an iframe, how can I access and click it from my script?
Would appreciate any insights!
Notes:
The button is a Front Chat Button
It is possible to collocate a .js file and a related .razor file as described here.
Is there a way to collocate a .js file and .cs file in a similar way? I image it looking similar to this:
MyService.cs
public class MyService
{
private readonly IJSRuntime _js;
private IJSObjectReference? _jsModule;
public MyService(IJSRuntime js)
{
_js = js;
}
public async Task MyMethod()
{
if (_jsModule == null)
{
var modulePath = $"./_content/Company.Library/Service/MyService.cs.js";
_jsModule = await _js.InvokeAsync<IJSObjectReference>("import", modulePath);
}
await _jsModule.InvokeVoidAsync("myjsmethod");
}
}
MyService.cs.js
export function myjsmethod() {
console.log('Hello World');
}
This compiles fine, but when run the MyService.cs.js file fails to load with the error “failed to fetch dynamically imported module”
Please I am new in Javascript. I am trying to write this php rand() function in Javascript, I am building a project in React as frontend and Nodejs/express.js as backend.
I can solve the below code;
$rand = rand(1, 4);
if($rand == 1) {
duckPic = "resources/pic1.png";
} else if($rand == 2) {
$profile_pic = "resources/pic2.png";
} else if($rand == 3) {
$profile_pic = "resources/pic3.png";
} else if($rand == 4) {
$profile_pic = "resources/pic4.png";
}
I have 4 checkboxes that filter based on its name/identifierValue. When the page loads ALL should be selected. If I click any other box ‘ALL’ should deselect and I then filter based on the selection. Then, if I click ALL all of the other checkboxes should deselect but ALL
identifiers should show.
Currently, I set the checkboxes to true or false via FormGroup in parent component.
I then listen to form changes to hanlde the logic.
The problem is I have to uncheck ALL in order to select another box.
Then when I click ALL after selecting other boxes they deselect properly but all items in the table dont show as expected.
After that I have to toggle all of the other boxes just to get the filtering back working again.
Here is the method I’m calling via ngOnInit by way of initializeSearchPage().
handleCheckboxSelection(values: any) {
const allSelected = values.ALL;
const checkBox1Selected = values.Checkbox1;
const checkBox2Selected = values.Checkbox2;
const checkBox3Selected = values.Checkbox3;
if (allSelected) {
// If "All" is selected, deselect others
this.reportListFG.get('filterGroup')?.patchValue(
{
Checkbox1: false,
Checkbox2: false,
Checkbox3: false,
},
{ emitEvent: false } // Prevent infinite loop
);
} else {
// If "All" is not selected, deselect "All" if any other is selected
if (checkBox1Selected || checkBox2Selected || checkBox3Selected) {
this.reportListFG.get('filterGroup')?.patchValue(
{
ALL: false,
},
{ emitEvent: false }
);
}
Here is my stackblitz
I am trying to integrate an existing library in my new codebase using typescript and Bun. i am facing an issue where this library is requiring modules in code asynchronously, like follows :
let target = require(AppRoot + targetName);
target.execute(targetTask);
so passing in the targetName, it can require the module which is a default exported object (usually an instantiated class). This was working fine when i was using this library in JS but when switching to Typescript the target became an Object with default being the actual instantiated class :
// in Javascript
Target {
execute : [Function]
}
// in Typescript
Target {
default : {
execute : [Funtion]
}
}
This change breaks the entire library of course as it relies on reading files that way. I am not suer if this is a Bun or Typescript issue, but is there a way to bypass forcing the default when importing for a specific library
Note: I already have esModuleInterop set to true in my tsconfig which according to chatgpt is the only hand-off solution
What I am trying to do is to get the heights of multiple elements with the same ‘class’. If the element’s height is over 400px I want it to set the height to the value it aquired minus 5px. And if it is under 400px I want it to do the same thing.
jQuery(document).ready(function( $ ){
var cardHeight = $('.card').height();
if (cardHeight > 400) {
$(this).height(cardHeight - 5);
}
else{
$(this).height(cardHeight - 5);
}
});
.wrapper {
width: 100%;
overflow: hidden;
}
.wrapper .card {
width: 20%;
float: left;
margin: 10px;
background-color: red;
}
.wrapper .card:nth-child(1) {
height: 333px;
}
.wrapper .card:nth-child(2) {
height: 333px;
}
.wrapper .card:nth-child(3) {
height: 500px;
}
.wrapper .card:nth-child(4) {
height: 500px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<body>
<div class="wrapper">
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
</div>
</body>
I’m trying to re-create a sort of a dropdown menu with multiple choices when clicked. However, the div i want to appear in position absolute still fill the space by making the div scrollable.
The clickable side is correctly implemented in Js by changing .select_cart_drop display to flex.
The goal would be to stack the drop div on the preview div in the wrapper of both of them.
Here is the code :
.select_cart {
position: relative;
width: 70%;
border: 1px solid lightgray;
}
.select_cart_drop {
position: absolute;
*/display: none;/*
flex-direction: column;
top: 0;
left: 0;
width: 100%;
z-index: 1;
}
<div class="select_cart">
<div class="cart_checkbox_label">
<div class="select_cart_container_quantité">Quantité :</div>
</div>
<div class="select_cart_drop">
<div>0 (supprimer)</div>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
<div>10 +</div>
</div>
</div>