Skip to main content

Posts

Validating Year in a date using JavaScript

I want to validate a person's date of birth and I am stuck trying to figure out how to go about checking if the YEAR of birth is valid using the ISO date format like this yyyy-mm-dd. I want to check if the year is valid and then use the last 2 digits of the year. So I want the format to be yy-mm-dd after validating the year. I have checked the month and the day but I am struggling to figure out how to validate the year before and after 2000. This is my code for checking MONTH and DAY function checkDateOfBirth(dateString){ const year = dateString.substring(0, 2); const month = dateString.substring(2, 4); const day = dateString.substring(4, 6); if ( day > 31 || month > 12 || (month == 2 && day > 29) || (month == (4 || 6 || 9 || 11) && day > 30) ) { return false; } return true; } The input string would be "940912" in the format yy-mm-dd. Any help/suggestions would be great Via Ac

How to make all video tags muted, except of 'this one'?

I have a video gallery, each item looks like <video muted="" allowfullscreen="" autoplay="" controls="" controlslist="nodownload noplaybackrate" disablepictureinpicture="" class="story loop="" poster="" style="max-height: 500px; width: 349px;" id=""> <source src="https://example.com/video.mp4" type="video/mp4"> </video> They have to look like gifs - on autoplay, and if user switches on the sound on one of the video, the others have to became muted, because now it's possible to switch on the sound on more then one video, and it's too much sound. I tried already that ways, and they didn't help 1 jQuery('video').on('volumechange', function() { jQuery('video').attr('muted'); jQuery(this).removeAttr('muted'); }) 2 jQuery('video').on('volumechange', function() { jQu

How to remove the error in python when there is no syntax error and program is executing partially but the program is not fully executing?

a=2 print("Enter x") x = int (input()) if (x<=1): print ("Prime numbers are integers greater than 1.") else: for i in range(2,x-1): remainder = x % i if remainder == 0 : status= 0 if status == 0: print ("x is not a prime number.") elif status == 1: print("x is a prime number.") if status == 0: print ("Factors of x:") for z in range (1,x): if x % z == 0: print(z) print ("Y=8X*X+1 = ",y) print ("Evaluation of the equation (Y=8X*X+1) for the values of x from -5 to 5:") for x in range (-5,5): y = 8 * x ^ 2 + 1 This is a Python program: used to determine whether a number entered ,X, is prime or not. If the number is prime the program will display all its factors. Then it will evaluate the equation: "Y= 8X^2 + 1" for the values of from -5 to 5. The program is debugging and there is no syntax error in the program. The program runs and only take the Input X and ends. The whole program is not executing. sou

Python code to read Excel files with 2.4m data and then generate 3 excel file of 1m,1m, .4m data [closed]

I have a excel file in which we have 2.4m data so because of Excel 1m limitation I'm unable to open it. I want to write python code which reads the data of big excel and also split data in 3 excel of 1m,1m,.4m data count I have tried using openpyxl able to read data but not able to generate 3 files. source https://stackoverflow.com/questions/75164123/python-code-to-read-excel-files-with-2-4m-data-and-then-generate-3-excel-file-of

NPM Error OpenSSL Configuration npm command does not work ANYWHERE

I use Node JS, like everyone else. Everything used to run smoothly. Creating a React App and starting it. But, recently, it has started to give me this error: C:\Program Files\nodejs\node.exe: OpenSSL configuration error: 48370000:error:8000007B:system library:BIO_new_file:Unknown error:c:\ws\deps\openssl\openssl\crypto\bio\bss_file.c:67:calling fopen(D:\openssl-1.0.2j-fips-D:\openssl-1.0.2j-fips-x86_64\OpenSSL\bin\openssl.cnf, rb) I am running Windows 11 and have tried everything available on the internet, and ChatGPT. No solution. A little help maybe? P.S. I have already tried the already answered question to this but it doesn't work for me Everything available on the internet Via Active questions tagged javascript - Stack Overflow https://ift.tt/dHsOnVo

How to make an asynchronous process as synchronous in javascript

I am currently developing a plugin for eslint. I have encountered the following problem. I want to make hot changes to the configuration file, so we are required to make an Http request to get the JSON file with the configuration. As for the context execution when reading the package.json, and traversing the scripts, when adding async/await, it executes in node the code, but does not return the context response from the context object. If I do it with callbacks exactly the same thing happens. I leave you the code so that you have a visual idea of the problem. With Promises using then(), catch(), doesnt works too. I think that what I am asking for in the JavaScript world is not possible, but by asking I don't lose anything. I understand that the functions like execSync, are native inside the C core written in JavaScript, and that's why they can be executed synchronously. Thanks and greetings. 'use strict'; const { readFileSync } = require("fs"); //------

The term 'pip' is not recognized as the name of a cmdlet, function, script file, or operable program error installing Selenium Python bindings

I am trying to install python selenium pip install selenium but I get this error: File "<stdin>", line 1 pip3 install selenium ^^^^^^^ SyntaxError: what is the solution for invalid syntax Snapshot: source https://stackoverflow.com/questions/75152111/the-term-pip-is-not-recognized-as-the-name-of-a-cmdlet-function-script-file