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.

How to load two external files in D3.js version 7?

To load one TopoJson file in D3 version 7 is simple as:

d3.json("file01.json").then(function(topology) {

To load two files in previous versions you could use for example in version 6:

Promise.all([
    d3.json("file01.json"),
    d3.json("file02.json", function(d) {
        data.set(d.code, +d.pop)
    })
]).then(function(loadData){

and in version 4, for example:

d3.queue()
  .defer(d3.json, "file01.json")
  .defer(d3.json, "file02.json", function(d) { data.set(d.code, +d.pop); })
  .await(ready);

I tried both in version 7 and received the notice that promisse or queue are not a function. So I interpreted that in version 7 there’s another way to load two external files.

Thanks for any help which I couldn’t find until now, despite searching all over the in Internet. There’s a lot of material about version 3 to 6, but much less to version 7.

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!

Google Sheets: How do I list rows of data copied from another sheet consecutively, in order, and without overwriting current data through scripting?

I’m kind of new to working with Google Sheets, and I’ve stumbled across an issue while creating buttons for a ticket system. I’ve been having trouble getting the copied data to just fill the other sheet from the second row and down without gaps or overwriting existing data.

The script basically checks if a checkbox of a certain row is ticked, copies the data in that row, moves that data to another sheet, and then resets that row to it’s original state. Meaning it doesn’t completely delete the row or format, but only copies the contents.

Here’s the code I’ve been working with so far:

function MigrateInProgress() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();  
    var s = ss.getSheetByName('Copy of New Tickets');
    var s2 = ss.getSheetByName('In Progress');
    var r = s.getRange('G:G');    
    var v = r.getValues();  
    var dataset = [];
for(var i=v.length-1;i>=0;i--) 
    if(v[0,i]=='true') { 
        var data = s.getRange(i+1,1,1,6).getValues(); 
        s2.getRange(i+1,s2.getLastColumn()-6,data.length,6).setValues(data); 
        var datasetrange = s.getRange(i+1,1,1,6);
        datasetrange.clear({contentsOnly: true});
        datasetrange.clear({formatOnly: false});
        s.getRange(i+1,7).setValue(false);    
  }
}

Here’s some screenshots to help contextualize what I mean:

Screenshot 1

Screenshot 2

Screenshot 3

Any help would be greatly appreciated. Thank you!

Mobile browser positions elements as if the view is 360px wide, but renders images on the page at a higher resolution. How does this work?

I was having a hard time figuring out how to phrase this. Sorry if this is a noob question, I’m new to responsive design and mobile web design in general.

My phone (Galaxy s10e) will render my webpage as if it’s 360 pixels wide, with all elements positioned appropriately based on this width. I have several image tags on the site that are the same width. I was using src images that are 360px wide, and this looks fine on desktop because it is actually rendering my images at 360px, but on mobile the images alone appear to be rendering at a much higher resolution, causing it to look terrible due to upscaling.

If someone could explain to me what is happening here it would really help, since I can’t find information on this specific behavior. Some questions I have:

  • Is the browser choosing to position the elements based on a 360px width while rendering the actual content at the screen’s resolution?
  • How do I account for this in my design? I considered rendering the images at the higher resolution and then having the page dynamically scale those images down (so even though the actual div is 360px, the browser can use the ‘extra space’ allotted by max-width to render the image at a higher resolution), but I want the images to remain 360px wide on desktop, not the higher max-width for mobile rendering.
  • Where can I learn all about this behavior so I know how to tackle responsive image scaling in the future?

Thank you for your time. Let me know if you have any other questions. I’m using ReactJS to develop the site.