Why do we use return? (python) what scenarios would it be useful in?
This is a program to make the text print with each word beginning with a capital letter no matter how the input is. So my question is why do we use return here : def format_name(f_name, l_name): formatted_f_name = f_name.title() formatted_l_name = l_name.title() return f"{formatted_f_name}{formatted_l_name}" print(format_name("ABcDeF", "Xy")) when I could just do this : def format_name(f_name, l_name): formatted_f_name = f_name.title() formatted_l_name = l_name.title() print(f"{formatted_f_name}{formatted_l_nam...
python return
2021-11-24 06:53:47
How to config esrally metric store so that meta part of rally-metrics-* can record took of each query
I use metric store to save esrally results. Some of my results, the "meta" includes "took" of each query: "meta": { "plugins": [ "vector" ], "attribute_xpack.installed": "true", "source_revision": "053779d", "distribution_version": "6.3.2", "distribution_flavor": "default", "index": "trademark_multi", "took": 129, ...
elasticsearch return
2021-11-24 06:53:44
get time and date using cron expression in golang
i'm currently looking for a solution for sometimes now, i have this cron expression time := '0 3,10,16,22 * * ?' and i need to parse this into date and compare it to get a result what my goal is to get time data from the time var and compare it, if the time is not in between 00:00 and 00:06 it will return bool false i understand for comparison i can use if clause but, how to parse this cron expression and turn it into date solution were not found yet. i've been reading cron package in godoc for sometimes and dont find it yet maybe i'm missing something? any kind of solu...
cron go time
2021-11-24 06:53:39
Is it possible replace the value of a cell in a csv file using grep,sed or both
I have written the following command #!/bin/bash awk -v value=$newvalue -v row=$rownum -v col=1 'BEGIN{FS=OFS=","} NR==row {$col=value}1' "${file}".csv >> temp.csv && mv temp.csv "${file}".csv Sample Input of file.csv Header,1 Field1,Field2,Field3 1,ABC,4567 2,XYZ,7890 Assuiming $newvalue=3 ,$rownum=4 and col=1, then the above code will replace: Required Output Header,1 Field1,Field2,Field3 1,ABC,4567 3,XYZ,7890 So if I know the row and column, is it possible to replace the said value using grep, sed? Edit1: Field3 will alwa...
bash csv git-bash linux
2021-11-24 06:52:47
how to make to array data types(object) as strictly equal (===) in JavaScript
In my application I have to make two array datatypes(one is any[] and other is number[]) as equal using strictly equal. my code is: .component.ts if (categoryIds === PhysicalPackageConst.nrtPatchCategory){ this.materialTypes = PhysicalPackageConst.nrtPatchMaterialType; categoryIds = []; } In the above if condition it is showing as false if I make it as ===(if I use == it is showing the data(true) but not for ===) package.constant.ts export const PhysicalPackageConst = { nrtGumCategory : [29], nrtPatchCategory : [30] ...
angular javascript operators typescript
2021-11-24 06:52:46
Why For loop in java gives different results if we put a space in the print statement and then print the variable
public class Countingtable { public static void main(String[] args) { // write a program to count/increase a number by 2 everytime. int number1; for (number1 = 2; number1 <= 20; number1++) System.out.println("this number is a multiple of 2 " + number1); } } Please note, If I remove the space in the print statement it gives different results? any clue will help and appreciated System.out.println("this number is a multiple of 2" + number1);
java javascript operators typescript
2021-11-24 06:52:27
BigQuery - quoting strings produced unexpected results
I am running the following query: select concat('{','"name"',':', chr(34), str, chr(34), ', ','"type"',':','"string"','},') jsonl from (select 'part_number' as str) which results in: and this is the expected results. But when I save the results to a csv file, the results look different. The issue is with the extra double quotation mark that is surrounding each element. Any idea what is causing this discrepancy. btw, my local machine is running Windows 11.
QML does not write to C++ property when bound to component and component value changes
I'm working on a QML project. In the UI I'm working on, I need to both update slider from C++ and read the current value into C++ from QML. Properties seems to be the right solution. So far I've read different questions on SO without success Two way binding C++ model in QML, Changed Properties do not trigger signal, etc... In my current code I declared a property in my C++ class class MyClass : public QObject { Q_OBJECT public: MyClass(QObject*); Q_PROPERTY(double myValue READ getMyValue WRITE setMyValue NOTIFY myValueChanged) void setMyValue(double n) ...
c++ qml qt qt6
2021-11-24 06:49:49
How to fit image data correctly to a model in python?
i am trying to trained a cnn model, but i really don't understand how to do it properly. i still learning about this kind of stuff so i'm really lost. I already tried doing stuff with it but still cannot get my head around it. can someone explain to me how to do it properly. when i try to fit the train data to the model this error pops up. WARNING:tensorflow:Model was constructed with shape (None, 224, 224, 3) for input KerasTensor(type_spec=TensorSpec(shape=(None, 224, 224, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_...
deep-learning keras python tensorflow
2021-11-24 06:49:28
Android TransactionTooLargeException when calling TakePicture
Need to utilise the camera in my app for work, I see that things have changed in API >= 28 compared to how I used to do it where I could use startActivityForResult. However I am facing a problem where I launch the camera app, and immediately get the 'TransactionTooLargeException' error message in the debug/run console. For calling up the camera, I am doing mGetContent = registerForActivityResult( new ActivityResultContracts.TakePicture(), result -> { if (result) { } } ); Where mGetContent is ...
android android-camera java tensorflow
2021-11-24 06:48:37
How to fill a column with formula till a row with data
I have a table as shown in figure. It is about the transaction of a few items with date, qty and rate. Column E calculates the total cost filling the column automatically as new entry is typed. Column F sums up the item quantity and column G calculates the current rate of the item for each row. What I want is that column also gets filled with a single formula in cells F3 and G3, as in the case of column E. Can it be done? Can an array formula do the trick? Regards, Pravin Kumar.
How to pass an argument to a spark submit job in airflow
I have to trigger a pyspark module from airflow using a sparksubmit operator. But, the pyspark module need to take the spark session variable as an argument. I have used application_args to pass the parameter to the pyspark module. But, when I ran the dag the spark submit operator is getting failed and the parameter I passed in considered as None type variable. Need to know how to pass a argument to a pyspark module triggered through spark_submit_operator. The DAG code is below: from pyspark.sql import SparkSession spark = SparkSession.builder.appName("PRJT").e...
airflow pyspark java tensorflow
2021-11-24 06:48:20
If else and switch case alternative in Javascript
Looking for an alternative to the conditional statement. As you can see from my code, the process is overly repetitious and disorganized. It will become increasingly difficult to maintain code as it grows in size. In order to avoid this situation, I'm looking for alternatives. function validate(values) { let errors = {}; // Email Error if (!values.email) { errors.email = "Email address is required"; } else if (!/\S+@\S+\.\S+/.test(values.email)) { errors.email = "Email address is invalid"; } // Password Error if (!values.password) { erro...
permission denied for attachment gmail android
When I press the button, I want to send the json file inside the device via mail. When I switch to the Gmail side, I get the error "permission denied for attachment". How can I solve this problem? manifest: <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE&q...
android android-intent gmail java
2021-11-24 06:47:21
Read the exit code of ansible inside sh file
I have a shell script, which triggers an ansible-playbook command say ansible-playbook install.yml. This works perfectly fine. Now inside the shell script, based on whether the Ansible command was successful or failure, I need to do something. Is there a way to capture the exit code of an Ansible command so that I can use it for further steps inside the shell script? Any alternate approaches would also be really helpful.
ansible ansible-2.x sh shell
2021-11-24 06:46:52
Missing credentials in config when trying to put object to s3 bucket
I've got an express service that is trying to write an object to an s3 bucket but I'm getting the following error: Missing credentials in config I'm assuming my AWS role locally which sets my credentials in .aws/credentials then in my Dockerfile I am copying them into my container. RUN mkdir "/home/node/.aws" && touch "/home/node/.aws/config" && touch "/home/node/.aws/credentials" RUN echo "${AWS_CREDENTIALS}" > "/home/node/.aws/credentials" The documentation says: The SDK automatically detects AWS ...
Postgres Querying/filtering JSONB with nested arrays
Below is my sample requirement I want customers who meet all the below conditions In country "xyz", incorporated between 2019 to 2021. Should be having at least one account with balance between 10000 and 13000 and branch is "abc" and transaction dates between 20200110 and 20210625. It is formatted and stored as number Should be having at least one address in the state "state1" and pin codes between 625001 and 625015 Below is table structure CREATE TABLE IF NOT EXISTS customer_search_ms.customer ( customer_id int...
How to upload images after cropping in Xamarin
I am using ImageCropper and MediaPlugin to Upload images. However I have problem getting the image after cropping the image. string imagefile; protected void OnClickedRectangle(object sender, EventArgs e) { new ImageCropper() { Success = (imageFile) => { Device.BeginInvokeOnMainThread(() => { view_imageavatar.Source = ImageSource.FromFile(imageFile); }); } }.Show(this); } async void edit_avatar_Tapped(object sender, EventArgs e) { try { await CrossMedia.Current...
Cannot remove underline nor change text color using a hyperlink
I have a certain part of my text to have a hyperlink, but when I use the anchor element, use CSS to have text-decoration off, and change the color to #987b74, It does not work. Does anyone have any clue what is wrong? I've tried everything! If needed, I can send my entire CSS, just let me know! Thank you for your help! :) header{ background-image: url(banner1.png); background-repeat: no-repeat; background-size: 100% 100%; background-color: #FACABC; background-position: center; display: block; position: relative; } h1{ text-align: cent...
css html hyperlink underline
2021-11-24 06:44:59
Powershell : Search the Subdirectory and copy the file to that directory
I have been working on a Powershell script from past 2 weeks and I haven't made much progress in that. So I'm trying to copy a file called version.properties from the root of my gradle project to the Subdirectories like "src/main/resources", "src/main/webapp" and "src/main/application". If i hard code the path it's working, but im trying to make it generic by finding the directory and copying my file to that directory. I want my version.properties file to be copied to "resources","webapp" and "application" direc...
Unable to find if a node exists in realtime database
I have a firebase realtime tree which has a particular node New Ride set when the user is online, when offline the node New Ride gets removed. This works ok for the first time, When the user tries to go online again I can't set up the node. I want to check if the node already exists in the tree if not add it. This is my code so far DatabaseReference rideRequestRef = FirebaseDatabase(databaseURL: firebaseUrl) .reference() .child("Drivers") .child(currentFirebaseUser.uid) .child("New Ride"); var ref = FirebaseDatabase(databaseURL: fir...
How to make "safe area" in UITextField with SecureTextEntry toggle?
I have a problem, I added secureTextEntry toggle in my text field, but text is on toggle button. extension UITextField { fileprivate func setPasswordToggleImage(_ button: UIButton) { if(isSecureTextEntry){ button.setImage(UIImage(named: "eye-active"), for: .normal) }else{ button.setImage(UIImage(named: "eye-inactive"), for: .normal) } } func enablePasswordToggle(){ let button = UIButton(type: .custom) setPasswordToggleImage(button) button.frame = CGRect(x: CGFloat(se...
ios swift uikit underline
2021-11-24 06:44:15
How to view Azure Advisor capacity metrics?
I am writing a capacity planning document and some of the information I would like to gather is resource CPU utilization, memory, network, disk, etc.. I've come across Azure Advisor, and I love the PDF/CSV it provides. However, I am curious as to how this person here was able to get a more detailed view showing columns that include CPU utilization, memory, and network which I don't see when I navigate to Azure Advisor... This is all I'm able to see: This is what i would like to see:
Concat column of one table to each column of another table
I have dates in one table: 2021-10-01 2021-10-02 And codes in another table: 0101 0102 I want my results to look like so: 2021-10-01 - 0101 2021-10-02 - 0101 2021-10-01 - 0102 2021-10-01 - 0102 Which translates to adding all codes to each date into a final table where each date has a code. Date table query: Select DATE from Table1 Code table query: Select CODE from Table2
sql sql-server tsql underline
2021-11-24 06:43:45
Node.JS / Mongo does not save complete Data
I created a first Schema and another one (2 tables) in MongoDB to house 2 separate information. Now the first works fine, without challenge , but the second schema is supposed to house user information. Now i have a problem with getting user information. I dont seem to understand what the problem is. The Schema Looks like this var db = require('../database'); var mongoose = require('mongoose'); var Schema = mongoose.Schema; var SubscriptionSchema = new Schema({ company_name : String, company_address : String, company_city : String, company_state : String...
mongodb node.js rest underline
2021-11-24 06:43:06
How to turn off the scan for the war files in Jetty10
I am working with Jetty10 and by defalut, war scan is enabled and the scan interval is set to 1 second. It means Jetty scans the complete web apps directory every 1 sec. Please correct me if I am wrong. the below code is in the jetty\etc\jetty-deploy.XML <Set name="scanInterval"><Property name="jetty.deploy.scanInterval" default="1"/></Set> I don't want that burden to my application and turning this scan off will reduce the overhead of jetty scanning complete web apps every 1 sec. So, my question is how can we turn off th...
java jetty jetty-10 underline
2021-11-24 06:42:22
Iterate the files from folder and process them in scala
I have a couple of files in a folder for different countries. like below Casedata_GBR_202110_timestamp.csv Casedata_ARG_202110_timestamp.csv now i have to process take these files process them by country wise and copy to respective folders. my destination folder structure will be like 2021-->11-->GBR 2021-->11-->ARG In spark scala/scala help me to write code to process file by country and move to respective country folder.
apache-spark scala jetty-10 underline
2021-11-24 06:42:17
How to disable a Windows registry key without deleting it
I wanted to disable an item in Windows context menus so I found the key relating to it. Deleting this key may solve my problem but is there any other way than deleting it would do the work? Perhaps adding a "--" string before its 'default' value?
contextmenu regedit registry registrykey
2021-11-24 06:41:27
discord.py: Time object in embed
I wondered if it was possible to build something like this: So that it can be put into an embed and shows the time. However when I looked through the discord.py docs I could not find this type of object. Searched google but no solutions. Can anyone help? Thanks in advance!
discord discord.py python registrykey
2021-11-24 06:41:19
MISDP/MISOCP in cvxpy
I'm trying to solve the following problem in CVXPY. The problem is a mixed-integer SDP due to the PSD matrix we're solving. However, according to this list it looks as though none of the solvers can handle such a problem. Can we use the fact that A is a 2x2 matrix to somehow convert this to a mixed-integer SOCP problem? import cvxpy as cp import matplotlib.pyplot as plt import numpy as np np.random.seed(271828) m = 2; n = 50 x = np.random.randn(m,n) off = cp.Variable(boolean=True) A = cp.Variable((2,2), PSD=True) b = cp.Variable(2) obj = cp.Maximize(cp.log_det(A)) co...