Skip to main content

Posts

Showing posts from July, 2021

I am not able to save data in firebase firestore

these images contain java script code Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW

localStorage removeitem not working on Chrome/Firefox extension

I'll try to delete a localStorage Item in JS with my Chrome/Firefox extension, but it seems like it won't work, and now I would like to know how can I debug this problem, here my code from my popup.js: var btn = document.createElement("BUTTON"); btn.innerText = "Delete matchs"; btn.onclick = function () { localStorage.removeItem('save_to_storage'); }; my popup.html: <!DOCTYPE html> <html lang="de"> <head> <script src='popup.js' defer></script> </head> <body> <div id='button'></div> </body> </html> If I press the button Delete matchs the save_to_storage item still appears in my developer tools, but if i type directly into the console localStorage.removeItem('save_to_storage'); it works as expected. I test it in firefox and chromium. I also tried to get the value of this item by using alert(localStorage.getItem('sav...

React this.props.createStream is not a function

how to fix such an error onSubmit is a function and should work as one if its not it will throw another error i double checked my code i tried binding this to it but still and there is a warning on formValues that its not used. so here's the code : import React from "react"; import { Field, formValues, reduxForm } from "redux-form"; import { connect } from "react-redux"; import { createStream } from "../../actions"; class StreamCreate extends React.Component { renderError({ error, touched }) { if (touched && error) { return ( <div className="ui error message"> <div className="header">{error}</div> </div> ); } } onSubmit = (formValues) => { this.props.createStream(formValues); }; render() { return ( <form className="ui form error" onSubmit={this.props.handleSubmit(this.onSubmit)} ...

(JS -GO) How to create a function that creates N(numbers) of objects with a n propriety?

im kinda newbie, and im trying to make a function in JS, also in Golang, to make N objects with N proprieties. (Js)Basically I want a function that returns N objects with N proprieties. So for I got this: function objects(name, age, idioms,school) { this.name = name; this.age = age; this.idioms= idioms; this.school = school; } I don't even know how to do this in golang.... Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW

Angular js install external library failed to instantiate module npm

In my AngularJS project I tried to add the external library ,example chart.js. So I started with command to add the new package in node_modules: npm install chart.js --save During download I see this warning: `-- chart.js@3.5.0 npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\chokidar\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"w"win32","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\karma\node_modules\chokidar\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"w"win32","arch":"x64"}) Despite the warning I fo...

How to make synchronous scaling of elements?

I've created ul - li drop-down menu. I used those tags because I added icons of flags (you'll see on pics). So, when I change size of window ul -element is scaled, and it's okay. But I also want to make scalable li -list. So, this is how it looks: ul - li list has to be like select - option drop-down menu. To be 'one' element. As you can see window 'Preferences' is scalable with settings inside, but not li -element. Here is scss : #select-li { cursor: pointer; padding: 8px; font-size: 15px; border-bottom: 0.1px solid rgba(0, 0, 0, .1); } #select-ul { position: absolute; cursor: pointer; border: 0.1px solid rgba(0, 0, 0, .1); border-top: 0; background-color: white; padding: 12px; height: 300px; overflow: auto; overflow-y:scroll; } For any case, here is Vue code: <ul v-if="showSortBy" id="select-ul"> <li id="select-li" @click="defCountry = country; showSortBy = !sho...

How do I gracefully prevent crashes in react native?

I would like to gracefully show an empty View when any error occurs (syntax, undefined, type errors, etc.) This is what I've tried, but it doesn't seem to fail gracefully. The whole app still crashes with this implementation. const Parent = (props) => { try{ return (<Child/>) //if Child logic crashes for any reason, return a blank view. }catch(err){ return <View/> } } Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW

Jest "mockResolvedValue" doesn't work with custom module?

square.js const multiply = require("./multiply"); const square = (n) => multiply(n, n); module.exports = square; multiply.js const multiply = (x, y) => x * y; module.exports = multiply; square.test.js const multiply = require("./multiply"); const square = require("./square"); jest.mock("./multiply"); test("square of 3 should be 9", () => { multiply.mockResolvedValue(9); expect(square(3)).toBe(9); }); In the above test, I get the error: Expected: 9, Received: {} I don't understand why this doesn't work, it works with axios and this also works if I replace mockResolvedValue with mockImplementation like this: multiply.mockImplementation(n => 9) Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW

How to remove annotation and why the arrow points to different area not this circle?

I am learning the D3 library. And I met two questions: why the arrow points to a different area, not this circle? 2. How to remove annotation when mouse out? We can see the arrow points to another area, not the red circle. And I am struggling with how to remove annotation after the mouse is out. Needs help. ;> function stringToNumber(data){ //convert "string" to "number" data.Year = +data.Year; data.Inflation = +data.Inflation; data.IntentionalHomicides = +data.IntentionalHomicides; data.LifeExpectancy= +data.LifeExpectancy; data.Population = +data.Population; data.SuicideMortality = +data.SuicideMortality; data.Unemployment = +data.Unemployment; data.HDI = +data.HDI; } <html> <script src="123123.js"></script> <script src = "https://unpkg.com/topojson@3.0.2/dist/topojson.js"></script> <body> <script src = "https://unpkg.com/...

TypeError: fs.readdir is not a function in reactjs

I'm trying to create a Blog posting project in React.js But, I'm new to Js itself. What I'm trying to do is, reading the list of files from the directory. const fs = require("fs"); const path = require("path"); const dirPath = path.join(__dirname,"../data/blogs/"); const getBlog = async () => { await fs.readdir(dirPath,(err, files) => { if(err) { return console.log("Failed to list contents of directory: " + err) } console.log(files) files.forEach((file,i) => { fs.readFile(`${dirPath}/${file}` , "utf8" , (err,contents) => { }) }) }) } I tried to do it from a YouTube video. But I got an error something like this. TypeError Do I have to explicitly install fs into my project? Then I saw some people doing const fs = require("fs").promises; instead of const fs = require("fs"); I tried that ...

get the id from button bootstrap (ajax)

i need help to get the id "${coin.id.toUpperCase()}" from toggle button bootstrap to make an array of checked id: in javascript using append: <div class="custom-control custom-switch"> <input type="checkbox" class="custom-control-input" id="${coin.id.toUpperCase()}"> <label class="custom-control-label" for="${coin.id.toUpperCase()}"></label></div> $(document).on("click", "input[type=checkbox]", function () { if ((this).checked === true) {currenciesArr.push($(this).parent().get(0).id); graphCurrencies.push($(this).parent().get(0).firstChild.innerText);} i got undefined. something wrong with getting the id .thank you Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW

vue-router: define pretty URL for filter page with pagination

I'm using NuxtJS for my static website and I want to create a shop page with filter, sort, and pagination. How can I define vue-router extend in nuxt.conf.js for this situation: shop page: example.com/shop/ shop page with pagination: example.com/shop/page/2 shop page with filters and pagination: example.com/shop/filters/color-green/size-big/page/2 shop page with filters, pagination and sort: example.com/shop/filters/color-green/size-big/page/2/sort/ASC I'm currently using this block of code, but this is very simple and works just for pagination: router: { trailingSlash: true, extendRoutes(routes, resolve) { routes.push({ path: '/shop/page/:number', component: resolve(__dirname, 'pages/shop.vue') }) } } Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW

OAuth, Scraping data - How to calculate device_id & device_token?

I'm trying to scrape olx.pl website. I want to get a phone number from advert. Example advert is here: https://www.olx.pl/d/oferta/segment-98-m2-grodzisk-maz-CID3-IDKMf0O.html#dbf8b32c9c You need to click: Zadzwoń / SMS to check phone number. As you can see, the phone number is generate in two steps. First is making request to: https://www.olx.pl/api/open/oauth/token/ This is POST request. Post params which is needed to make this request: client_id - this is into HTML source ( CTRL + U in your browser) client_secret - this is into HTML source ( CTRL + U in your browser) grant_type => ' device ' (always the same value) scope => ' i2 read write v2 ' (always the same value) device_id - this param I need to calculate , but I don't know how device_token - this param I need to calculate , but I don't know how Second step is making POST request for: https://www.olx.pl/api/v1/offers/683654480/phones/ Here is using everything...

How to keep aspect ration of Image and Watermark in Laravel php

I am trying to add Watermark of 800x100px to Images which can have any resolution greater than 800x100, i.e. 801x110, 1200x1000, 1300x200, 1920x1080, 4000x2010, etc. I want to keep the aspect ratio of Watermark and image to 2:50 . i.e., if image has 1000px width, then watarmark over image should occupy 20px(1000/50). Here is my Function : in helper.php use Image; //calling from Controller public static function addwatermark ($name) { $thumbnail = Image::make($name); $watermarkSource = 'public/img/watermark/watermark.png'; $thumbnail->insert($watermarkSource, 'bottom-left', 0, 0); $thumbnail->save($name)->destroy(); } in ImageController.php $folder = 'public/folder/'; $large = 'myfile.jpeg'; Helper::addwatermark($folder.$large); source https://stackoverflow.com/questions/68604977/how-to-keep-aspect-ration-of-image-and-watermark-in-laravel-php

import javascript files with relative path php

If I hardcode a javascript module import in my php code, it works: <script type="module"> import { logFoo1, logFoo2 } "/Root/js/foo.js"; logFoo1(); logFoo2(); </script> Not very relevant, but just in case, the foo.js: export function logFoo1() { console.log('logged from imported js file1'); } export function logFoo2() { console.log('logged from imported js file2'); } The server path is different so I handle that with a variable $rootPath = "/Root" so that my includes work along the project. Like for ecample <?php include($_SERVER['DOCUMENT_ROOT'] . $rootPath . "/includes/headgeneral.php")?> How may I add an import with a relative path in my javascript so that there are no hardcoded paths? I tried: <?php $dir = $rootPath . "/js/foo.js;"; echo "dir is $dir" ?> <script type="module"> import { logFoo1, logFoo2 } from <?php $di...

Appending a circle to an svg using javascript called by php

I have been searching for an answer that will work and have been unable to find one. I have a game map that I am using for an RP guild. I am using the map to display influence which we hold in that game's world. I have no issue displaying the map if I have it all coming through in echo statements in php, however, what I would like to do is only have the influence areas draw on the map as pulled from the database. I have the following function which works when called from within my .js file: function drawInfluence(id, x, y, inf, dis) { svg = document.getElementById("small_map"); var pt = svg.createSVGPoint(); pt.x = x; pt.y = y; var c = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); c.setAttribute('id',"c"+id); c.setAttribute('r',"15"); c.setAttribute('cx',pt.x); c.setAttribute('cy',pt.y); c.setAttribute('fill',inf); c.setAttribute(...

How to verify that a string contains a valid MySQL VARCHAR data type? [duplicate]

How to verify if a string is of the following format? VARCHAR(n..m) Where n >= 0; m > n; m <= 65535 Examples valid strings: $s = "VARCHAR(100)"; $s = "VARCHAR(1)"; $s = "VARCHAR(65535)"; $s = "varchar(50)"; Examples invalid strings: $s = "VARCHAR()"; $s = "VARCHAR(70000)"; $s = "VARHAR(50)"; $s = "varchar"; Can this be done with PHP preg_match() or with a different method? source https://stackoverflow.com/questions/68604835/how-to-verify-that-a-string-contains-a-valid-mysql-varchar-data-type

Can't acces "home page" OJS 3211 + OldGregg

My ojs home page (ojs 3211+OldGregg, php 7.4) can not accessible, but other pages are accessible. error log file shows: [01-Aug-2021 00:56:47 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to a member function getLocalizedFullTitle() on null in /home/jurnalpr/lab.jurnalim.id/plugins/themes/oldGregg/OldGreggThemePlugin.inc.php:227 Stack trace: #0 /home/jurnalpr/lab.jurnalim.id/lib/pkp/classes/cache/GenericCache.inc.php(63): OldGreggThemePlugin->_toCache(Object(FileCache), NULL) #1 /home/jurnalpr/lab.jurnalim.id/lib/pkp/classes/cache/FileCache.inc.php(115): GenericCache->get(NULL) #2 /home/jurnalpr/lab.jurnalim.id/plugins/themes/oldGregg/OldGreggThemePlugin.inc.php(181): FileCache->getContents() #3 /home/jurnalpr/lab.jurnalim.id/lib/pkp/classes/plugins/HookRegistry.inc.php(107): OldGreggThemePlugin->browsePopular('TemplateManager...', Array) #4 /home/jurnalpr/lab.jurnalim.id/lib/pkp/classes/template/PKPTemplateManager.inc.php(906): HookRegistry::call('Temp...

How to show the total on the last rows with same value? (Laravel)

I have table 'transaction_items' in my dtaabse that looks similar to this... id transaction_id qty unit_price 1 100 1 10.00 1 100 2 10.00 1 100 3 10.00 1 200 1 20.00 1 200 1 20.00 1 300 1 15.00 Current I fetch the data: $data['transaction_items'] = DB::table('transaction_items')->get(); and run a foreach loop: foreach ($transaction_items as $trans) { <tr> <td> </td> <td> </td> <td> </td> <td> * WHOLE TRANSACTION TOTAL</td> This outputs the data perfectly as you would expect. Though my last value (*WHOLE TRANSACTION TOTAL) of my output is running another a query and foreach loop to get the 'total' of the whole transaction. <tr> <td> <?php $totals = DB::table('transaction_items')->select('qty', 'unit_price')->where('transaction_id', '=', $trans->transaction_id)->...

SQL Query to print individual array from the serialize data

I have some serialize data: Want to show them based on their last array key by using any PHP code or direct from Xampp Database with query. Basically I want from array[0]=> value then array[1]=>value like that, to show all individual array value is from each array. Or from the serialized data. s:1121:"a:1:{i:0;a:5:{i:0;a:7:{s:4:"type";s:4:"text";s:8:"required";s:5:"false";s:5:"label";s:6:"Issue:";s:9:"className";s:12:"form-control";s:4:"name";s:18:"text-1475766502491";s:6:"access";s:5:"false";s:7:"subtype";s:4:"text";}i:1;a:7:{s:4:"type";s:4:"text";s:8:"required";s:5:"false";s:5:"label";s:9:"Platform:";s:9:"className";s:12:"form-control";s:4:"name";s:18:"text-1475766502680";s:6:"access";s:5:"false";s:7:"subtype...

Git Pre-Commit hook for PHPCS is giving me error in Windows for Laravel

I have installed PHPCS from composer.json "require-dev": { "phpstan/phpstan": "^0.12.93", "squizlabs/php_codesniffer": "^3.6" }, I am using laravel 8 so I have added below code for pre-commit file in .git/hooks/pre-commit file: #!/bin/sh # get bash colors and styles here: # http://misc.flogisoft.com/bash/tip_colors_and_formatting C_RESET='\e[0m' C_RED='\e[31m' C_GREEN='\e[32m' C_YELLOW='\e[33m' function __run() #(step, name, cmd) { local color output exitcode printf "${C_YELLOW}[%s]${C_RESET} %-20s" "$1" "$2" output=$(eval "$3" 2>&1) exitcode=$? if [[ 0 == $exitcode || 130 == $exitcode ]]; then echo -e "${C_GREEN}OK!${C_RESET}" else echo -e "${C_RED}NOK!${C_RESET}\n\n$output" exit 1 fi } modified="git diff --diff-filter=M --name-only --cached | grep \".php$\...

Laravel redirect never reaches intended function

I am redirecting to a named route in Laravel 7 and instead of the route being redirected it returns the user to the previous page. Controller return redirect()->route('NAMEDRoute')->with("Information", $information[0]); web.php Route::get('/x/y', "Controller@function")->name('NAMEDRoute'); This just returns me to the route I was on before, I have tested other routes that also work but the function that this calls is never called. There are no other routes that have the same name and this does use a middleware but the user is authenticated. Does redirecting affect authentication? Thanks source https://stackoverflow.com/questions/68604729/laravel-redirect-never-reaches-intended-function

Error when trying to use textapi.sentiment in javascript

I keep receiving this error Error: Authentication failed at IncomingMessage. And this is snippet of my code in the server.js file : var aylien = require("aylien_textapi"); var textapi = new aylien({ application_id: process.env.API_ID, application_key: process.env.API_KEY }); app.get('/test', (req, res) => { textapi.sentiment({ text: 'John', }, function (error, response) { if (error === null) { res.status(200).send(response) } else { console.log(error) } }); }) I have added the app id and key correctly but the response is always Authentication failed , didn't find an answer so far so had to create a question for it. and i use this code on client side to trigger the server response : fetch('http://localhost:8081/test') .then((res) => { console.log(res) return res.json() }) .then(function (data) { console.log(data) docu...

I have created my own toolbar and added a button on it but i can't have that button clicked

My goal is to call a fragment from the main activity using a button on a tool bar. I have included this toolbar on my main_activity but what code can I write inside the main_menu javascript so that the "finish button" on the toolbar can call a fragment. I have attached a code below: <?xml version="1.0" encoding="utf-8"?> <androidx.appcompat.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/bar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/colorPrimaryforLogin" <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:id="@+id/finish" android:clickable="true" ...

Getting attachment with laravel (IMAP) and sending to javascript

Basically i am downloading email from user folder with IMAP. I can get all the information I need, minus the attachments. I don't know how to handle them before sending them to javascript (front-end), I'll probably have to convert them to base64 or something. According to this documentation , would I be able to create a javascript file object with the information provided (size, content, name, type)? But how to send? that is the question. $email = email::on('user'); $attachs = $oMessage->getAttachments(); if($attachs->count()){ foreach ($attachs as $attach) { $attachs_vetor[] = base64_encode(implode($attach->getAttributes())); } } return ['attachments'=>$attachs_vetor]; I tried something like that, but I think it made my rollback process difficult in javascript. Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW

createAsyncThunk function returns userId undefined data attribute

I'm trying to fetch appointment data from my rails-api backend using the createAsyncThunk function. When I console.log('appointmentDate', appointmentDate); console.log('doctorId', doctorId); console.log('userId', userId); After clicking the submit button to create a new appointment; I get: appointmentDate => 2021-07-30 which is fine doctorId => 2 which is also fine. userId => undefined which is not what I'm expecting. I expected a number just like doctorId I have tested the backend with postman and everything is fine. And since I can't fetch the correct data. I can't create an appointment when I submit the form This is how I'm destructuring the user state before adding it to the postAppointment action creator for dispatch const { data: userData } = useSelector((state) => state.user); const { userId } = userData; since `user_Id` is part of the `user` state in my `store`. I can destructure it as above and add it to my `dis...

How do I gracefully prevent crashes in react native?

I would like to gracefully show an empty View when any error occurs (syntax, undefined, type errors, etc.) This is what I've tried, but it doesn't seem to fail gracefully. The whole app still crashes with this implementation. const Parent = (props) => { try{ return (<Child/>) //if Child logic crashes for any reason, return a blank view. }catch(err){ return <View/> } } Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW

How to customize a string by variable in Javascript?

I want to print an errormessage using javascript in certain cases. The string is german and the start depends on a variable called blfType which can be "field", "line" or "block" and the string then would be "This field already has this prerequisite" if blfType is field. I tried to do that similiar as I would do it in python: alert("Das Feld"*(blfType == 'field') + "Die Zeile"*(blfType == 'line') + "Der Block"*(blfType == 'block')+" besitzt diese Vorraussetzung bereits"); But this would just print "NaN besitzt diese Vorraussetzung bereits" . Is there any other way how I can do this in just one line or do I have to do create another Variable that takes the start of the sentence. In this case I would do this in python like that: const gerblfType = "Feld" if blfType === "field" else "Zeile" if blfType === "line" else "Block...

How to add javascript into php?

Here is my js code <script> function myform() { var n = document.getElementById("name").value; if (n == "") { document.getElementById("username").innerHTML = "Please enter your name"; return false; } if (!isNaN(n)) { document.getElementById("username").innerHTML = "Please enter valid name"; return false; } } </script> How to write this js code into php m trying all code in echo but not working plz help after php echo using echo'<script> function myform() { var n = document.getElementById("name").value; if (n == "") { document.getElementById("username").innerHTML = "Please enter your name"; return false; } if (!isNaN(n)) { document.getElementById("username").innerHTML = "Please enter valid name"; return false; } } </script>'...

Data isn't inserting in Database table [duplicate]

These are the queries to create a registeration form <?php if(isset($_POST['submit'])){ $name = $_POST['name']; $email = $_POST['email']; $mobno = $_POST['mobno']; $password = $_POST['password']; $user_id=uniqid(); $query = "insert into users (user_id, name, email, mobno, password) values('$user_id', '$name', '$email', '$mobno', '$password')"; $run = mysqli_query($conn, $query); if($run === true) { echo "Your account is created successfully"; } else{ echo "Your account is not created"; } } ?> I am unable to create an account through this line of code source https://stackoverflow.com/questions/68595934/data-isnt-inserting-in-database-table

Is there a Wordpress plugin for Order of Service integrated with WooCommerce?

Does anyone knows if there's an Order of Service plugin for Wordpress/WooCommerce? I developed myself one that we've been using for years, but it's not integrated with WooCommerce. Basically, I want something that allows me to register my client and the product that he/she is giving me to fix (it's for an service center). After our analysis, we want to include in WooCommerce platform the products and services that we'll need use and do, previously registered. I also tought of using the WooCommerce page for "Orders" in admin interface, but there are a few information that I need to include, such as the product brande, reference, colors and so on. The plugins I've found to add custom fields also adds they on checkout page in my ecommerce, which is not the case. Thank you very much source https://stackoverflow.com/questions/68595924/is-there-a-wordpress-plugin-for-order-of-service-integrated-with-woocommerce

Getting attachment with laravel (IMAP) and sending to javascript

Basically i am downloading email from user folder with IMAP. I can get all the information I need, minus the attachments. I don't know how to handle them before sending them to javascript (front-end), I'll probably have to convert them to base64 or something. According to this documentation , would I be able to create a javascript file object with the information provided (size, content, name, type)? But how to send? that is the question. $email = email::on('user'); $attachs = $oMessage->getAttachments(); if($attachs->count()){ foreach ($attachs as $attach) { $attachs_vetor[] = base64_encode(implode($attach->getAttributes())); } } return ['attachments'=>$attachs_vetor]; I tried something like that, but I think it made my rollback process difficult in javascript. source https://stackoverflow.com/questions/68595923/getting-attachment-with-laravel-imap-and-sending-to-javascript

Laravel validate() method returns index html page when false

I'm building my first laravel API and when I try to validate some mock form data using Postman with POST method, the application returns to me the HTML of the index page and status 200. Here is my code public function store(Request $request) { $request->validate([ 'name' => 'required', 'slug' => 'required', 'price' => 'required' ]); return Product::create($request->all()); } The application returns the object that was inserted in the database if the validation was successful (if the data was filled in), but returns a HTML file otherwise. How can I change the way the method 'validate()' operates? I'm guessing it is just returning the user to the main page if the form data was not filled correctly I am using Laravel 8 source https://stackoverflow.com/questions/68595460/laravel-validate-method-returns-index-html-page-when-false

How To Add Arrays Within Arrays And Then Output Their Values In Index Aswell As Associative Array Format?

I got Mysql Tables: //Valid list of Mysql Tables. $tables = array('links','countries'); I got Mysql Table 'Links' Columns: //Valid list of Mysql Table Columns. $links_table_columns = array('email','domain','url','anchor','description','keyword'); I got Mysql Table 'Countries' Columns: //Valid list of Mysql Table Columns. $countries_table_columns = array('Australia','Canada','UK','USA','New Zealand'); Now, how do I add arrays within an array so by just looking at it you can tell which one is array and which ones are it's sub-arrays ? I made two attempts: 1. $tables_and_columns = array('table'=>array('links'),array('links'=>array('column'=>email,'column'=>domain,'column'=>url,'column'=>anchor,'column'=>description,'column'=>keyword))); $valid_param_keys_and_valu...

401 Unauthorized When trying to call a google cloud functions

I have a simple node.js function inside Google Cloud Function (that is called from inside my website's code) and I used previously the id_token that I got when I'm connected inside Google Cloud SDK and use this: gcloud auth print-identity-token , but it only last 60 minutes, so after that my application can't use anymore the google cloud function. So I tried to generate my own token with the help of the service account key: https://cloud.google.com/docs/authentication/production#create_service_account But I always got a "401 Unauthorized" when I call my link with the "Authorization: Bearer token" header Maybe it's because I don't know what to put inside the " aud " value (inside the payload array) <?php namespace MyProject\Parser; use Firebase\JWT\JWT; use GuzzleHttp\Client; abstract class GoogleCloudParser extends AbstractParser { /** * Returns the HTML for the given URL * @param string $url * @return strin...

jQuery autocomplete issues

I am having some small issues with my autocomplete feature. When I make a selection, the position of that selection in the scrollbar is used the next time I try to make a selection, when it should actually be resetting to the top of the scrollbar. Another issue I have is that my cursor is used to scroll through the autocomplete suggestions, so if I move my cursor to the bottom of the box, it will start scrolling down. However, I only want to scroll with the scrollbar directly or through arrow keys. I'm not sure how to do this though. I looked at some similar examples but couldn't find a working solution with my code. Here's the code I have so far: $.ajax({ type: "POST", url: "../FileDrop/autofill.php", data: {text: text}, dataType: 'JSON', success: function (data) { var dataArray = []; for (var email = 0; email < data.length; email++) { dataArray.push(data[ema...

Method FIFO in Codeigniter

I need help to solve method fifo using codeigniter Table 1 barang id barang name 1 book 2 pen table 2 stock in id_stock_in id_barang supplier stock_in 1 1 supplier 1 20 2 1 supplier 2 30 table 2 stock out id_stock_out id_barang supplier stock_out 1 1 supplier 1 40 I want result like this table last stock id_last_stock id_barang supplier stock_in stock_out last_stock 1 1 supplier 1 20 40 0 2 1 supplier 2 30 0 10 source https://stackoverflow.com/questions/68595858/method-fifo-in-codeigniter

Javascript Loop based on PHP Loop

I need help creating a javascript snippet to show each individual popup when hovering over each card title. Card 1 shows popup 1, card 2 shows popup 2, etc. HTML/PHP loop setting up multiple popups. The number of popups change depending on how many custom posts (WordPress) have been created. <?php while ($post_query->have_posts()) {?> <?php $post_query->the_post();?> <div class="card" id="card-0<?php echo $counter; ?>"> <h4 class="post-title">“<?php echo get_the_title(); ?>”</h4> </div> <?php }?> <div class="popup" id="popup-0<?php echo $counter++; ?>"> <h4 class="post-title">“<?php echo get_the_title(); ?>”</h4> <p class="blurb"><?php echo get_field('blurb'); ?></p> </div> This is my Javascript to show/hide each popup, however since I don't know how many popups wi...

Encoding format (jfif) is not supported

I have Laravel project that admin can upload images with different size. The problem occur when admin uploads product image in jfif format it shows a error Encoding format (jfif) is not supported. . I used laravel intervention image package everything is working fine but jfif format is not supported. Please explain why? And how I fix this bug. Controller code: $request->validate([ 'product_id' => 'required', 'product_name' => 'required', 'product_image' => 'required|image|mimes:jpeg,png,jpg|max:2048', 'description' => 'required', ], [ 'product_id.required' => 'Product id required', 'product_name.required' => 'Product name required', 'regular_price.required' => 'Actual price required', 'selling_price.required' => 'Discount price required', 'description.required' => 'Product descrip...

PHP Converting Decimal Time To H:M:S

So I'm passing a variable from Javascript into PHP that marks the Current Time on a video being played. And I have no problem passing that decimal into mySQL, but I don't want it in decimal form. The Javascript .currentTime function seems to output a float or a double in seconds. And when I try to pass that into my VARCHAR in mySQL I get an empty spot, not null, just blank. It works if I remove this code and just switch $currentTimeRaw for $currentTime. That effectively bypasses this piece of code. So I know the problem is here but I can't figure out what I did wrong. $currentTimeRAW = $_GET['currentTime']; $minutes = 0; $hours = 0; while($currentTimeRAW >= 3600){ $currentTimeRAW = $currentTimeRAW - 3600; $hours++; } while($currentTimeRAW >= 60){ $currentTimeRAW = $currentTimeRAW - 60; $minutes++; } if($hours>0){ $currentTime = $hours.':...

PHP Word - Remove placeholder from template so it does not leave a gap (blank line)

I'm using PHPWord to generate reports based on a template. I replace placeholders in that template $templateProcessor = new TemplateProcessor('template.docx'); $templateProcessor->setValue('placeholder_name', 'value5123'); and save the new file $templateProcessor->saveAs('report.docx'); Pretty straightforward. However, there are some values which are optional, so they leave stray placeholders behind, and the best I've been able to do is replace them with an empty string, which still leaves blank lines. Is there a way to remove the placeholder expression altogether and prevent it (and the blank line) from showing in the final file? Thanks source https://stackoverflow.com/questions/68595748/php-word-remove-placeholder-from-template-so-it-does-not-leave-a-gap-blank-li

Receive emails and save in DB

Is is possible to receive emails (from other mailbox) and save in db? for example - I have mailbox in Gmail and I want that all received messages will save in my db. Any idea? source https://stackoverflow.com/questions/68595729/receive-emails-and-save-in-db

dropdown menu items with php foreach

I'm working on a dropdown menu that has items from the database using PHP for each loop The code is making only one dropdown item but the database have more than 1 rows so where is the problem? Table: ------------------------------------- | id | Address | text | ------------------------------------- | 1 | foo | 5 | ------------------------------------- | 2 | bar | 13 | ------------------------------------- the dropdown contains [ foo ] only. <?php foreach($items as $newitem){?> <div class="dropdown-menu" style="height:29vh; width:30vh;"aria-labelledby="myInput"> <a class="dropdown-item" href="#"><?=$newitem['name'];?></a> </div> <?}?> source https://stackoverflow.com/questions/68595482/dropdown-menu-items-with-php-foreach

Running Laravel Application on Server

I have a question regarding Laravel hosting. I am developing a booking system to be able to book online courses. It's a bit more extensive application with some functions and different roles (user, manager, admin, trainer). There are also some database accesses. About 200 people will register, but they will never use the application at the same time. To my actual question: What are the hardware requirements? How much RAM do I need to host the whole thing? How much RAM would be recommended for the MySQL database? source https://stackoverflow.com/questions/68595510/running-laravel-application-on-server

seleccionar más columnas en consulta [closed]

estoy tratando de realizar una consulta que no muestre campos repetidos cuando se cumpla una condicion, eso lo resolví con la variable $historial1, eso lo hice y está ok estaria necesitando mostrar dos columnas más de mi tabla y ordernarlos por una de esas columnas, a continuación mi consulta: $historialtodo = Historial::select(DB::raw('(valor)')) ->where('direccion','=', 7)->get(); $historial1 = Historial::select(DB::raw('DISTINCT(valor)')) ->where('direccion','=', 1)->get(); $historial = $historialtodo->union($historial1); como haría para meter en el serlect las dos columnas que me faltan?, intenté lo siguiente: $historialtodo = Historial::select('id_historial','direccion',DB::raw('(valor)')) ->where('direccion','=', 7)->get(...

How to check dom for react onKeyDown

Im creating examples of things that would cause trouble for keyboard only users. I have an element that I created like this: <div id="role_tab_div_with_react_onclick_has_keydown" role="tab" onClick={() => activateDialog()} tabIndex="0" onKeyDown={() => activateDialog()}> <div class="btn-label">Click me (role=tab - has onkeyDown)</div> </div> But, when rendered to the DOM, the onKeyDown is not present even thought it is now keyboard activatable. <div id="role_tab_div_with_react_onclick_has_keydown" role="tab" tabindex="0"> <div class="btn-label">Click me (role=tab - has onkeyDown)</div> </div> So, my check to see if the element already has a onkeydown event: if (el.hasAttribute('onKeyPress' || 'onKeyDown')) is not finding it. Is there a way to determine if it does have a react version of onKeyDown present? Via Active questi...

Rendered more hooks than during the previous render - nextjs

I want to get my items' with a api call inside useEffect`: export const MyComponent = () => { // const cartContext = useCartContext(); let [items, setItems] = useState([]); useEffect(() => { api.get('cart?detail=true').then((res: any) => { const result = res; setItems(result.gifts); }).catch(err => { console.log(err); }) }); return ( <div className="cart-factor-items"> { items.map((item, index) => { return ( <div>....</div> but I got this error message: Rendered more hooks than during the previous render. Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW

Automatic Login from QWebEngineView to Website

I am trying to use the code below to create a view of a monday.com in a PySide2 app. I want to be able to login directly from the code instead of having to input my email and password. I have found some code pretty similar to the one shown below and adapt it to how monday.com's login page is structured. I am currently able to enter my email and password as well as to click the login button. But, for some reason, it appears as if the page did not detect the entries although you can visually see them. I've tried to put a second function that runs after "handle_load_finished" and included the JavaScript for clicking the button there but it would still run and not detect that entries were there. from PySide2.QtCore import QUrl from PySide2.QtWidgets import QMainWindow, QApplication from PySide2.QtWebEngineWidgets import QWebEngineView import os import sys class MainWindow(QMainWindow): def __init__(self, *args, **kwargs): super(MainWindow, self).__init__...

Fatal error: Uncaught Error: Call to a member function bind_param() on bool in db.php21 Stack trace:#0 db.php92 executeQuery'INSERT INTO pos', Array#1

Hello So to make things clear This is the full text of the error because i dont have enough space to type it on my title "Fatal error: Uncaught Error: Call to a member function bind_param() on bool in C:\xampp\htdocs\movieworld\app\database\db.php:21 Stack trace: #0 C:\xampp\htdocs\movieworld\app\database\db.php(92): executeQuery('INSERT INTO pos...', Array) #1 C:\xampp\htdocs\movieworld\app\controllers\posts.php(77): create('posts', Array) #2 C:\xampp\htdocs\movieworld\admin\posts\create.php(2): include('C:\xampp\htdocs...') #3 {main} thrown in C:\xampp\htdocs\movieworld\app\database\db.php on line 21" Ok so let me explain how I'm struggling even though i have a tutorial that i'm following I am following Awa Melvine's blog tutorial ( https://www.youtube.com/watch?v=-tfqW25lKvo&list=PL3pyLl-dgiqD0eKYJ-XSxrHaRh-zsA2tP&index=23 ) but for some reason when i am trying to post something i am getting this error and i am not sure why and...