Loading Images in Phaser and Node js

Im am trying to load images in phaser with node js and i always get the same error

:3000/assets/img/feet/idle/survivor-idle_0.png:1 Failed to load resource: the server responded with a status of 404 (Not Found)

if you know a way to get this to work please tell me. here is my code:

preload() {
        // Used for preloading assets into your scene
        
        //Idle feet image
        this.load.image('idleFeetFrame', '/assets/img/feet/idle/survivor-idle_0.png');
}

What is the alternative method of ‘window.external’ in VB Script?

I used the WebBrowser control to add existing Web application written by VB Script code to my Windows Forms client applications.

But, I have some problem. I have to communicate between Web application and Windows Forms applications. I already found similar function in Javascript. ‘window.external’.
I’m looking for the alternative method of ‘window.external’ in VB Script.

please check the following code. how to implement to execute windows Forms Application methods in VB Script?

<script language="vbscript" type="text/vbscript">
   Sub callForm2()
      window.external.ShowMessage("from vbscript")
   End Sub
</script
public class ScriptManager
{
   private Form _form = null;
   public ScriptManager(Form1 form)
   {
      _form = form;
   }


   public void ShowMessage(object msg)
   {
      MessageBox.Show(msg.ToString());
   }
}

Hot to fix “Type ‘string’ is not assignable to type ‘T'”?

Here’s the code with error:

    let createArray = function<T>(length: number, value: T): T[] {
        let result: T[] = [];
        for (let i = 0; i < length; i++) {
            if (typeof value === 'string') {
                result[i] = value + '_' + i;  // Type 'string' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'.
            } else {
                result[i] = value;
            }
            
        }
        return result;
    }
    
    createArray(3, 'x');

I have no idea why Typescript can not recognize the Generics T as string in this case.

How can I fix it?

Trying use react slot machine cause: Support for the experimental syntax ‘jsx’ isn’t currently enabled error

I am trying to use slot machine in react but when I try use this I get an following error:

./node_modules/react-slot-machine-gen/src/react-slot-machine.js
SyntaxError: C:Projectnode_modulesreact-slot-machine-gensrcreact-slot-machine.js: Support for the experimental syntax 'jsx' isn't currently enabled (38:7):

  36 |   render() {
  37 |     return (
> 38 |       <div id={this.props.id} className="slot-machine" ref="wrapper"></div>
     |       ^
  39 |     );
  40 |   }
  41 | };

Add @babel/preset-react (https://git.io/JfeDR) to the 'presets' section of your Babel config to enable transformation.
If you want to leave it as-is, add @babel/plugin-syntax-jsx (https://git.io/vb4yA) to the 'plugins' section to enable parsing.

And simple react code

import SlotMachine from "react-slot-machine-gen";

<div className={styles.page_container}>
        <SlotMachine reels={reels} play={play}/>
        <input type="text"/>
        <button onClick={() => {
            setPlay(true);
        }}>Play
        </button>
    </div>

Information above does not solve this problem.
Thank you, any help will be appreciated

estoy intentando hacer un embed basico para un bot de discord [closed]

estoy intentando hacer un embed basico para un bot de discord este es el siguiente codigo

client.on("message", (message) =>{
   if(message.author.bot) return;
   if (!message.content.startsWith(prefix)) return;
//comandos
   const args = message.content.slice(prefix.length).trim().split(/ +/g)
   const command = args.shift().toLowerCase();
//embeds
if(command === 'embed'){
 const embed = new Discord.MessageEmbed()
   .setTitle('Infomacion del servidor');
 message.channel.send(embed);
}
});
client.login(config.token);

error:

DiscordAPIError: Cannot send an empty message
at RequestHandler.execute (C:UsersChinuDesktopbotdsGolden-botnode_modulesdiscord.jssrcrestRequestHandler.js:350:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (C:UsersChinuDesktopbotdsGolden-botnode_modulesdiscord.jssrcrestRequestHandler.js:51:14)
at async TextChannel.send (C:UsersChinuDesktopbotdsGolden-botnode_modulesdiscord.jssrcstructuresinterfacesTextBasedChannel.js:175:15) {

method: ‘post’,
path: ‘/channels/929202157410988113/messages’,
code: 50006,

JavaScript: does reassigning a variable declared by `let` change the memory location of that variable?

I have a variable foo which has the value of string foo

let foo = 'foo'

let’s say the variable foo is loaded at the memory address 100000f91. Does this re-assignment

  1. change its memory address, let’s say from 100000f91 to 100000f92?
  2. only rewrite the content/data at the address 100000f91?
foo = bar

What about changing it to a different type? does this change the answer?

foo = 123

Comparing data from JSON and input.value

I am working on small shopping cart project. I have products in JSON.file, also I have input for finding price of products.
I am using class method
question is: this are strings or numbers? -> (3) [’35’, ’35’, ’35’]


searchItem(data) {
    let that = this

    searchBtn.addEventListener('click', function(e) {
      
       const input = document.querySelector('.input').value

           
       const findItem = data.filter(function(item) {
          if(item.price === input) {
            return item
          }
        })   // this return all data of product so I filtered only prices bellow


        const getItem = findItem.map(item => {
          return item.price
        })                      
 
       // this give:    (3) ['35', '35', '35']  


    
         if(input === getItem) {     
             console.log('same') 
        } else {
          console.log('try it again') 
        }
                         
         // this cond. show me :  console.log('try it again')
         // HOW TO GET:   console.log('same')  
      
       e.preventDefault()
    })


Load image from URL and upload to media library in Strapi

I’m building a CSV importer for my Strapi application and one of its task is to read an image URL from a cell and download it from the URL and save it to media library.

The code looks like this:

const request = require('request').defaults({ encoding: null });

request.get(src, function (err, res, body) {
    const fileName = src.split('/').pop();

    strapi.plugins.upload.services.upload.upload({
        files: {
            path: body,
            name: fileName,
            type: res.headers['content-type'],
            size: Number(res.headers['content-length']),
        },
        data: {
            ref: 'products',
            refId: data.itemID,
            field: 'images'
        }
    });
});

The download works and I get a Buffer in the body variable of the request.get callback. But passing this to strapi.plugins.upload.services.upload.upload give me the following error:

UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_VALUE]: The argument 'path' must be a string or Uint8Array without null bytes. Received <Buffer ff d8 ff e1 10 c1 45 78 69 66 00 00 49 49 2a 00 08 00 00 00 0f 00 00 01 03 00 01 00 00 00 6c 05 00 00 01 01 03 00 01 00 ...

I already tried to replace path: body, with path: new Uint8Array(body), but without no luck.

Any idea what I do wrong here?

Thanks for your help!

Trying to understand the differences across these promises and setTimeouts [duplicate]

I’m learning about promises, setTimeout and async calls and have done a great job of confusing myself. I think I’m lacking some understanding around the callback and how setTimeout works. I’ve been looking at Mozilla documentation and the various Stackoverflow posts regarding these topics. I’m still having some trouble wrapping my head around why some of the functions I’ve created behave the way they do regarding the timeouts that are set.

Between wait0 and wait1 I don’t understand why the timeout for wait0 works properly and wait1 doesn’t adhere to it. With wait2 it is like wait1 except wrapped in an arrow function expression. Why does that make the timeout work properly? wait3 isn’t actually using the callback so that makes sense why the promise and then functions don’t do anything. But it stops wait4 from running. Is it blocking progression indefinitely or actually ending execution? For wait4 I’m also not passing a value into the callback like with wait0 but the timeout isn’t being adhered to.

function wait0() {
    return new Promise((resolve, failure)=>{
    setTimeout(resolve, 2000);
  });
}

function wait1() {
    return new Promise((resolve, failure)=>{
    setTimeout(resolve('resolved ' + new Date().toGMTString()), 2000);
  });
}

function wait2() {
    return new Promise((resolve, failure)=>{
    setTimeout(()=>{
        resolve('resolved ' + new Date().toGMTString());
    }, 2000);
  });
}

function wait3() {
    return new Promise((resolve, failure)=>{
    setTimeout(()=>{}, 2000);
  });
}

function wait4() {
    return new Promise((resolve, failure)=>{
    setTimeout(resolve(), 2000);
  });
}

async function test() {
  await wait0().then((result)=>console.log(result)); // Works as expected
  console.log(new Date().toGMTString());
    await wait1().then((result)=>console.log(result)); // Doesn't adhere to timeout
  console.log(new Date().toGMTString());
  await wait2().then((result)=>console.log(result)); // Works as expected
  console.log(new Date().toGMTString());
  await wait3().then((result)=>console.log(result)); // Never resolves
  console.log(new Date().toGMTString());
  await wait4().then((result)=>console.log(result)); // Doesn't adhere to timeout
  console.log(new Date().toGMTString());
}


test();

How to iterate through and modify each element

I have a readSourceList that I need to iterate through and modify the name with the word “bill” in front of them. Would I be able to do that within this function?:

DataExplorerUI.prototype.consumptionResponse = function (data) {
    var self = this;
    console.log(self.readerSourceList);
    $.each(data, function () {
        this.key = Enumerable.from(self.readerSourceList).first("$.f == " + this.key).name;
        $.each(this.values, function () {
            this.x = getUTCTimeInUserTimeZone(this.x);
        });
    });
};

Thanks

I’m trying to create and advanced command handler and I’m getting the error ‘CLIENT_MISSING_INTENTS’ and I feel like I’ve written the code perfectly

So I’m trying to branch off from a basic command line to an advanced command handler where the commands will call the command from a different file. I’ve been following videos and guides and I feel like there should be no issues and I also don’t have any errors within VSC. But after starting the discord bot and I inputted the node . command and got the error [Symbol(code)]: ‘CLIENT_MISSING_INTENTS’. This is my current code


    const client = new Discord.Client();

    const prefix = '-'

    const fs = require('fs');

    client.commands = new Discord.Collection();

    const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
    for(const file of commandFiles){
        const command = require(`./commands/${file}`);

        client.commands.set(command.name, command);
    }


    client.once('ready', () => {
        console.log('You are connected to Weekly Releases!');
    });

    client.on('messageCreate', message => {
        if(!message.content.startsWith(prefix) || message.author.bot) return;

        const args = message.content.slice(prefix.length).split(/ +/);
        const command = args.shift().toLowerCase();

        if(command === 'ping'){
            client.commands.get('ping').execute(message, args);

        } else if (command == 'youtube'){

        }
    });

    client.login```
and I don't know where to look for the issue. Any tips and tricks will help.

Get the “map” object in Mapbox-GL react native

I have a code like that:

import React, { Component } from 'react'
import MapboxGL from '@react-native-mapbox-gl/maps'

MapboxGL.setAccessToken( 'xxxx' )

export default class DebugMap extends Component {

  render() {
    return <View style={{ flex: 1}}>
        
      <MapboxGL.MapView
          ref={(c) => (this.map = c)}
          onPress={v => this.map.moveTo( 40, 10 )}
          style={{flex: 1}}>

          <MapboxGL.Camera
            zoomLevel={10}
            centerCoordinate={[50, 20]}
          />
        </MapboxGL.MapView>

    </View>
  }
}

The map is displayed normally an centered around 50, 20, but if I press it, an error is thrown:

TypeError: _this3.map.moveTo is not a function. (In '_this3.map.moveTo(48, 11)', '_this3.map.moveTo' is undefined)

What am I missing?

Need to launch a static web page

The website is built on via HTML css, JS files + yarn lock. How can I launch and where do I need to host this static web page?

I tried to launch it via WordPress, Github+Google Drive but it was not successful for me. Your help would be highly appreciated!

Rendering NextJS response in Rails

I am trying to figure out how I can render the response from a NextJS request inside a rails application as as attempt to iteratively modernize my application (Trying to avoid putting react into the rails app as I am looking to break the code out into separate services as well at the end). Currently I have it where I am seeing this in the browser (I can see the title on the tab change so I know it is rendering the html from the response)

enter image description here

Can ensure the html document is being rendered like so

enter image description here

The problem is my rails application doesn’t serve any of the javascript that is being returned from the NextJS application. If I inspect one of the 404’s I can see that it’s looking under /_next/static for all the responses, which doesn’t exist as far as the rails application knows.

enter image description here

I have looked for documentation around this for both rails and NextJS and have not found anything. Anybody know how I can serve the javascript assets along with the html or have any other suggestions?

This is the method on my registration controller in Rails and how I am rendering the html from the NextJS response.

  def new
    @html = HTTParty.get("http://localhost:3000")

    render html: @html.html_safe
  end