Trying to randomize the padding of an element to create a small rain effect

I am trying to randomize the position of diagonal falling lines using padding. Whenever I try to use the below code the lines do not change. However, if I add style:padding-left:300px to the style of the rain and remove my JavaScript I can move the element to the right by 300px. I can theoretically do this and map out each line however I would like to know how to randomize the padding, preferably dynamically and not just onpageload

<script>
function randomnumber(min, max) {
  var rn = Math.random() * (max - min) + min;
  document.querySelector('#rain .line').style.padding = rn+'px';
}

</script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 

<style>   
body{
   background:#000000;
   margin: 100px; 
}

.line {
 height: 1px;
 width: 40px;
 background: white;
 transform: rotate(45deg);
}

.rainsize{
height:100%;
width:100%;
opacity:0%;
z-index:1000;
position:fixed;
width:100%;
top:0px;
left:0px;
}

.move{
position:relative; 
animation-name: moverain;
animation-duration: 3s;
animation-iteration-count: infinite;
}
@keyframes moverain {
0%{top:0px;left:0px;}
100%{top:1000px;left:1000px;}
}

</style>


<div onpageload="randomnumber('10','1000')"class="rainsize"></div>


<div id=rain class="move">
  <div class="line""></div> 
</div>

<div id=rain class="move">
  <div class="line""></div> 
</div>

<div id=rain class="move">
  <div class="line""></div> 
</div>

<div id=rain class="move">
  <div class="line""></div> 
</div>

<div id=rain class="move">
  <div class="line""></div> 
</div>

<div id=rain class="move">
  <div class="line""></div> 
</div>

<div id=rain class="move">
  <div class="line""></div> 
</div>

<div id=rain class="move">
  <div class="line""></div> 
</div>









How to prevent Nav Menue toggle from changing y position

I’m very new to WordPress and I’m experiencing a bug where the y position of the page gets updated involuntarily.

I’m using a floating menu but each time I toggle the Nav menu it resets my view to the top of the page (not very useful for links that point to a specific position on the page that are stored within the nav menu).

The element in question

<button type="button" class="navbar-toggle">
    <span class="screen-reader-text"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Toggle sidebar &amp; navigation</font></font></span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
</button>

After some research the closest I’ve been able to identify what is causing this issue is the line of code e(document.body).toggleClass("side-nav-open") in scripts.min.js?ver=1.6.0

function s() {
    e(document.body).toggleClass("side-nav-open").addClass("side-nav-transitioning"); <-----
    const t = e("#slider").data("flexslider");
    t && (e(document.body).hasClass("side-nav-open") ? (i = t.playing,
    t.playing && t.pause()) : i && t.play());
    let s = !1;
    e(".site").one("transitionend", function() {
        e(document.body).removeClass("side-nav-transitioning"),
        s = !0
    }),
    setTimeout(function() {
        s || e(document.body).removeClass("side-nav-transitioning"),
        n.trigger("resize")
    }, 230)
}
e(".navbar-toggle, .side-nav-overlay").on("click touchend", function() {
    e(document.body).hasClass("side-nav-transitioning") || (s(),
    e(document.body).hasClass("side-nav-open") ? n.width() <= 640 ? t.find(".side-nav__close-button > button").focus() : t.find("nav.mobile-menu-wrapper ul li:first-child").focus() : t.find(".header-navigation-wrapper button.navbar-toggle").focus(),
    e.fn.keepFocusInMobileSidebar())
}),

using break points I was able to stop at the line e(document.body).toggleClass("side-nav-open").addClass("side-nav-transitioning"); and executing e(document.body).toggleClass("side-nav-open") in the console I saw my page jump to the top.

I’m hoping someone could help me complete my research and identify why my page no longer stays put when the navigation menu is clicked. Since I very rarely work on WordPress I’m not sure what info would be pertinent and what information would be noise, please post in the comments the data that would be most beneficial to trouble shoot this issue.

The current active theme is Inspiro version 1.6 https://www.wpzoom.com/free-wordpress-themes/inspiro-lite/

How can I disable the save credit card info popup in the chrome on Android device?

I am try to run some automation scripts writing with WD.js on the lamda cloud server,but I can not handle this popup,any suggestions?Thanks so much!

Here is my capabilities setting,but it seems not work.

  exports.config = {
  seleniumHost: 'hub.lambdatest.com',
  seleniumPort: 80,
  test: '../tests/demo.js',
  capabilities: [{
        build: "test demo",
        name: "work flow",
        platform: "Android",
        deviceName: "Huawei P20 Pro",
        platformVersion: "9",
        acceptSslCerts: true,
        visual: "true",
        browserName: 'chrome',
        chromeOptions: {
          prefs: {
            credentials_enable_service: false,
            'profile.password_manager_enabled': false,
            'profile.default_content_setting_values.notifications': '2'
        },
         args: ['--ignore-certificate-errors',
           '--disable-features=Translate',
           '--disable-popup-blocking',
           '--disable-notifications',
           '-incognito']
    }
    }]
}

enter image description here

I want to get array of multiple emp for particular Manager

I have a data where each emp has manager, i’m trying to get an array with emp with perticular manager. for ex: Manager1 with array of all his emp and Manager2 with all his emp. i have pasted a sample out.how can i get that?

const response = [
    {
        "emp":{
            "firstName":"Abhi"
        },
        "manager":{
            "firstName":"Ashok"
        }
    },
    {
        "emp":{
            "firstName":"Lokesh"
        },
        "manager":{
            "firstName":"Ashok"
        }
    },
    {
        "emp":{
            "firstName":"Harish"
        },
        "manager":{
            "firstName":"Ashok"
        }
    },
    {
        "emp":{
            "firstName":"Kaushik"
        },
        "manager":{
            "firstName":"Sunil"
        }
    },
]
            
            

Sample output i need:

[
    {
        "manager":"Ashok",
        "emp":[
            {
                "firstName":"Abhi"
            },
            {
                "firstName":"Lokesh"
            },
            {
                "firstName":"Harish"
            }
        ]
    },
    {
        "manager":"Sunil",
        "emp":[
            {
                "firstName":"Kaushik"
            }
        ]
    }
]

How can I stop the browser from url-encoding for react js form for POST data values with password field value included with #

I wanted to stop URL encoding for reactjs form password filed, when I entered the ‘#” in password browser automatically converts it into URL encoding format like ‘%23’, want to stop that or any other solution for this issue.

form is like:

              labels={{
                        passwordInputLabel: 'Password',
                        passwordPlaceHolder: 'Enter password',
                        loginButtonMessage: 'Logging In'

How to run a request in a function in Nodejs?

I have the following code to run a request and return the result in NodeJS :

const https = require('https')

async function GetStatus(HostName, Path) {  
    const options = {hostname: HostName,port: 443,path: Path,method: 'GET'}                     
    const req = https.request(options, res => {     
        res.on('data', d => {
            var result = JSON.parse(d);
            console.log('A - the status is ' + result.status);
            return result.status;               
        })
    })
    
    req.on('error', error => {console.error(error)});
    req.end();  
}

async function T() {
    var x = await GetStatus('www.domain.com', '/path');     
    console.log('B - The status is ' + x);
}

T();

I’m trying to run the function GetStatus to get some results based on the https request.

When running this code, I’m getting A – The status is something while the output of the function is B – The status is undefined

Does anyone know how to solve that please ? such that the function returns the result as expected instead of undefined.

Thanks.
Regards,

All my requests to Firestore are classified as unverified because of AppCheck?

I enforced Firebase AppCheck for Firestore.

Now, when I try to access data, I get an error:

    firebase
      .firestore()
      .doc(firestoreRoot.configs.priceIds._pathUrl)
      .get()
      .then((v) => console.log(v.data()));

appcheck error

In Firebase, it says all my requests are unverified:

enter image description here

This only happens for firestore.

Is there something else I must do?

I enabled AppCheck in my app using:

  const appCheck = firebase.appCheck();
  appCheck.activate("MY_SITE_KEY", true);

I tried disabling AppCheck in the firebase console, and now all my requests are accepted.

Trying to get value from object using external url but

When i start bot console say:

Online with undefined/5

and when 10 secconds are passed give this error:

undefined:1
[object Promise]
^
SyntaxError: Unexpected token o in JSON at position 1

My Code:

let jogadores
client.on("ready", async () => {

async function players_online() {
    const response = fetch(`http://ip:port/dynamic.json`);
    const data = JSON.parse(response);
    jogadores = data.clients;


}

async function autoconnect() {

    if (jogadores === -1) {
        console.log('Offline');

    } else {
        console.log('Online with ' + jogadores + '/5')

    }
}
autoconnect()

setInterval(() => {
    client.user.setStatus('dnd');
    client.user.setActivity(`Online with ${jogadores} players.`, { type: 'PLAYING' })
    players_online()
}, 10000)

})

The script does not send the changed data

I encountered a problem that my script does not send the changed data to Discord.
All other functionality works well. What could be the problem?

Here’s the code:

var send = WebSocket.prototype.send;

WebSocket.prototype.send = function (data) {
    if (WebSocket.prototype.toString.call(data) === "[object ArrayBuffer]") {
        var array = new Uint8Array(data);
        var modules = DiscordNative.nativeModules.requireModule('discord_erlpack');
        var unpackeddata = modules.unpack(array);
        console.Log("(WS LOG) received wsdata -> " + JSON.stringify(unpackeddata));
        if (unpackeddata.op == 4) {
            unpackeddata.d.self_mute = true;
            unpackeddata.d.self_deaf = true;
            unpackeddata.d.self_video = true;
            console.log("WS Packet 4")
        } else if (unpackeddata.op == 12) {
            for (var stream of unpackeddata.d.streams) {
                stream.quality = 1;
                stream.max_bitrate = 8000;
                stream.max_framerate = 10;
                console.log("WS Packet 12")
            }
        } else if (unpackeddata.op == 24) {
            unpackeddata.d.type = 123;
            unpackeddata.d.limit = 123;
            unpackeddata.d.offset = 123;
            console.log("WS Packet 24");
        }
        var packed = modules.pack(unpackeddata);
        var buffer = packed.buffer;
        array = new Uint8Array(buffer);
        data = array;
    } else {
        console.log("(WS LOG) received wsdata -> " + data);
    }
    return send.apply(this, [data]);
}

How do I secure my React Native Expo app from hackers? [closed]

I’d hate to build an entire application to only have it hacked.

I am using Firebase and Expo. I know about security rules for Firebase but is there any rules I need to abide by for the JavaScript within React Native/Expo?

Like, is there anyway a user can just change my javascript code and use it against me? I’ve heard about runtime attacks but I don’t know if people can do that in a mobile app like they can in a browser. I’ve seen where a user/attacker can literally just change variables and turn it into code that sends application data to the attackers server but I don’t know how that works.

Reactjs: Navigating to component from Navbar component without using data file

I am new to React and following a React tutorial. I am confused about how to have my Accordion component be directed to the path without utilizing the data file I created while following the tutorial. In general, I want the user to click “FAQ” in the navbar and be sent to the Accordion component.

Thank you for helping me further my knowledge in React!!

Navbar:

import React, {useState, useEffect} from 'react';
import { NavLink } from 'react-router-dom';
import { FaBars } from "react-icons/fa";
import {Nav, ExternalButton, NavbarContainer, NavLogo, MobileIcon, NavMenu, NavItem, NavLinks, NavBtnLink, NavBtn } from './NavbarElements';
import { IconContext } from 'react-icons/lib';
import Accordion from '../Accordion/Accordion';
import { animateScroll as scroll } from 'react-scroll';

const Navbar = ({toggle}) => {
    const [scrollNav, setScrollNav] = useState(false)

    const changeNav = ()=>{
        if(window.scrollY >= 80)
        {
            setScrollNav(true)
        }
        else
        {
            setScrollNav(false)
        }
    }
    useEffect(()=> {
        window.addEventListener('scroll', changeNav)
    }, []);

    const toggleHome = () => {
        scroll.scrollToTop();
    }
    return (
      <>
      <IconContext.Provider value={{color: '#fff'}}>
      <Nav scrollNav={scrollNav}>
          <NavbarContainer>
              <NavLogo to='/' onClick={toggleHome}>Verticality</NavLogo>
              <MobileIcon onClick={toggle}>
                  <FaBars />
              </MobileIcon>
              <NavMenu>
                  <NavItem>
                      <NavLinks to="about"
                      smooth={true} duration={500} spy={true} exact='true' offset={-80}
                      >About</NavLinks>
                  </NavItem>
                  <NavItem>
                      <NavLinks to="start"
                      smooth={true} duration={500} spy={true} exact='true' offset={-80}
                      >Get Started</NavLinks>
                  </NavItem>
                  <NavItem>
                      <NavLinks to='faq'
                      smooth={true} duration={500} spy={true} exact='true' offset={-80}
                      >FAQ</NavLinks>
                  </NavItem>
                  <NavItem>
                      <NavLinks to="nft"
                      smooth={true} duration={500} spy={true} exact='true' offset={-80}>NFTs</NavLinks>
                  </NavItem>
              </NavMenu>
              <NavBtn>
                  <ExternalButton href="google.com" target="_blank" rel="noopener"> Purchase</ExternalButton> 
              </NavBtn>
          </NavbarContainer>
      </Nav>
      </IconContext.Provider> 
      </> 
    );
};


export default Navbar

Data.js

import Accordion from '../Accordion/Accordion';
export const homeObjOne = {
    id: 'about', 
    lightBg: false,
    lightText: true, 
    lightTextDesc: true, 
    // topLine: 'A Crypto which is here to stay',
    headline: 'Buy Now or Regret Later',
    description: 'Text ',
    buttonLabel: 'Purchase',
    imgStart: true,
    img: require('../../images/svg1.svg').default,
    alt: 'Car',
    dark: true,
    primary: true,
    darkText: false
};

export const homeObjTwo = {
    id: 'start', 
    lightBg: true,
    lightText: false, 
    lightTextDesc: false, 
    topLine: 'So, how do we get started?',
     description: 
    `text `,
    buttonLabel: <td onClick={() => window.open("https://docs.pancakeswap.finance/get-started", "_blank")}>Learn More</td>, 
    imgStart: true,
    img: require('../../images/svg2.svg').default,
    alt: 'checking off list  ',
    dark: false,
    primary: false,
    darkText: true
};


export const homeObjThree = {
    id: 'nft', 
    lightBg: false,
    lightText: true, 
    lightTextDesc: true, 
    topLine: 'NFTs are here to stay...',
    headline: 'AND SO ARE WE!',
    description: 'text  ',
    imgStart: true,
    img: require('../../images/svg3.svg').default,
    alt: 'Construction',
    dark: true,
    primary: false,
    darkText: false
};

App.js

import React from 'react';
import {BrowserRouter as Router, Switch, Route, Link} from 'react-router-dom';
import './App.css';
import Accordion from './components/Accordion/Accordion';
import DisclaimerPage from './components/FooterPages';
import { homeObjTwo } from './components/InfoSection/Data';
import Home from './pages';
import aboutUs from './pages/aboutUs';
import disclaimer from './pages/disclaimer';

function App() {
  return (
    <Router>
      <Switch>
        <Route path='/' component={Home} exact />
        <Route path='/aboutUs' component={aboutUs} exact />
        <Route path='/disclaimer' component={disclaimer} exact />
        <Route path='/faq' component={Accordion} exact /> //does not work
      </Switch>
    </Router>
  );
}

export default App;

I don’t how much help this will be but here is the Accordion.js

import React,{useState} from 'react';
import {Data} from './Data';
import styled from 'styled-components';
import { IconContext } from 'react-icons';
import { FiPlus, FiMinus} from 'react-icons/fi'
import { AccordionSection, Container, Wrap, Dropdown} from './AccordionElements';





const Accordion = () => {
    const [clicked, setClicked] = useState(false)
    const toggle = index => {
        if(clicked == index)
        {
            return setClicked(null)
        }
        setClicked(index)
    }
    return (
        <IconContext.Provider value={{color : '#00FFB9', size: '25px'}}>
        <AccordionSection>  
        <Container>
            {Data.map((item, index) => {
               return (
                   <>
                   <Wrap onClick={()=> toggle(index)} key={index}>
                   <h1>{item.question}</h1>
                   <span>{clicked === index ? <FiMinus /> : <FiPlus />}</span>
                   </Wrap>
                  {clicked === index ? (
                    <Dropdown>
                   <p>{item.answer}</p>
                   </Dropdown>
                  ) : null}
                  
                   </>
               ) 
            })}
        </Container>
        </AccordionSection>
        </IconContext.Provider>

        )
}

export default Accordion

How to add delay/ fade effect when changing inputs in Shiny?

I would like to add delay/ fade effects to the value, subtitle, icon and color arguments of a reactive valueBox on shinydashboard. I have no idea how to do this as I have little knowledge of Javascript, and it seems that the solutions for this require JS. Alternatives with CSS are also useful.

I tried use shinycssloaders but I didn’t like the effect it produces when the value changes from less or more than 100.

My code:

library(shiny)
library(shinydashboard)

header <- dashboardHeader()

sidebar <- dashboardSidebar(
  sidebarMenu(
    
    id = "tabs", width = 300,
    
    menuItem("Analysis", tabName = "dashboard", icon = icon("list-ol"))
    
  )
)

body <- dashboardBody(
  
  tabItems(
    
    tabItem(tabName = "dashboard", titlePanel("Analysis"), 
            
            fluidPage(
              
              column(2, 
                     
                     box(title = "Analysis", width = 75, 
                         sliderInput(
                           inputId = 'aa', label = 'AA', 
                           value = 0.5 * 100, 
                           min = 0 * 100, 
                           max = 1 * 100, 
                           step = 1
                         ), 
                         
                         sliderInput(
                           inputId = 'bb', label = 'BB', 
                           value = 0.5 * 100, 
                           min = 0 * 100, 
                           max = 1 * 100, 
                           step = 1
                         ), 
                         
                         sliderInput(
                           inputId = 'cc', label = 'CC', 
                           value = 2.5, min = 1, max = 5, step = .15
                         ), 
                         
                         sliderInput(
                           inputId = 'dd', label = 'DD', 
                           value = 2.5, min = 1, max = 5, step = .15
                         ), 
                         
                         actionButton("execute1", "Click me")
                     )
              ), 
              
              column(8, 
                     tagAppendAttributes(class = "b1", valueBoxOutput(outputId = "box1", width = 6)))
            )
    )
  )
)

ui <- dashboardPage(header, sidebar, body)

server <- function(input, output, session) {
  
  ac <- function(aa, bb, cc, dd) {
    (aa + cc) + (bb + dd)
  }
  
  reac_1 <- reactive({
    tibble(
      aa = input$aa, 
      bb = input$bb, 
      cc = input$cc, 
      dd = input$dd
    )
  })
  
  pred_1 <- reactive({
    temp <- reac_1()
    ac(
      aa = input$aa, 
      bb = input$bb, 
      cc = input$cc, 
      dd = input$dd
    )
  })
  
  output$box1 <- renderValueBox({
    req(input$execute1)
    expr = isolate(valueBox(
      value = pred_1(), 
      subtitle = ifelse(test = pred_1() <= 100, 
                        "subtitle 1", "subtitle 2"), 
      icon = icon(ifelse(test = pred_1() <= 100, "smile", "angry")),  
      color = ifelse(test = pred_1() <= 100, "light-blue", "orange")
    ))
  })
  
}

shinyApp(ui, server)

Correctly delaying setTimeout

In the following function

function test1(n, delay) {
  for (let i = 0; i < n; i++) {
    setTimeout(() => {
      console.log(i)      
    }, delay)    
  }  
}

test1(3, 1000)

After 1 second, I immediately console.log 1, 2, and 3 simultaneously.

If I multiply delay by i,

function test1(n, delay) {
  for (let i = 0; i < n; i++) {
    setTimeout(() => {
      console.log(i)      
    }, i * delay)    
  }  
}

test1(3, 1000)

I console.log every i in my loop after 1 second. Why does this work?

Also, why does the code below

function test2(n, delay) {
  let promise = new Promise(resolve => setTimeout(() => {
    resolve()    
  }, delay))
  for (let i = 0; i < n; i++) {
    promise.then(console.log(i))  
  }  
}

test2(3, 1000)

immediately console.log 1, 2, and 3 simultaneously instead of waiting every second to console.log the next i value? Is there a way to console.log the next i value after waiting every second without using async and await?

How do I return value modified by an AFTER INSERT trigger in Knex.js?

I want to get back a value after I insert my data

const data = {name: "Christmas Shirt 1", price: 5.99, sku: "20210911S", warehouse_id: 2}

const skuCode = await query.returning(['sku_code'], {includeTriggerModifications:true}).insert(data);

console.log(skuCode) // ["20210911-NY"];

However, the table that I’m inserting into has a AFTER INSERT trigger that will append a prefix to the sku_code field:

CREATE TRIGGER inventory_trigger
ON inventory AFTER TRIGGER AS
BEGIN
  UPDATE t
  SET sku_code = CASE t.warehouse 
    WHEN 1 THEN t.sku_code + "NV"
    WHEN 2 THEN t.sku_code + "NY"
  END
  FROM inventory t
  JOIN inserted i ON t.id = i.id
END

Is there a way for me to get the value after the AFTER INSERT trigger using Knex’s returning()? I know I can add similar logic in my JS code that manually prepends the prefix but I don’t want to duplicate the logic.

Count the number of values

Here is a task to count the number of true in each age:

users = {
 // ...
 age = x; // random number
 sport_life true; // or false
 // ...
}

And display it in a chart (chart.js). Here is how to update.
I don’t know how to put it all together. Thanks in advance!