requerir faker y nuestra error module not fou [closed]

este error me da cuando ejecuto el comando node index.js

mm@MadMacBook-Pro src % node index.js
internal/modules/cjs/loader.js:329
      throw err;
      ^

Error: Cannot find module '/Users/mm/Desktop/ddd/node_modules/faker/index.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (internal/modules/cjs/loader.js:321:19)
    at Function.Module._findPath (internal/modules/cjs/loader.js:534:18)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:888:27)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.<anonymous> (/Users/mm/Desktop/ddd/src/index.js:1:15)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32) {
  code: 'MODULE_NOT_FOUND',
  path: '/Users/mm/Desktop/ddd/node_modules/faker/package.json',
  requestPath: 'faker'
}

enter image description here

How to make a dropdown menu transition with CSS?

I have created a responsive navigation-bar/menu but I want it to appear with a sliding animation from the top to the bottom when the needed button is presed. The menu does appear on itself but it completely ignores the transitioni have set it to execute. I tried multiple methods – using webkit library, using the change in height method, etc. It appears that none of them work with my code. If anyone can help, please reach to me.

const toggleButton = document.querySelector('.dot_a');
const navbarLinks = document.querySelector('.nav-list');

toggleButton.addEventListener('click', () => {
  navbarLinks.classList.toggle('active')
})
body {
  background-image: url(1.jpg);
  background-size: cover;
  background-repeat: no-repeat;
  background-attachment: fixed;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: bold;
  margin: 0;
}

.pro_column1 {
  width: 15%;
}

.pro_column2 {
  width: 85%;
}

.nav {
  overflow: hidden;
  background-color: white;
  /*opacity: 60%;*/
  margin: 10px;
  border-radius: 10px;
  width: 850px;
  /*background:#3c6382;
  /*box-shadow:0px 5px 20px rgba(0,0,0,0.1);*/
  /*border: solid black 2px;*/
}



.nav a {
  color: #747d8c;
  text-align: center;
  padding: 27px 10px;
  text-decoration: none;
  font-size: 17px;
  margin: 0;
  border-radius: 10px;
  transition: 1s;
}

.nav a:hover {
  background-color: #ddd;
  color: black;
  -webkit-animation: 1s ease-in forwards;
}

.dot_a {
  padding: 25px 10px;
  font-size: 17px;
  text-align: center;
  margin: 0;
  display: inline-block;
  border-radius: 10px;
  transition: 1s;

  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -o-user-select: none;
  user-select: none;
}

i {
  /*float: right;*/
  font-size: 20px;
  border: none;
  outline: none;
  color: #747d8c;
  padding: 25px 5px;
  font-family: inherit;
  margin: 0px;
  border-radius: 20px;
  transition: 1s;
}

.dot {
  height: 15px;
  width: 15px;
  border-radius: 50%;
  display: inline-block;
  margin: 0px;
}

.column {
  float: left;
  width: 33.33%;
  padding: 10px;
  height: 300px;
}

.row:after {
  content: "";
  display: table;
  clear: both;
}

@media screen and (max-width: 870px) {
  .nav a {
    padding-top: 5px;
    padding-bottom: 5px;
    display: block;

    
    
  }
  .dot_a {
    padding-top: 3px;
    padding-bottom: 0px;
  }
  .nav {
    width: 90%;
    
  }
  .dot {
    margin-top: 15px;
    margin-bottom: 15px;
  }


  .nav-list{  
    display: none;
    overflow: hidden;
  

  }

  .nav-list.active {
    display: block;
    overflow: visible;
    margin: 0;
    padding: 0; 
    -webkit-transition:max-height 500ms ease-in;
    -moz-transition:max-height 500ms ease;
    -o-transition:max-height 500ms ease;
    transition:max-height 500ms ease;

  
  }

}
<!DOCTYPE html>
<html>
<head>
<title>Начало</title>
<link rel="shortcut icon" type="image/png" href="favicon.jpg">
<link rel="stylesheet" href="IndexStyle.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://kit.fontawesome.com/d2896764d5.js" crossorigin="anonymous"></script>
</head>
<body>
<center>
<nav class="nav">
    <div class="dot_a">
      <span class="dot" style="background-color: transparent; width: 5px; height: 5px;"></span>
      <span class="dot" style="background-color: #ff4757;"></span>
      <span class="dot" style="background-color: #ffa502"></span>
      <span class="dot" style="background-color: #2ed573;"></span>
    </div>
    <span class="nav-list">
      <a class="anchors" href="Index.html"><i class="fas fa-house-damage"></i>&nbsp;&nbsp;НАЧАЛО</a>
      <a class="anchors" href="HtmlPage.html"><i class="fas fa-code"></i>&nbsp;&nbsp;HTML&CSS</a>
      <a class="anchors" href="#"><i class="fas fa-tools"></i>&nbsp;&nbsp;ИНСТРУМЕНТИ</a>
      <a class="anchors" href="#"><i class="fas fa-thumbtack"></i>&nbsp;&nbsp;ЗАДАЧИ</a>
      <a class="anchors" href="#"><i class="far fa-address-card "></i>&nbsp;&nbsp;ЗА НАС</a> 
    </span>
  </nav>
</center>
  <script src="ResponsiveMenu.js" ></script>
</body>
</html>

replit node.js to 000webhost

I’ve been trying to make one for a while but I’m just too bad.

I want it so when you type $whitelist (the ip)

it automatically changes only the

$ip = array(‘ip address’,);

on 000webhost main.php

please help

How to write a quickSort function using prototypes

How do you write a quickSort function using the prototype

//Start of Array function?
//I dont know what more to say or how to explain what I am doing here.

function ArrayList() {
     this.items = [];
    }
      ArrayList.prototype.insert = function(item) {
        this.items.push(item);
    }
      ArrayList.prototype.toString = function() {
        return this.items.join();
    }
    

//This is a function to create a non sorted array using the array function above

    function createNonSortedRandomArray(size) {
      var elements = size;
      var array = new ArrayList();
      for (var i=elements; i>0; i--) {
        array.insert(i);
      }
      return array;
    }
    
    swap = function(array, index1, index2) {
      var aux = array[index1];
      array[index1] = array[index2];
      array[index2] = aux;'

// quickSort function begins here

    ArrayList.prototype.quickSort = function() {
      quick(this.array, 0, this.array.length - 1);
    }
    
    quick = function(array, left, right) {
      var index;
    
      if (array.length > 1) {
    
        index = partition(array, left, right);
    
        if (left < index - 1) {
          quick(array, left, index - 1);
        }
    
        if (index < right) {
          quick(array, index, right);
        }
      }
    };
    
    partition = function(array, left, right) {
      var pivot = array[Math.floor((right + left) / 2)],
      i = left,
      j = right;
    
      while (i <= j) {
        while (array[i] < pivot) {
          i++;
      }
    
      while (array[j] > pivot) {
        j--;
      }
    
      if (i <= j) {
        swap(array, i, j);
        i++;
        j--;
      }
    }
    return i;
    
    };
    

// Execute code block here

    var array2 = new createNonSortedRandomArray(33);
    console.log(array2.toString());
    array2.quickSort();
    console.log(array2.toString());`

The action ‘NAVIGATE’ with payload {“name”:”Home”} was not handled by any navigator. Do you have a screen named ‘Home’?

I’m using the React NavigationV6 to create a static app for now.

After setting up my Navigation process like this Im having an issue moving to the Home Screen from the Login and Register Screen. And also the Home screen is not rendering the Bottom Tab which is meant to show icons.

I did it this way

package.json

    "@react-native-community/masked-view": "^0.1.11",
    "@react-native-masked-view/masked-view": "^0.2.6",
    "@react-navigation/bottom-tabs": "^6.0.9",
    "@react-navigation/material-bottom-tabs": "^6.0.9",
    "@react-navigation/native": "^6.0.6",
    "@react-navigation/native-stack": "^6.2.5",
    "@react-navigation/stack": "^6.0.11",
    "axios": "^0.24.0",
    "expo": "~44.0.0",
    "expo-status-bar": "~1.2.0",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "react-native": "0.64.3",
    "react-native-confirmation-code-field": "^7.2.0",
    "react-native-gesture-handler": "~2.1.0",
    "react-native-paper": "^4.11.2",
    "react-native-reanimated": "~2.3.1",
    "react-native-safe-area-context": "3.3.2",
    "react-native-safe-area-view": "^1.1.1",
    "react-native-screens": "~3.10.1",
    "react-native-vector-icons": "^9.0.0",
    "react-native-web": "0.17.1",
    "react-redux": "^7.2.6"

App.js

import React from "react";
import RootNavigation from './src/navigation/RootNavigation';

export default function App() {
  return (
      <RootNavigation/>
  );
}

RootNavigation.js

import React from "react";
import { NavigationContainer } from "@react-navigation/native";
import { SafeAreaProvider } from "react-native-safe-area-context";
import AuthNavigation from "./AuthNavigation";

const RootNavigation = () => {
  return (
    <SafeAreaProvider>
      <NavigationContainer>
        <AuthNavigation />
      </NavigationContainer>
    </SafeAreaProvider>
  );
};

export default RootNavigation;

AuthNavigation.js

import React from "react";
import { createStackNavigator } from "@react-navigation/stack";
// Screens
import Onboarding from "../screens/Auth/Onboarding";
import Login from "../screens/Auth/Login";
import Register from "../screens/Auth/Register";
import VerifyCode from "../screens/Auth/VerifyCode";
import ForgotPassword from "../screens/Auth/ForgotPassword";
import MainTabNavigation from "../navigation/MainTabNavigation";

const Stack = createStackNavigator();

const AuthNavigation = () => {
  return (
    <Stack.Navigator
      screenOptions={{ headerShown: false }}
      initialRouteName="Onboarding"
    >
      <Stack.Screen name="Onboarding" component={Onboarding} />
      <Stack.Screen name="Login" component={Login} />
      <Stack.Screen name="Register" component={Register} />
      <Stack.Screen name="VerifyCode" component={VerifyCode} />
      <Stack.Screen name="ForgotPassword" component={ForgotPassword} />
      <Stack.Screen name="MainTabNavigation" component={MainTabNavigation} />
    </Stack.Navigator>
  );
};

export default AuthNavigation;

MainTabNavigation.js

import React from "react";
import MaterialCommunityIcons from "react-native-vector-icons/MaterialCommunityIcons";
import { createMaterialBottomTabNavigator } from "@react-navigation/material-bottom-tabs";
import HomeStackNavigation from "../navigation/HomeStackNavigation";
import WalletStackNavigation from "../navigation/WalletStackNavigation";
import HistoryStackNavigation from "../navigation/HistoryStackNavigation";
import ProfileStackNavigation from "../navigation/ProfileStackNavigation";

const Tab = createMaterialBottomTabNavigator();

const MainTabNavigation = () => {
  return (
    <Tab.Navigator
      initialRouteName="Home"
      activeColor="#e91e63"
      barStyle={{ backgroundColor: "tomato" }}
    >
      <Tab.Screen
        name="Home"
        component={HomeStackNavigation}
        options={{
          tabBarLabel: "Home",
          tabBarIcon: ({ color, size }) => (
            <MaterialCommunityIcons name="home" color={color} size={24} />
          ),
        }}
      />
      <Tab.Screen
        name="Wallet"
        component={WalletStackNavigation}
        options={{
          tabBarLabel: "Wallet",
          tabBarIcon: ({ color, size }) => (
            <MaterialCommunityIcons name="home" color={black} size={24} />
          ),
        }}
      />
      <Tab.Screen
        name="History"
        component={HistoryStackNavigation}
        options={{
          tabBarLabel: "History",
          tabBarIcon: ({ color, size }) => (
            <MaterialCommunityIcons name="bell" color={color} size={24} />
          ),
        }}
      />
      <Tab.Screen
        name="Profile"
        component={ProfileStackNavigation}
        options={{
          tabBarLabel: "Profile",
          tabBarIcon: ({ color, size }) => (
            <MaterialCommunityIcons name="account" color={color} size={24} />
          ),
        }}
      />
    </Tab.Navigator>
  );
};

export default MainTabNavigation;

HomeStackNavigation.js

import React from "react";
import { createStackNavigator } from "@react-navigation/stack";
import Home from "../screens/Home/Home";
import Wallet from "../screens/Home/Wallet/Wallet";
import History from "../screens/Home/History/History";
import Profile from "../screens/Home/Profile/Profile";

const HomeStack = createStackNavigator();

const HomeStackNavigation = () => {
  return (
    <HomeStack.Navigator>
      <HomeStack.Screen name="Home" component={Home} />
      <HomeStack.Screen name="Wallet" component={Wallet} />
    </HomeStack.Navigator>
  );
};

export default HomeStackNavigation;

WalletStackNavigation.js

import React from "react";
import { createStackNavigator } from '@react-navigation/stack';
import Wallet from "../screens/Home/Wallet/Wallet";

const WalletStack = createStackNavigator();

const WalletStackNavigation = () => {
  return (
    <WalletStack.Navigator>
      <WalletStack.Screen name="Wallet" component={Wallet} />
    </WalletStack.Navigator>
  );
};

export default WalletStackNavigation;

Login.js

import React, { useState } from "react";
import {
  StyleSheet,
  View,
  Text,
  Image,
  TouchableOpacity,
  TextInput,
} from "react-native";

const Login = (props) => {
  const [email, setEmail] = useState();
  const [password, setPassword] = useState();

  return (
    <View style={styles.container}>
      <View style={styles.textContainer}>
        <View style={styles.backButtonContainer}>
          <TouchableOpacity onPress={() => navigation.goBack()}>
            <Image
              source={require("../../../assets/images/back-arrow.png")}
              style={styles.backButton}
            />
          </TouchableOpacity>
        </View>

        <Text style={styles.text}>Let's sign you in!</Text>
        <Text style={styles.textTwo}>Welcome back. You've been missed!</Text>
      </View>

      <View style={styles.registerFormContainer}>
        <View style={styles.textInputContainer}>
          <TextInput
            style={styles.textInput}
            onChangeText={setEmail}
            value={email}
            placeholder="Email"
          />
        </View>

        <View style={styles.textInputContainer}>
          <TextInput
            style={styles.textInput}
            onChangeText={setPassword}
            value={password}
            placeholder="Password"
          />
        </View>

        <TouchableOpacity style={styles.forgotPasswordButton} onPress={() => navigation.navigate("ForgotPassword")}>
          <Text style={styles.forgotPasswordText}>Forgot Password?</Text>
        </TouchableOpacity>

        <View style={styles.buttonContainer}>
          <TouchableOpacity
            style={styles.button}
            onPress={() => props.navigation.navigate("Home")}
          >
            <Text style={styles.buttonText}>Login</Text>
          </TouchableOpacity>
        </View>

        <View style={styles.haveAnAccount}>
          <Text>
            Dont Have an Account?
            <Text
              style={styles.haveAnAccountText}
              onPress={() => props.navigation.navigate("Register")}
            >
              {" "}
              Create One
            </Text>
          </Text>
        </View>
        
      </View>
    </View>
  );
};

export default Login;

Refactor custom route component after updating react-router-dom

I am working on a project, using this boilerplate https://github.com/ankushjain2001/fastapi-react-mongodb and updated the dependencies for the frontend to new major versions.

I already fixed some errors, but cant get custom routes refactored properly..

This is how it is used in the App.js
<ProtectedRoute path="/admin" exact strict component={Home} />

And this is the Component itself

export const ProtectedRoute = ({component: Component, ...rest}) => {
  return (
    <Route 
      {...rest}
      render={props => {
        // Goto the concerned route when authenticated
        if (auth.isAuthenticated()){
          return <Component {...props}/>
        }
        // Goto the default login page when not authenticated
        else {
          return (
            <div>
              <Landing {...props}/>
            </div>
          )
        }
      }}
    />
  );
};

The error I am getting is:

Uncaught Error: [ProtectedRoute] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>

How can i fix this? Thanks in advance 🙂

React bootstrap carousel not showing static video but audio is working, slides are present

import React from 'react';

import Carousel from 'react-bootstrap/Carousel';
import 'bootstrap/dist/css/bootstrap.min.css';
import { videoCarouselData } from './carouselData';
import Video from './Video';

const VideoCarousel = () => {
  return (
    <Carousel>
      {videoCarouselData.map((videoItem, index) => {
        return (
          <Carousel.Item key={index}>
            <Video video={videoItem.video} title={videoItem.title} />
            <Carousel.Caption>
              <h3>{videoItem.title}</h3>
              <p>{videoItem.detail}</p>
            </Carousel.Caption>
          </Carousel.Item>
        );
      })}
    </Carousel>
  );
};

export default VideoCarousel;

This is the react bootstrap video carousel

import React from 'react';
import { VideoContainer, VideoFile, VideoWrapper } from './VideoElements';
import Vid1 from '../../res/video/Alostro.mp4';

const Video = ({ video, title }) => {
  return (
    <>
      <VideoContainer>
        <VideoWrapper>
          <VideoFile
            width='560'
            height='315'
            src={video}
            title={title}
            frameborder='0'
            allowFullScreen
          />
          {console.log(video)}
        </VideoWrapper>
      </VideoContainer>
    </>
  );
};

export default Video;
import styled from 'styled-components';

export const VideoContainer = styled.div`
  position: relative;
  overflow: hidden;
  padding-top: 56.25%;
  /* width: 100vw;
  height: 100vh; */
`;

export const VideoWrapper = styled.div`
  position: relative;
  /* padding-bottom: 56.25%; 16:9 */
  height: 0;
`;

export const VideoFile = styled.iframe`
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: translate(-50%, -50%);
  border:0;

  @media (min-aspect-ratio: 16/9) {
    /* height = 100 * (9 / 16) = 56.25 */
    height: 56.25vw;
  }

  @media (max-aspect-ratio: 16/9) {
    /* width = 100 / (9 / 16) = 177.777777 */
    width: 177.78vh;
  }
`;

Video component and styling

import React from 'react';
import PictureCarousel from '../Components/PictureCarousel/PictureCarousel';
import { pictureCarouselData } from '../Components/PictureCarousel/pictureCarouselData';

import VideoCarousel from '../Components/VideoCarousel/Carousel';
import { videoCarouselData } from '../Components/VideoCarousel/carouselData';
import Video from '../Components/VideoCarousel/Video';

const Home = () => {
  return (
    <>
      <VideoCarousel />
      {/* <Video /> */}
      {/* <PictureCarousel slides={pictureCarouselData} /> */}
    </>
  );
};

export default Home;
Where video carousel will be rendered.

Where the video carousel is rendered

So I’m trying to create a video carousel using react bootstrap carousel. the videos do not show up but from dev tools i can see the carousel item is there and is in fact working, the audio even plays, but the videos do not show.

How do I a space between elements of flatMap function?

I am putting together a Pokédex application for a school project.
My tutor suggested I use a flatMap function to display pokémon types and abilities as there is sometimes more than one.

However, they just get listed with commas between them and no spacing. I’d like to add some spacing between the pokémon types. Can anyone help me with how to do that?

Code below:

function loadDetails(pokemon) {
    let url = pokemon.detailsUrl
    return fetch(url)
        .then(function (response) {
            return response.json()
        })
        .then(function (details) {
            pokemon.imageUrl = details.sprites.front_default
            pokemon.height = details.height
            pokemon.weight = details.weight
            pokemon.abilities = details.abilities.flatMap(
                (element) => element.ability.name
            )
            pokemon.types = details.types.flatMap(
                (element) => element.type.name
            )
        })
        .catch(function (e) {
            console.error(e)
        })
}

How can you use Javascript to duplicate a JSON object based on the value of a key in the object?

Considering the following JSON object example as input, how would you use Javascript to duplicate each object based on the number of times found in the “Count” key/value pair?

Example Input:

    [
   {
      "name":"David",
      "Count":2
   },
   {
      "name":"John",
      "Count":3
   }
]

Example Output:

    [
   {
      "name":"David"
   },
   {
      "name":"David"
   },
   {
      "name":"John"
   },
   {
      "name":"John"
   },
   {
      "name":"John"
   }
]

How to send an email with content from my javascript code

i am making a small testing website where i would like to receive an email when i sign or log into it.

<button id="username" type="submit" onclick="sendEmailL()">Log in</button>

<script src="https://smtpjs.com/smtp.js">
      (function sendEmailL() {
        emailjs.init("user_id");
        var templateParams = {
          name: 'Hello',
          notes: 'Welcome back ' + document.getElementById('username').value
        };
 
  emailjs.send("service_id","template_id", templateParams)
    .then(function(response) {
       console.log('SUCCESS!', response.status, response.text);
    }, function(error) {
       console.log('FAILED...', error);
    });
  })();
}</script>

Following EmailJS i could have made the perfect script i needed:

But at the last moment i saw that the Dynamic Attachments “Dynamic Attachments are used to send attachments from your JavaScript code” setting is not free and require a subscription ( which i don’t want to buy because i am just making things for my personal use ).

So is there any free alternative that can do exactly what i want to? Or is there any way to do this using EmailJS but not while not buying a sub? Thanks

Making a jQuery Custom Validator Optional

I added a custom validation method to jQuery Validation such as:

$.validator.addMethod('myregex', function (value) {
    return /d/.test(value);
}, 'Please enter a valid input.');

Note that I know there is a build in number check. That is just an example, I actually want to use more custom regex validators.

The problem is that now the field form is always required. Even if I set the value required to false in the code such as:

   $("form[name='my-form']").validate({
        // Specify validation rules
        rules: {
            form-field: {
                required: false,
                myregex: true
            },

I want my regex to check if the data entered on a field is valid, but not force the field to be completed as its optional.

Python: Microwave Timer

I am at a very beginner level with Python and I have a simple project for myself. My goal is to build a simple timer with only two functions using tkinter and python. The first button starts the countdown timer at 30 seconds. And the second button stops it. However, I would like each additional press of the first button to add an additional 30 seconds to whatever time is currently left on the countdown clock. The first two elements have proven not too difficult using this prior thread, but adding additional time to the active timer is something I cannot reach.

Essentially, the goal is to recreate the functionality of the “+30 seconds” button on a microwave, with an updating display, where the initial press both adds 30 seconds and starts the timer, each subsequent press adds an additional 30 seconds to the countdown timer, and the second button stops the timer.

Here’s what I’ve been using for the basic timer logic.

def countdown(t=30):
while t:
    mins, secs = divmod(t, 60)
    timer = '{:02d}:{:02d}'.format(mins, secs)
    print(timer, end="r")
    time.sleep(1)
    t -= 1
print('Done!')

How to make a simple text markup in HTML? [closed]

Is there a way I could add my own text markup?

What I mean by this is for e.g. I have an input field, and when I type a word for e.g. “apple” that word will be green, but if I type “orange” it will be the color orange.

Long story short, each word I type in the input field is a different color (which I will pre-set in my code)?

Is it possible to do this?