zoom/pan two deck.gl containers simultaneously?

I have two deck.gl containers that zoom/pan separately. I want to be able to zoom/pan both of them when I zoom/pan on either. Right now the containers are in two instantiations of deck.gl, but I’m not sure how I can create multiple containers in one new Deck.gl({})

Looking at the documentation, I see how this is possible with React, but I don’t want to use React.

Any thoughts?
Here is my code, and it’s also in a Plunkr– where you’ll find the geojson.

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            width: 100vw;
            height: 100vh;
            margin: 0;
            padding: 0;
            background: #dad6d0;
        }

        #ca1 {
            height: 100vh;
            width: 50vw;
            position: absolute;
            left: 0;
        }

        #ca2 {
            height: 100vh;
            width: 50vw;
            position: absolute;
            left: 50vw;
        }
    </style>
</head>

<body>
    <div id='ca1'></div>
    <div id='ca2'></div>
    <script src='https://unpkg.com/deck.gl@latest/dist.min.js'></script>
    <script>
        const { DeckGL, GeoJsonLayer, MapController } = deck;

        const ca_state = new GeoJsonLayer({
            data: 'california.json',
            id: 'castate',
            opacity: 1,
            getLineWidth: 23,
            stroked: true,
            filled: true,
            getFillColor: f => [10, 67, 216],
            getLineColor: f => [25, 95, 190],
            pickable: false
        });

        const ca_state2 = new GeoJsonLayer({
            data: 'california.json',
            id: 'castate',
            opacity: 1,
            getLineWidth: 23,
            stroked: true,
            filled: true,
            getFillColor: f => [218, 207, 82],
            getLineColor: f => [25, 95, 190],
            pickable: false
        });

        class MyMapController extends MapController {
            handleEvent(event) {
                if (event.type === 'pan') {
                    // do something
                } else {
                    console.log('custom map controller')

                    super.handleEvent(event);
                }
            }
        }

        new DeckGL({
            mapStyle: '',
            initialViewState: {
                latitude: 37.337840681197655,
                longitude: -120.19909774948918,
                zoom: 5.5,
                maxZoom: 16,
                minZoom: 0,
                pitch: 0
            },
            controller: MyMapController,
            container: 'ca1',
            layers: [ca_state],
        });

        new DeckGL({
            mapStyle: '',
            initialViewState: {
                latitude: 37.337840681197655,
                longitude: -120.19909774948918,
                zoom: 5.5,
                maxZoom: 16,
                minZoom: 3,
                pitch: 0
            },
            controller: MyMapController,
            container: 'ca2',
            layers: [ca_state2],
        });
    </script>
</body>

</html>

How to open accordion open on hover

How to make accordin to open on hover?
I want the accordin open on hover and close when I move the cursor to another direction.
I want this because it has an arrow function that mean the arrow move up when open and down when it gets close.

<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">

    <title>Hello, world!</title>
  </head>
  <body>
    <div class="accordion" id="accordionExample">
  <div class="accordion-item">
    <h2 class="accordion-header" id="headingOne">
      <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
        Accordion Item #1
      </button>
    </h2>
    <div id="collapseOne" class="accordion-collapse collapse show" aria-labelledby="headingOne" data-bs-parent="#accordionExample">
      <div class="accordion-body">
        <strong>This is the first item's accordion body.</strong> It is shown by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
      </div>
    </div>
  </div>
  <div class="accordion-item">
    <h2 class="accordion-header" id="headingTwo">
      <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
        Accordion Item #2
      </button>
    </h2>
    <div id="collapseTwo" class="accordion-collapse collapse" aria-labelledby="headingTwo" data-bs-parent="#accordionExample">
      <div class="accordion-body">
        <strong>This is the second item's accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
      </div>
    </div>
  </div>
  <div class="accordion-item">
    <h2 class="accordion-header" id="headingThree">
      <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
        Accordion Item #3
      </button>
    </h2>
    <div id="collapseThree" class="accordion-collapse collapse" aria-labelledby="headingThree" data-bs-parent="#accordionExample">
      <div class="accordion-body">
        <strong>This is the third item's accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
      </div>
    </div>
  </div>
</div>

    <!-- Optional JavaScript; choose one of the two! -->

    <!-- Option 1: Bootstrap Bundle with Popper -->
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>

    <!-- Option 2: Separate Popper and Bootstrap JS -->
    <!--
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
    -->
  </body>
</html>

How to make accordin to open on hover?
I want the accordin open on hover and close when I move the cursor to another direction.
I want this because it has an arrow function that mean the arrow move up when open and down when it gets close.

SWC with JavaScript: How to handle CSS imports and how to absolute imports?

TL;DR

  • How can you tell SWC to compile CSS files imported in React components?
  • How can you tell SWC to compile absolute imports in tests and in React components?

Context

We’re migrating from Babel to SWC. (I asked a question a little while ago. I’m improving on that question’s answer.)

We’re migrated the command from:

"test": "NODE_ENV=test riteway -r @babel/register 'src/**/*.test.js' | tap-nirvana",

to

"test": "SWC_NODE_PROJECT=./jsconfig.json riteway -r @swc-node/register src/**/*.test.js | tap-nirvana",

where the jsconfig.json looks like this:

{
  "compilerOptions": {
    "allowJs": true,
    "baseUrl": "./src",
    "jsx": "react-jsx"
  }
}

If we write try to compile a test for a self-contained component (no absolute imports, no CSS) it works:

import { describe } from 'riteway';
import render from 'riteway/render-component';

function HomePageComponent({ user: { email } }) {
  return <p>{email}</p>;
}

describe('home page component', async assert => {
  const user = { email: 'foo' };
  const $ = render(<HomePageComponent user={user} />);

  assert({
    given: 'a user',
    should: 'render its email',
    actual: $('p').text(),
    expected: user.email,
  });
});

The test compiles fine.

With Babel we had a .babelrc like this:

{
  "env": {
    "test": {
      "plugins": [
        [
          "module-resolver",
          {
            "root": [
              "."
            ],
            "alias": {
              "components": "./src/components",
              "config": "./src/config",
              "features": "./src/features",
              "hocs": "./src/hocs",
              "hooks": "./src/hooks",
              "pages": "./src/pages",
              "redux": "./src/redux",
              "styles": "./src/styles",
              "tests": "./src/tests",
              "utils": "./src/utils"
            }
          }
        ]
      ]
    }
  },
  "presets": [
    [
      "next/babel",
      {
        "ramda": {}
      }
    ]
  ],
  "plugins": [
    ["styled-components", { "ssr": true }]
  ]
}

Where the styles where taken care of by styled-components and the absolute imports where defined via the module-resolver plugin. (We switched away from styled-components to CSS modules, which is why we import from .module.css CSS files. Anyways …)

If we write the test how we wanted to write it with their actual imports like this:

import { describe } from 'riteway';
import render from 'riteway/render-component';
import { createPopulatedUserProfile } from 'user-profile/user-profile-factories';

import HomePageComponent from './home-page-component';

describe('home page component', async assert => {
  const user = createPopulatedUserProfile();
  const $ = render(<HomePageComponent user={user} />);

  assert({
    given: 'a user',
    should: 'render its email',
    actual: $('p').text(),
    expected: user.email,
  });
});

It fails with:

$ SWC_NODE_PROJECT=./jsconfig.json riteway -r @swc-node/register src/features/home/home-page-component.test.js | tap-nirvana
/Users/janhesters/dev/my-project/src/features/home/home.module.css:1
(function (exports, require, module, __filename, __dirname) { .container {
                                                              ^

SyntaxError: Unexpected token '.'

when we leave in the CSS import in home-page-component.js, or with:

$ SWC_NODE_PROJECT=./jsconfig.json riteway -r @swc-node/register src/features/home/home-page-component.test.js | tap-nirvana
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'user-profile/user-profile-factories'
Require stack:
- /Users/janhesters/dev/my-project/src/features/home/home-page-component.test.js
- /Users/janhesters/dev/my-project/node_modules/riteway/bin/riteway

respectively, when we get rid of the CSS import.

How can we help SWC understand CSS (or mock CSS modules) and how can we help it understand absolute imports?

We already set the baseUrl in jsconfig.json

Polymorphic callback function not recognized

I am getting the error Uncaught (in promise) TypeError: modNums is not a function. I am following a guide and what I have below is roughly similar to what they did.

Is the issue coming from the fact that I am trying to call the callback inside of a fetch callback? How can I make the modNums function get called? Mind you modNums is just the name of the parameter and there are multiple function that are meant to be accepted for that function value (hence polymorphism).

function updatePageText (chapter, page, modNums) {
  fetch("../../assets/json_files/parsedPages.json")
    .then((Response) => Response.json())
    .then((data) => {
      modNums(chapter, page, data); 

_

updatePageText(chapterNum, pageNum, increasePage);

Leave server command? [closed]

I am Owner of a Discord Bot. I want to have like a leave server command, where I can put the ID and then the bot leaves the server. For example ,leaveserver 1234567 and then the bot leaves the server. How can I do that?

trying to grab a value from an array in javascript

im trying to make it so it only shows specific sizes for the array i have, this is the array

const products = [{
    name: "14K bracelet",
    id: "1",
    description: "Beautfull 14K gold Bracelet",
    price: 100,
    size: [1, 2, 3, 4]
    
}

and this is how im trying to grab the values from it

                    <Dropdown.Item className="dropdown-item" href="#/action-1">{products.size[0]}</Dropdown.Item>

but im getting this error

TypeError: Cannot read properties of undefined (reading '0')

Can’t access redux actions from props when working with react router

I’m pretty new to react and redux and I have been having a problem accessing my redux actions from the props when used in conjunction with react router. I have tried lots of configurations for formatting but no matter what I try the props only have the react router functions i.e. history, match and location. I am using connected-react-router but it does not seems to be doing anything. I have been able to access the redux actions from my nav menu components so I don’t think anything is wrong there.

Here is a sample of the latest configuration I tried:

const mapStateToProps = (state) => {
    return { isSignedIn: state.auth.isSignedIn }
}

const ConnectedApp = connect(
    mapStateToProps,
    { signOut, signIn }
)(App);

ReactDOM.render(
    <Provider store={store}>
        <ConnectedRouter basename={baseUrl} history={history}>
            <ConnectedApp />
        </ConnectedRouter>
    </Provider>,
  rootElement);

and here is inside App:

class App extends Component {
    static displayName = App.name;


  render () {
    return (
        <Layout>
            <Route exact path='/' component={(props) =><Home {...props}/>} />
            <Route exact path='/LogInExisting' component={(props) => <LogInExisting {...props} />} />
            <Route exact path='/LogInCreate' component={(props) => <LogInCreate {...props} />} />
      </Layout>
    );
  }
}

I feel like I am missing something obvious but I really could use some help.

🍎”help.microsoft.com 🍎*877[947]7788*🍎

Microsoft is a major technology company that sells software, electronics and computers around the world. As one of the largest companies in the world, it isn’t surprising that its tech support department gets a lot of calls every day.
Microsoft prefers it when customers begin their support requests through the Microsoft website. Once on the “Contact Us” page, you will be presented with a menu of products and services
Microsoft Support Number help.microsoft.com talk to a person toll–free number The certified experts directly get in touch with you over the call, understand the issue and provide the best solution accordingly. They might narrate the steps to resolve the errors over the call or seek remote access to your system to perform the solution steps to get rid of the errors. Seeking Microsoft Helpline Number Support is the best way to fix Microsoft errors.
Please note, every software is prone to errors and glitches. Despite being a robust and advanced application, Microsoft may show errors. But this does not put a question mark to its proficiency and capabilities. Here are some of the most impeccable features of Microsoft.
https://stackoverflow.com/questions/70898043/help...

Not allowed to load local resource: blob: “blob:https://

I’m trying to download files from the Network tab, I get a link like this “blob:https://aaaaaaaaaaa.org/c8788081-fc3c-4779-b576-0a184c698c35″, but when I try to download, I get “Not allowed to load local resource: blob:<URL>”. What am I doing wrong?

I added the launch key to chrome browser (–disable-web-security –allow-file-access-from-files –allow-file-access), didn’t help.

async function sleep(millis) {
    return new Promise(resolve => setTimeout(resolve, millis));
}
(async () => {
                    
    var nodes = UI.panels.network.networkLogView.dataGrid.rootNode().flatNodes,
    arrUrls = [];               
    nodes.forEach(function() {
        
        var req = arguments[0].request();       
        if (req !== undefined) {
            const substring = "blob:https";
            if (req.url().includes(substring)) {
                arrUrls.push(req.url());
            }
        }
    });
    
    i = 0;
    for (const sUrl of arrUrls) {
        await sleep(1000);        
        i++;
        
        var link = document.createElement('a');     
        link.href = sUrl;
        link.download = i + '_download.jpg';
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link);
        delete link;
    }
})();

enter image description here
enter image description here

Unable to inject CSS style from service_worker in tab after chrome.alarms has elapsed in Manifest v3

when i tried injection of CSS file using Chrome.scripting API inside chrome.alarms.onAlarm on callback from service_worker js file inside a tab

chrome.alarms.onAlarm.addListener(function() {
    chrome.scripting.insertCSS({
        target: { tabId: tabs.id },
        files: ["inject.css"]
    });
});

but it doesn’t work but when i tried chrome.action.setBadgeText it work fine similarly chrome.notifications API doen’t seems to be working inside this block

chrome.alarms.onAlarm.addListener(function() {
    chrome.action.setBadgeText({text: 'yes'});
    
});

my manifest.json file

{
    "name": "TimeCode",
    "description": "A extension to inject some specific functionallity in leetcode",
    "version": "1.0",
    "manifest_version": 3,
    "icons": {
    
        "32": "./images/output-onlinepngtools1.png",
        "48": "./images/output-onlinepngtools2.png",
        "128": "./images/output-onlinepngtools3.png"
    },
    "background": {
        "service_worker": "./background.js"
    },
    "action": {
        "default_title": "Set timer to your leetcode problem",
        "default_popup": "popup.html",
        "default_icons": {
            "32": "./images/output-onlinepngtools1.png",
            "48": "./images/output-onlinepngtools2.png",
            "128": "./images/output-onlinepngtools3.png"
        }
    },
    "permissions": [
        "activeTab",
        "tabs",
        "storage",
        "scripting",
        "alarms",
        "notifications",
        "storage"
    ],
    "host_permissions": [
        "https://leetcode.com/problems/*"
    ]
}

my background file

const tabId = async function getCurrentTab() {
    let queryOptions = { active: true, currentWindow: true };
    let [tab] = await chrome.tabs.query(queryOptions);
    return tab;
}
  
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
    if (changeInfo.status === 'complete' && /^http/.test(tab.url)) {
        chrome.scripting.executeScript({
            target: { tabId: tabId },
            files: ["./foreground.js"]})
        .then(() => {console.log("INJECTED THE FOREGROUND SCRIPT.");})
        .catch(err => console.log(err));}
});

chrome.alarms.onAlarm.addListener(function() {
    chrome.action.setBadgeText({text: 'yes'}),
    chrome.scripting.insertCSS({
        target: { tabId: tabId },
        files: ["inject.css"]
    }),
    chrome.notifications.create({
        type:     'basic',
        iconUrl:  'timeout.png',
        title:    'Time out',
        message:  'Set Time limit has passed',
        buttons: [{title: 'Continue.'}],
        priority: 2});
    
});
  
chrome.notifications.onButtonClicked.addListener(function() {
    chrome.storage.sync.get(['minutes'], function(item) {
         chrome.action.setBadgeText({text: 'ON'});
    chrome.alarms.create({delayInMinutes: item.minutes});
    });
});

popup.js file

'use strict';

function setAlarm(event) {
  let minutes = parseFloat(event.target.value);
  chrome.action.setBadgeText({text: 'ON'});
  chrome.alarms.create({delayInMinutes: minutes});
  chrome.storage.sync.set({minutes: minutes});
  window.close();
}

function clearAlarm() {
  chrome.action.setBadgeText({text: 'OFF'});
  chrome.alarms.clearAll();
  window.close();
}

//An Alarm delay of less than the minimum 1 minute will fire
// in approximately 1 minute increments if released
document.getElementById('Easy').addEventListener('click', setAlarm);
document.getElementById('Medium').addEventListener('click', setAlarm);
document.getElementById('Hard').addEventListener('click', setAlarm);
document.getElementById('cancelAlarm').addEventListener('click', clearAlarm);

Solve Nim Game Leetcode with Recusion(DP)

I am trying to solve the following leetcode problem of Nim Game.
https://leetcode.com/problems/nim-game/

One simple solution in O(1) is:

var canWinNim = function(n) {    
   return n%4 !== 0;
};

But I am also trying to solve it using DP. Below is my code which is incorrect. I believe there is some issue in the else block at the end. Please help.

var canWinNim = function(n, myChance=true, memo={}) {    
  if(n in memo) return memo[n];
  if(myChance){
    if(n<=3) return true;
    if(n===4) return false;
  } else {
    if(n<=3) return false;
    if(n===4) return true;
  }

  let a = canWinNim(n-1, !myChance, memo);
  let b = canWinNim(n-2, !myChance, memo); 
  let c = canWinNim(n-3, !myChance, memo);
  if(myChance){
    memo[n] = a||b||c;
    return memo[n];
  }
  memo[n] = !(a||b||c);
  return memo[n];
};