on-internet

Only arrays and Traversables can be unpacked error with a guzzle HTTP POST request with multiple files

So I'm trying to do a POST request with guzzle with multiple files. The user has selected one or more files in a form and hit submit to POST the form. The following code gets run in the controller after that: public function upload(Request $request){ $validator = Validator::make($request->all(), [ 'file-upload' => 'required', 'file-upload.*' => 'file|mimes:mp3,wav,mp4' ]); if ($validator->fails()) { return redirect('/upload-files') ->withErrors($validator) ->withInput(); } $names = []; if($request->hasFile('file-upload')) { foreach ($request->file('file-upload') as $file) { if(file_exists($fil

Join the discussion →

webpack 5 - Parsed request is a module

I'm creating webpack5 setup for an small app and while doing I'm facing the below mentioned issue. Please suggest the way to resolve Issue Snapshot Module not found: Error: Can't resolve 'faker' in 'C:\Gowtham\micro-frontend-training\products\src' resolve 'faker' in 'C:\Gowtham\micro-frontend-training\products\src' Parsed request is a module using description file: C:\Gowtham\micro-frontend-training\products\package.json (relative path: ./src) Field 'browser' doesn't contain a valid alias configuration resolve as module C:\Gowtham\micro-frontend-training\products\src\node_modules doesn't exist

Join the discussion →

Filter on columns using read_parquet

I would need to filter a date column based on two other dates in a dataframe (dataframe is too big and cannot load it and do it as usual in pandas), I used the following snippet of code but I am not able to do it as it throws error: filename = "df.parquet" date_filters = [('current', '>=', 'start'), ('current', '<=', 'end')] df = pd.read_parquet(filename, engine='pyarrow',filters=date_filters) This is the error that I get. ArrowNotImplementedError: Function greater_equal has no kernel matching input types (array[timestamp[us]], scalar[string]) I am wondering if there is another way of doing it

Join the discussion →

smtp client throwing error message operation has timed out

I am using SmtpClient with office365 mailserver to send email. But everytime i try smtpclient.Send(msg),it will throw 'Operation has timed out' smtpexception. I have tried all the earlier options like to change the port to 587 and increase the timeout value but nothing works. Can anyone help me out. Below is my source code. using (MailMessage msg = new MailMessage { From = new MailAddress("[email protected]"), Subject = this.Subject, Body = this.Body, IsBodyHtml = true }) { msg.To.Add(new MailAddress("[email protected]")); using (SmtpClient client = new SmtpClient { Host = "smtp.office

Join the discussion →

Getting incomplete transcript from the youtube transcript api

I was trying to get youtube videos transcript but, I don't know why I am getting incomplete transcript from the youtube transcript api. I am using youtube-transcript-api 0.4.3 here is my code from youtube_transcript_api import YouTubeTranscriptApi def Transcript(url): id = url.split('watch?v=') srt = YouTubeTranscriptApi.get_transcript(id[1]) print(srt) # text_list = [] # for i in srt: # text_list.append(i['text']) # text = ' '.join(text_list) # print(text) Transcript('https://www.youtube.com/watch?v=TQMbvJNRpLE') here is the output screen, it is showing incomplete transcript not sure what to

Join the discussion →

Redisson client ; RedisTimeoutException issue

I am using Google cloud managed redis cluster(v5) via redisson(3.12.5) Following are my SingleServer configurations in yaml file singleServerConfig: idleConnectionTimeout: 10000 connectTimeout: 10000 timeout: 3000 retryAttempts: 3 retryInterval: 1500 password: null subscriptionsPerConnection: 5 clientName: null address: "redis://127.0.0.1:6379" subscriptionConnectionMinimumIdleSize: 1 subscriptionConnectionPoolSize: 50 connectionMinimumIdleSize: 40 connectionPoolSize: 250 database: 0 dnsMonitoringInterval: 5000 threads: 0 nettyThreads: 0 codec: !<org.redisson.codec.JsonJacksonCodec> {} I am ge

Join the discussion →

Alternative to http status code 403 for a banned user

I am wondering what the best practice for the following scenario is: I have an application where a manager using the device authenticates on behalf of a customer. If the customer is banned, what is the best practice for the http status code I return them? When I return a 403 it seems as if the request they made was invalid, it does not convey to the agent the user is banned. In the same sense I do not want to send a 401 unless the credentials used to make the request were invalid. I have read a few answers and the spec and haven't found what I was looking for. I was leaning towards a custom 2X

Join the discussion →

How to specify different background colors for each facet label in ggplot2?

A plot will be made from these data: library(ggplot2) mtcars %>% gather(-mpg, key = "var", value = "value") %>% ggplot(aes(x = value, y = mpg)) + geom_point() + facet_wrap(~ var, scales = "free") + theme_bw() How can I change the gray color of the titles of the panels for instance panels of am and hp green panels of gear drat disp red panels of vs wt blue panels cyl qsec carb black add a legend green = area red = bat blue = vege black = indus

Join the discussion →

Upgrading OpenLayers from v 5.3.0 to v 6.12.0 results in "ReferenceError: TileLayer is not defnied"

I try to update this layer from OpenLayers v5.3.0 to v6.12.0 but I get an error: ReferenceError: TileLayer is not defined as if the function was not loaded from the ol library call: <link rel="stylesheet" type="text/css" href="/iliad/bibliotheques_javascript/olv6.12.0/css/ol.css"> <script type="text/javascript" src="/iliad/bibliotheques_javascript/olv6.12.0/build/ol.js" data-url="/iliad/autoconfINRAP.json"></script> the layer code in v5.3.0 var osmLyr = new ol.layer.Tile({ olParams: { crossOrigin: "Anonymous", }, source: new ol.source.OSM(), opacity: 1, name: 'Carte Osm', description: "carte o

Join the discussion →

How to remove space between prefixIcon and texformfield text?

How to remove space after prefix icon in TextFormField in flutter? I've already tried isCollapsed = true, isDense = true. And I have set my contentPadding: EdgeInsets.all(0). Using prefix instead of prefixIcon however solves my issue, but there is another problem. Prefix appears only on focus. How to solve my problem? I want to prefix(or prefixIcon) to appear always visible at the beginning. And TextFormField's text must be like continue of the prefix.

Join the discussion →

How to get version number from string in bash

I have a variable having following format bundle="chn-pro-X.Y-Z.el8.x86_64" X,Y,Z are numbers having any number of digits Ex: 1.0-2 # X=1 Y=0 Z=2 12.45-9874 # X=12 Y=45 Z=9874 How can I grab X.Y and store it in another variable? EDIT: I wasn't right with my wording, but I want to store X.Y into new variable not individual X & Y's I'm looking to finally have a variable version which has X.Y grabbed from bundle: version="X.Y"

Join the discussion →

Find Item in Array / Replace With Array Using Awk?

I'm trying to make my code more clean. My function seems rather oblique to do a simple find/replace. Is there a cleaner way to do this find/replace array function with awk or something similar? # Finds first item in array that matches find item, and replaces it with 1 or more array elements. # Preserves sort order of original array. find_replace_in_list(){ # $1 = list # $2 = find item string # $3 = replace array. local -n _list=$1 local -n _replace_list=$3 for i in "${!_list[@]}"; do # Iterate over indices. if [ ${_list[$i]} == "$2" ]; then # Insert the replace array starting at indice. local

Join the discussion →

How to wait for API response to return component?

I am building a page component that returns data from an API call and passes the values to my return statement. My page continues to return as blank because the page loads before the variables are returned from the API. How can I wait to render the page until my API has returned a response? The two variables are initialized as so and are not updated until the API response: var userData const [customer_email, setEmail] = useState(); const [newuserid, setUserId] = useState(); useEffect(() => { userData = Cookies.get("user-data"); if (userData) { console.log("Userdata !== null"); try { userData =

Join the discussion →

ORA-19025: EXTRACTVALUE returns value of only one node

I can successfully read from xml definition which has only one node. But when I am trying to read multiple node from xml definition I get the following error - ORA-19025: EXTRACTVALUE returns value of only one node. Below is my xml definition <form xmlns:fr="http://orbeon.org/oxf/xml/form-runner" fr:data-format-version="4.0.0"> <applicant> <userId>1234</userId> <userName>Dan Johnson</userName> <userEmail>[email protected]</userEmail> </applicant> <background> <additionalDuties>Nothing</additionalDuties> <grid-7> <position>Service desk analyst</position> <workplace>Chicago</workplace> <date>

Join the discussion →

"ValueError: setting an array element with a sequence" when assigning the result of np.where

When I execute this Python code, I get an error message: ValueError: setting an array element with a sequence a = np.array([1,3,5,7,9], dtype=int) c = np.array([3,4,7,8,9], dtype=int) b = np.zeros(len(a)) for i in range(len(a)): b[i] = np.where(a == int(c[i])) What's the problem? The whole error: --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-606-7b50beb044f5> in <module>() 14 15 for i in range(len(a)): ---> 16 b[i]= np.where(a == int(c[i])) ValueError: setting an array element with a sequence.

Join the discussion →

Cannot deserialize value of type `java.util.LinkedHashMap` from Array or what would be a correct type of my field

I try to pass a json object to an api on a Spring boot. Before I was passing values using postman all worked fine. The format was as follows: { "shortname": "test2", "fullname": "testing2", "address": "addrtest2", "telephone": "380979379993", "website": "www.site2.com", "sociallinks": { "facebook": "fb2.com" }, "foundationyear": "1992" } Now in my Angular app I am passing json as follows: {"shortname":"test","fullname":"Bogdan Onyshenko","address":"Пр. Победы 72в","telephone":"0669829242","website":"http://193.70.37.242/index.php?route=extension/feed/google_sitemap","foundationyear":"2004","so

Join the discussion →

What is the correct fast way to compare two `Uint8List`s' equality?

Given Uint8List a = ...; Uint8List b = ...; I want to compare whether their content are the same. Of course I can use listEquals in Flutter, or write down a naive loop like: for (int index = 0; index < a.length; index += 1) { if (a[index] != b[index]) return false; } However, given that Uint8List is quite a special array, and it is often quite big, I guess where there is a better (faster) approach to do so?

Join the discussion →

java.lang.ClassCastException: cannot be cast to org.openqa.selenium.WebElement using executeScript() to return shadowRoot from shadowHost

Getting Issue : java.lang.ClassCastException: com.google.common.collect.Maps$TransformedEntriesMap cannot be cast to org.openqa.selenium.WebElement Code trials: JavascriptExecutor execute = (JavascriptExecutor)uiDriver.webDr; WebElement shadowDomHostElement = uiDriver.webDr.findElement(By.cssSelector("authoring-ui[ng-version='12.0.1']")); WebElement executeshadow = (WebElement)execute.executeScript("return arguments[0].shadowRoot", shadowDomHostElement); Unable to cast the WebElement, please need help on this

Join the discussion →

Automated emails from a Google Sheet

I was looking for a solution to send automated emails from a Google Sheet connected to a Google Form, so I found Google Scripts. I never worked with it (or other scripts) before, so it's all new to me. I did find a lot of information on the internet, but I still have some questions. Let's explain the situation. So I'm selling two different products in a Google Form, they both have a different price, so I was looking for a solution to send mails to the customers with the total price and some extra information. I have a Google Sheet where all the answers are put in automatically. So I have 12 co

Join the discussion →

Play sound on key press - JavaScript

I don't know what is wrong with my code the sound is not playing when I am pressing the keys. for(var i=0;i<document.querySelectorAll(".drum").length;i++) { document.querySelectorAll("button")[i].addEventListener("click",function() { var buttoninnerhtml = this.innerHTML; makesound(buttoninnerhtml); }); } document.addEventListener("keydown",function(event){ makesound(event,key); }); function makesound(key) { switch (key) { case "w": var audio = new Audio('sounds/tom-1.mp3'); audio.play(); break; case "a": var audio = new Audio('sounds/tom-2.mp3'); audio.play(); break; case "s": var audio = new

Join the discussion →

Proper implementation of using a idempotency key with another service like stripe

What is the proper way to handle idempotency in a rails application? I am using devise and need to make sure that each user doesn't get multiple duplicate PaymentIntents for the same purchase. Since the idempotency key needs to be used with each subsequent failed request should it be something saved in the database, session, etc..? Stripe suggests to use idempotency keys to prevent duplicate PaymentIntents for the same purchase: https://stripe.com/docs/payments/payment-intents#best-practices

Join the discussion →

Xcode 13+ Missing "Products" folder when creating a framework

In Xcode 13+ When I create a framework, there is no "Products" folder as it used to be there prior to that version same like the below image Even when I build the project, I still cannot find the ".framework" file anywhere. All tutorials on google follow the same flow of creating the framework project, building then extracting the .framework binary from the Products folder, but that doesn't seem to be available in Xcode 13+ Any one have a clue?

Join the discussion →

Python requests.exceptions.SSLError: HTTPSConnectionPool(): Max retries exceeded with url

PC OS: Win10 20H2 IDE: PyCharm 2021.3 Python version: 3.10 The requests package version: 2.27.1 The software (may cause the problem) on pc: Clash for Windows(v 0.18.2) The code is following: import requests create_account_url = "https://opentdb.com/api.php" para = { "amount": 10, "difficulty": "medium", "type": "boolean" } response = requests.get(create_account_url, params=para) response.raise_for_status() print(response.json()) The problem is: Running the code above when I open the button(System Proxy) in Clash, the error is: requests.exceptions.SSLError: HTTPSConnectionPool(host='opentdb.com

Join the discussion →

Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project

I am working with React Native & I am getting this error: "Requiring module "node_modules/react-native-reanimated/src/Animated.js", which threw an exception: Error: Reanimated 2 failed to create a worklet, maybe you forgot to add Reanimated's babel plugin?" and my app appears to not be working after I installed Secure Store. It would not open then told me to update my emulator which I did, in turn that deleted all my dependencies. I reinstalled all of them, erased node modules and ran Yarn Install to reinstall everything. Now this error keeps popping out. Any advice would be appreciated...I am

Join the discussion →

How do I issue a warning message from PowerShell that does not require user input

I am running a batch script that invokes a .exe file, if the file is not present then I wish to issue a warning, similar to the system.windows.messagebox class, but without the need for the user to respond, because I want the batch script to continue to run without pausing for user interaction. I tried this via powershell PowerShell -Command "Add-Type -AssemblyName PresentationFramework;[System.Windows.MessageBox]::Show('Application not found','Warning',1,48)" But this requires user response, and I can't seem to find any way around this as the message box class does not seem to have the option

Join the discussion →

Wrong time scaling in Grafana

I have a problem with the visualization in Grafana. My problem is that dates are shifted one hour into the future. Grafana visualisation At the time of the screenshot it was 19:45. The data was recorded between 18:53 and 19:02 and also correctly noted in the database (InfluxDB). But are displayed from 19:53 to 20:02 in Grafana (as also seen on the picture above). DBeaver database data overview I have already checked the Grafana Server's time as well as the InfluxDB installation time and they match the current time. My time zone is 'Europe/Berlin' (CET). I think this problem has something to do

Join the discussion →

How can I lazily import a module in python?

I have classes which require dependencies in order to be instantiated but are otherwise optional. I'd like to lazily import the dependencies and fail to instantiate the class if they aren't available. Note that these dependencies are not required at the package level (otherwise they'd be mandatory via setuptools). I currently have something like this: class Foo: def __init__(self): try: import module except ImportError: raise ModuleNotFoundError("...") def foo(self): import module Because this try/except pattern is common, I'd like to abstract it into a lazy importer. Ideally if module is avai

Join the discussion →

Checking if key is being held down

I've got a game where you place towers on the map, it's working fine they can click and the towers place the the build mode is set to false. I Want to allow the player to hold shift down then they can place multiply towers then when they release shift the build mode will change to false but i can't figure it out. This is what i've got so far but doesn't seem to work as intended func _input(event): if event.is_action_released("ui_accept") and build_mode == true: verify_and_build() if event.is_action_released("multi_build"): cancel_build_mode() I've assigned ui_accept to left click and multi_bui

Join the discussion →

How to export static images on Nextjs?

when I want to export my nextjs app, it says that I cannot export my images on static websites. Error: Image Optimization using Next.js' default loader is not compatible with next export. Possible solutions: - Use next start to run a server, which includes the Image Optimization API. - Use any provider which supports Image Optimization (like Vercel). - Configure a third-party loader in next.config.js. - Use the loader prop for next/image. How can I make it so that it does ? Is there a way for me to simply tell it to render images statically ? I dont want to go throught other onlines images loa

Join the discussion →
Older stories