How would I export data as a JSON format from MongoDB Atlas?
I can Export Data from MongoDB Compass but I can’t find any option on MongoDB Atlas to export it
Blancer.com Tutorials and projects
Freelance Projects, Design and Programming Tutorials
Category Added in a WPeMatico Campaign
How would I export data as a JSON format from MongoDB Atlas?
I can Export Data from MongoDB Compass but I can’t find any option on MongoDB Atlas to export it
My backend schema for portfolio is array of type String that contains the path of the images.
I even tried:
portfolio: {
type: [String],
},
gave same result.
and its response looks something like this (notice it’s array of paths)
this is how my axios.get looks like,
if i use the responseType: blob, it gives back object like this
this is affecting the my process of displaying array of paths that i have, convert them into blob to be able to display them on frontend
even though i tried to manually convert the blobs into array again (the for loop in my code), it looks like this now, but still unable to load the files
Doing some searching, I realized that some people add “use strict”; into their JavaScript code. Once I added the statement, the error stopped appearing. Unfortunately, Google did not reveal much of the history behind this string statement. Certainly it must have something to do with how the JavaScript is interpreted by the browser, but I have no idea what the effect would be.
So what is “use strict”; all about, what does it imply, and is it still relevant?
Do any of the current browsers respond to the “use strict”; string or is it for future use?
Im trying to fix this bug, and I have tried alot things but nothing help, if I give x value I can fix bug on safari but than bug repodruces on other browsers(mozila,chrome etc…), anyhow the bug is reproducing once in many times on other browsers …
<div class="CoveoShowIfFieldValue" data-field="@isRecommended" data-field-value="True">
<svg height="25px" style="overflow:visible!important;">
<g id="recommendedBadge" style="object-fit:contain!important;">
<rect x="0" y="0" rx="15px" ry="15px"/>
<text id="badgeText" y="66%" font-family="Metric" text-anchor="middle" class="CoveoText" data-value="RECOMMENDED" style="text-transform: uppercase;"></text>
<g class="tooltip" transform="translate(21,62)">
<rect x="-6%" width="450" y="-35" height="25" rx="5px" ry="5px"/>
<text y="-31" dy="1em" font-family="Metric" text-anchor="middle" font-weight="100" class="CoveoText" data-value="RecommendedTooltip"></text>
</g>
</g>
</svg> </div>
Im trying to solve the anagram counter in node js but I cant seem to figure it out.
These are the input and outputs of the program.
{
Input
Input contains up to 200 words, one per line. Each word consists of upper- and lower-case letters (a–z) and may have as many as 100 characters. Input ends at end of file.
Output
For every input word, output the total number of unique anagrams that can be made from it. For the purpose of this problem, upper- and lower-case letters are considered distinct.
}
I was wondering if anyone has a solution for it in node js.
I want to write my own barcode reader in JavaScript to be used on an iPhone. I have coded lots of other JavaScript projects before, so I’m quite experienced with html + JavaScript + css, but I’m not familiar with accessing the camera via JavaScript. But I found a nice tutorial and hoped to learn from it. But there seems to be an error in this tutorial.
Here is the tutorial: https://usefulangle.com/post/352/javascript-capture-image-from-camera
Here is the demo: https://usefulangle.com/demos/352/camera-capture-photo.html
And here is the complete source code of this demo, as available today, at 2022-05-21 (html, css and JavaScript are all included in one file):
<!DOCTYPE html>
<html><head>
<title>Demo - Capture Photo From Webcam Using Javascript</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
<style type="text/css">
button {
width: 120px;
padding: 10px;
display: block;
margin: 20px auto;
border: 2px solid #111111;
cursor: pointer;
background-color: white;
}
#start-camera {
margin-top: 50px;
}
#video {
display: none;
margin: 50px auto 0 auto;
}
#click-photo {
display: none;
}
#dataurl-container {
display: none;
}
#canvas {
display: block;
margin: 0 auto 20px auto;
}
#dataurl-header {
text-align: center;
font-size: 15px;
}
#dataurl {
display: block;
height: 100px;
width: 320px;
margin: 10px auto;
resize: none;
outline: none;
border: 1px solid #111111;
padding: 5px;
font-size: 13px;
box-sizing: border-box;
}
</style>
</head>
<body>
<button id="start-camera">Start Camera</button>
<video id="video" width="320" height="240" autoplay=""></video>
<button id="click-photo">Click Photo</button>
<div id="dataurl-container">
<canvas id="canvas" width="320" height="240"></canvas>
<div id="dataurl-header">Image Data URL</div>
<textarea id="dataurl" readonly=""></textarea>
</div>
<script>
let camera_button = document.querySelector("#start-camera");
let video = document.querySelector("#video");
let click_button = document.querySelector("#click-photo");
let canvas = document.querySelector("#canvas");
let dataurl = document.querySelector("#dataurl");
let dataurl_container = document.querySelector("#dataurl-container");
camera_button.addEventListener('click', async function() {
let stream = null;
try {
stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: false });
}
catch(error) {
alert(error.message);
return;
}
video.srcObject = stream;
video.style.display = 'block';
camera_button.style.display = 'none';
click_button.style.display = 'block';
});
click_button.addEventListener('click', function() {
canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
let image_data_url = canvas.toDataURL('image/jpeg');
dataurl.value = image_data_url;
dataurl_container.style.display = 'block';
});
</script>
</body></html>
The problem is, that this demo works well on some of my devices, but fails on others. Among the failing devices it performs worst on iPhone 8, but this is the device I need most to work perfect, because I want to use my iPhone as barcode scanner.
Computer: do-it-yourself Hackintosh (MacOS Catalina 10.15.7 on non-Apple hardware)
Camera: logitech HD Webcam C525
The demo works fine on all of these browsers:
12 years old Macbook Pro (13 inch, Mid 2010)
MacOS Catalina Version 10.15.7 (unsupported version installed with Catalina Patcher)
The demo works fine on all of these browsers:
Notebook “hp Elitebook”
Windows 10 Enterprise version 21H2
The demo works fine on all of these browsers:
iPad Pro, 12.9 inch, 3rd generation
iPadOS Version 15.4.1
The demo works fine on all of these browsers, but only in portrait mode!
iPad Pro, 12.9″, 3rd generation
iPadOS Version 15.4.1
in landscape mode
Same error in all browsers: Distorted captured image: The live image is in portrait mode, the captured image is landscape, showing my face double as wide as it really is.
iPhone 8
iOS Version 15.4.1
The live image is black on all browsers. You see just a black rectangle
In landscape mode: The captured image is ok (user’s face is visible and not distorted)
In portrait mode: Distorted captured image (as described for iPad in portrait mode)
Failing does not depend on the browser but on the device. The demo works even on exotic machines like a Hackintosh or a 12 years old Macbook Pro but fails with two different errors on an iPhone 8.
There are two errors:
Please, I need a correction of the demo code, so that it shows the live video image on all devices, including iPhone 8. The corrected code please also shall not show any distorted captured image in portrait mode of mobile devices.
Optional additional question: (An answer would be nice, but more important is an answer to the issue described above)
I have written a barcode scanner for iPhone 3 and iPhone 4 about 10 years ago in native Objective-C. It was no problem to have a video image 320 pixels wide and only 80 pixels high (to scan EAN-13 and other linear barcodes). Is it possible to have such a 4:1 video window also when using html + JavaScript?
need help badly! I’m trying to add a lazy load feature to my project using vanilla javascript but it only loads the first image and other images remain blurred and not loading.
Here is script:
// Lazy loading images
const imgTargets = document.querySelectorAll('img[data-src]');
const loadImg = function (entries, observer) {
const [entry] = entries;
if (!entry.isIntersecting) return;
// Replace src with data-src
entry.target.src = entry.target.dataset.src;
entry.target.addEventListener('load', function () {
entry.target.classList.remove('lazy-img');
});
observer.unobserve(entry.target);
};
const imgObserver = new IntersectionObserver(loadImg, {
root: null,
threshold: 0,
rootMargin: '200px',
});
imgTargets.forEach(img => imgObserver.observe(img));
HTML CODE:
<div class="popup swiper-slide swiper-slide2 first-non" style="background: transparent;">
<img class="lazy-img fetures__img"
src="assets/theme/images/laz-non-legendary-1.png"
data-src="assets/theme/images/non-legendary-1.png" />
</div>
<div class="popup swiper-slide swiper-slide2 first-non" style="background: transparent;">
<img class="lazy-img fetures__img"
src="assets/theme/images/laz-non-legendary-2.png"
data-src="assets/theme/images/non-legendary-2.png" />
</div>
<div class="popup swiper-slide swiper-slide2 first-non" style="background: transparent;">
<img class="lazy-img fetures__img"
src="assets/theme/images/laz-non-legendary-3.png"
data-src="assets/theme/images/non-legendary-3.png" />
</div>
Here’s CSS just for blur effect:
.lazy-img {
filter: blur(20px);
}
I need to get access token from SharePoint, In order to upload some files!
I got access token from postman successfully, But when I try to do the same request with Javascript!
const generateToken = async () => {
const headers = { "Content-Type": "application/x-www-form-urlencoded" };
var formdata = {};
formdata["grant_type"] = "client_credentials";
formdata["client_id"] = "<client_id>";
formdata["client_secret"] = "<client_secret>";
formdata["resource"] =
"00000003-0000-0ff1-ce00-000000000000/site_url@tenant_id";
const body = Object.keys(formdata)
.map((key) => `${key}=${formdata[key]}`)
.join("&");
var requestOptions = {
method: "POST",
headers,
body,
};
await fetch(
"https://accounts.accesscontrol.windows.net/<tenant_id>/tokens/OAuth/2",
requestOptions
)
.then((response) => response.json())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));
};
generateToken();
when I execute the page which have this script I got this error
error TypeError: Failed to fetch
at generateToken
But IDK why the respose status is 200 OK, without returning body which contain access_token
Any help is much appreciated!
Hello I have a question concerning js charts. I have already created one in django application and i want to generate a javascript alert by clicking a certain point in the chart.
How can the alert get the value of the point that i choose?
For example with the value 92 like what is shown in the figure below:

When I try to add GitHub as my deployment method, it just pops up ands says one of these two things. Error1(image)
But the really odd part is that when I look on GitHub it shows Heroku as a OAuth application that is added but says it was never used. And then, in logs it says things like this:
Does anyone know what’s going on? I’m using Heroku to host a discord bot and ever since I logged out of GitHub on Heroku because it was acting up I cant get back in.
Estor haciendo una pagina con angular donde al obtener los datos de la base quiero que en el datatable se seleccione los datos en la tabla no son todos son algunos pero al incluir las líneas en el typescript
let table = $('#myTable').DataTable();
table.rows('.important').select();
me sale el siguiente error:
error TS2339: Property ‘select’ does not exist on type ‘RowMethods’.
en el app.module.ts ya le importe el: DataTablesModule
alguien que me pueda ayudar por favor??
I’m trying to add some extra divs to the build-in blogs “read more” links. I’ve managed to add all the necessary div but I’m struggling to move the text from where it is into another div. I’ve managed to move it using:
”’jQuery(“.readmore”).detach().appendTo(‘.js-add-btn-assets’);”’
But instead of moving the one .readmore element to the .js-add-btn-assets. Its making copies of all of the Read More Links on the page and putting them all under the .js-add-btn-assets so I essentially have 4 .readmore elements for every Read More link.
How do I change this so the .readmore class is only moving to the .js-add-btn-assets within its respected parent class instead of all classes on the page?
Like this:
Here all the code I’m currently using
<span class="more-link">
<a href="#" class="readmore">Continue reading
<span class="screen-reader-text">Blog Template</span>
</a>
</span>
var AddButtonWrap = document.querySelectorAll(".more-link");
for (i = 0; i < AddButtonWrap.length; i++) {
AddButtonWrap[i].classList.add("dbtb-button-wrap add-dbtb-button-div");
}
var SelectButtonDiv = document.querySelectorAll(".add-dbtb-button-div"); {
for (i = 0; i < SelectButtonDiv.length; i++) {
var dbtbBtnDiv = document.createElement('div');
dbtbBtnDiv.className = 'dbtb-button js-add-btn-assets';
SelectButtonDiv[i].appendChild(dbtbBtnDiv);
}
}
jQuery(".readmore").detach().appendTo('.js-add-btn-assets');
I have been working on building a simple table that gets its data from a mongodb database that is being queried for the json data and now the data needs to be passed to the vue component on the frontend but when I try to open the page I get a ErrorEception: Array to string conversion I think the error is occurring in the vue component when accessing the json but not sure why or how to fix it. To understand the code here is what I have done so far:
api.php route:
Route::middleware('api')->group(function () {
Route::resource('/home', [ProductController::class,'home']);
});
web.php route:
Route::get('{any}', function () {
return view('home');
})->where('any', '.*');
PostController Home method:
public function home() {
$posts = Post::paginate(4);
return response()->json($posts);
}
Home component:
<template>
<div>
<table>
<tr>
<td>Id</td>
<td>Title</td>
<td>Status</td>
</tr>
<tr v-for="El in results" v-bind:key="El.id" >
<td>{{El.id}}</td>
<td>{{El.STATUS}}</td>
</tr>
</table>
</div>
</template>
<script>
export default{
data() {
return {
results: []
};
},
methods: {
fetch() {
axios.get('/api/home')
.then(response => this.results = response.data)
.catch(error => console.log(error));
}
}
}
</script>
Home.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">Data</div>
<div class="card-body">
<home-component></home-component>
</div>
</div>
</div>
</div>
</div>
@endsection
The full error message if needed:
ErrorException
Array to string conversion
at vendor/laravel/framework/src/Illuminate/Routing/ResourceRegistrar.php:416
412▕ protected function getResourceAction($resource, $controller, $method, $options)
413▕ {
414▕ $name = $this->getResourceRouteName($resource, $method, $options);
415▕
➜ 416▕ $action = ['as' => $name, 'uses' => $controller.'@'.$method];
417▕
418▕ if (isset($options['middleware'])) {
419▕ $action['middleware'] = $options['middleware'];
420▕ }
+14 vendor frames
15 routes/api.php:20
IlluminateSupportFacadesFacade::__callStatic()
+3 vendor frames
19 routes/api.php:21
IlluminateRoutingRouteRegistrar::group()
Any help is appreciated.
I have my access control permissions for an App stored in a database, the main table being Permissions. It follows the pattern of:
UserRole | Entity/Subject | Permission
Basic Video View
Basic Video Create
Admin Video Delete
That is a tiny fraction example of the table. There are hundres of entity/subject values and there is another table with field-level permissions. Therefore we are talking a substantial amount of permission data.
The user gets a UserRole assigned to them which gives them permissions. But how do I check against the Permissions data for what a UserRole can or cannot do?
The options are:
Permissions table in the database. This will result in a lot of calls to the DB for each and every user trying to do something.Permissions data into a secure JWT cookie and have the application read against that instead of the database. This means having a relatively large cookie going back and forth between client and server. It also means exposing the permissions system to the user who can easily read the cookie. But if the permissions data stays mostly the same (only the UserRole changes for each user) then why send the whole Permissions table back and forth each time?Permissions data into the persistant store (like Vuex, Redux etc) and have the app read against that. This seems like a viable option but client-side storage is not secure and can be tampered with. It also doesn’t help the backend understand if a user can perform an action or not – so Node.js will still have to look this data up each time.I have seen a library called CASL which is interesting, but seems to code the permissions into the app rather than using a database. I suppose you could get it from the database but then it wouldn’t be much different to option 1 above.
What is a good or recommended way of acheiving a permission system that can be accessed by front and backend where the values come from a DB?
I am making a form for my html website and when I press the submit button the function is not running after I release the button , I am not using onClick I am using onSubmit. I want it to run continously after the button is pressed also when I release the button it’s showing that my questions variable and answer varibale is blank. How do I fix this?
<!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>Aspire Education</title>
<link rel="stylesheet" href="style.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link
href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"
rel="stylesheet">
</head>
<body>
<div class="titleBar">
<span class="title">Aspire Education</span>
</div>
<form onsubmit="onPressReturn()">
<label class="question_text" for="question">Question</label>
<input class="question_input" type="text" id="question" placeholder="Enter question">
<label class="answer_text" for="answer">answer</label>
<input class="answer_input" type="text" id="answer" placeholder="Enter answer">
<button type="submit">Add question</button>
</form>
<script>
var clicked = false
function work() {
clicked = true
let question = document.getElementById('question').value
let answer = document.getElementById('answer').value
console.log(clicked);
console.log(answer);
return [clicked, question, answer]
}
function onPressReturn() {
[clicked, question, answer] = work()
}
if (clicked == true) {
console.log('question = ' + question)
console.log('answer = ' + answer)
}
</script>
</body>
</html>