Merry christmas.
Now in this christmas season can anyone help me to create a code in shape of christmass tree which prints a christmass tree.
Category: javascript
Category Added in a WPeMatico Campaign
Why ^ in my javascript return a wrong number?
I need to do the XOR between 2 integer in js:
var s0 = 3739107566 ^ 500947912;
//11011110110111100100000011101110 ^ 00011101110110111101101111001000
and then I do the output:
console.log(s0);
If I use an online XOR calculator the output is 3271924518.
My output is -1023042778.
Can someone explain me why my output is complety wrong?
React native issue – IOS version of app works fine in all scenario but crashes the Android
I am having issues in my react native app where certain feature is crashing the app on android device, but it is working just fine on IOS devices. There is a reshare feature in my app which crashes android devices. Also when I navigate to some pages the android devices crash, but IOS version just works fine.
Can somebody provide me a reason on why it might be happening.
Its urgent so please let me know soon.
State hook not changing boolean value
In the code below I am having an issue.
I was trying to implement doubleClick behavious and the state hook for the boolean changes to trigger it. The problem is that even though handleDoubleClick function is triggered, setAllowSingleClick is not changing the value to false so than anyway the handleClick funtion is getting triggered.
const CLICK_DELAY_TIME = 200;
const [allowSingleClick, setAllowSingleClick] = useState(true);
let timer = 0;
const handleClick = () => {
timer = setTimeout(() => {
if (allowSingleClick) {
doSMTH1()
}
}, CLICK_DELAY_TIME);
};
const handleDoubleClick = () => {
clearTimeout(timer);
setAllowSingleClick(false);
doSMTH();
};
<div
onClick={handleClick}
onDoubleClick={handleDoubleClick}
>
Angular JS: How to load angular js partial view page in specific element after button click
Angular js partial view page not loading after the button click. I have loaded the initial rendering page, once we click the button. Partial view page will render, at this time angular modules are not triggered and not returning the proper text. How can I achieve this type of scenario?
Layout.cshtml
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - Application</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.8/angular.min.js"></script>
<script src="~/Scripts/app.js"></script>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
</head>
<body>
<div ng-app="myApp">
<div id="content"><button onclick="clicked()">Click Here</button></div>
</div>
@RenderBody()
<script>
function clicked() {
$.ajax({
type: "GET",
url: "/Home/About",
data: null,
dataType: "html",
contentType: 'application/json; charset=utf-8',
success: function (data) {
$('#content').append(data);
},
error: function (ex) {
console.log(ex);
}
});
}
</script>
</body>
</html>
app.js
var myApp = angular.module('myApp', []);
myApp.controller('MyController', ['$scope', function ($scope) {
// Function to be called on page load
$scope.firstFunction = function ($scope) {
$scope.text = "GeeksForGeeks"
}
}]);
HomeController.cs
public PartialViewResult About()
{
ViewBag.Message = "Your application description page.";
return PartialView(@"~/Views/Home/About.cshtml");
}
Partial View Page:
About.cshtml
<div ng-controller="MyController">
<center ng-init="firstFunction(this)">
<h1 style="color: green;">{{text}}</h1>
</center>
</div>
Note: While clicking the button, GeeksForGeeks needs to display,
here {{text}} is appending in UI element
Creating all possible unique permutations of objects with given constraints in javascript?
I have a problem related to maximising profits in an auction system.
Users are allowed to bid on 10 different items, across various rounds. In some cases, users can also bid on more than 1 item, i.e., make a combined bid on 2 or more items.
Each bid can be represented by a JSON object of the following format:
{
"user_id": 1,
"item_ids": [1]
"amount": 100
}
Where the user_id is unique identifier for the user submitting the bid, the item_ids array is the list of items that specific bid was made on, and the amount is the bid amount.
Considering there are 10 items available, and there are more than 20 users in the auction, I would like to create all possible permutation of bids with the following constraints
- Each item can only have 1 bid associated with it
- Each user must have at most one bid in the set
Once I have all possible permutations as stated above, I would like to be able to loop over all the sets, and compute the total amount for all bids in the set, and thus, select the collection of bids, which would maximise profits, given the constraints.
Any alternate methods to achieve this would also be appreciated.
how to change style on multiple classes after creating the classes?
so what im doing here its when the change event happens i want to create a new span element with the value on input field.
my question is how i can style every new span element with color red for example?
if i create for example 3 spans i have to specify which one i want to style like design[0].style.color = "red"; so this one will add the color red on the 1st span, so my goal its to make all spans i create with the color = "red"
my html
<body>
<div id="main">
<input type="text" id="msg" placeholder="type somthing here" onchange="getMessage()"><br>
</div>
</body>
my javaScript
function getMessage(){
var inel = document.getElementById("msg"),
mainel = document.getElementById("main");
let create = document.createElement("SPAN");
create.innerHTML += inel.value + "<br>";
mainel.appendChild(create)
let att = document.createAttribute("class")
att.value="list"
create.setAttributeNode(att)
var design = document.getElementsByClassName("list");
design.style.color = "red";
msg.value = "";
}
How can I pull data from another website?
We fill in the username and pass part. We press the try it out button.
I want it to take the data from the FullTokenString part and add it to the Authorization part in picture-3.
I want it to automatically write “example” in the path part. then the try it out button will be pressed.
enter image description here
I want to publish the data in the “value” field in the “response body” section on my own website.
Can you help with the algorithm or software to run this?
PDF with ADA compliance [closed]
Do you know if there’s a library I can use to create a PDF with ADA compliance?
I have searched for something like that but I haven’t found anything.
Thanks,
PHP Datepicker Validate if age is lower than 18 years old
can I do a warning validate from Datepicker and alert swal like this?
i do that and it error that is_string is not defined….
H E L P
i’m new in php btw
p.s. comment is a think that i tried to make in different way sorry abort that
form
<div class="form-group">
<label>Birthdate</label>
<div class="input-group date">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span><input type="text" class="form-control datepicker_class" id="birth_date" name="birth_date" onchange="validateAge">
</div>
</div>
function
function validateAge(){
var birthday = new $('#birth_date').val();
// let birthday = $('#birth_date').val();
// check = explode('/',birthday);
birthday = explode("/", birthday);
// alert(check);
if (is_string(birthday)) {
birthday = strtotime(birthday);
}
// check
// 31536000 is the number of seconds in a 365 days year. strtotime for 1 years : 31556926
if(time() - birthday < 18 * 31556926) {
swal({
title: "warning",
text: "your age is lower than 18",
type: "warning"
});
}
return true;
}
How to hide thecurrent page content and show the searched result using the react js?
I have created a newsfeed app where user can search according to publisher and title
and I have two routes / and /publisher and let’s say when I am on / I render the button and when I search and got the results I want to show only results and hide the buttons. i have created different component for search and result rendering here is the current working web app can anyone suggest a solution to get the result
https://newsfeed-33137.web.app/
Misspelling length in a for loop in a function doesn’t throw an exception. Why? [duplicate]
function multiplyAll(arr) {
let product = 1;
for (let i = 0; i < arr.lenght; i++) {
for (let j = 0; j < arr[i].length; j++) {
product = product * arr[i][j];
//console.log(product);
}
}
return product;
}
In the first for loop length has been misspelt but the the code doesn’t throw any error and does not even run.
How to iterate loop inside pure HTML table in react native
I am pushing my items in an array (table format) and then I am showing
that array in the table but it gets undefined.
class Invoice extends Component{
state= {
addItems = [];
}
template=()=>{
let items = "";
let items_array = [];
for(let i=0;i<this.state.addItems.length;i++)
{
items = (
<tr>
<td></td>
</tr>
)
items_array.push(items);
}
const html=`
<html>
<body>
<table>
<thead>
<tr>
<th>Item Name</th>
</tr>
</thead>
<tbody>
${items_array}
</tbody>
</table>
</body>
</html>
`
return html;
}
printToFile = async () => {
const html = this.template();
const { uri } = await Print.printToFileAsync({
html,
});
}
render(){
return(
<Button onPress={this.printToFile}>Print</Button>
)
}
}
Can anyone figure out what’s wrong with the code.
how to add subscript and superscript in LineControl editor
how to add subscript and superscript in LineControl editor
editor
How API request file should look like in React app? [closed]
I’ve joined a new project and I see that there are many places that duplicate axios request boilerplate code, for example the following file:
export class Api {
static sendEmail = async (mail: string) => {
const response = await axios({
method: 'post',
url: `${apiUrl}/auth/login`,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
data: {
email: mail
}
});
return response;
};
static getAdminDashboardData = async () => {
const response = await axios({
method: 'get',
url: `${apiUrl}/admin/dashboard`,
headers: {
Authorization: `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
});
return response;
};
static getIndices = async () => {
const response = await axios({
method: 'get',
url: `${apiUrl}/admin/indices`,
headers: {
Authorization: `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
});
return response;
};
static getListHr = async () => {
const response = await axios({
method: 'get',
url: `${apiUrl}/admin/partenaires`,
headers: {
Authorization: `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
});
return response;
};
static getListProvider = async () => {
const response = await axios({
method: 'get',
url: `${apiUrl}/admin/prestataires`,
headers: {
Authorization: `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
});
return response;
};
}
So I want to create a common file for all api calls. This is what I came up with so far.
import axios from 'axios';
export default axios.create({
baseURL: 'http://localhost:8080/api',
headers: {
'Content-type': 'application/json'
}
});
I know this file should be a little more advanced, i.e. filled with more options, so maybe someone can recommend how to structure it.