hello, I have really failed to build my strapi project on my machine

here is the error in the console. I have tried deleting node modules, clearing cache, and rebuilding several times all in vain.

app.js:239 Uncaught Error: Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: ENOENT: no such file or directory, open '/home/fahdjamy/Desktop/Projects/sovTech/virtually-visiting-backend/.cache/admin/src/components/Fonts/index.js'
 at Object../.cache/admin/src/components/Fonts/index.js (app.js:239:1)
 at __webpack_require__ (bootstrap:79:1)
 at Object../.cache/admin/src/app.js (app.js:33:1)
 at __webpack_require__ (bootstrap:79:1)
 at Object.0 (toArray.js:10:1)
 at __webpack_require__ (bootstrap:79:1)
 at checkDeferredModules (bootstrap:45:1)
 at Array.webpackJsonpCallback [as push] (bootstrap:32:1)
 at main.chunk.js:1:57

picture

How to force websockets on Firebase 9?

Before Firebase 9, you could force websockets instead of long polling. After upgrading to 9, we can’t get long-polling working, even after loosening out content security policy a lot. What’s the right approach to enable this?

We used to be able to enable this easily with: database.app.firebase_.database.INTERNAL.forceWebSockets()


Related to this question but the answer requires hardcoding ws:// instead of http:// (and further says this is not recommended.)

Our code is shared across platforms and we need to be able to force websockets on one platform while leaving the values untouched on another.

Window is in random offsets on page refresh

I’m using GSAP animations in a project and I keep running into this bug where upon page refresh the window will sometimes be in random places. When this happens I just type in window.pageXOffset to see where it’s at. This sometimes happens with the Y axis as well. I’m using Chrome, but I’ve tested it out on Safari and it hasn’t happened but it’s a totally random bug. It usually will happen when my inspector is out and I’ve been clicking around A LOT! Clicking the ’empty cache and hard reload’ button has fixed it every time. This is a wordpress project too, so I’m not sure when the scripts get loaded if that matters. Anyone know what’s going on???

Countdown with time() PHP and moment.js

I built a PHP function that returns a future value in timestamp format. With that, I tried in script to get the countdown from that timestamp. Example: 1646435355 – 1646435055 = 300 seconds. I know that function “time()” of PHP return values in “seconds”, and javascript read on milliseconds, but, the question is: “How convert seconds that return of PHP function time() in milliseconds”? I read the docs of “moment.js” and find a line that talk about “unix” on function moment, but, i try this and dont work. You can help?

var duration = moment.duration(<?php echo $timerCount; ?> * 1000, 'milliseconds');
var interval = 1000;
setInterval(function(){
    duration = moment.duration(duration.asMilliseconds() - interval, 'milliseconds');
    $('#time').text(moment(duration.asMilliseconds()).format('h:mm:ss'));
    if(duration.asSeconds() <=0) {
        window.location.replace(window.location.pathname + window.location.search + window.location.hash);
    }
}, interval);

$timerCount is time()+5 minutes. And… Yes, i changed “milliseconds” to “seconds” and etc and nothing works.

How do I insert dots into date and limit the year in angular material date picker?

The component in Angular material datepicker:

inputEvent(event, type: number): void {...}
changeEvent(event, type: number): void {...}

newDateStart: Date = null;
endDateStart: Date = null;

The template:

<mat-date-range-input [rangePicker]="picker">
    <input #fromInput matStartDate placeholder="Start Date"
           (dateInput)="inputEvent($event, 0)"
           (dateChange)="changeEvent($event, 0)">
    <input #toInput matEndDate placeholder="End Date"
           (dateInput)="inputEvent($event, 1)"
           (dateChange)="changeEvent($event, 1)">
</mat-date-range-input>

And the CustomDateAdapter for datepicker:

export class CustomDateAdapter extends NativeDateAdapter {

  parse(value: any): Date | null {
    // if ((typeof value === 'string') && (value.indexOf('.') > -1)) {
    if (typeof value === 'string') {
      let str: string[] = [];

      if (value.indexOf('.') > -1) {
        str = value.split('.');
      } else if (value.indexOf(' ') > -1) {
        str = value.split(' ');
      } else if (value.indexOf('-') > -1) {
        str = value.split('-');
      }

      const year = Number(str[2]);
      const month = Number(str[1]) - 1;
      const date = Number(str[0]);

      return new Date(year, month, date);
    } else if ((typeof value === 'string') && value === '') {
      return new Date();
    }
    const timestamp = typeof value === 'number' ? value : Date.parse(value);
    return isNaN(timestamp) ? null : new Date(timestamp);
  }

  getFirstDayOfWeek(): number {
    return 1;
  }
}

The date format is 05.03.2022 where 05 – day, 03 – month, 2022 – year.

One may enter:

  1. “05032022” in this case I need to add “.” into this string to get “05.03.2022” and plase this new string into input in the template
  2. “05.03.202200” in this case I need to limit the year by 4 number length

How do I insert dots into date and limit the year in angular material date picker?

How to synchronize button text of buttons under different tab in react?

I have a component with a button. The component is created in its parent component twice (under different tabs). If the user clicks the button, the button text will change. I hope the button texts are always the same whatever button is clicked and changed.
I have tried updating the state of the course component in click functions, so the text of the button can be changed based on the state condition. It doesn’t work. I guess the click function just updates the state of a component of one tab rather than another tab. Any way to implement the synchronization? Thanks!

Draw straight line on canvas with javascript

I want to draw straight line on HTML canvas using with javascript but when I research for how does it done every result abut the solition is using with static position

it’s one of the result when ı search

 const ctx = canvas.getContext('2d');
    ctx.beginPath();
    ctx.moveTo(100, 100);
    ctx.lineTo(300, 100);
    ctx.stroke();   

but its not work with dynamic position same way
does anybody know the solition of using with dynamic width and height

Rails 7 failing to import yarn package (https://github.com/keisto/vanilla-rangeslider)

This is a non-jQuery version of IonRangeSlider (https://github.com/IonDen/ion.rangeSlider):

https://github.com/keisto/vanilla-rangeslider

I have used this before by trying to stick to pure JS and avoid adding another layer with JQ.

I installed this via yarn and it’s in my node_modules folder.

I added this to my app/javascript/application.js file:

import IonRangeSlider from 'vanilla-rangeslider/js/rangeslider'

after also trying just:

import IonRangeSlider from 'vanilla-rangeslider'

In my compiled JS file in dev all it has is this:

  // ../../node_modules/vanilla-rangeslider/js/rangeslider.js
  var require_rangeslider = __commonJS({
    "../../node_modules/vanilla-rangeslider/js/rangeslider.js"() {
    }
  });

and if I try and initialize a slider all I get is:

Uncaught ReferenceError: ionRangeSlider is not defined

Any ideas here as to what I am missing? I have added some other yarn based JS package with no issues.

Javscript – Three.js Disable panning on mobile devices?

So I’m making a 3d project with three.js. Everything works as expected on my laptop. I’m using OrbitControls to allow camera movement, but i have disabled right click panning, because I want the camera just to rotate. When switching to a mobile device (iphone), using two fingers I’m able to move the camera (not rotate). Is there a way to disable this behaviour on mobile devices?
My OrbitControls:

this.controls = new OrbitControls(this.camera, this.renderer.domElement)
this.controls.enableDamping = true
this.controls.maxPolarAngle = Math.PI * 0.45
this.controls.mouseButtons = {
  LEFT: THREE.MOUSE.ROTATE,
  MIDDLE: THREE.MOUSE.DOLLY,
  RIGHT: ''
}

Update function:

_RAF() {
    requestAnimationFrame(() => {
      this.water.material.uniforms[ 'time' ].value += 1.0 / 60.0
      this.controls.maxDistance = 10000.0
      this.controls.minDistance = 10.0
      this.controls.update()
      this.camera.updateProjectionMatrix()
      this.renderer.render(this.scene, this.camera)
      this._RAF()
    })
  }

Use chrome.scripting.insertCSS to inject CSS at document_start with Manifest v3 for a Chrome extension?

It used to be possible on Manifest v2 with chrome.tabs.insertCSS to inject CSS with
runAt: document_start in the details of the object when injecting from the background page

https://developer.chrome.com/docs/extensions/reference/tabs/#method-insertCSS

This appears to have been removed with Manifest v3’s chrome.scripting.insertCSS and there doesn’t seem to be a runAt option available anymore for CSS from a background page.

https://developer.chrome.com/docs/extensions/reference/scripting/#method-insertCSS

It now seems to default to document_idle

Is there another way of doing it?
Putting the CSS file in the manifest file isn’t really an option as it needs to create the CSS in the background page.

The new chrome.scripting API does let content scripts be injected at document_start but not CSS.

Thanks for any help with this.

React and Tailwind Custom Fonts from ttf file

Hey i want to add some custom fonts from files.

These are the font files that i want to load.

These are the font files

My index.css

body {
  margin: 0;
  padding: 0;
}

@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500&display=swap");

@tailwind base;
@tailwind components;

@tailwind utilities;

Thanks in advance

Follow a array based on the variable

Im trying to get my client to know which array it should follow.

var json = [{
  command: "command 1", 
  giveRole: "884005303811702794"
}, {
  command: "command 2", 
  giveRole : "948609651673563179"
  }];
  for (var key in json) {
    if (json.hasOwnProperty(key)) {
      console.log(json[key].command);
      console.log(json[key].giveRole);
    }
  }
  client.on('message', message => {
    if (message.content.startsWith(json[key].command)) {
      target.roles.add([json[key].giveRole]);
    }
  });

For exempel if i send “command 1” it should give role “884005303811702794” not “948609651673563179”.