How can i format a cell to transpose time -30minutes from a different cell?

I have a spreadsheet On google sheets that creates a different tab and moves data from the data entry tab to the date tab.

I am looking to transpose the time value from one cell to another cell but minus the time by 30 minutes. For example, Cell L has 1:30:00PM and I would like Cell O to read 1:00:00PM. I would also need to format Both column O and P to time rather than automatic.

I would like it to do this for the entire set of data that I am entering.

Would it be easier to add this into the Data entry sheet and have the data formatted there or does this need to be done after the destination sheet is created?

I have tried just simply formatting the cells on the data sheet but when I paste information from my excel document it moves the formula that i have in the cells and doesn’t work.

How to consume paginated GeoJSON sources

I would like to consume the following GeoJSON source in Mapbox:

https://geospatial.alberta.ca/titan/rest/services/transportation/access_facility_roads/FeatureServer/0/query

If I try loading this into Mapbox using:

const map = new mapboxgl.Map({
    container: 'map',
    style: 'mapbox://styles/mapbox/streets-v11',
});

map.on('load', () => {

    map.addSource('main-source', {
        type: 'geojson',
        data: 'https://geospatial.alberta.ca/titan/rest/services/transportation/access_facility_roads/FeatureServer/0/query?where=1%3D1&returnExceededLimitFeatures=true&f=geojson'
             
    });

    // Some calls to addLayer for styling
});

This seems to work, except that this dataset is paginated, and cuts off results after 2000 features. This is indicated by the (illegally placed?) key and properties member attached to the returned FeatureCollection:

{
    type: "FeatureCollection",
    exceededTransferLimit: true,
    features: [. . .],
    properties: { exceededTransferLimit: true }
}

The API supports pagination via a resultOffset query parameter that can be specified.

How do I cleanly do this in Mapbox, though? I thought that maybe transformRequest might work, but it only allows transforming a single request into another single request.

I could issue “manual” HTTP requests to the endpoint, gather the results, then call setData on the GeoJSON source with the data, but I’d prefer to keep loading data as Mapbox’s responsibility as much as possible.

Does Mapbox have any built-in mechanisms to handle this case?

overriding an array value makes my logics about arrays go crazy

I cant understand whats going on here.

My goal of the code is to print the second largest value in an array.

  1. I created a function that comes with the largest value.
  2. I took the index of the largest value in the array.
  3. A copy or another array like the first one but I modified the largest value to 0.

But when I try to print the new largest value in the second array I don’t know why it didn’t work as the first one.

The function that bring largest value:

let arr = [2, 3, 30, 3, 40, 4, 8, 70, 5, 2, 72, 5, 2];

function maxValue(nums) {
  let max = 0;
  let index;
  for (let i = 0; i < nums.length; i++) {
    if (nums[0] > nums[i]) {
      max = nums[0];
      index = i;
    } else if (max < nums[i]) {
      max = nums[i];
      index = i
    }
  }

  return max;
}

Here the code where I make newArr with modification:

let newArr = arr.map(function(e, i) {
  if (e === maxValue(arr)) {
    e = 0;
  }
  return e;
});

Here is the complete code I used:

let arr = [2, 3, 30, 3, 40, 4, 8, 70, 5, 2, 72, 5, 2];

function maxValue(nums) {
  let max = 0;
  let index;
  for (let i = 0; i < nums.length; i++) {
    if (nums[0] > nums[i]) {
      max = nums[0];
      index = i;
    } else if (max < nums[i]) {
      max = nums[i];
      index = i
    }
  }

  return max;
}

console.log("the largest value: " + maxValue(arr));

let newArr = arr.map(function(e, i) {
  if (e === maxValue(arr)) {
    e = 0;
  }
  return e;
});

console.log("the second largest value: " + maxValue(newArr));

the results:

the largest value: 72

the second largest value: 5

I was expecting in the result in the second line to be: “the second largest value: 72”

I don’t know what I am missing in understanding the issue here.

Function does not exist error, but it clearly exists

const {
    currentBuild,
    updateComponent,
    addStorageComponent,
    removeStorageComponent,
    addCaseFan,
    removeCaseFan,
    addRamComponents,//Property 'addRamComponents' does not exist on type 'BuilderStore'.ts(2339)
    removeRamComponents,//Property 'removeRamComponents' does not exist on type 'BuilderStore'.ts(2339)
    clearBuild,
    getTotalPrice,
    checkCompatibility,
    canUseStockCooler,
    useStockCooler,
  } = useBuilderStore();
  const { addItem } = useCartStore();

I’m getting this error but, in builderStore.s i have defined the function:

interface BuilderStore {
  currentBuild: PCBuild;
  savedBuilds: PCBuild[];
  updateComponent: (category: keyof PCBuild, component: BuildComponent | undefined) => void;
  addStorageComponent: (component: BuildComponent) => void;
  removeStorageComponent: (index: number) => void;
  addRamComponents: (component: BuildComponent) => void;
  removeRamComponents: (index: number) => void;
  addCaseFan: (component: BuildComponent) => void;
  removeCaseFan: (index: number) => void;
  clearBuild: () => void;
  saveBuild: () => void;
  getTotalPrice: () => number;
  checkCompatibility: () => string[];
  canUseStockCooler: () => boolean;
  useStockCooler: () => void;
}

Am I doing something wrong or is this some weird coding bug

i tried renaming the function, force restarted vite, cleared cache, nothing fixed it

Send real-time slider value from Max/MSP to a local website

I’m working on a project where I want to send a changing slider value from Max (Max/MSP) to a local website (e.g., localhost:8080) in real time. The value should be received by JavaScript in the browser so I can update visuals accordingly.
What I have:

A Max patch with a slider (or number box).

A simple local HTML/JS site served via http-server.

Little experience using node.script and WebSockets inside Max, but I've run into issues with connection readiness and error handling.

What I’m trying to find out:

What's the best way to send real-time data from Max to a browser?

Do I need to use WebSockets, or is there a simpler method?

If I use node.script in Max, how do I structure the script to properly handle input and send messages out (especially on loadbang or slider change)?

Optional:

If you have a minimal working example using either WebSockets or another protocol, that would be hugely helpful.

Thanks in advance!

“Loop and merge” with questions on separate pages

(Follow-up on Make number of rows in a matrix equal to a previous answer .) I am looking for a SurveyJS code example, similar to the “Loop and Merge”, with one page of answers per entity (instead of a column in the matrix, as in the example).

In my use case, the user enters the number of classrooms they teach, then I ask for the classroom names in a matrix with a row for each of the classrooms.

I then want a separate page of answers for each classroom, such as number of pupils, number of children who get help from their parents, and a text summary of the learning environment. I would like the classroom name previously entered to appear at the top of the page.

Is this possible in SurveyJS?

Building a Project .Using React Js and Bootstrapped [closed]

  1. I am starting to build this project.. But I have Intermediate Skills.. Not yet mastered the React JS ..How Can I not pancic when handling or n]being called for projects.. Cause I wannna Learn on the go

I’m expecting the codes be on my fingertips but now I’m kinda using also AI tools to help me code and finish on time

How Can I Solve The Problem Of Aligning My Objects?

I`m making a web game with procedurally generated layers and dimensions within them and
I have a problem with aligning the layer objec.

I want the layers to be next to each other (with overflow set to scroll in their main container) so I tried using inline-block for them which didn’t work as expected

thats how it looks

The layers are for some reason placed at the bottom of one another and in case of overflow on x axis they start appearing on the next line beneath

just like that

function createLayer()
{
    document.getElementById("mainContainer").innerHTML += '<div class="dimContainers id="dimContainer1"><p>Layer</p></div>'
}

function createDim()
{
    document.getElementById("dimContainer1").innerHTML += '<div class="dims" id="dim1-1"><p>Dim</p></div>'
}
.headContainer
{

    width: 100%;
    height: 60px;

    background-color: antiquewhite;

    border-radius: 15px;

}

.headContainer p
{
    font-size: 35px;

    margin-top: 0px;

    padding-top: 10px;
    padding-bottom: 10px;
}

#mainContainer
{
    overflow-y: scroll;
    overflow-x: scroll;

    height: 850px;
    width: 100%;

}



.dimContainers
{

    margin-right: 15px;

    width: 250px; 
    height: auto; 

    background-color: rgb(49, 107, 107);

    display: inline-block;

}

.dims
{
    height: 50px;
    width:85%;

    margin-bottom: 5px;
    margin-left: 5px;
    margin-right: 5px;

    border-radius: 5px;

    background-color: brown; 

}
<center>
        <div class="headContainer"><p id="ilrTitle">Infinite Layers: Reworked</p></div>
        </center>

        <button onclick="createLayer()"></button>
        <button onclick="createDim()"></button>

        <div id="mainContainer">
            <div class="dimContainers" id="dimContainer1" style="width: 250px; height: auto; background-color: rgb(49, 107, 107);">
                <p>Layer</p>
            </div>
        </div>

I tried using all display methods that include inline- but they work even worse

How to get current local time from client side and send it to PHP to save in database? [closed]

I’m trying to get the current local time from the user’s browser using JavaScript, then send that time over to PHP so I can insert it into my database.

What I need:

I want the exact local time of the user (their timezone, not the server’s).

The time should be sent to PHP (preferably using POST).

Then I want to insert that into my database (e.g., MySQL).

I don’t need to display the time on the website, I just need to pass it in the background.

Ive tried the fetch method, but it seems to not work properly.

Open a modal above the other with a minimum of offset

The goal is to be able to open a modal above another, giving the latter a bit of an offset.

I wrote this:

openModal = function( ele ) {

    var dialogs = $(".modal.show"); //opened dialog
    var currentId = ele.attr("id");

    $(document).ready(function() {

        // var rect = document.getElementById( currentId ).getBoundingClientRect();
        // get 0 for all keys

        var currentTop = 0;
        var currentLeft = 0;

        var n=1;

        for ( var dialog of dialogs ) {
            
            var $dialog = $(dialog)

            if( currentId !=  $dialog.attr("id") ) {

                currentTop = 20*n;
                currentLeft = 20*n;

                n++;

            }

        }

        // show modal
        ele.modal("show");

        // set offset
        ele.offset({ left: currentLeft, top: currentTop });

    });

};

It works pretty well, but there is a problem when I close a modal.

It is possible to replicate it like this:

  • Open a modal
  • Open a (second) modal above the first
  • Close the second modal
  • Open the second modal again.

At this point, instead of having offset*1 I have offset*2

Error calculating offset

I can’t figure out why.
Some hint?

weird buggy growth for the javascript snake [closed]

I was watching a tutorial video for a javascript snake, however, for some reason, it wasn’t working how it was supposed to so i kept asking chatgpt (sadly) how to fix the horizontal growth bug, and after millions of fixes its just vertical now. any help with this? i cant figure out what I’m doing wrong either.

const CANVAS = document.getElementById("game-canvas");

const CONTEXT = CANVAS.getContext("2d");

const SEGMENT_WIDTH = 32.0;
const SEGMENT_HEIGHT = 32.0;

const COLUMNS = CANVAS.width / SEGMENT_WIDTH;
const ROWS = CANVAS.height / SEGMENT_HEIGHT;

class Segment {
    constructor(x, y, direction ) {

        this.x = x;
        this.y = y;

        this._direction = direction;
        this.OLD_direction = this.direction

        this.next = null;

    }
    
    get direction() {
        
        return this._direction;

    }

    set direction(direction) {

        this.OLD_direction = this._direction;

        this._direction = direction;
    }

    setDirection(direction) {
        this.direction = direction;
    }

    move() {
    
        this.OLD_direction = this.direction;

        if (this._direction === 0) this.y--;
        else if (this._direction === 1) this.y++;
        else if (this._direction === 2) this.x--;
        else if (this._direction === 3) this.x++;

        if (this.x < 0) this.x = COLUMNS - 1;
        else if (this.x >= COLUMNS) this.x = 0;
        if (this.y < 0) this.y = ROWS - 1;
        else if (this.y >= ROWS) this.y = 0;

        if (this.next !== null) {
            this.next.direction = this.OLD_direction;
            this.next.move();
        }
}

}

const ROOT = new Segment(COLUMNS / 2, ROWS / 2, 0);

window.addEventListener("keydown", event => {

    if (event.code === "KeyW") {

        if (ROOT.direction !== 1) ROOT.direction = 0;

    } else if (event.code === "KeyS") {

        if (ROOT.direction !== 0) ROOT.direction = 1;

    } else if (event.code === "KeyA") {

        if (ROOT.direction !== 3) ROOT.direction = 2;
        
    } else if (event.code === "KeyD") {

        if (ROOT.direction !== 2) ROOT.direction = 3;
        
    }

});

function addSegment() {
    let lastSegment = ROOT;
    while (lastSegment.next !== null) {
        lastSegment = lastSegment.next;
    }

    let dir = lastSegment.OLD_direction;

    let newX = lastSegment.x;
    let newY = lastSegment.y;

    if (dir === 0) newY += 1;       
    else if (dir === 1) newY -= 1;  
    else if (dir === 2) newX += 1;  
    else if (dir === 3) newX -= 1;  

    if (newX < 0) newX = COLUMNS - 1;
    else if (newX >= COLUMNS) newX = 0;
    if (newY < 0) newY = ROWS - 1;
    else if (newY >= ROWS) newY = 0;

    lastSegment.next = new Segment(newX, newY, dir);
}

let foodX = 0;
let foodY = 0;

function randFoodPosition() {

    foodX = Math.floor(Math.random() * COLUMNS);
    foodY = Math.floor(Math.random() * ROWS);

}

randFoodPosition();

let elapsedFrames = 0;

function update() {

    if (elapsedFrames > 10) {

        ROOT.move();

        if (ROOT.x === foodX && ROOT.y === foodY) {

            addSegment()

            randFoodPosition()
        }

        elapsedFrames = 0

    } else elapsedFrames++;
}

function render() {

    console.log("Rendering...?");
             
    CONTEXT.fillStyle = "#60c198";

    CONTEXT.fillRect(0.0, 0.0, CANVAS.width, CANVAS.height);

    let currentSegment = ROOT;

    while (currentSegment !== null) {

        CONTEXT.fillStyle = "black";

        CONTEXT.fillRect(currentSegment.x * SEGMENT_WIDTH, currentSegment.y * SEGMENT_HEIGHT, SEGMENT_WIDTH, SEGMENT_HEIGHT);

        currentSegment = currentSegment.next
    }

    CONTEXT.fillStyle = "#183026";

    CONTEXT.fillRect(foodX * SEGMENT_WIDTH, foodY * SEGMENT_HEIGHT, SEGMENT_WIDTH, SEGMENT_HEIGHT);
}

function tick() {
             
    update();

    render();

    window.requestAnimationFrame(tick);
            
}

tick();
#game-canvas {
    position: absolute;

    left: 50%;
    top: 50%;

    transform: translate(-50%, -50%);
}
<canvas id="game-canvas" width="512" height="512"></canvas>

How to move elements matching a condition to the end of an Immutable.js Map?

I have an Immutable.Map (plannedLoads) and I want to move all entries where val.get(‘loads_client_id’) === ClientId.CLIENT_SLOT to the end of the map, preserving the order of all other entries.

Currently, I try this approach:
` let plannedLoads = !unplannedMode
? rootLoads.get(PLANNED_LOADS) || defaultMap
: defaultMap;

let plannedLoadsSlot = plannedLoads.filter(
    val => val.get('loads_client_id') === ClientId.CLIENT_SLOT
);

plannedLoads = plannedLoads.filter(
    val => val.get('loads_client_id') !== ClientId.CLIENT_SLOT
);

plannedLoads = plannedLoads.concat(plannedLoadsSlot);`

But this does not work as expected. But this does not work as expected — instead of moving these entries to the end, the map returns them back to their original positions.. Also, I want to avoid converting the map to arrays or lists to save memory.

How can I reorder entries in an Immutable.js Map to move certain entries to the end without converting to other data structures?

adding labels on the links of sankey charts using plotly.js

I tried adding labels on the links of my sankey that would show the value of the link. I just tried adding “label” property to the link also in the trace of the sankey chart, but this did not work. Is this property for the links also possible like it exists for the nodes or is there any other way to add the values on the links and not just on the tooltips? Here is a code example fiddle

window.addEventListener('DOMContentLoaded', () => {
   const chartDiv = document.getElementById('chartDiv');

   const labels = ["Start", "Middle", "Begin", "End", "Final"];
   const labelIndex = new Map(labels.map((label, i) => [label, i]));
   const links = [
      { source: "Start", target: "Middle", value: 5, label: "Test" },
      { source: "Start", target: "Middle", value: 3, label: "Test2" },
      { source: "Middle", target: "Start", value: 1, label: "" },
      { source: "Start", target: "End", value: 2, label: "" },
      { source: "Begin", target: "Middle", value: 5, label: "Test" },
      { source: "Middle", target: "End", value: 3, label: "" },
      { source: "Final", target: "Final", value: 0.0001, label: "" }
   ];
   const sources = links.map(link => labelIndex.get(link.source));
   const targets = links.map(link => labelIndex.get(link.target));
   const values = links.map(link => link.value);

   const customData = links.map(link => [link.source, link.target, link.value]);

   const trace = {
      type: "sankey",
      orientation: "h",
      arrangement: "fixed",
      node: {
         label: labels,
         pad: 15,
         thickness: 20,
         line: { color: "black", width: 0.5 },
         hoverlabel: {
            bgcolor: "white",
            bordercolor: "darkgrey",
            font: {
               color: "black",
               family: "Open Sans, Arial",
               size: 14
            }
         },
         hovertemplate: '%{label}<extra></extra>',
         color: ["#a6cee3", "#1f78b4", "#b2df8a", "#a9b1b9", "#a9b1b9" ]
      },
      link: {
         source: sources,
         target: targets,
         value: values,
         label: values,
         arrowlen: 20,
         pad: 20,
         thickness: 20,
         line: { color: "black", width: 0.2 },
         color: sources.map(i => ["#a6cee3", "#1f78b4", "#b2df8a", "#a9b1b9", "#a9b1b9"][i]),
         customdata: customData,
         hoverlabel: {
            bgcolor: "white",
            bordercolor: "darkgrey",
            font: {
               color: "black",
               family: "Open Sans, Arial",
               size: 14
            }
         },
         hovertemplate:
            '<b>%{customdata[0]}</b> → <b>%{customdata[1]}</b><br>' +
            'Flow Value: <b>%{customdata[2]}</b><extra></extra>'
      }
   };

   const layout = {
      font: { size: 14 },
      //margin: { t: 20, l: 10, r: 10, b: 10 },
      //hovermode: 'closest'
   };

   Plotly.newPlot(chartDiv, [trace], layout, { responsive: true, displayModeBar: true })
      .then((plot) => {
         chartDiv.on('plotly_click', function(eventData) {
            console.log(eventData);
            if (!eventData || !eventData.points || !eventData.points.length) return;
            const point = eventData.points[0];
            if (typeof point.pointIndex === "number") {
               const nodeLabel = point.label;
               alert("Node clicked: " + nodeLabel + "nNode index: " + point.pointIndex);
               console.log("Node clicked:", point);
            } else if (typeof point.pointNumber === "number") {
               const linkIdx = point.pointNumber;
               const linkData = customData[linkIdx];
               alert(
                  "Link clicked: " +
                  linkData[0] + " → " + linkData[1] +
                  "nValue: " + linkData[2] +
                  "nLink index: " + linkIdx
               );
               console.log("Link clicked:", point);
            } else {
               console.log("Clicked background", point);
            }
         });
      });
});

Make number of rows in a matrix equal to a previous answer

I am writing a survey in SurveyJS and I would like the number of rows in a survey to equal a previous answer. It would be something like this, except that this fails:

const surveyJson = {
  "elements": [
    {
      "type": "text",
      "name": "num_classrooms",
      "inputType": "number",
      "min": 1,
      "max": 20,
      "title": "How many classrooms do you teach in this school?",
      "isRequired": true
    },
    {
  "type": "matrixdynamic",
  "name": "familyMatrix",
  "title": "Classroom Information",
  "columns": [
    {
      "name": "name",
      "title": "Name",
      "cellType": "text"
    },
    {
      "name": "age",
      "title": "Age",
      "cellType": "number"
    }
  ],
  "rowCount": "{num_classrooms}",
  "minRowCount": "{num_classrooms}",
  "maxRowCount": "{num_classrooms}"
    }
  ]
}

I know that I can let the user add or delete rows in a matrix, but for clarity I prefer that the user first give the number of classrooms and only after fill information.

I searched online for an answer and also tried AI, but couldn’t find a solution. The problem is similar to this question from Kobo Toolbox: asking for number of household members and adding a row for each member.

How can I do the same in SurveyJS?

rbv_api.setFieldValue, not updating text area field

I have been give an older project to work within Metacom Portals that I understood it was known as Rollbase (Event Bridge Infinite Blue). I have the issue of trying to change a text area field value via rbv_api.setFieldValue to my static value but it does not work. There is also a different solution with a different approach that seems to work but the difference is not huge since my solution is even simpler just putting the static value in the set field value (the other solution takes the response from a JSON request).

Check below my implementation and see why it would not work, permissions are all on yes and there is no default value overwriting it. When I print before and after setting the value it shows null for both. The value to be entered is static in the formula. No other errors.

Formula: rbv_api.setFieldValue("TEST_Operation", {!id}, "Text_Test", "TEST");