I want to exclude some number in the series without conditional statement
Eg:
exclude number 6 and 9 in the series of number 10
Blancer.com Tutorials and projects
Freelance Projects, Design and Programming Tutorials
Category Added in a WPeMatico Campaign
I want to exclude some number in the series without conditional statement
Eg:
exclude number 6 and 9 in the series of number 10
I’m looking for a solution to automate creation of Google apps (Google developer) to enable user login through user’s Google account.
A public webpage with a Google login would use the app.
It might be possible through Google API but I cannot prove this one.
The same issue would be with Facebook – I found one very old answer (=It is not possible to create an application using Graph API).
Is it possible to programmatically (through an API) modify an existing FB or Google app to add a new website (new domain).
Can you advice about the endpoints and calls, please?
I am trying to use NORDVPN servers for proxy. I can get it working if i use a socks client but i want to use the normal servers (if possible).
const getIpUrl = "https://api.ipify.org?format=json";
export const requestCurrentIp = () =>
axios.get(getIpUrl, {
httpsAgent: tunnel.httpsOverHttps({
proxy: {
host: vpn,
port: 89,
proxyAuth: `${username}:${password}`,
},
}),
});
When i do this, i get this message:
tunneling socket could not be established, cause=Hostname/IP does not match certificate's
altnames:
Host: api.ipify.org. is not in the cert's altnames: DNS:*.nordvpn.com, DNS:nordvpn.com
I am working on a Protractor – browserstack framework from scratch.
While using onComplete function as mentioned on the site in conf.ts – https://automate.browserstack.com/dashboard/v2/quick-start/get-started#introduction
// Code to mark the status of test on BrowserStack based on test assertions
onComplete: function (passed) {
if (!passed) {
browser.executeScript('browserstack_executor: {"action": "setSessionStatus", "arguments": {"status":"failed","reason": "At least 1 assertion has failed"}}');
}
if (passed) {
browser.executeScript('browserstack_executor: {"action": "setSessionStatus", "arguments": {"status":"passed","reason": "All assertions passed"}}');
}
}
I’m getting below error on Console
*Debugger attached.
conf.ts:87:1 – error TS2322: Type ‘(passed: any) => void’ is not assignable to type ‘() => void’.
87 onComplete: function (passed) {
node_modules/protractor/built/config.d.ts:410:5
410 onComplete?: () => void;
~~~~~~~~~~
The expected type comes from property 'onComplete' which is declared here on type 'Config'*
Can someone help me understand how to resolve this error?
4
I’m trying to write a javaScript cts query to query only unique values from a key from a json document based on another key. i.e, similar to a query like select distinct(name) from data-hub-staging where source=’source1′
{
"source": "source1",
"name": "John",
"DOB": "1-01-1990",
"load_date": "2021-10-23 10:23:55"
}
I have been trying the below query but it returns all the fields, I wanted only the name field.
const query = cts.jsonPropertyValueQuery(
"source",
"source1");
[...new Set (cts.search(query)
.toArray()
.map(doc => doc.root.name).sort())]
I am trying to import a gltf file in vue.js using babylon.js and add 3 dimensional view to the webpage. I can’t figure out how to do that and the documentation online is pretty vague as well. Here’s what I tried:
This is what I put in Hello.vue file
<div>
<h1> Hello </h1>
<Scene>
<Box :position="[0, 0, 5]"></Box>
</Scene>
</div>
</template>
<script src = "./Hello.js">
</script>
This is what I put in Hello.js file
import vb from 'vue-babylonjs';
import Hello from './Hello.vue';
Vue.use(vb);
new Vue({
components: { Hello },
render: c => c('Hello'),
}).$mount('#app');
var delayCreateScene = function () {
// Create a scene.
var scene = new BABYLON.Scene(engine);
// Create a default skybox with an environment.
var hdrTexture = BABYLON.CubeTexture.CreateFromPrefilteredData("../assets/magic_book_of_eden/textures/material_0_baseColor.png", scene);
var currentSkybox = scene.createDefaultSkybox(hdrTexture, true);
// Append glTF model to scene.
BABYLON.SceneLoader.Append("../assets/magic_book_of_eden/", "scene.gltf", scene, function (scene) {
// Create a default arc rotate camera and light.
scene.createDefaultCameraOrLight(true, true, true);
// The default camera looks at the back of the asset.
// Rotate the camera by 180 degrees to the front of the asset.
scene.activeCamera.alpha += Math.PI;
});
return scene;
};
If possible, could someone explain using an example how that could be done? I am getting the gltf model from sketchfab. Thank you!
I am trying to workout how to include a csv file link to a button within my react material table cell.
From the backend db, I have a column that holds a link to a csv file on a server, i.e.
filePath = 'https://my-file-server/files/outcome.csv'
that has been assigned to filePath
within my react component.
I then want to basically emulate a <a href={filePath}>Download CSV</a>
within my table cell, so tried using React-Router Link, i.e.:
import { Link } from 'react-router-dom';
<TableCell>
<Link to={filePath}>
<Button>
Download CSV
</Button>
</Link>
</TableCell>
Now I am running my app from localhost:3000/my-route
and when I click on my Download CSV
button, it actually changes my url path to:
http://localhost:3000/my-route/my-file-server/files/outcome.csv
which is not what I want. I actually expected it to point directly to:
https://my-file-server/files/outcome.csv
and then thought it would just download within my browser to my computer’s download directory.
Unsure what I am doing wrong?
I’ve a function that print out this format:
{
"name": "Google",
"url": "https:/google.com"
}
,
{
"name": "Facebook",
"url": "https://wts-kalix.polystar.net/Kalix/#/portal/619551b520fbf40c1cf22bad/618419244a4be06500ba0e8a"
}
,
And i need to delete the last comma so that the JSON format become valid which character should i use when it prints out
I am using react-contentEditable package from npm. When my user clicks a contact, I want to show a nice label, name, and also a button to remove this label from the editable div if the user wants.
I have the label and name figured out, but I cant seem to understand how to pass the onClick to a button when it is rendered like this below
`<label contentEditable="false" class="p-1 rounded-capsule">${contact.firstName + " " + contact.lastName + " "}<span class="badge fs--1 badge-soft-success badge-pill ml-2">${contact.phone_number}</span><button class="badge-pill badge-soft-primary">X</button></label>`)) // How do I pass an onClick to the button?
Here is the full component
import React, { useState, useRef, useEffect, Fragment } from 'react';
import ContentEditable from 'react-contenteditable';
const [toField, setToField] = useState({value: " ", html: " "})
const toFieldRef = useRef()
const addContactsToDiv = () => {
let selectedContactsArray = [] // create and empty array
const Matches = selectedRows.filter((row) => {
const isMatched = contacts.some(contact => { if(contact._id == row) {
selectedContactsArray.push({firstName: contact.firstName, lastName: contact.lastName, phone_number:contact.phone_number, _id: contact._id})
}})
return isMatched
})
const matchedContactsArray = []
selectedContactsArray.map(contact => { // mapping over selected to add html
// How can I add an onClick to the button when I have to pass it as string?
matchedContactsArray.push((`<label contentEditable="false" class="p-1 font-weight-bold bg-primary ml-2 text-white rounded-capsule shadow-none fs--3">${contact.firstName + " " + contact.lastName + " "}<span class="badge fs--1 badge-soft-success badge-pill ml-2">${contact.phone_number}</span><button class="badge-pill badge-soft-primary">X</button><span name="indy-contacts" class="d-none">${contact._id}</span></label>`))
})
matchedContactsArray.map(contact => { return contact})
const stringifiedRows = matchedContactsArray.toString() // push stringified results in to array
setToField({...toField, html: stringifiedRows}) // update state with array instead of updating state inside loop
}
<ContentEditable
name="to"
innerRef={toFieldRef} // passing our ref instead of state
html={toField.html} // the html = our ref.current property
//value={toField}
onBlur={handleBlur}
onClick={() => {handleClick()}}
onChange={handleChange} // this sets our refs.current = event.target.value
style={{minHeight: "7em", maxHeight: "10em", overflow: "auto"}}
className="border border-2x border-300 bg-light rounded-soft fs-1"
>
</ContentEditable>
This might have been asked before, but I have a situation where I have an object type which my backend expects like so:
type TagTypeThatMyBackendWants = {
id: string;
name: string;
}
It consist of two string type keys, the key names being id and name. I get these type of Tag-objects from my backend and my backend also expects objects like these back. Now, the problem is that I am using a library that handles these tags, but the library expects the objects to look like this:
type TagTypeThatALibraryWants = {
id: string;
text: string;
}
So it is basically the same object, but instead of a name key with a type of string, the library expects a text key with a type of string. I kind of already solved this by doing some custom mapping back and forth, but this raised the question if there is an “official” or a recommended way to do something like this – like casting from one object type to another, with the ability to tell TypeScript that the name-key “maps” to text-key and vice versa.
Im using a ref value to be able to only execute a click event if the ref value is changing
for example if I want to update/del the array inside let myRef = ref([]);
do i just drill inside the proxy and do the operations
like
selectedElements.value.push(3);
which returns
Proxy {0: 3}
or what is the correct way to update/del the ref.value ?
export default {
setup() {
let myRef = ref([]);
return {
myRef
};
},
};
</script>
I wrote a simple script to count words while typing in form
My question is why by changing the value of the word_count field when typing;
The EventListener of word_count is not fired
document.getElementById('subject').addEventListener('change', function() {
var string = this.value
string = string.replace(/s+/g, " ");
var words = string.split(/s+/).length;
document.getElementById('word_count').value = words;
}, false);
document.getElementById('subject').addEventListener('keypress', function() {
var string = this.value
string = string.replace(/s+/g, " ");
var words = string.split(/s+/).length;
document.getElementById('word_count').value = words;
}, false);
document.getElementById('word_count').addEventListener('change', function() {
alert('change fired');
}, false);
<form>
<div> <label for="story">string:</label>
<textarea id="subject" name="subject"></textarea>
</div>
<div> <label for="story">count:</label>
<input id="word_count">
</div>
</form>
I have some text like that:
"<loremipsum,1,2,3>val=5,<loremipsum,1,2,3,4,5>val=6,<loremipsum,1,9>val=75"
I want to split this text with comma after val variable as like that:
["<loremipsum,1,2,3>val=5", "<loremipsum,1,2,3,4,5>val=6", "<loremipsum,1,9>val=75"]
How can I split this text with comma after > character.
I’m working on a web application that has a custom camera screen, for which I’m supposed to implement tap to focus using getUserMedia
Here’s the code:
const permissionConstraints = {
video: {
width: { exact: 1280 }, height: { exact: 1280 },
aspectRatio: { ideal: 1 }, facingMode: 'environment' }
};
navigator.mediaDevices.getUserMedia(permissionConstraints).then((permissionsObj) => {
console.log(permissionsObj);
})
const ipv6="([a-zA-Z0-9]{1,4}+):([a-zA-Z0-9]{1,4}+):([a-zA-Z0-9]{1,4}+):([a-zA-Z0-9]{1,4}+):([a-zA-Z0-9]{1,4}+):([a-zA-Z0-9]{1,4}+):([a-zA-Z0-9]{1,4}+):([a-zA-Z0-9]{1,4}+)";
const regex = new RegExp(ipv6);
const result = SAMPLE_STRING.match(regex);
console.log(result);
run code result is
SyntaxError: Invalid regular expression: /([a-zA-Z0-9]{1,4}+):([a-zA-Z0-9]{1,4}+):([a-zA-Z0-9]{1,4}+):([a-zA-Z0-9]{1,4}+):([a-zA-Z0-9]{1,4}+):([a-zA-Z0-9]{1,4}+):([a-zA-Z0-9]{1,4}+):([a-zA-Z0-9]{1,4}+)/: Nothing to repeat
The ‘ipv6’ works with a regex-compiler, but not with javascript.
And i must use the ‘new Regex’ object.
how can i make the work?