Skip to main content

Posts

Showing posts from September, 2021

i want to redirect to specified html page java included

hello i have problem i have a index page inside of it form i put in it phone number and email and quanity and it send request to my email , the problem im facing is after i click procceed it stay on same page , and nothing change i want when i click procced to redirect me to specified html file the html part is <div style="opacity: 0.9;" class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content" style="background: #002b49;"> <div class="modal-header" style="border: none;"> <h5 class="modal-title" id="exampleModalLabel"> </h5> <button type="button" style="background: none; border: none; color: #fff;" class="close" data-dismiss="modal&q

What this message mean? Trying to run a model that was trained in TeachableMachine

I try to run a python program but every time it shows this message: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations: AVX AVX2 To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. WARNING:tensorflow:No training configuration found in the save file, so the model was not compiled. Compile it manually. The program that I use is: from keras.models import load_model from PIL import Image, ImageOps import numpy as np # Load the model model = load_model('path/to/trained/model/keras_model.h5') # Create the array of the right shape to feed into the keras model # The 'length' or number of images you can put into the array is # determined by the first position in the shape tuple, in this case 1. data = np.ndarray(shape=(1, 224, 224, 3), dtype=np.float32) # Replace this with the

How to calculate the grade from a CSV file and output to a CSV

A CSV file has been provided where a list of students have taken an exam with 6 questions. Each question is either scored manually (like for an essay) or automatically (like for an MCQ) but never both manually or automatically. A python script is need to return, for each student, their user name and the total number of points they have scored for the exam. The table returned as q1Out.csv has 2 columns: Username and RawMark. The following code has been provided: def read_data_file(filename): with open(filename) as csvfile: reader = csv.reader(csvfile) # Pull in the data into a data structure into a a list of lists, csv_data = list(reader) return csv_data def calculate_raw_grades(data): # Define the data structure for collecting grades for each student. # A dummy list has been added just to make the stub run. grades = list() return grades def write_report(grades, filename): with open(filename, 'w') as outfile:

Search specific words in pdf and return only pdf link where words were found (Python)

I am trying to search for multiple words in many PDFs. Links to these PDFs are saved in a dataframe. The goal is for python to return a text stating "The words are located in pdf link "). Here is the code I have so far: (FYI g7 is the name of the dataframe where the links are saved).The issue here is that the code returns the same link multiple times for every time the word is found. The dataframe (named g7) looks like this: URL 0 https://westafricatradehub.com/wp-content/uploads/2021/07/RFA-WATIH-1295_Senegal-RMNCAH-Activity_English-Version.pdf 1 https://westafricatradehub.com/wp-content/uploads/2021/07/RFA-WATIH-1295_Activit%C3%A9-RMNCAH-S%C3%A9n%C3%A9gal_Version-Fran%C3%A7aise.pdf 2 https://westafricatradehub.com/wp-content/uploads/2021/08/Senegal-Health-RFA-Webinar-QA.pdf 3 https://westafricatradehub.com/wp-content/uploads/2021/02/APS-WATIH-1021_Catalytic-Business-Concepts-Round-2.pdf 4 https://westafricatradehub.com/wp-content/uploads/2021/02/APS-WATIH-10

Can sysfs gpio descriptors stay open as long as wrapper class lives?

I'm trying to write a basic wrapper gpio class that will handle read and write to gpio pins in a nvidia jetson, using linux sysfs interface, with python. I want to keep /sys/class/gpio/gpioXXX/value open as a file to avoid repeating file open/close using with open(...) as f approach. The reason for my approach is that I will keep changing the value in my process (to toggle a LED on-off) regularly. I'm thinking of closing it once the wrapper class gets deleted. The thing is that I know that opening files without close counterparts can cause resources leaks and that makes me anxious. class GPIOWrapper: def __init__(self): self.fd = open("/sys/class/gpio/gpioXXX/valu","w+") def set(self,val): self.fd.write(str(val)): # 0 or 1 self.fd.flush() def read(self): return self.fd.read() def __del__(self): self.fd.close() What I'm asking is if the above approach valid? Or is it risky and I should stic

Updating R version of JupyterLab

I am using R in Jupyterlab with Anaconda .I need to update my R version of Jupyterlab. The r-base version of Anaconda is 4.1.1, but when I write version to Jupyter cell, it says my R version is 4.0.3. How can i update it 4.1.1 ? Thank you. source https://stackoverflow.com/questions/69392980/updating-r-version-of-jupyterlab

How to Scrape Product Pages using Python grequests and BeautifulSoup

from bs4 import BeautifulSoup import grequests import pandas as pd # STEP 1: Create List of URLs from main archive page def get_urls(): urls = [] for x in range(1,3): urls.append(f'http://books.toscrape.com/catalogue/page-{x}.html') print(f'Getting page url: {x}', urls) return urls # STEP 2: Async Load HTML Content from page range in step 1 def get_data(urls): reqs = [grequests.get(link) for link in urls] print('AsyncRequest object > reqs:', reqs) resp = grequests.map(reqs) print('Status Code > resp (info on page):', resp, '\n') return resp # Step 3: Extract title, author, date, url, thumb from asynch variable resp containing html elements of all scraped pages. def parse(resp): productlist = [] for r in resp: #print(r.request.url) sp = BeautifulSoup(r.text, 'lxml') items = sp.find_all('article', {'class': 'product_pod'})

force python container to stay in "running" state for debugging

Im using the follwoing docker file to run a python script FROM python:3 COPY . /app RUN pip install requests RUN mkdir /app/foo ENTRYPOINT [ "python3", "/app/main.py"] the issue is that a file that need to be created , dose not created and i cant debug it inside the container it stopped to fast . each run the contianer dies within 6 sec - i tried: infinite while loop in the python script . adding RUN tail -f to docker file with 0 success. im running on docker desktop (win 10) source https://stackoverflow.com/questions/69397766/force-python-container-to-stay-in-running-state-for-debugging

facebook-business | Update from 10->12

Does anyone know what could be causing this depreciation issue (act_******** technically is an actual number, but hiding it from the question)? Message: Call was not successful Method: POST Path: https://graph.facebook.com/v10.0/act_*********/insights Params: {'date_preset': 'today', 'action_attribution_windows': '["1d_click"]', 'level': 'ad', 'limit': '1000', 'status': '["ACTIVE"]', 'fields': '["account_id","account_name","action_values","actions","ad_id","ad_name","adset_id","adset_name","campaign_id","campaign_name","clicks","cpc","cpm","ctr","date_start","date_stop","impressions","inline_link_clicks","reach","spend","website_purchase_roas"]'} I'

UART communication Raspberry Pi Pico to Raspberry Pi

I am trying to communicate with a raspberry pi pico with my raspberry pi 4 over uart. The below code does transmit data, but I am only receiving data from the print statement. import os import utime from machine import ADC temp_sensor = ADC(4) # Default connection of temperature sensor def temperature(): # get raw sensor data raw_sensor_data = temp_sensor.read_u16() # convert raw value to equivalent voltage sensor_voltage = (raw_sensor_data / 65535)*3.3 # convert voltage to temperature (celcius) temperature = 27. - (sensor_voltage - 0.706)/0.001721 return temperature #print setup information : print("OS Name : ",os.uname()) uart = machine.UART(0, baudrate = 9600) print("UART Info : ", uart) utime.sleep(3) while True: temp = temperature() print(str(temp)) uart.write(str(temp)) utime.sleep(1) And the code on my raspberry pi 4 is: import serial import time import nump

Instruct: Fix Dropdown Component in Reactstrap

First of all, I'm sorry because I'm not very good at English I used the DropDown component at reactstrap and it had a bit of a problem, compoent not get select value and after solving that problem i want to share how i solved it. Thank you for your interest. import React, { useState } from 'react' import { Button, Dropdown, DropdownItem, DropdownMenu, DropdownToggle } from 'reactstrap' const MyExample = () => { const toggle = () => setDropdownOpen(prevState => !prevState) const [dropdownOpen, setDropdownOpen] = useState(false) const [itemDropDown, setItemDropDown] = useState('DropDown') const itemsCourseType = ['Item1', 'Item2', 'Item3', 'Item4'] const getItemsDropDown= items => {setItemDropDown(items)} return ( <div> <Dropdown isOpen={dropdownOpen} toggle={toggle}> <DropdownToggle caret> {courseType} </DropdownToggle> <DropdownMenu> {itemsCourseType.map((item,

binary search in array of object javascript

I have an array of objects : array = [ { name:'alex', number:36783712773 }, { name:'gabe', number:99938873, }, and so on like this ] I know the basic concept of binary search and how it works but most of the examples of the internet deal with an array of numbers so I cannot figure out to search by name and phone through the array of objects. I can search from the backend but I do not want to make unnecessary http calls for a thing which can easily be dealt with in javascript. All I want from you guys is either refer me to some tutorial which does what I want to accomplish or if you yourself can help me please do. Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW

Opacity(Transparency) and dragging in P5.js/Javascript

I need help with changing the opacity(transparency) of the objects and dragging the objects. I can change the opacity(transparency) but when I do the objects are no longer draggable. The image below sheds more light on the question https://ibb.co/2qhX6Jt The relevant lines for fill colour are lines 54-74 The relevant lines for dragging objects are lines 117-161 You can run and edit the code using P5.js editor, This is the link to the code. https://editor.p5js.org/Chigoz/sketches/ulMnSYag4 Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW

How do you convert a 32bit RGB png with encoded height values to 16 bit png using browser side javascript?

I am trying to create a 16bit heightmap png from a 32bit Rgb encoded height value png. According to mapbox I can decode their png pixel values to height values in meters with this formula. height = -10000 + ((R * 256 * 256 + G * 256 + B) * 0.1) I am new to understanding this type of information and have tried to figure it out myself but I need some help. I found this program called image-js , docs for this program are here . Note I am using this in the browser not with node. I think it has the abilities that I need. However, I am really not sure how to get the data from the original image and create a new 16bit png with the new height values calculated from the above formula. If you look in the docs under image I can set many properties such as bitDepth and set that to 16 getPixelsArray() this function will give me an array of pixels values in the form of r,g,b. I think I can then run each pixel through the above formula to get the height. After that how do I turn this height

How to Run fs.writeFileSync() From a Visual Studio Code Command?

I am trying to make a vscode extension and one of the things I am trying to do is create/edit a file when using a specified command. I have the command working. when I try run the following code using "node test.js", the fs.writeFileSync() method creates the file as expected. let fs = require('fs'); try { fs.writeFileSync("test.txt", "Test success!"); } catch (error) { console.log(error); } However when I run my custom command from my "extension.js" file (code below), I see the pop up message "Testing!", but no file is created by the fs.writeFileSync() method. I don't get any errors either. My only guess is that there is an unknown restriction in place that keeps the code from creating files. Does anybody have any ideas how I can get fs.writeFileSync() to work? const vscode = require('vscode'); let fs = require('fs'); /** * @param {vscode.ExtensionContext} context */ fun

Need to define this array and figure out how to get first value php

I have a php var that var_dump 's this which is coming from a for loop query to the database. string(19) "2021-09-14 15:23:27" string(19) "2021-09-17 09:59:28" string(19) "2021-09-23 10:29:33" string(19) "2021-09-24 16:07:50" I first tried to convert them all to a single array with no luck. when I covert it to an array using explode I get this which is multiple arrays. array(1) { [0]=> string(19) "2021-09-14 15:23:27" } array(1) { [0]=> string(19) "2021-09-17 09:59:28" } array(1) { [0]=> string(19) "2021-09-23 10:29:33" } array(1) { [0]=> string(19) "2021-09-24 16:07:50" } Ultimately what I need to do is get the strings values separately for different calculations. for example: I would like to get the first string "2021-09-14 15:23:27" and use it for calculating time passed against another string such as "2021-09-24 16:07:50". I know I'm missing something

Is it possible to redirect the user to the first page of pagination if the pagination is empty In wordpress

I am trying to redirect the user to the first page of the pagination if the pagination is empty. I have three bootstrap tabs (Both, Blog, News). The blog tab contains 5 posts. The news tab contains more than 12 posts. I am displaying 6 posts per page. The issue here is that if I am on the second page of News tab and click the Blog tab, the second page of the blog tab is opening (which does not exist). For better Understanding Here is my code. <ul class="nav nav-tabs" id="myTab"> <li class="nav-item"> <a href="#sectionA" class="nav-link active" data-toggle="tab">Section A</a> </li> <li class="nav-item"> <a href="#sectionB" class="nav-link" data-toggle="tab">Section B</a> </li> <li class="nav-item"> <a href="#sectionC" class="n

Uncaught TypeError: mysqli_error(): Argument #1 ($mysql) must be of type mysqli, string given in C:\xamppCópia\cadastrar.php:76 Stack trace: #0

Estou tendo esse erro ao inserir dados na tabela Fatal error: Uncaught TypeError: mysqli_error(): Argument #1 ($mysql) must be of type mysqli, string given in C:\xampp\htdocs\devy\DAVID - Cópia\adm\cadastrar.php:76 Stack trace: #0 C:\xampp\htdocs\devy\DAVID - Cópia\adm\cadastrar.php(76): mysqli_error('INSERT INTO pri...') #1 {main} thrown in C:\xampp\htdocs\devy\DAVID - Cópia\adm\cadastrar.php on line 76 $inserir = "INSERT INTO prisioneiro (`nome`, `apelido`, `datanascimento`, `sexo`, `identidade`, `contacto`,`endereco`, `provincia`, `cidade`, `sela`, `dataentrada`, `datasaidada`,`tipo_prisao`, `acusacao`, `arquivo`) VALUES ( '$nome', '$apelido', '$datanascimento', '$sexo', '$identidade','$contacto', '$endereco', '$provincia', '$cidade','$sela', current_timestamp(), '$datasaida','$tipo_prisao', '$acusacao', '$novo_nome')";

PHP Fatal error: Uncaught Error: Class 'FPDF' not found in

I am working to implement the artkonekt/pdf-invoice project from GitHub. I used the normal composer require konekt/pdf-invoice install method as specified in the readme.md file--and everything installed without any errors. When I simply try to view the provided example file /vendor/konekt/pdf-invoice/examples/example1.php , the browser gives back an "HTTP ERROR 500" and the Apache2 error.log file includes the entry: [Thu Sep 30 11:02:40.813756 2021] [php7:error] [pid 26112] [client 72.36.41.73:55343] PHP Fatal error: Uncaught Error: Class 'FPDF' not found in /var/www/html/generate/vendor/konekt/pdf-invoice/src/Invoi cePrinter.php:18\nStack trace:\n#0 /var/www/html/generate/vendor/konekt/pdf-invoice/examples/example1.php(5): include()\n#1 {main}\n thrown in /var/www/html/generate/vendor/ko nekt/pdf-invoice/src/InvoicePrinter.php on line 18 Other than the attribution credits at the top of InvoicePrinter.php , the next few lines are: namespace Konekt\PdfInvoice;

syntax error, unexpected '$path' (T_VARIABLE) in C:\xamppp\htdocs\ecommerce\include\function.php on line 39

This is the line of code that I'm having a problem on function __autoload($class_name){ $class_name = strtolower($class_name); $path = LIB_PATH.DS."{$class_name}.php"; if(file_exists($path)){ require_once($path); }else{ die("The file {$class_name}.php could not be found."); } } source https://stackoverflow.com/questions/69396443/syntax-error-unexpected-path-t-variable-in-c-xamppp-htdocs-ecommerce-incl

Laravel Scout - multiple searchable arrays from one model

I am trying to create individual searchable arrays in Laravel Scout from a single City model, by iterating through its relationships. I have multiple fields returning arrays, all tied to the same hasMany relationship. While Algolia can parse the arrays when returning search results, the presence of multiple arrays in the objects is causing the issue. For instance, a current result is {city_name: 'Sydney', user_name: ['user_one', 'user_two'], user_id: [1, 2]} . The intended result is two objects: {city_name: 'Sydney', user_name: 'user_one', user_id: 1} and {city_name: 'Sydney', user_name: 'user_two', user_id: 2} . Region->cities is a many-to-many relationship, and Region->user is a one-to-many relationship. Since toSearchableArray returns a single searchable object, I've tried (unsuccessfully) to override it using searchable() : City.php: public function users() { $regionIds = $this->regions() ->

Magento API throws 500 error, says check exception log but nothing is there

I am using guzzle to test upload products with the Magento API. Whenever I run this script: <?php require_once ('connparams.php'); try { $response = $client->request('post', 'products', [ "headers" => $headers, 'body' => json_encode([ 'product' => ['attribute_set_id' => 13], ['sku' => 12548], ['name' => 'widget'], ['price' => 1], ['type_id' => 'simple'] ]) ]); } I get the following error (which I'm outputting to a txt file with the catch block): ERROR at: 06:50:15 pm | 500 | Internal Server Error | An error has happened during application run. See exception log for details. When I check the exception log in Magento, there is not a new entry. There are entries for exceptions when I test the API with swagger. source https://stackoverflow.com/questions/69

Parsing JSON with PHP Amazon Api 5 [duplicate]

I try to get the DisplayValues from Json code with PHP but I can't do it. { "ItemInfo": { "Features": { "Label": "Features", "Locale": "en_US", "DisplayValues": [ "Vented clear cover doubles as a 6-quart capacity popcorn bowl", "Stir rod is motorized and improves popping, get more popped corn, larger kernels per batch", "Convenient nesting lid is ideal for small storage" ] } } To get Locale I do this: // Convert JSON string to Array $someArray = json_decode($response, true); $productosMaximos = count($someArray['SearchResult']['Items']); $productosMaximosResta = ($productosMaximos - 1); if($productosMaximos <= 8){ $productosMaximosFuncion = $productosMaximosResta; }else{ $productosMaximosFuncion = 7 ; } for ($i = 0; $i <= $p

Adding a CUSTOM POST TYPE to a Wordpress site doesn't include all the options the theme has in other POST TYPES

I am using a theme for my Wordpress site: THEME: https://themeforest.net/item/prague-architecture-and-interior-design-wordpress-theme/19618927 Site: RainProPixel.com The theme has several post types, but I would like to add more. I've added a new one called "Training" to "Post-type.php": <?php /* Portfolio post type. */ function register_custom_post_type() { $services_url_slug = cs_get_option('services_url_slug') ? cs_get_option('services_url_slug') : 'services-item'; $services_category_slug = cs_get_option('services_category_slug') ? cs_get_option('services_category_slug') : 'services-category'; // New Post Type register_post_type( 'services', array( 'labels' => array( 'name' => esc_html__( 'Services','prague-plugins'), 'singular_name' => esc_html__( 'Service','prague-plugins') ), 'supports

Print digits 1 to 9 in python with 9 thread

import threading class MyThread(threading.Thread): def __init__(self, name): threading.Thread.__init__(self) self.name = name def run(self): thread = threading.current_thread() print(self.name) #print('{} - start'.format(thread.name)) for d in range(9): a = MyThread(d+1) a.start() this block of code print 1 to 9 sequential! I think this code didn't run well. source https://stackoverflow.com/questions/69382296/print-digits-1-to-9-in-python-with-9-thread

Unable to convert comma separated integers and non-integer values in a series column in Python

I have an object column with amounts like 150,01 and 43,69. Thee are about 5,000 rows. Naturally, I tried to convert the series into the locale format, which suppose to turn it into a float format. I came back with the following error: ValueError: could not convert string to float: ' - ' Now that I'm aware that there are non-numeric values in the list, I tried to use isnumeric methods to turn the non-numeric values to become NaN. Unfortunately, due to the comma separated structure, all the values would turn into -1. How do I turn the "," values to "." by first removing the "-" values? I tried .drop() or .truncate it does not help. If I replace the str",", " ", it would also cause trouble since there is a non-integer value. Please help! Documentation that I came across Finding non-numeric rows in dataframe in pandas? Replace comma and dot in Pandas source https://stackoverflow.com/questions/69382012/unable-to-conve

Load folder of images (dataset) stored in Google Cloud Storage using python

I am trying to load folder of images from Google Cloud Storage bucket into python file (version 3.9) using different way but didn't work! My folder contains approximately 930,000 images in path : buket-name/main-folder/image-folder I tried this solution and it takes along time without any result. I define the google credential and service account, but still no response! Thank you in advance. source https://stackoverflow.com/questions/69382325/load-folder-of-images-dataset-stored-in-google-cloud-storage-using-python

How to clean a dataset having string values?

I am working on a dataset where few values in one of the column are string. due to that i am getting error while performing operations on dataset. sample dataset:- 1.99 LOHARU 0.3 2 0 2 0.3 5 2 0 2 2 1.99 31 0.76 2 0 2 0.76 5 2 7.48 4 2 1.99 4 0.96 2 0 2 0.96 5 2 9.45 4 2 1.99 14 1.26 4 0 2 1.26 5 2 0 2 2 1.99 NUH 0.55 2 0 2 0.55 5 2 0.67 2 2 1.99 99999 0.29 2 0 2 0.29 5 2 0.06 2 2 full dataset can be found here:- https://www.kaggle.com/sid321axn/audit-data?select=trial.csv I need to found the missing values and outlier in the dataset. below is the code i am using to find missing values:- #Replacing zeros and 99999 with `np.NaN` dataset[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]]=dataset[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]].replace(99999,np.NaN) #if 12,14 and 17 can have zeroes then dataset[[0,1,2,3,4,5,6,7,8,9,10,11,13,15,16]]=dat

import pyautogui jupyter notebook browser [closed]

Poderiam ajudar quanto ao uso da Biblioteca Pyautogui. Estou usando Jupter Notebook versão on line, pois não posso instalar no windows do trabalho devido bloqueio de segurança. Realizo a instalação através do comando !pip3 install pyautogui, instalo e verifico através do !pip list, porém quando faço o import pyautogui aparece o seguinte mensagem de erro: KeyError Traceback (most recent call last) in ----> 1 import pyautogui /srv/conda/envs/notebook/lib/python3.6/site-packages/pyautogui/init.py in 247 248 try: --> 249 import mouseinfo 250 251 def mouseInfo(): /srv/conda/envs/notebook/lib/python3.6/site-packages/mouseinfo/init.py in 221 raise 222 --> 223 _display = Display(os.environ['DISPLAY']) 224 225 def _linuxPosition(): /srv/conda/envs/notebook/lib/python3.6/os.py in getitem(self, key) 667 except KeyError: 668 # raise KeyError with the original key value --> 669 raise KeyError(key) from None 670 return self.decodevalue(value) 671 KeyError: 'DISPLAY'

TypeError: Provided value for 'message' must be of type: ServiceBusMessage in a Service Bus Queue Azure

I have the following code that connects a JSON file with an Azure Service Bus Trigger but when the trigger is activated I encounter the error TypeError: Provided value for 'message' must be of type: ServiceBusMessage . I have found the following link that provides some sort of help but it wasn't that useful How to specify content type as application/json while sending message to azure service bus queue in node js? module.exports = async function (context, myBlob) { context.log("JavaScript blob trigger function processed blob \n Blob:", context.bindingData.blobTrigger, "\n Blob Size:", myBlob.length, "Bytes"); if(context.bindingData.name.indexOf("json_results") == -1){ context.log(context.bindingData.name); return; } const data = JSON.parse(myBlob.toString()); context.log(data); // service bus queue const { ServiceBusClient } = require("@azure/service-bus"); // connection string to your Service

Randomize for loop in javascript

I have a for loop that generates html. I'd for this method to generate the elements randomly. Right now they are cardinally generated i.e. d1, d2, ... di. I want them to follow a random sequence i.e. d1, di, di-3, .. di-k. //create description inputs html += '<table id=\"tablestyle\">' for (let i = numberOfInputs; i < dlArray.length+numberOfInputs; i++){ html += '<td id="row'; id = (1+i-numberOfInputs); html += id; html +='">\n'; html += '\t\t<div id=\"t'; html += id; html +='" class=\"ltarget\"></div>\n \t</td >\n \t<td id=\"d2\">' html +=dlArray[i-numberOfInputs]; html +='</td >\n </tr>\n'; } html += '</table>'; Any help with this would be greatly appreciated. Thanks. Via Active questio

Datum-Data difference in map behavior in d3

I'm pretty new to d3js and trying to understand the difference between using data and datum to attach data to elements. I've done a fair bit of reading the material online and I think I theoretically understand what's going on but I still lack an intuitive understanding. Specifically, I have a case where I'm creating a map using topojson. I'm using d3js v7. In the first instance, I have the following code to create the map within a div (assume height, width, projection etc. setup correctly): var svg = d3.select("div#map").append("svg") .attr("width", width) .attr("height", height) .attr("transform", "translate(" + 15 + "," + 0 + ")"); var path = d3.geoPath() .projection(projection); var mapGroup = svg.append("g"); d3.json("json/world-110m.json").then(function(world){ console.log(topojson.feature(world, world.objects.land)) mapGroup.app

How to make a computed data reactive after having fetched data via VueX?

In a Vue.js application, I have fetched a product based on provided route id. Product object in an array has pictures. I want to create a copy of reactive data "mosaicImagesList" that is reflected once the product is fetched, and it should have following structure: [ { "url": "https://via.placeholder.com/650x250", "isWide": true, "isTall": false }, { "url": "https://via.placeholder.com/350x150", "isWide": true, "isTall": false } ] It shows an output in console.log , but it shows an empty list of array in the rendered page. Here is my code: export default { name: 'products.show', data () { return { slide: 0 } }, computed: { product () { return this.$store.state.product }, images () { const items = this.product.picture || [] const result = [] items.forEach(image =

Using php and the while loop to print a table of data that is being selected from a mysql db [duplicate]

I am new at php and am trying to learn CRUD applications. For this part of the code I have a table set up in a database (mysql). I am trying to interact with the table. I want a user to login (that part works) and when they are logged in- I store a message in $_SESSION that says ie. 'success'. This lets me know the user is logged in. Not the problem. The second piece is that IF there are rows IN THE TABLE already (from previous sessions) I want to print out these rows in a table. If there are no rows I want to print out "No rows" I am trying to use simple logic here where first I create the $row variable by doing a fetch that comes from a pdo object(also fine). If that row is TRUE ie. it exists, print the table. If that row is false, print no rows. However, I keep getting the whole table printed, say 5 times. Instead of the 5 rows in the table. Also, I am not sure I am using the correct type of while () statement. Which right now reads, while ($row = $stmt->fetc

LinkedIn API UGC Post Mention: share commentary is invalid

I'm using LinkedIn API to create posts. I also use the LinkedIn Mentions to create posts with mentions. I can successfully create a post with mention except if I add in the message emojis or accents. Without mentions feature, I'm able to create any post with success. Posts that work: Hello Stackoverflow Hello 😄 Stackoverflow Hellóó Stackoverflow Hello Stackoverflow (with mention to the linkedin page) Posts that do not work: Hello 🤣 Stackoverflow (with mention to the linkedin page) Hellóó Stackoverflow (with mention to the linkedin page) I receive the following error: com.linkedin.content.common.ResponseException: share commentary is invalid I send the following data to LinkedIn: array ( 'author' => 'urn:li:organization:X', 'lifecycleState' => 'PUBLISHED', 'visibility' => array ( 'com.linkedin.ugc.MemberNetworkVisibility' => 'PUBLIC', ), 'specificContent' => a

Need suggestion creating a Custom Form with file upload feature, editable and searchable

I am rookie in programming. I only have basic programming skill, so looking for some suggestions on how to go about it. I want to create a custom form with text data and file upload. The user will fill in the data and upload the file. User will enter data for multiple people. Now the text data and file will be saved in a database. Later the user should be able to search the database for the person, see the old entered data/file and edit the form again , also resubmit it with additional data. Now as i understand I need to do the following: Form ( PHP) database (MySql) Would this be sufficient or am I missing anything? Appreciate all the help !! Thanks!! source https://stackoverflow.com/questions/69381354/need-suggestion-creating-a-custom-form-with-file-upload-feature-editable-and-se

PHP Script ,php://input check for empty File

Hello i need help with my PHP script. The Upload function works great, but many files are empty. Can you help me please to check first IF file is empty or < 1 byte. and Ignore them. <?php $vist_page = "post2.php"; include "logger.php"; file_put_contents("outputfile.txt".uniqid(), file_get_contents("php://input")); ?> Thanks ;) source https://stackoverflow.com/questions/69381055/php-script-php-input-check-for-empty-file

how to assign a variable to a html code including an if statement in php [duplicate]

I would like to have a variable $output inside while loop containing some html and a if statement which will give class ".time_active" only to the first while loop result. I'm not able to find a way to embed if statement properly any help would be much appreciated. $count= 0; while($start_time < $end_time){ $count++; $output = "<label> <input type='radio' class='if($count == 1) {echo 'time_active';}' id='id_slot' name='time'> <span class='display'>span tag</span> </label>"; } echo $output; source https://stackoverflow.com/questions/69366552/how-to-assign-a-variable-to-a-html-code-including-an-if-statement-in-php

Laravel Session with database driver keeps updating after logging out

I switched to database driver for Session and migrated the table. I've noticed that even after the logout action, the value last_activity in the table keeps getting updated after every refresh, even if the user isn't logged-in anymore. I've tried removing it from the records of the database, but once the user refreshs at the login page, it gets inserted again. I believe I'm doing something wrong to logout the user well. I want Laravel to stop refreshing the record of the session, as it might cause issues if every logged-out user kept accessing the database with their refreshes. I'm logging in like this: if (Auth::attempt($request->only('email', 'password'), ($request->remember_me === "on" ? true : false))) { // return settings too if(Auth::user()->active === false){ return response()->json(array('status' => 'failure', 'message' => "Your account isn&#

How to access amount, kwh and numberOfPay of each region based on RegionalCode? [closed]

How to echo amount, kwh and numberOfpay based on RegionalCode and Region Name I have been trying to address this issue but it showing my Warning: Attempt to read property "amount" on string in [ { "regionCode": "0", "": { "amount": "291377681.35999995", "kwh": "5589027.089364664", "numberOfPay": "43876" } }, { "regionCode": "3", "AZARE Region": { "amount": "13494424.550000023", "kwh": "286885.42398979055", "numberOfPay": "3863" } }, { "regionCode": "7", "BAUCHI Region": { "amount": "55739882.11",

Sending Whatsapp message via PHP programmatically for OTP

I see that sending OTP via SMS has been too expensive nowadays especially for global SMSs. Therefore, I want to use Whataspp so send OTPs for login and other stuffs instead of SMS. Therefore, I would like to be able to send message via PHP programmatically. I see whatsapp has a documentation here for it's business API https://developers.facebook.com/docs/whatsapp . However, I cannot see any example or sample code for any programming language, let alone PHP. Therefore, I wanted to know if there are any sample codes available that you could suggest me to have a look at or a working code that may you have written for your own sake in PHP. source https://stackoverflow.com/questions/69366333/sending-whatsapp-message-via-php-programmatically-for-otp

Sending Email with PHP and AJAX

I am creating a sign up form. Instead of using $_POST I used jQuery to get the form data and I'd like to send an email to the customer. The signup page is working property but i am having trouble to send an email with the data. Here is the button to send the data <button type="button" class="next action-button" id="fourthnext" >Register</button> if($input.attr("id") == "fourthnext"){ //some code $.ajax({ type: 'POST', url : path_to_functions, data: data1, success: function(data){ if (data!='') { finalerror.html(data); finalerror.show(); fourthstepload.hide(); show_result(); //Disable the button and test the user to go back #TODO throw new Error(); }else{ finalerror.html(data); finalerror.show(); fourt

How do I echo out particular wp_register_script or wp_enqueue_script version and id in WordPress?

I want to echo out the version of a particular wp_register_script or wp_enqueue_script on the frontend. Like Superfish JS registered via: wp_register_script( 'superfish', GENESIS_JS_URL . "/menu/superfish{$this->suffix}.js", array( 'jquery', 'hoverIntent' ), '1.7.10', true ); wp_register_script( 'superfish-args', apply_filters( 'genesis_superfish_args_url', GENESIS_JS_URL . "/menu/superfish.args{$this->suffix}.js" ), array( 'superfish' ), PARENT_THEME_VERSION, true ); And, I want to get the version of these JS reflected on frontend via: add_filter('the_content','addToEndOfPost'); function addToEndOfPost($content) { if (is_single()){ return $content . '<p>Version of Superfish JS:</p>'; } return $content;} Even if I could get the separate script as a variable, I might be able to use a delimiter to separate out the version and id of these scripts.

Fastest way to reset a numpy array to zero?

I have a large numpy array that I need to reset its values to 0 regularly. I tried these: x = np.zeros((10**4, 10**6), dtype=np.float32) %timeit x[:7000, :] = 0.0 # 4 seconds %timeit x[:7000, :].fill(0.0) # 4 seconds On the other hand, creating a new array is much faster: %timeit x = np.zeros((10**4, 10**6), dtype=np.float32) # 8 microseconds However, the new array has different memory address that significantly decreases the performance of subsequent copying. Is there a way to reset the array values to 0 as fast as creating a new array? Otherwise, is there a way to creating a new zeros array that keeps the same memory address? source https://stackoverflow.com/questions/69367142/fastest-way-to-reset-a-numpy-array-to-zero

Writing the user input to a binary file in hex format using Python 3.8

I am new to python and was trying to do a simple job but I am having a problem. I am trying to take a large number as input from user say 500 and write it to a file in hex format. For this I tried to take a small number as first step and write it, but I get the error as below 10 0xa Traceback (most recent call last): File "temp.py", line 7, in <module> fp.write(bytes(('num',))) TypeError: 'str' object cannot be interpreted as an integer The sample code used is as below. intval = int(input()) num = hex(intval) print(num) with open('hexFile.iotabin', 'wb') as fp: fp.write(bytes(('num',))) fp.close() Could you let me know What am I doing wrong here? For large number say 500, I would like to split it to two bytes while writing. Will to_bytes() be able to help once the issue above is resolved or is there any other simple way. source https://stackoverflow.com/questions/69360021/writing-the-user-input-to-a-bin

Python instalation tests running "forever"

This is the first time I am installing python, as I am using an instalation of Oracle Linux 6 and it seemed not present in the repository when I tried the simpler ways of doing it. I downloaded the source of version Python 3.9 and am trying to compile it, but tests seem to be running for a long, looooong time. Is that normal? Can I interrupt it? How many time can they go on? 5:19:13 load avg: 0.00 running: test_socket (5 hour 5 min), test_logging (5 hour 14 min) 5:19:43 load avg: 0.00 running: test_socket (5 hour 5 min), test_logging (5 hour 14 min) 5:20:13 load avg: 0.00 running: test_socket (5 hour 6 min), test_logging (5 hour 15 min) 5:20:43 load avg: 0.00 running: test_socket (5 hour 6 min), test_logging (5 hour 15 min) 5:21:13 load avg: 0.00 running: test_socket (5 hour 7 min), test_logging (5 hour 16 min) 5:21:43 load avg: 0.00 running: test_socket (5 hour 7 min), test_logging (5 hour 16 min) 5:22:13 load avg: 0.00 running: test_socket (5 hour 8 min), test_logging (5 hour 17 mi