Why does console.log(65 == ‘A’) output false in JavaScript?

console.log(65 == ‘A’) // => false: why the output is false in JavaScript.

In the ASCII character set, the value of ‘A’ is 65. When I try to compare 65 and ‘A’ in C, the expression will evaluate to 1, meaning “true.” But in JavaScript, the case is different because I think JavaScript uses the Unicode character set, and every character in Unicode represents itself as a hexadecimal code. Please guide me.

Cannot use Vue DevTool despite multiple configuring attempts

I’m developing a mini board game with Vue.js frontend and Django backend. Currently, I use Django to serve the static files under a /static directory, and I configured vite.config.js to output the build result to that directory under Django’s base directory.

Now I want to use DevTools to debug the frontend. I’ve got the frontend to run successfully with npm run dev. However, now I want to test the interoperability with backend, and due to the Same-Origin Policy, it needs to be served by the source as the api endpoints. So I made the following configurations:

import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueDevTools(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
  build: {
    define: {
      '__VUE_PROD_DEVTOOLS__': true, // Force Vue DevTools to be available
    },
    sourcemap: true,
    watch: true,
    minify: false,
    rollupOptions: {
      output: {
        entryFileNames: 'src/[name].js',
        chunkFileNames: 'chunks/[name].js',
        assetFileNames: 'assets/[name].[ext]'
      }
    },
    outDir: '../backend/static'
  }
})
import './assets/main.css'

import { createApp } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import App from './App.vue'
import Game from './Game.vue'
import Login from './Login.vue'
import Register from './Register.vue'

const routes = [
    { path: '/', component: Game },
    { path: '/loginpage', component: Login },
    { path: '/registerpage', component: Register },
];

const router = createRouter({
    history: createWebHistory(),
    routes: routes
});


const app = createApp(App);

app.config.devtools = true;

app.use(router);
app.mount('#app');

But the devtools extension for firefox complains about Vue.js is detected on this page. Devtools inspection is not available because it's in production mode or explicitly disabled by the author.

How can I fix it? Thanks!

How to start animation and show cursor from editor?

how to add the animate=”true” and the showCursor:true during the abcjs.editor creation:

    function initEditor() {
        new ABCJS.Editor("abc", { paper_id: "paper0",
            synth: {
                el: "#audio",
                options: { displayLoop: true, displayRestart: true, displayPlay: true, displayProgress: true, displayWarp: true }
            },
            generate_warnings: true,
            warnings_id:"warnings",
            abcjsParams: {
                generateDownload: true,
                clickListener: selectionCallback
            }
        });
    }

The animation docs https://configurator.abcjs.net/animation includes the showCursor:true, but it is not included in the editor demo: https://www.abcjs.net/abcjs-editor.html Although it works in https://editor.drawthedots.com/ and in the wordpress plugin.

Text and images not posting correctly, misalignment in my PHP blog site

I’m building a simple blog site using PHP, and I am new to PHP. I’m stuck with solving the issue of the arrangement of both text and images when users post content.

Issue Details

Text Issue: The text displayed is not the same as what the user posted; it’s showing different text.

Image Misalignment and Duplication: Images sometimes don’t appear in the correct order, or they duplicate.

Multiple Image Uploads: When users try to upload multiple images, only one or two images get posted.

Here’s the code I’m using for handling the content (text and images):

PHP Code for Handling Post Request

<?php
include 'connect.php';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $content = trim($_POST['content']);
    $imagePaths = []; // Array to store valid image paths
    $uploadOk = true;

    // Validate content
    if (empty($content)) {
        die("Post content cannot be empty!");
    }

    // Handle file uploads
    if (isset($_FILES['profilePictures'])) {
        $targetDir = "uploads/";
        foreach ($_FILES['profilePictures']['tmp_name'] as $key => $tmpName) {
            $fileName = basename($_FILES['profilePictures']['name'][$key]);
            $fileTmp = $tmpName;
            $fileSize = $_FILES['profilePictures']['size'][$key];
            $imageFileType = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
            $allowedTypes = ["jpg", "jpeg", "png"];

            // Validate file type and size
            if (in_array($imageFileType, $allowedTypes) && $fileSize <= 5000000) {
                if (!is_dir($targetDir)) {
                    mkdir($targetDir, 0777, true);
                }

                $uniqueFileName = uniqid() . "_" . $fileName;
                $targetFile = $targetDir . $uniqueFileName;

                if (move_uploaded_file($fileTmp, $targetFile)) {
                    $imagePaths[] = $targetFile;
                }
            }
        }
    }

    // Save post to the database
    $imagesSerialized = serialize($imagePaths);
    $sql = "INSERT INTO posts (content, image_path) VALUES (?, ?)";
    $stmt = $conn->prepare($sql);
    $stmt->bind_param("ss", $content, $imagesSerialized);

    if ($stmt->execute()) {
        echo "Post submitted successfully!";
    } else {
        echo "Error: " . $stmt->error;
    }

    $stmt->close();
    $conn->close();
}
?>

HTML Form for Image and Text Input

<form action="publish.php" method="POST" enctype="multipart/form-data">
            <div id="editableDiv" contenteditable="true" placeholder="Write your story here..."></div>
            <input type="hidden" name="content" id="hiddenContent">
            <label for="profilePicture" class="camera-icon">&#128247;</label>
            <input type="file" name="profilePictures[]" id="profilePicture" multiple accept=".jpg, .jpeg, .png" style="display: none;" onchange="insertImageIntoDiv(event)">
            <button type="submit" onclick="submitContent()">Publish</button>
</form>

JavaScript for Inserting Images and Saving Content

function insertImageIntoDiv(event) {
    const fileInput = event.target;
    const editableDiv = document.getElementById('editableDiv');

    if (fileInput.files) {
        Array.from(fileInput.files).forEach((file) => {
            const reader = new FileReader();

            reader.onload = function (e) {
                const imgElement = `<img src="${e.target.result}" alt="Uploaded Image" style="max-width: 100%; height: auto; margin: 5px 0;">`;
                editableDiv.innerHTML += imgElement;
            };

            reader.readAsDataURL(file);
        });
    }
}

function submitContent() {
    const editableDiv = document.getElementById('editableDiv');
    const hiddenContent = document.getElementById('hiddenContent');
    hiddenContent.value = editableDiv.innerHTML;
}

Any help would be greatly appreciated! Thank you

NodeJS promise recursive function meets condition and stops executing but does not return

I have made a recursive function in NodeJS which is in a promise. It is supposed to recursively query a server, and it has two conditions. If it runs out of the max amount of servers, it will return an error and quit. This part works fine. The second part is if it gets a response which contains “true” then it will have succeeded and should exit and return the response. The exting part works fine and it stops as soon as it gets a response with “true” but it does not return it.

Here is my code, I have removed the parts where I set the tensordock variables to save space.

function getPorts(getPortsInputTensordockServer) {
  return new Promise((resolve, reject) => {
    try {
      request(getPortsInputTensordockServer, (error, response, getPortsResponseBody) => {
        getPortsResponseBody = JSON.stringify(getPortsResponseBody)
        getPortsResponseBody = getPortsResponseBody.split("[")
        getPortsResponseBody = getPortsResponseBody[1]
        getPortsResponseBody = getPortsResponseBody.split("]")
        getPortsResponseBody = getPortsResponseBody[0]
        getPortsResponseBody = getPortsResponseBody.split(",")
        return resolve(getPortsResponseBody)
      })
    } catch (err) {
      reject(err)
    }
  })
}

function createVM(n, createVMResponseBody) {
  return new Promise((resolve, reject) => {
    (async () => {
        try {
            if (createVMResponseBody.includes("true") === true) {
                return resolve(createVMResponseBody)
              }
              if (n === 21) {
                return resolve("oh no! no more servers")
              }
              var tensordockServer = eval("tensordockServer" + n)
              var tensordockServerName = tensordockServerMap.get("tensordockServerName" + n)
              var getPortsResult = await getPorts(tensordockServer)
              
              var createVMOptions = {
                'method': 'POST',
                'url': 'https://marketplace.tensordock.com/api/v0/client/deploy/single',
                'headers': {
                  'Content-Type': 'application/x-www-form-urlencoded'
                },
                form: {
                  'api_key': 'xxxx',
                  'api_token': 'xxxx',
                  'password': 'superC0mplexPassword',
                  'name': 'My NVIDIA RTX A4000 Server',
                  'gpu_count': '1',
                  'gpu_model': 'rtxa4000-pcie-16gb',
                  'vcpus': '4',
                  'ram': '8',
                  'external_ports': `{${getPortsResult[0]}, ${getPortsResult[1]}}`,
                  'internal_ports': '{22, 8888}',
                  'hostnode': tensordockServerName,
                  'storage': '150',
                  'operating_system': 'Windows 10'
                }
              };
              createVMResponseBody = await createVMRequest(createVMOptions)
              createVM(n + 1, createVMResponseBody)
        } catch (err) {
            return reject(err)
        }
    })()
  })
}

function createVMRequest(createVMRequestInput) {
  return new Promise((resolve, reject) => {
    try {
      request(createVMRequestInput, (error, response, createVMRequestBody) => {
        createVMRequestBody = JSON.stringify(createVMRequestBody)
        resolve(createVMRequestBody)
      })
    } catch (err) {
      reject(err)
    }
  })
}

async function testCall() {
    const result = await createVM(1, "test")
    console.log(`The result is ${result}`)
}

testCall()

I also tried changing the condition to if it includes “test” and that works fine.

By using of dispatch data are not storing in the redux slice , after that getting the data showing undefine vidoeList and filtervideo

code ->response by Api
Error

why this happen, even i check my times my code and in every step I am debugged

homepage are stored the data in the reduce by dispatch , and based on the videolist and filtervideo are show in the page , but i when i try the last time also facing this problem , show i solve by storing token in the locale storage

React Test Error: Test suite failed to run, ReferenceError: global is not defined

I’m trying to push my brach-code for merging, but I’m stuck on this error after I tried running the command: npm test

Error: Test suite failed to run

    ReferenceError: global is not defined

      at Object.<anonymous> (node_modules/graceful-fs/graceful-fs.js:92:1)

I saw a solution regaring it in on the platform and tried adding
`”jest-environment-jsdom”: “^27.0.6” as a dev dependency, but that didn’t resolve my error.

Here’s a copy to my package.json file:

{
  "name": "reactapp",
  "version": "0.1.0",
  "license": "GPL-2.0",
  "engines": {
    "node": ">=14.0.0 <15"
  },
  "private": true,
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^1.2.36",
    "@fortawesome/free-regular-svg-icons": "^5.12.1",
    "@fortawesome/free-solid-svg-icons": "^5.15.4",
    "@fortawesome/react-fontawesome": "^0.1.19",
    "@sentry/browser": "^4.6.6",
    "@tinymce/tinymce-react": "^3.14.0",
    "ajv": "^6.12.6",
    "ajv-keywords": "^3.5.2",
    "axios": "^0.21.2",
    "axios-mock-adapter": "^1.22.0",
    "bootstrap": "^4.5.3",
    "cheerio": "^1.0.0-rc.12",
    "classnames": "^2.2.6",
    "d3": "^7.8.5",
    "date-fns": "^2.14.0",
    "diff": "^5.0.0",
    "dompurify": "^3.1.3",
    "font-awesome": "^4.7.0",
    "fs-extra": "^11.2.0",
    "global": "^4.4.0",
    "history": "^4.10.1",
    "html-react-parser": "^1.4.14",
    "html-to-pdfmake": "^2.0.6",
    "joi": "^14.0.6",
    "jquery": "^3.7.1",
    "jwt-decode": "^2.2.0",
    "leaflet": "^1.9.4",
    "lodash": "^4.17.21",
    "lz-string": "^1.5.0",
    "moment": "^2.29.2",
    "moment-timezone": "^0.5.33",
    "pdfmake": "^0.1.65",
    "prop-types": "^15.7.2",
    "react": "^17.0.2",
    "react-autosuggest": "^10.1.0",
    "react-bootstrap": "^1.0.1",
    "react-circular-progressbar": "^2.1.0",
    "react-collapsible": "^2.10.0",
    "react-datepicker": "^7.6.0",
    "react-day-picker": "^7.4.10",
    "react-dom": "^17.0.2",
    "react-html-parser": "^2.0.2",
    "react-icons": "^4.3.1",
    "react-input-range": "^1.3.0",
    "react-leaflet": "^4.2.1",
    "react-leaflet-cluster": "^2.1.0",
    "react-modal": "^3.16.3",
    "react-multi-select-component": "^4.0.2",
    "react-phone-input-2": "^2.14.0",
    "react-redux": "^7.2.0",
    "react-router-dom": "^5.2.0",
    "react-router-hash-link": "^2.3.1",
    "react-scripts": "^5.0.1",
    "react-select": "^5.7.2",
    "react-sticky": "^6.0.3",
    "react-table": "^6.10.0",
    "react-toastify": "^5.3.1",
    "react-tooltip": "^4.2.10",
    "react-use-websocket": "^3.0.0",
    "reactjs-popup": "^2.0.5",
    "reactstrap": "^8.4.1",
    "read-excel-file": "^5.5.3",
    "recharts": "^2.12.7",
    "redux": "^4.0.5",
    "redux-actions": "^2.6.5",
    "redux-concatenate-reducers": "^1.0.0",
    "redux-persist": "^5.10.0",
    "redux-thunk": "^2.3.0",
    "sass": "^1.83.4",
    "tinymce": "^7.2.0",
    "typescript": "^4.9.5",
    "uuid": "^9.0.1",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "prestart": "npm run test",
    "postinstall": "node ./postinstall.js",
    "start": "react-scripts start",
    "build": "npm run postinstall && react-scripts build",
    "test": "cross-env CI=true react-scripts test --env=jest-environment-jsdom-sixteen",
    "test:watch": "react-scripts test --env=jest-environment-jsdom-sixteen",
    "test:coverage": "cross-env CI=true react-scripts test --env=jest-environment-jsdom-sixteen --coverage",
    "eject": "react-scripts eject",
    "start:local": "react-scripts start",
    "lint": "eslint . --ext .jsx,.js",
    "lint:fix": "eslint --fix . --ext .jsx,.js",
    "prepare": "husky install"
  },
  "resolutions": {
    "wrap-ansi-cjs": "^6.0.0",
    "jest-environment-jsdom": "^27.0.6"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "devDependencies": {
    "@babel/helper-validator-identifier": "^7.12.11",
    "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
    "@jest/globals": "^27.0.6",
    "@testing-library/jest-dom": "^4.0.0",
    "@testing-library/react": "^12.0.0",
    "@testing-library/user-event": "^13.5.0",
    "@types/react-router-dom": "^5.3.3",
    "babel-eslint": "^10.1.0",
    "cross-env": "^5.2.1",
    "enzyme": "^3.11.0",
    "enzyme-adapter-react-16": "^1.15.8",
    "enzyme-to-json": "^3.6.2",
    "eslint": "^7.32.0",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-config-prettier": "^5.1.0",
    "eslint-plugin-import": "^2.29.1",
    "eslint-plugin-jsx-a11y": "^6.9.0",
    "eslint-plugin-prettier": "^3.4.1",
    "eslint-plugin-react": "^7.35.0",
    "eslint-plugin-react-hooks": "^4.6.2",
    "eslint-plugin-testing-library": "^3.6.0",
    "husky": "^7.0.4",
    "jest": "^27.0.6",
    "jest-environment-jsdom": "^27.0.6",
    "jest-environment-jsdom-sixteen": "^2.0.0",
    "msw": "^0.19.5",
    "node-fetch": "^3.1.1",
    "prettier": "^1.19.1",
    "redux-mock-store": "^1.5.4",
    "sinon": "^7.3.2",
    "surge": "^0.21.6"
  }
}

Any clues on how to resolve this issue?

How can I optimize my website’s loading speed without compromising design quality?

The problem is how to improve a website‘s loading speed without compromising its design quality. This involves optimizing images, reducing file sizes, minimizing code, leveraging caching, using a CDN, and employing lazy loading while maintaining the visual appeal and functionality of the site.

I tried optimizing images and minifying CSS/JavaScript to improve my website’s loading speed. I expected the site to load faster without losing any visual quality or design features. However, while the site became faster, some design elements slightly degraded in quality, especially images, indicating further adjustments are needed in compression techniques.

Restructuring a super call in a constructor to use the ‘this’

I have the following service:

import {
  ENVIRONMENT_TOKEN
} from '@reg/environment/domain'

@Injectable({ providedIn: 'root' })
export class RegStore extends ImmutableStore<TRegState> {
  #env = inject(ENVIRONMENT_TOKEN)
  constructor() {
    super({
      name: 'RegistrationStore',
      mutationProducerFn: produce as unknown as MutationFn<TRegistrationState>,
      initialState: new RegState(),
      plugins: [
       // this.#env.signalStoryStorePlugins ERROR 'this' call cannot be used before 'super'
        useStorePersistence({
          persistenceKey: 'RegStore',
          persistenceStorage: localStorage,
          
        }),          
      ]
    })
  }

  store: Immutable<TRegState> = this.state()

}

How could the call – this.#env be restructured to remove the error?

Linkedin Console Automation Script

https://github.com/Gurukishore-G/Linkedin-Automation

Here is the url to the automation script that I use in browser console to automate the sending of connection requests in Linkedin. The script sends adds a note to each connection request. But the notes are very generic, and I want to personalize them by making sure, the script extracts the name of the person and adds it to the note.

Now:

Hi, there. I’m actively looking for potential career opportunities and would like to connect!”

What I want to achieve:

Hi {their name}, this is Gurukishore. I’d like to connect with you to explore career opportunities. Some briefing about my profile… Looking forward to getting in touch!

What modifications does the script need to make this possible, reading and extracting essential data.

Trying to use get images to be loaded by CSS url in Electron

I am having trouble implementing any information I can find about how to get my CSS to work under Electron where it has background-image w/ url classes.

At this point, I have an import statement in my renderer that imports the desired png, but it ends up just being the string of the renamed file deployed i.e. a47d7c47249596e68144.png

Now getting that to be loaded by the CSS is unknown. I saw some articles talk about creating a custom handler on the protocol class, but I can’t figure out how to use it. I did this:

protocol.handle('image', (request) => {
      console.log("!!!!!! request for image "+request.url);
    });

just to test if it ever gets called by the css when I do this:

background-image: url("image://logos/logo.png");

but while no errors occur, I never see my console log so it is never getting called.

What am I missing in this process or what should I do differently?

I just want it working the simplest way possible.

In my webpack config it loads images as so:

module: {
    rules: [
      {
        test: /.css$/,
        use: [
          'style-loader',
          'css-loader'
        ]
      },
      {
        test: /.(jpe?g|svg|png|gif|ico|eot|ttf|woff2?|aac|flac|mp3|ogg|wav)(?v=d+.d+.d+)?$/i,
        type: 'asset/resource',
      },
    ],
  }

OpenLayers: GeoTIFF on top of OSM layer shows large border

I am trying to load a GeoTIFF on top of an OSM layer with the openlayers library (v10.2.1).

The code to load the GeoTIFF roughly looks like this:

      this.modelLayerSource = new GeoTIFF({
        projection: 'EPSG:4326',
        interpolate: true,
        normalize: false,
        sources: [
          {
            url: this.modelService.getModelFileUrl(c),
            bands: [1]
          },
        ],
      });

      if (!this.modelLayer) {
        this.modelLayer = new TileLayer({
          style: {
            color: [
              'interpolate',
              ['linear'],
              ['band', 1],
              2,
              [255, 255, 255],
              2.5,
              [4,90,141]
            ]
          },
          source: this.modelLayerSource
        });
      }
      
      this.modelLayer.setSource(this.modelLayerSource);

      if (!this.map.getLayers().getArray().includes(this.modelLayer)) {
        this.map.getLayers().insertAt(1, this.modelLayer);
      }

      this.modelLayer.changed();
      this.modelLayerSource.refresh();

The map with the OSM layer is initialized as follows:

    useGeographic();
    proj4.defs("EPSG:32718","+proj=utm +zone=18 +south +datum=WGS84 +units=m +no_defs +type=crs");
    proj4.defs("EPSG:3857","+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs");
    proj4.defs("EPSG:4326","+proj=longlat +datum=WGS84 +no_defs +type=crs");

    register(proj4);

    this.map = new Map({
      target: this.myMap.nativeElement,
      layers: [
        this.osmLayer,
        this.vectorLayer
      ],
      view: new View({
        projection: 'EPSG:3857'
        // center: fromLonLat([-76.2591842, -6.5692892]),
        // zoom: 6
      }),
    });

The result looks like this (ignore the colored circles and grey squares these come from a vector layer that is displayed correctly):
geotiff on top of OSM with large white border

Here is another screenshot from QGIS with the same file:
qgis with same geotiff image

How can I get rid of the large white border around the GeoTIFF in openlayers?

Trouble when deploying a NextJS app to Netlify

To give you some context I am currently working on deploying an app to Netlify.
Its my first time deploying a NextJS app and I seems to be having issues.
What I would normally do with a regular React app is just select the frontend folder within my Gtihub Repo and just do a npm run build and have the dist folder be the one selected.

But I seem to be doing something wrong.

I have done those exact same steps only thing different is I selected the .next folder like literally put the “.next” within the configuration.

As I was trying to deploy there were some common failures due to some unused components which honestly gave me high hopes. As I fixed those issues and the deployment “succeded” I ended up with an Error on my main page.

These were the configuration I did within my Deployment settings: https://postimg.cc/w3ktp0Zt

This is how my Files are structured within my NextJS app: https://postimg.cc/HJGW5yFD

As you can see. Its a simple one page application.
I am not sure if it has something to do with how my Pages are setup. I understand NextJS uses a file based routing.

Any help or guidance into how to handle this issue as well as to how to deploy NextJS in general would be highly appreciated!