font-face: I don’t know if I used it right

This is what I first did… it removes the flag ‘ensure text remains visible during webfont load’. But, I don’t know if this is correct.

@font-face {
  font-family: myFirstFont;
  src: url('Akshar-Bold.ttf'),
  url('Akshar-Regular.ttf');
  font-weight: normal;
  font-display: fallback;
}

I tried this but it slows down the performance on lighthouse. This is the first time I’m using font-face so I really have no idea what I’m doing… ˙◠˙

@font-face {
  font-family: 'myFirstFont';
  src: url('Akshar-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: fallback;
}

@font-face {
  font-family: 'myFirstFont';
  src: url('Akshar-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: fallback;
}

failed to add a leaflet ruler plugin

i always get : js: Uncaught ReferenceError: map is not defined

Add Leaflet-Ruler plugin

    m.get_root().header.add_child(folium.CssLink("https://unpkg.com/[email protected]/dist/leaflet.css"))
    m.get_root().header.add_child(folium.CssLink("https://cdn.rawgit.com/gokertanrisever/leaflet-ruler/master/src/leaflet-ruler.css"))
    m.get_root().html.add_child(folium.JavascriptLink("https://unpkg.com/[email protected]/dist/leaflet.js"))
    m.get_root().html.add_child(folium.JavascriptLink("https://cdn.rawgit.com/gokertanrisever/leaflet-ruler/master/src/leaflet-ruler.js"))
    my_js = '''
    L.control.ruler().addTo(map);
    '''
    m.get_root().script.add_child(folium.Element(my_js))

i trired to add this plugin to a folium map in python but i always get error

How to get Basic Constraints in a certificate by JS

everyone
I’m trying use JavaScript to parse a PEM format certificate now. I’m expecting to get the
Basic Constraint value to distinguish whether a certificate the user uploaded is a CA.
The Basic Constraint value in the certificate is as follows:
example cert parse
My coding environment is Vue2 and jsrsasign v11.1.0 and nodejs v18.9.0.
My code is bellow.

<template>
  <div class="parseCert">
    <el-upload
      class="uploadFile"
      ref="upload"
      drag
      action="aa"
      :on-change="onChange"
      :auto-upload="false">
      <i class="el-icon-upload"></i>
      <div class="el-upload__text">Drag cert file to here</div>
    </el-upload>
  </div>
</template>

<script>
  import { X509 } from 'jsrsasign'
  export default {
    data () {
      return {
      }
    },
    methods: {
      onChange (file) {
        let reader = new FileReader()

        let cert = new X509()

        reader.onload = function () {

          cert.readCertPEM(reader.result)
          cert.getSubject().array.forEach(e => {
            console.log('ds: ' + e[0].ds + ', type: ' + e[0].type + ', value: ' + e[0].value)
            }
          )
          // Here is I try to get the basicConstraints
          // But it seems that it is nothing can be get
          const basicConstraints = cert.getExtBasicConstraints() 
          console.log('Basic Constraints: ' + basicConstraints)
          console.log(basicConstraints)
          for (const key in basicConstraints) {
            if (Object.prototype.hasOwnProperty.call(basicConstraints, key)) {
              const value = basicConstraints[key];
              console.log(`Key: ${key}, Value: ${value}`);
            }
          }
        }

        reader.readAsText(file.raw)
      }
    }
  }
</script>

<style>
</style>

My code can’t get the Basic Constraint value and I have no idea how to fix.
Am I using the jsrsasign module by mistake?
There is any better or right way to achieve my goal?

Using autofit.js in vue+elementUi causes element offset

Autofit. js is a solution for adapting to large screens, but when used in conjunction with elementUI, it can cause the inner elements to shift. For example, when the item setting of el table is set to show overflow tooltip, the displayed elements will send offset when the mouse moves into this grid

I hope to achieve a normal effect without causing element displacement. Thanks

How to use a package installed via npm in a standard javascript file?

I installed this package via npm: https://www.jsdelivr.com/package/npm/zebra-browser-print-wrapper

I first did npm i zebra-browser-print-wrapper like it states.

In my normal javascript file, I added the cdn link like below:

<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/index.min.js"></script>

Before writing any code to leverage this new package, when I load the page, I get the following error in the console:

Uncaught ReferenceError: exports is not defined at index.min.js:7:1461

which is this line within that file:

Object.defineProperty(exports, "__esModule", {

I do see the package is in my package.json file as follows:

{
  "devDependencies": {
    "tailwindcss": "^3.3.5"
  },
  "scripts": {
    "build": "npx tailwindcss -i ./static/css/src/input.css -o ./static/css/styles.css",
    "watch": "npx tailwindcss -i ./static/css/src/input.css -o ./static/css/styles.css --watch"
  },
  "dependencies": {
    "flowbite": "^2.4.0",
    "zebra-browser-print-wrapper": "^0.1.4". <-------------
  }
}

I’m not sure if I’m missing something basic/simple. I’m fairly new to npm.

Dropdown Menu For Images P5js

I am trying to make a drop down menu in p5js that displays images. I keep running into an error with loading images. When I attempted to troubleshoot and loaded an image in another sketch I did not get the error but I am getting it here. I am hoping a fresh pair of eyes could help. Thank you for your time and help!

let picker; 
let drum1, drum2, drum3, drum4, drum5;
let img;
let drumType = 'what';

function setup() {
    createCanvas(windowWidth, windowHeight);

    drum1 = loadImage('drum1.jgp');
    drum2 = loadImage('drum2.jpg');
    drum3 = loadImage('drum3.jpg');
    drum4 = loadImage('drum4.jpg');
    drum5 = loadImage('drum5.jpg');

    textAlign(CENTER);
    background(200);
  
    picker = createSelect();
 
    picker.position(10, 10);

    picker.option('djembe');
    picker.option('two hand drums');
    picker.option('one hand drum');
    picker.option('Talking drum');
    picker.option('five hand drums');
   
    picker.changed(pickEvent);

    img = drum5;
}

function draw() {
    background(200, 220, 10);
    textAlign(LEFT);
    image(img, 0, 0, width, height);
    text(trim + ' is a good drum', 10, 50); // look up what trim is

}

function pickEvent() {
    // get the item chosen with .value()
    drumType = picker.value();
        
    if (drumType === 'djembe') {
        img = drum1;
    } else if (drumType === 'two hand drum') {
        img = drum2;
    } else if (drumType === 'one hand drum') {
        img = drum3;
    } else if (drumType === 'talking drum'){
        img = drum4;
    } else  {
        img = drum5;
    }

}djembe
two hand drums
one hand drum
Talking Drum
five hand drums

How to combine two php scripts. Top part one and bottom sticky footer another and will expand to 50 and auto resize back to 10

Hi I need help to combine two php scripts. The top part will be a social script and the bottom will be a media player that will be in the form of a sticky footer showing the media player. When clicked on the height will be automatically adjusted to 50 percentage of the page and will auto shrink to 10%.
Is this possible? Like an iframe? Thanks

I tried to use network sites in WordPress and iframe to do this but I decided to leave WordPress and go for PHP scripting and I’m very stuck in how to combine the two scripts. Im using wowonder for social and the bottom music component deepsound. Your help and expertise is greatly warrented

Second html Dialog opening and closing immediately when opened from first html dialog

I am trying to open a second HTML Dialog from a button on the first HTML Dialog using the HTML Dialog element. I can see the second dialog open for a split second then it closes both dialogs.
I have searched but can’t find anything that works.
Here is a shortened version of my code. You can run this code and it will explain what I want to happen as you click the buttons.

Let me mention that I have the code to post the information and it works, I just need the second HTML Dialog to open and stay open until the Post or Cancel button is clicked.
Thanks

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div>
    <div>
      <h2>Split Transaction</h2>
    </div>
    <button data-open-modal1>Add Transaction</button>
  </div>
  <dialog id="dialog1">
    <h3>This is dialog 1</h3>
    <p>This dialog allows the user to enter transaction information.</p>
    <p>If the transaction has to be split into two categories</p>
    <p>they would click on the Split button which would open dialog 2 on top of</p>
    <p>dialog 1 and allow dialog 2 information to be entered.</p>
    <p>Then the user would click Post to post dialog 2 information, dialog 2 would then close</p>
    <p>and return to dialog 1 (this dialog)</p>
    <p>where the user would click Post on dialog 1 to post the transaction data.</p>
    <form id="form" action="" method="post">
      <button id="transdialogsplitbutton" data-post-modal1 formmethod="dialog" value="split" onclick="split(this, value)">Split</button>
      <button id="transdialogsubbutton" data-post-modal1 formmethod="dialog" value="post" onclick="postrecurring(this, value)">Post</button>
      <button id="transdialogcancelbutton" data-close-modal1 formmethod="dialog" onclick="closedialog()">Cancel</button>
    </form>
  </dialog>

  <dialog id="dialog2">
    <h3>This is dialog 2</h3>
    <p>When the user clicks on Post it would post the information on this dialog 2</p>
    <p>and return to dialog 1 where the user will click on Post to post that information.</p>
    <form action="" method="post">
    <button id="transdialogsubbutton" data-post-modal2 formmethod="dialog" value="post" onclick="postsplit(this, value)">Post</button>
    <button id="transdialogcancelbutton" data-close-modal2 formmethod="dialog" onclick="closedialog()">Cancel</button>
    </form>
  </dialog>

  <script>
    const openModal1 = document.querySelector('[data-open-modal1]');
    const closeModal1 = document.querySelector('[data-close-modal1]');
    const postModal1 = document.querySelector('[data-post-modal1]');
    const modal1 = document.querySelector('#dialog1');

    openModal1.addEventListener('click', () => {
      modal1.showModal();
    });

    closeModal1.addEventListener('click', () => {
      modal1.close();
    });
  </script>

  <script>
    function postrecurring(element, value) {
      alert("Transaction Information Posted");
    };
  </script>

  <script>
    function split(element, value) {
      alert("Dialog 2 Should Open");
    };
  </script>

  <script>
    const openModal2 = document.querySelector('[data-open-modal2]');
    const closeModal2 = document.querySelector('[data-close-modal2]');
    const postModal2 = document.querySelector('[data-post-modal2]');
    const modal2 = document.querySelector('#dialog2');
  </script>

<script>
      openModal2.addEventListener('click', () => {
      modal2.showModal();
    });

    closeModal2.addEventListener('click', () => {
      modal2.close();
    });
  </script>

  <script>
    function postsplit(element, value) {
      alert("Split Posted");
    };
  </script>

  <script>
    function closedialog(element, value) {
      alert("Dialog Closed");
    };
  </script>

</body>
</html>

I’ve tried everything I can think of but still can not find anything that works the way I want.

How do I update the DOM using JavaScript fetch method to filter user data from API?

I am looking to GET Data from API and display in HTML page using JavaScript fetch function.
The JavaScript codes are detailed below. I can read the console.log of the user data from API. However, nothing is displayed on the HTML page as expected.


    <script>
      fetch('https://dummyjson.com/user')
        .then(response => response.json())
        .then(data => console.log(data));
    </script>

I can’t seem to figure out what is missing.

Screenshot 1: Data API

I have added a loop function to retrieve and filter the API data and insert the result into HTML tag as detailed below:

    <script>
      fetch('https://dummyjson.com/user')
        .then(result => {
          return result.json();
        })
        .then(data => console.log(data))
        .then(data => {
          data.forEach(user => {
            const show = `<p>${user.firstName}</p>`;
            let html = document.querySelector('item');
            html.insertAdjacentHTML('after begin', show);
          });
        });
    </script>

Screenshot 2: Console.log results

Expected result should have been the first names (firstName) of all the user.

When the code runs, output does not display the expected result in the HTML page.
The console log does not show any errors. Simply a blank page.

Complete Code Below:


<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <style>
          body {
        background: transparent;
        color: #2c0493;
        padding: 44px;
        margin: 0;
        height: 100vh;
        align-items: center;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
          Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
      }

      h3,
      h2 {
        margin: 0;
      }
    </style>
  </head>
  <body>
    <h2 id="header">GET Data from API</h2>
    <h3>And display in HTML with JavaScript</h3>
    <hr />
    <div id="item"></div>
    <script>
      fetch('https://dummyjson.com/user')
        .then(result => {
          return result.json()
        })
        .then(data => console.log(data))
        .then(data => {
          data.forEach(user => {
            const show = `<p>${user.firstName}</p>`
            let html = document.querySelector('item')
            html.insertAdjacentHTML('afterbegin', show)
          });
        });
    </script>
  </body>
</html>

More Screenshots here:

Screenshot 3: No HTML output

Expected output:

Screenshot 4: Expected output

After Effects Expressions – Stopping CurrentTime at needed moment or frame

I need my
linear(time, starttime, starttime+duration, key1.value key2.value)
work when it triggers by if.
Problem is i cant attach start time to start frame of if() condition.

How i catch elapsed time minimal value and stop it from changing?
For example if my if() triggers at 50 frame how i can catch this value of 50 and stop it? Because everything i tried before is keep.

I have one parent layer. There is opacity change from 0 to 100 just for triggering if() when opacity is over 50.

And i have rotation parent keys. I want set parent keys one time and make other layers rotate like it parent keys when if() works.

 `var keykey1 = thisComp.layer("Parent control layer").transform.opacity.key(1);
 var keykey2 = thisComp.layer("Parent control layer").transform.opacity.key(2);
 var kr1 = thisComp.layer("Parent control layer").transform.rotation.key(1);
 var kr2 = thisComp.layer("Parent control layer").transform.rotation.key(2);
 var N = thisComp.layer("Parent control layer").transform.opacity;
 var dlit = kr2.time - kr1.time;
 var startTime = (N > 50 && typeof startTime === 'undefined') ? time : 1;
 var elapsedTime = (N > 50) ? time - startTime : 0;
 var currentTime = time;
 var pya = 6;
 var endt= pya+dlit;



 if ( N > 50) {
value=linear(time, pya, endt, kr1.value, kr2.value);
}`
 

I’ve tried math.min and chat gpt but this dont work.

design a basic implementation of a cache using a linked list data structure based on the java LinkedList

I have a project for a class that I am working on, and I am nothing short of lost, the description of it is as follows:

In this project, we will design a generic implementation of a cache using a linked list data structure based on the LinkedList class in Java. For this project will use the one provided by Java to ensure the highest accuracy! Please review the methods available in the LinkedList class from Java. Then, we will deploy our cache in a simple application, summarized below, to test the efficiency of the cache.

This project will also use the concept of a website and webpages. A website consists of multiple webpages. A web server is a program that serves up webpages to clients (for example, web browsers). Reading a webpage from the disk (as they are stored as files) takes a long time. To improve access speed, a web server would typically store the webpages in a cache. We will use our generic cache to store webpages and then write a test program to check its efficiency. The webpages will be generated synthetically with the provided class files to make it easier to test the cache.

We are supposed to create 2 classes on top of the many classes provided, but I honestly do not even know where to start, as vague of a description as it is, it is all I can provide. I do know we are supposed to create a Cache.java and a:
Design and write a test program, CacheExperiment.java, that uses the WebpageGenerator and the Cache to process Webpages as described in the next bullet. The usage should be as follows:
java CacheExperiment
<debug-level=0-3> []

I will provide screenshots of the general functionality of the program and what the finished product should look like:

What the output should look likeExample of 10 Cache Size, 100 webpages, 3.0 standard deviation, and 0 debug level

I apologies again for the vague description of what it should be, but any help is appreciated

I have also provided my github repository so files can be viewed: https://github.com/antoniofren/Project12

Unable to upload file from file that in src to cloudnary

In my src directory, there is a temp file, using multer I upload the file in the temp file but I cannot upload the file in cloudinary. Why it happen please help me, please help me

Here is my code:

console.log("file detail:", JSON.stringify(req.file))
 //output {"fieldname":"avatar","originalname":"Screenshot 2024-07-27 004034.png","encoding":"7bit","mimetype":"image/png","destination":"uploads/","filename":"Screenshot 2024-07-27 004034.png","path":"uploadsScreenshot 2024-07-27 004034.png","size":474631}
if (req.file) {
  try {
    const result = await cloudinary.v2.uploader.upload(req.file.path, {
      folder: "learnify",
      width: 250,
      height: 250,
      gravity: "faces",
      crop: "fill",
    }).then(result=>console.log('RESULT',result)).catch(error => {
      console.error(error.message)});// For result i get undefined

    if (result) {
      user.avatar.public_id = result.public_id;
      user.avatar.secure_url = result.secure_url;

      // Remove file from server
      fs.rm(`../temp/${req.file.filename}`);
    }
  } catch (error) {
    return next(new AppError("File not upload, please try again", 500));
  }

I am trying to upload file to cloudnary from temp file…

How to make TELEGRAM to Join compulsory to access the website’s page?

Hello Members,
I have a little feature which I want to add in my website.

I want that if somebody opens any page of my website, A popup message of “You have to Join the TELEGRAM Channel first” should come & if the users want to access the page, they have to join the TeleGram Channel Compulsory through the given link. Without joining the Telegram channel, the page should not be accessible.
Is it possible!! Can we add some type of feature like this??

if anyone help [It would be helpful].
Thank You.

I added the POPUP saying ‘Join the Telegram Channel first’ but It didn’t work. As it was happening that if the user click the Join Button and then came back without joining it, the page was becoming accessible, which I don’t want.
[ USER HAVE TO JOIN THE TELEGRAM CHANNEL COMPULSORY ]

How to create a timer/delay in Thingsboard rule chain?

I have a device that outputs the following telemetry onto thingsboard: pressure (number), flow (number), and flushing(0 or 1). Below is the semi-pseudo code that I want to implement through the rule chain using the script nodes. Currently, I am trying to store the time as a server attribute/metadata and compare the values after 30 seconds, but I have been unsuccessful. Any help is appreciated!

// create alarm when below criteria is met

// when flushing occurs
// wait 30 seconds
// after 30 seconds check values of pump1 & pump2 statuses & pressure value
// if all criteria is met
// return true (send to create alarm node)
// else return false

var FLUSHING_DURATION = 30 *
1000; // 30 seconds in milliseconds

// Retrieve the flushing start time from the metadata
var flushingStartTime = metadata.flushingStartTime;

if (msg.flushing==1) {
if (flushingStartTime === undefined ||
flushingStartTime === null) {
// If flushing is active and we don't have a start time, set it
flushingStartTime = Date.now();
metadata.flushingStartTime = flushingStartTime;
console.log(flushingStartTime);
}
} else {
// If flushing is not active, reset the start time
flushingStartTime = null;
metadata.flushingStartTime = null;
}

if (flushingStartTime && Date.now() - flushingStartTime >=
FLUSHING_DURATION) {
// Check conditions after 30 seconds of flushing
return msg.pressure1_psi < 40 && msg.pump1_status ===
2 && msg.pump2_status === 2;
}

return false;