I need a regex to capture both Yellow Green: and Blue Purple: from the following body of text, the format is multiline.
Yellow Green: undefined characters/symbols/spaces
Blue Purple: undefined characters/symbols/spaces
Blancer.com Tutorials and projects
Freelance Projects, Design and Programming Tutorials
Category Added in a WPeMatico Campaign
I need a regex to capture both Yellow Green: and Blue Purple: from the following body of text, the format is multiline.
Yellow Green: undefined characters/symbols/spaces
Blue Purple: undefined characters/symbols/spaces
I am developing a code playground. Everything works in my computer,
It has a saving system. Encodes your code and puts it in the URL. When page loads, gets the code from the URL. It works perfectly fine. It uses Vite, vanilla JS, and I used the Vite setting on Vercel, but the saving system doesn’t work. When you reload, instead of getting the code, It gives a 404 error message, as the URL isn’t on the dist folder.
What can I do?
Complete code: https://github.com/L1ghtingBolt/codeebox/
When I console.log the data I get from firestore inside the then() function as shown below, it displays the data without the problem. However, if I append that data in the peopleData variable and console.log the peopleData variable, I get an empty string.
let db = getFirestore();
let peopleCollection = collection(db, 'People');
getDocs(peopleCollection)
.then((people) =>{
people.docs.forEach(person =>{
let personData = person.data(person);
console.log(`${personData.Name} is an ${personData.Occupation} aged ${personData.Age}`);
})})
.catch(err =>{
console.log(err)
})
Here I get an empty string logged
let peopleData = ``;
getDocs(peopleCollection)
.then((people) =>{
people.docs.forEach(person =>{
let personData = person.data(person);
peopleData += `${personData.Name} is an ${personData.Occupation} aged ${personData.Age}`;
})})
.catch(err =>{
console.log(err)
})
console.log(peopleData);
https://codepen.io/wr234/pen/LYzBLbY
$(".swiper-slide").click(function(e){
console.log("test");
});
Hi im using Swiper slider.
But the event does not run when clicking on an element created by loop.
If you click slider1 created with loop after slider4, console.log is not captured.
How can we make an event happen?
$(".swiper-slide").click(function(e){
console.log("test1");
});
$(".swiper-slide").on("click", function(e){
console.log("test2");
});
var swiper = new Swiper(".mySwiper", {
slidesPerView: 3,
centeredSlides: false,
spaceBetween: 10,
loop: true,
loopFillGroupWithBlank: 1,
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
touchRatio: 0,
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Swiper demo</title>
<meta
name="viewport"
content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1"
/>
<!-- Link Swiper's CSS -->
<link
rel="stylesheet"
href="https://unpkg.com/swiper/swiper-bundle.min.css"
/>
<!-- Demo styles -->
<style>
html,
body {
position: relative;
height: 100%;
}
body {
background: #eee;
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
font-size: 14px;
color: #000;
margin: 0;
padding: 0;
}
.swiper {
width: 100%;
height: 100%;
}
.swiper-slide {
text-align: center;
font-size: 18px;
background: #fff;
/* Center slide text vertically */
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
}
.swiper-slide img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
.swiper {
margin-left: auto;
margin-right: auto;
}
</style>
</head>
<body>
<!-- Swiper -->
<div class="swiper mySwiper">
<div class="swiper-wrapper">
<div class="swiper-slide">Slide 1</div>
<div class="swiper-slide">Slide 2</div>
<div class="swiper-slide">Slide 3</div>
<div class="swiper-slide">Slide 4</div>
</div>
<div class="swiper-button-next"></div>
<div class="swiper-button-prev"></div>
<div class="swiper-pagination"></div>
</div>
<!-- Swiper JS -->
<script src="https://unpkg.com/swiper/swiper-bundle.min.js"></script>
<!-- Initialize Swiper -->
<script>
/*
$(".swiper-slide").click(function(e){
console.log("test");
});
*/
</script>
</body>
</html>
So I call my backend.js
from my python code like this
# server is requested to start
startServer = subprocess.Popen(['node', 'backend.js'])
# startServer.wait()
if startServer.poll:
print('Server could not be started')
sys.exit()
And my backend.js
contains
app.listen(port, () => {
console.log(`Server is listening at http://localhost:${port}`);
});
How can the backend tell python that server for some reason failed to start and exit the program or server has started and now you can go ahead? I have tried waiting for the startServer to end but that just stops the python code until server is stopped. So is there a way by which the callback function in app.listen
can send information to the python code?
I have a function to validate in input field / date field. When using (keypress) it is working fine on web but not in mobile. And when I am using (keyup) , the validation is not working in web as well.
What is the permanent solution for PWA Angular for this issue ?
// to validate date in numberic and / only
keyPressAlphanumeric(event: any) {
var inp = String.fromCharCode(event.keyCode);
if (/[0-9_/]/.test(inp)) {
return true;
} else {
event.preventDefault();
return false;
}
}
<input matInput [matDatepicker]="picker" maxlength="10" [max]="maxDate" placeholder="MM/DD/YYYY" required
formControlName="DOI" autocomplete="off" (keypress)="keyPressAlphanumeric($event)">
How can I convert the following Curl to Ajax Call?
this curl is sending a request to GeoServer to publish all layers with matching names coming from the tables.txt file
for /f %%a in (tables.txt) do curl -v -u admin:geoserver -XPOST -H "Content-type: text/xml" -d "<featureType><name>%%a</name></featureType>" http://localhost:8080/geoserver/rest/workspaces/cite/datastores/geonode/featuretypes
pause
I have tried the following methods.
await fetch("localhost:8080/geoserver/rest/workspaces/cite/datastores/…", {
method: 'POST',
headers: {
"Content-type": "text/xml"
},
body: {
"<featureType><name>totalpotatoyield2020</name></featureType>": ""
},
auth: {
"user": "admin",
"password": "geoserver"
}
})
Sit excepturi est voluptatibus ut amet aut tenetur excepturi id sit ut quia molestiae reiciendis qui soluta et omnisSit excepturi est voluptatibus ut amet aut tenetur excepturi id sit ut quia molestiae reiciendis qui soluta et omnisSit excepturi est voluptatibus ut amet aut tenetur excepturi id sit ut quia molestiae reiciendis qui soluta et omnisSit excepturi est voluptatibus ut amet aut tenetur excepturi id sit ut quia molestiae reiciendis qui soluta et omnisSit excepturi est voluptatibus ut amet aut tenetur excepturi id sit ut quia molestiae reiciendis qui soluta et omnisSit excepturi est voluptatibus ut amet aut tenetur excepturi id sit ut quia molestiae reiciendis qui soluta et omnis
I should call an API then use it’s data as parameter for another request:
const { data, isLoading, error } = useQuery('fetchAvailableProducst', fetcher, { enabled: false });
const sendOrder = (categoryID) => {
const availableProducst = /* function to fetch a list of category */
const ids = [];
availableProducst.map(item => {
ids.push(item.id);
});
sendOrderMutation.mutate(ids);
}
the above code doesn’t work, I just written for mentioning to an idea… Actually I’m looking for a way to add something like await
before availableProducst
(which comes by useQuery()
) to get list then fill ids
and then call sendOrderMutation
to send order…
But is there any way to use await
for useQuery()
data?
I have 2 pages, index.html, and tracklist.html. For my webpage, I want to get an artist’s name and an album name from 2 text boxes on index.html, use those as the parameters for my getAlbumTracks() function, and display the array of tracks on tracklist.html after clicking a search button (button is on index.html).
Below I have my index.html, tracklist.html, and app.js, and as of right now, when I run getAlbumTracks() in the console on tracklist.html with manually inputted parameters, I am able to display the array on the page, like this: https://gyazo.com/af94a5c5966d9c1cbaea74369a35add2 but don’t know how to do it with user input from textboxes on a different page. I’m a bit new to javascript so any help is appreciated, thanks!
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Rank It</title>
<link rel="stylesheet" href="style.css" />
<script src="app.js"></script>
</head>
<body>
<form action="tracklist.html">
<div>
<div>
<div class="search">
<input
type="text"
id="album"
class="searchbar"
placeholder="Album Name"
/>
</div>
</div>
<br /><br />
<div>
<div class="search">
<input
type="text"
id="artist"
class="searchbar"
placeholder="Artist's Name"
/>
</div>
</div>
<br /><br />
<div>
<div class="search">
<input type="submit" value="Click" onclick="display" />
</div>
</div>
</div>
</form>
</body>
</html>
tracklist.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style2.css" />
<script src="app.js"></script>
<title>Rank It</title>
</head>
<body>
<div class="tracklist">
<div id="arrPrint"></div>
</div>
</body>
</html>
app.js:
async function getAlbumTracks(AlbumName, ArtistName) {
//API that gets json file of album information given artist's name and album name
const response = await fetch("https://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=d94b7d68284cbab1cdb7c2c3c81fd913&artist="
+ ArtistName + "&album=" + AlbumName + "&format=json")
const data = await response.json();
//Declaring numberOfTracks and TrackList array
const numberOfTracks = data.album.tracks.track.length;
const TrackList = [];
//For Loop that gets each song name and puts them in TrackList[]
for (let i = 0; i < numberOfTracks; i++) {
TrackList[i] = data.album.tracks.track[i].name;
}
//All the code below is used to display the tracks with numbers on the webpage
let arrPrint = document.getElementById("arrPrint");
let list = "<ol>";
for (let i = 0; i < numberOfTracks; i++) {
list += "<li>" + TrackList[i] + "</li>";
}
arrPrint.innerHTML = list;
}
//Function that is supposed to take user input and call the getAlbumTracks function but it doesn't work
function displayAlbumTracks() {
let Album = String(document.getElementById("album").value);
let Artist = String(document.getElementById("artist").value);
getAlbumTracks(Album, Artist);
}
<input class="input" pInputText [disabled]="disabled" [(ngModel)]="data.input.value"
(change)="inputOnChanges()" (keypress)="keyPress($event)" >
.ts file
const pattern = /^[+]?([0-9]+(?:[.][0-9]*)?|.[0-9]+)$/;
console.log('event is::',event);
const inputChar = String.fromCharCode(event.charCode);
if (!pattern.test(inputChar)) {
// invalid character, prevent input
event.preventDefault();
}
I am using above regex. Also, it says charCode is deprecated.
HI I have created a filter functionality, which has two dropdowns, on the basis of selection of these dropdowns select it shows the results, but I want to modify it a little, what I am trying to achieve is, on select of single dropdown it should also show the result, which is currently not showing, please help me modify this code`
<script>
$('#city, #state').on('change', function(){
// set reference to select elements
var city = $('#city');
var state = $('#state');
// check if user has made a selection on both dropdowns
if ( city.prop('selectedIndex') > 0 && state.prop('selectedIndex') > 0) {
// remove active class from current active div element
$('.result.active').removeClass('active');
// get all result divs, and filter for matching data attributes
$('.result').filter('[data-city="' + city.val() + '"][data-state="' + state.val() + '"]').addClass('active');
}
});
</script>
<style>
.result {display:none;}
.result.active {display:block;}
</style>
<!-- partial:index.partial.html -->
<select id="city">
<option value="select">CITY</option>
<option value="beaches">Noida</option>
<option value="museums">Mahrastra</option>
<option value="mountains">Delhi</option>
</select>
<select id="state">
<option value="select">STATE</option>
<option value="chill">UP</option>
<option value="fast-paced">Mahrastra</option>
<option value="both">Delhi</option>
</select>
<div class="result" data-city="beaches" data-state="chill" data-pincode="glenchill">glen gallery one</div>
<div class="result" data-city="beaches">no gallery</div>
<div class="result" data-city="beaches" data-state="fast-paced" data-pincode="glenfast-paced">glen gallery two</div>
<div class="result" data-city="beaches" data-state="both" data-pincode="glenboth">glen gallery two</div>
<div class="result" data-city="beaches" data-state="glenchill">beaches and chill glenn</div>
<div class="result" data-city="beaches" data-state="glenfast-paced">beaches and fast-paced glenn</div>
<div class="result" data-city="beaches" data-state="glenboth">beaches and both glenn</div>
<div class="result" data-city="museums" data-state="chill">museums and chill</div>
<div class="result" data-city="museums" data-state="fast-paced">museums and fast-paced</div>
<div class="result" data-city="museums" data-state="both">museums and both</div>
<div class="result" data-city="mountains" data-state="chill">mountains and chill</div>
<div class="result" data-city="mountains" data-state="fast-paced">mountains and fast-paced</div>
<div class="result" data-city="mountains" data-state="both">mountains and both</div>
`
I’ve been working on my Django App for a couple of months now and decided to use React as my front-end, which I know is bad habit for development and makes everything a lot more complicated. I run npm build for my front-end app with Django, but when I launch the Django Project, it shows me the Django Rest Apis. When I wanted it to show me my UI, I built in React. Everything in my Django settings should be correct from tutorials and documentations, so I believe that isn’t the issue. I’ve tried calling the my API’s but I believe that isn’t the issue either.
I am trying to keep everything as simple as possible, so if I’m missing stuff in my code I apologize, I just want to understand the very basics of React without having a lot of side code.
Here is my App.js
import React from 'react';
import './App.css';
import Form from './Form';
class App extends React.Component {
render(){
return(
<Form />
)
}
}
export default App;
index.js
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
I am trying javascript to print out json data.
https://devsheet.com/code-snippet/editorjs-blocks-json-to-html-javascript/
I have tried this sample code but undefined problem occurs.
obj = '{"header":"John", "paragraph":30, "list":"New York"}';
html = '';
Object.keys(obj).forEach(function(block, index) {
console.log(block['type']); // it prints undefined, it is expected to print keys (header, paragraph, etc.)
switch (block['type']) {
case 'paragraph':
html += '<p>'+ block['data']['text'] +'</p>';
break;
case 'header':
html += '<h'+ block['data']['level'] +'>'+ block['data']['text'] +'</h'+ block['data']['level'] +'>';
break;
...
...
console.log(block[‘type’]); <—- it prints undefined, it is expected to print keys (header, paragraph, etc.)
How can I solve it?