Id
int64
34.6M
60.5M
Title
stringlengths
15
150
Body
stringlengths
33
36.7k
Tags
stringlengths
3
112
CreationDate
stringdate
2016-01-01 00:21:59
2020-02-29 17:55:56
Y
stringclasses
3 values
59,314,030
How can I store user input in arrays and then print them out?
<p>I am a beginner programmer and I am making a little application for practice.</p> <p>You enter your budget, then you add an expense(name, amount) and it subtracts and tells you your current budget.</p> <p>I want to make it so you can see all of your expenses after each execution.</p> <p>I have tried to make for loops that store the names of the expenses and then print them. But I am doing something wrong :/.</p> <p>Sorry for my bad English, I am from Croatia!</p> <p>Here is some beginner ugly code.</p> <pre><code> int length = 0; String[] listOfNames = new String[length]; boolean active = true; int budget = 0; Scanner input = new Scanner(System.in); //user input System.out.println("Enter current budget in HRK"); int enteredAmount = input.nextInt(); //user input for budget budget = enteredAmount; while(active) { System.out.println("Current budget is " + budget + " HRK"); System.out.println("Enter expense name and amount"); System.out.println("Name: "); String name = input.next(); //name of expense for(int i=0; i&lt;listOfNames.length;i++){ //adds entered expense names to array listOfNames[i] = name; length++; } System.out.println("Amount: "); int enteredAmount1 = input.nextInt(); budget -= enteredAmount1; // subtracts the budget from the users input System.out.println("Expense: " + name + ", Amount: " + enteredAmount1); // prints final result for(int j=0; j&lt;listOfNames.length; j++) // prints stored strings in array { System.out.println(listOfNames[j]); } } </code></pre> <p>} }</p>
<java>
2019-12-12 23:14:07
LQ_CLOSE
59,314,229
How to check string values in javascript
<p>I'm trying to compare the value of a string and if the first two values = @@ then call a div</p> <p>This is my code example but doesn't seem to work. Is this the correct approach or am I off mark. Be gentle, I'm new to javascript.</p> <pre><code>&lt;script type = "text/javascript"&gt; var str = "@@this is the line for the test"; if (str.substring(0,2) == "@@" { document.write(str.substring(0,2)); } else { document.write("found nothing"); } &lt;/script&gt; </code></pre>
<javascript>
2019-12-12 23:41:00
LQ_CLOSE
59,317,463
How to use super() to call base class function in python 2.7.13?
<p>I have a multilevel inheritance (A->B->C). In base class i have a dictionary variable called "my_dict". From derived class, I am calling base class function by super().add_to_dict() to add some values. </p> <p>Below code works as expected in python 3.7. But in Python 2.7.13 it throws error. can some one help me to fix it for 2.7.13?</p> <pre><code>from collections import OrderedDict class A(): def __init__(self): self.my_dict = OrderedDict() def add_to_dict(self): self.my_dict["zero"]=0 self.my_dict["one"]=1 class B(A): def add_to_dict(self): super().add_to_dict() self.my_dict["two"]=2 def print_dict(self): print("class B {}".format(my_dict)) class C(B): def add_to_dict(self): super().add_to_dict() self.my_dict["three"]=3 def print_dict(self): print("class C {}".format(self.my_dict)) obj = C() obj.add_to_dict() obj.print_dict() </code></pre> <blockquote> <p><strong>Output ( 2.7.13):</strong></p> <p>File "test.py", line 15, in add_to_dict super().add_to_dict()</p> <p><strong>TypeError: super() takes at least 1 argument (0 given)</strong></p> </blockquote> <p><strong>Output (python 3.7)</strong></p> <p>class C OrderedDict([('zero', 0), ('one', 1), ('two', 2), ('three', 3)])</p>
<python><inheritance><super>
2019-12-13 06:50:05
LQ_CLOSE
59,317,913
Duplicate data php
<p>can I check the same data in input in form PHP? this is the program code, but what happens is the same data can still be entered and there is no data checking. I've tried in to change <code>if($query &gt;0)</code> bu the data can be input and be the same.</p> <pre><code>&lt;?php if(!defined('INDEX')) die(""); include("library/config.php"); // cek apakah tombol daftar sudah diklik atau blum? if(isset($_POST['simpan2'])){ // ambil data dari formulir $tanggalmasuk = $_POST['tanggalmasuk']; $tanggalmasuk = date('Y-m-d', strtotime($tanggalmasuk)); $nomorttb1 = $_POST['nomorttb1']; $nama_supplier1 = $_POST['nama_supplier1']; $nama_barang1 = $_POST['nama_barang1']; $jumlahkirim = $_POST['jumlahkirim']; $nomorrefrence = $_POST['nomorrefrence']; $nomorsurat = $_POST['nomorsurat']; // buat query $sql="SELECT * from masuk where po_nomor= '$_POST[nomorttb1]'"; $query = mysqli_query($con, $sql); if($query &gt;0){ echo "Data Sudah Ada"; echo "&lt;meta http-equiv='refresh' content='1; url=?hal=masuk'&gt;"; }else{ $sql = "INSERT INTO masuk( tanggal, po_nomor, idsupplier, idbarang, terima,refrence,surat) VALUES ('$tanggalmasuk', '$nomorttb1', '$nama_supplier1', '$nama_barang1', '$jumlahkirim', '$nomorrefrence', '$nomorsurat')"; $query = mysqli_query($con, $sql); } // apakah query simpan berhasil? if($query){ echo "Data berhasil disimpan!"; echo "&lt;meta http-equiv='refresh' content='1; url=?hal=masuk'&gt;"; }else{ echo "Tidak dapat menyimpan data!&lt;br&gt;"; echo mysqli_error(); } } else { die("Akses dilarang..."); } </code></pre> <p>what I can do to my code and what I can change</p>
<php><mysql>
2019-12-13 07:24:00
LQ_CLOSE
59,318,570
reg ex for searching filenames
<p>I want to select the files, whose names ends with <code>_90.jpeg|_180.jpeg|_270.jpeg|_90.jpg|_180.jpg|_270.jpg</code>.</p> <p>currently I am using the following approach</p> <pre class="lang-py prettyprint-override"><code>pattern = re.compile('_90.jpeg|_180.jpeg|_270.jpeg|_90.jpg|_180.jpg|_270.jpg') pattern.search(filename) </code></pre> <p>Is there any cleaner way to represent the _xxx.yyyy in regular expression. </p>
<python><regex>
2019-12-13 08:17:30
LQ_CLOSE
59,320,282
Refactoring to one line statement bool value
<p>Is there a way to turn this into a one-liner it works as does what its meant to do but I can't help but think it could be one line as I am just simply returning a bool.</p> <pre><code>private bool RequiresTable() { return Settings.Filter.Criteria.Any(w =&gt; w.NameSpace == "XXX"); } </code></pre>
<c#>
2019-12-13 10:10:14
LQ_CLOSE
59,322,388
I want to parse part of my json data into table.Json is given below,I only want to get "Data"=[ ] part in my table
in this json, I want to parse only Data:[] part { "head": { "StatusValue": 200, "StatusText": "Success" }, "body": { "Data": [ { "payer_type_id": 1, "payer_type": "Self Pay" }, { "payer_type_id": 2, "payer_type": "Corporate" }, { "payer_type_id": 6, "payer_type": "Insurance" } ], "RecordCount": 3, "TotalRecords": null } }
<ios><json><swift><parsing><url>
2019-12-13 12:12:39
LQ_EDIT
59,323,509
Making an input icon (search icon) responsive
<p>Typical for a search bar, I've added a magnifying glass icon on the left side for UI purposes. On desktop it looks fine and stays at the position nicely. However, when switching to mobile the icon is repositioning itself according to the device width.</p> <p>I thought by increasing the <code>left</code> parameter for <code>@media (max-width: 768px)</code> it will be fixed but it seems to behave differently.</p> <p>A gif of the issue with the code on the right side is added. What am I doing wrong?</p> <p><a href="https://i.stack.imgur.com/15qtK.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/15qtK.gif" alt="Search icon behaving differently for mobile sizes"></a></p>
<html><css>
2019-12-13 13:25:19
LQ_CLOSE
59,323,993
long to wide format aggregate R tidyverse
<p>Hi given the following dataframe</p> <pre><code>library(tidyverse) df &lt;- data.frame(READS=rep(c('READa', 'READb', 'READc'),each=3) ,GENE=rep(c('GENEa', 'GENEb', 'GENEc'), each=3), COMMENT=rep(c('CommentA', 'CommentA', 'CommentA'),each=3)) &gt; df READS GENE COMMENT 1 READa GENEa CommentA 2 READa GENEa CommentA 3 READa GENEa CommentA 4 READb GENEb CommentA 5 READb GENEb CommentA 6 READb GENEb CommentA 7 READc GENEc CommentA 8 READc GENEc CommentA 9 READc GENEc CommentA </code></pre> <p>I want to convert from long to wide format aggregating by Gene Column so that i get the following</p> <pre><code> GENEa GENEb GENEc READSa 3 3 3 READSb 3 3 3 </code></pre> <p>I have tried with no success:</p> <pre><code> library(tidyverse) df %&gt;% group_by(GENE) %&gt;% select(-COMMENT) %&gt;% spread(READS) </code></pre> <p>Note that the original dataframe is huge so any optimized code would help.</p> <p>Thanks for your help.</p>
<r><tidyverse>
2019-12-13 13:55:54
LQ_CLOSE
59,324,109
Angular Internal: What happens when we inherit a class
<p>Basically i searching to understand what happens when we inherit one class in another internally, also does it like bring performance issue incase if i inherit in n classes.</p>
<javascript><angular><class><inheritance><angular8>
2019-12-13 14:03:09
LQ_CLOSE
59,324,181
How to run the Go executable file generated after building the Go file?
<p>After I build the main.go file using <code>go build go.main</code>, I get the main executable file. How do I run the main file? If I do <code>go run main.go</code>, it automatically builds + runs the executable. But I want to know the command to run the already build executable file.</p>
<go>
2019-12-13 14:07:04
LQ_CLOSE
59,324,322
How to find the origin figure of an axis in Matplotlib
<p>Given an axis instance, is it possible to know to which figure instance does it belong?</p>
<python><matplotlib><plot>
2019-12-13 14:15:57
LQ_CLOSE
59,325,796
http POST not reaching backend
<p>I'm trying to pass an email value to the backend, but it never reaches the endpoint. I have the same url path being called, but <code>console.log("You've made it to the backend");</code> never outputs. Why is that? It's definitely hitting the angular service because Made It outputted to console no problem.</p> <p>angular service</p> <pre><code>import { Injectable } from "@angular/core"; import { HttpClient, HttpParams } from "@angular/common/http"; import { Router } from "@angular/router"; import { PasswordReset } from "./password.model"; @Injectable({ providedIn: "root" }) export class PasswordResetService { constructor(private http: HttpClient, private router: Router) {} sendEmail(email: string) { const password: PasswordReset = { email: email }; console.log("Made It"); return this.http.post( `http://localhost:3000/api/users/passwordreset`, password ); } } </code></pre> <p>app.js</p> <pre><code>app.post("/api/users/passwordreset", function(req, res) { console.log("You've made it to the backend"); let emailValue = req.body.email; if (req.body.email !== undefined) { User.findOne({ email: req.body.email }) .then(user =&gt; { if(user){ console.log("fetchedUser"); console.log(user._id); var payload = { id: user._id, email: user.email }; var secret = user.password + "-" + user.passwordCreated; console.log("THE SECRET IS: " + secret); var token = jwt.sign(payload, secret); console.log("payload"); console.log(payload); var ses_mail = "From: 'Auction Site' &lt;" + emailValue+ "&gt;\n"; ses_mail = ses_mail + "To: " +emailValue + "\n"; ses_mail = ses_mail + "Subject: Password Reset Request\n"; ses_mail = ses_mail + "MIME-Version: 1.0\n"; ses_mail = ses_mail + "Content-Type: multipart/mixed; boundary=\"NextPart\"\n\n"; ses_mail = ses_mail + "--NextPart\n"; ses_mail = ses_mail + "Content-Type: text/html; charset=us-ascii\n\n"; ses_mail = ses_mail + '&lt;a href="http://localhost:3000/resetpassword/' + payload.id + '/' + token + '"&gt;Click here to reset password&lt;/a&gt;'; // /:id/:token var params = { RawMessage: { Data: new Buffer.from(ses_mail) }, Destinations: [emailValue ], Source: "'AWS Tutorial Series' &lt;" + emailValue + "&gt;'" }; ses.sendRawEmail(params, function(err, data) { if(err) { res.send(err); console.log(err); } else { res.send(data); } }) } if (!user) { return res.status(401).json({ message: "Auth failed" }); } }); } else { res.send("Email address is missing."); } }); </code></pre>
<node.js><angular>
2019-12-13 15:47:23
LQ_CLOSE
59,327,528
is there any way to run this applet code and why is my code wrong please help me guys
import java.applet.*; import java.awt.Graphics; public class App extends Applet { public void paint (Graphics g) { g.drawString ("Hello World", 20, 20); } }
<java><applet>
2019-12-13 17:48:50
LQ_EDIT
59,328,099
SWIFT ARKIT detect the hand and nails, and place the object on the nails?
<p>I would like to know how to detect a person’s hand and nails, and then use ARKIT to place an object on her nails. Frankly, I’ve been looking for information about it for several days in Google, I haven’t found anything that could help me. I would really appreciate if you could help me! Thanks a lot in advance!</p>
<ios><swift><swift4><arkit><swift5>
2019-12-13 18:35:13
LQ_CLOSE
59,328,570
Need resultset on following resulset in sql
I have result set as follows, **Employer_id Type Amount** 1 penalty 100 1 interest 120 2 penalty 50 2 interest 60 2 contribution 70 1 contribution 140 I need result as, **Employer_id penalty interest contribution** 1 100 120 140 2 50 60 70 Is it possible in sql? can anyone provide query if possible.
<sql><sql-server>
2019-12-13 19:16:22
LQ_EDIT
59,329,045
How would I setup a HTML page to have a new title each new day?
<p>So my ultimate goal here is to have the site have a new title each day (24 hours).</p> <p>I am not a very experienced program, but, I am aware something similar could be done with JS.</p> <p>I saw this idea:</p> <pre><code>setInterval(function() { //change title //document.title = "Some new title"; }, 3000); </code></pre> <p>I'm not sure how I can take this idea above, which I do not fully understand and make it use, for example, a large array or predefined titles and select one at random each day.</p> <p>Would it be possible to select the title out of another file or should I have them all in the JS file? On the question just asked, should I have the JS code in the HTML file itself or referenced as a file like a CSS file?</p> <p>I really appreciate any walkthrough/help I can get on this. I hope your days are well all.</p>
<javascript><html>
2019-12-13 19:57:08
LQ_CLOSE
59,330,405
C# delete files based on text file
<p>Hy,</p> <p>I have a FilesToDelete.txt file filled with file paths like:</p> <pre><code>C:\Users\Me\Pics\file01.png C:\Users\Me\Pics\file03.png C:\Users\Me\Pics\file15.png etc... </code></pre> <p>How can I delete these files with C#? Thanks!</p>
<c#>
2019-12-13 22:08:28
LQ_CLOSE
59,330,441
When to use routing in Angular?
<p>I started building my first Angular app using routing with unique url for every "main" component. But then I discovered the material and really liked what the tabs are doing. </p> <p>What will be pros and cons of using angular routing together with Angular material when I can just render pages with mat-tab-group like this:</p> <pre><code>&lt;mat-tab-group&gt; &lt;mat-tab label="First"&gt; &lt;app-comp1&gt;&lt;/app-comp1&gt; &lt;/mat-tab&gt; &lt;mat-tab label="Second"&gt; &lt;app-comp2&gt;&lt;/app-comp2&gt; &lt;/mat-tab&gt; &lt;mat-tab label="Third"&gt; &lt;app-comp3&gt;&lt;/app-comp3&gt; &lt;/mat-tab&gt; &lt;/mat-tab-group&gt; </code></pre> <p>In my application I don't need to strictly restrict access to different components views.</p>
<angular><angular-material><angular-routing>
2019-12-13 22:11:52
LQ_CLOSE
59,332,004
Error : [WinError 267] The directory name is invalid
**I tried this code in jupyter notebook, and this error occured.** *Error : [WinError 267] The directory name is invalid: 'plantdisease/PlantVillage/Pepper__bell___Bacterial_spot/0022d6b7-d47c-4ee2-ae9a-392a53f48647___JR_B.Spot 8964.JPG/'* I'm using python 3.6 in anaconda environment, I tried running this code but it showed error. I can't figure out what the problem is.The file location actually exists at the given location, still it shows invalid. '''image_list, label_list = [], [] try: print("[INFO] Loading images ...") root_dir = listdir(directory_root) for directory in root_dir : # remove .DS_Store from list if directory == ".DS_Store" : root_dir.remove(directory)''' for plant_folder in root_dir : plant_disease_folder_list = listdir(f"{directory_root}/{plant_folder}") for disease_folder in plant_disease_folder_list : # remove .DS_Store from list if disease_folder == ".DS_Store" : plant_disease_folder_list.remove(disease_folder) for plant_disease_folder in plant_disease_folder_list: print(f"[INFO] Processing {plant_disease_folder} ...") plant_disease_image_list = listdir(f"{directory_root}/{plant_folder}/{plant_disease_folder}/") for single_plant_disease_image in plant_disease_image_list : if single_plant_disease_image == ".DS_Store" : plant_disease_image_list.remove(single_plant_disease_image) for image in plant_disease_image_list[:200]: image_directory = f"{directory_root}/{plant_folder}/{plant_disease_folder}/{image}" if image_directory.endswith(".jpg") == True or image_directory.endswith(".JPG") == True: image_list.append(convert_image_to_array(image_directory)) label_list.append(plant_disease_folder) print("[INFO] Image loading completed") except Exception as e: print(f"Error : {e}")'''
<python><artificial-intelligence>
2019-12-14 03:11:09
LQ_EDIT
59,332,212
Microservices architecture best practises
<p>I don't know if this is the right platform for this question or not, either way, I am venturing into microservices, have been in for some time though not long and was stuck on the right architecture or rather, best practices:</p> <p>Which is better and why, having all services of a microservices architecture app inside one docker and running many containers in parallel or having each of those services running in their own docker container (which each docker can be run in multiple instances)?</p> <p><strong>P.S.</strong> The services must not necessarily be run using docker</p>
<docker><microservices>
2019-12-14 04:02:15
LQ_CLOSE
59,333,122
C++ - why does sizeof return the false value for an array when used as return value in a function
<p>I have a little problem regarding the size of an array (int, char, etc.). First of all I need to tell you, that I am a beginner in C++ with some background in some other programming languages. Now let us consider the following program: </p> <pre><code>int IntArrayLength(int Array[]){ return (sizeof(Array) / sizeof(Array[0])); } int main(){ int array[] = {10,20,30,40,50}; cout &lt;&lt; (sizeof(array) / sizeof(array[0])) &lt;&lt; endl; // returns 5, which is the correct value cout &lt;&lt; IntArrayLength(array) &lt;&lt; endl; // returns 2, no matter how many elements are in the array } </code></pre> <p>Why does the function <code>IntArrayLength</code> return the value of 2 while the expression <code>(sizeof(array) / sizeof(array[0]))</code> returns the correct value, when not put into a function.</p> <p>Thanks in advance!</p>
<c++><arrays><int><sizeof>
2019-12-14 07:19:15
LQ_CLOSE
59,333,170
Can someone please tell me why my "name" class goes over my navigation menu on mobile please
<p>When viewed at mobile and tablet, my "name" class will conflict with my burger menu.</p> <p><a href="https://johnblairgraphicart.firebaseapp.com/" rel="nofollow noreferrer">https://johnblairgraphicart.firebaseapp.com/</a></p>
<html><css><class>
2019-12-14 07:29:07
LQ_CLOSE
59,333,186
How do i play an animation on a button press
<p>Im making my first game but I am stuck. I am making the main menu. I want to make it that when I press the start game button an animation plays and it starts that game. I have no idea where to start. The button to start the game works and I have created the animation and that works but I don't know how to combine then.</p> <p>I have tried to make the button play the animation play with 'animation.play' but that does not work.</p> <p>Thanks in Advance.</p>
<c#><visual-studio><unity3d><animation><button>
2019-12-14 07:32:36
LQ_CLOSE
59,333,274
How do I add both a variable and a string into the same print statement?
<p>I'm trying to write a basic Python RPG for my friend, and I'm trying to make a stat generator. From what I learned in classes, I'm supposed to <code>print('Your ability score in this is ' + var1 + '.')</code></p> <p>Here's the entire code block where I'm getting the error.</p> <pre><code>Your elemental attack is '''+ elematk + '''.''') </code></pre> <p>And the error I'm getting is</p> <pre><code> File "/Users/data censored/Desktop/Basic RPG.py", line 24, in &lt;module&gt; Your elemental attack is '''+ elematk + '''.''') TypeError: can only concatenate str (not "int") to str </code></pre> <p>Maybe I'm just bad at this. I looked at another answer saying that commas separate a string and a var, but that didn't work either.</p>
<python>
2019-12-14 07:47:17
LQ_CLOSE
59,334,179
How to run my python script parallely with another Java application on the same Linux box in Gitlab?
I have a jar file which needs to be continuosly running in the Git linux box but since this is a application which is continuosly running, the python script in the next line is not getting executed. How to run the jar application and then execute the python script simultaneously one after another? #.gitlab.ci-yml file 1. pwd && ls -l 2. unzip ZAP_2.8.0_Core.zip && ls -l 3. bash scan.sh 4. python3 Report.py scan.sh file has the code "java -jar app.jar" Since, this application is continuosly running, 4th line code "python3 Report.py" is not getting executed. How do I make both these run simulataneously without the .jar application stopping?
<python><python-3.x><git><gitlab>
2019-12-14 10:17:00
LQ_EDIT
59,335,634
how to create a dict from row and sublist?
> I have this data : [enter image description here][1] [1]: https://i.stack.imgur.com/CmvIP.png I would like create a dictionary like : a={'Group':['Wo', 'Me','CHi']} but in the case column 'group' row 5 the value of column 'Me' is 2 ,how I can make to see its value like : a={5:[0, [1,1],0]} Like create another list if the value is > 1:
<python><pandas><dictionary>
2019-12-14 13:37:06
LQ_EDIT
59,340,503
ArrayList is allowing me to store items to it but not call them using .get(), says it isn't an ArrayList
<p>I am writing a program to simulate a restaurant menu system using the command design pattern. I made the construtor in my Menu class initialize an arraylist.</p> <pre><code>import java.util.ArrayList; public class Menu { public ArrayList&lt;MenuItem&gt; listOfMenuItems; public Menu() { listOfMenuItems = new ArrayList&lt;MenuItem&gt;(); } public void addItemToMenu(String itemName, String itemDescription, double cost) { MenuItem newMenuItem = new MenuItem(itemName, itemDescription, cost); listOfMenuItems.add(newMenuItem); } public void displayMenu() { for(MenuItem item : listOfMenuItems) { System.out.println("NAME: " + item.getItemName() + ", DESCRIPTION: " + item.getItemDescription() + ", COST: " + item.getItemCost()); } } } </code></pre> <p>When calling a new Menu in my client, it allows me to store items (as if it was an arraylist), it also allows me to implement the command design pattern and print all of my items out. However, I was adding a Tab class which used information from my Menu object, but it doesn't let me use .get() to retrieve information from my arraylist.</p> <pre><code>import java.util.*; public class testClient { public static void main(String[] args) { Menu menu = new Menu(); Tab tab; System.out.println("MENU:"); menu.addItemToMenu("lobster", "#1234" , 25.99); menu.addItemToMenu("chicken", "#5687" , 20.99); menu.addItemToMenu("steak", "#4567" , 21.99); DisplayMenu dispMenu = new DisplayMenu(menu); SubmitButton onPressed = new SubmitButton(dispMenu); onPressed.submit(); System.out.print("\n"); System.out.println("ORDERS:"); Order order = new Order(); order.addNewOrder("#1234"); order.addNewOrder("#5678"); SubmitOrder submitOrder = new SubmitOrder(order); SubmitButton onSubmitPressed = new SubmitButton(submitOrder); onSubmitPressed.submit(); tab.constructTab(newMenu.get(0).getItemName(), order.get(0).getOrderItemNumber(), newMenu.get(0).getItemCost()); } } </code></pre> <p>The line tab.constructTab(....), returns the following error:</p> <pre><code>testClient.java:31: error: cannot find symbol tab.constructTab(menu.get(0).getItemName(), order.get(0).getOrderItemNumber(), menu.get(0).getItemCost()); ^ symbol: method get(int) location: variable menu of type Menu testClient.java:31: error: cannot find symbol tab.constructTab(menu.get(0).getItemName(), order.get(0).getOrderItemNumber(), menu.get(0).getItemCost()); ^ symbol: method get(int) location: variable order of type Order testClient.java:31: error: cannot find symbol tab.constructTab(menu.get(0).getItemName(), order.get(0).getOrderItemNumber(), menu.get(0).getItemCost()); ^ symbol: method get(int) location: variable menu of type Menu 3 errors </code></pre> <p>it says that menu is of type Menu when it should be an arraylist? I don't understand why it allows me to add items then.</p> <p>Please let me know if you need any additional code.</p> <p>Thank you in advance!</p>
<java><object><arraylist>
2019-12-15 01:17:49
LQ_CLOSE
59,340,505
Change the number and variety of data fields without altering methods?
<p>I'm including my Java assignment below. I'm a bit puzzled by the instructions. I am supposed to use a new data field. The class is supposed to only have one data field. I am not, however, supposed to alter the methods. I don't really have any idea how to do this and make it work without altering the methods.</p> <blockquote> <p>Modify the Time2 class (below) to implement the time as the number of seconds since midnight. The class should have one data field (an int with the number of seconds since midnight) instead of three. This change should not affect the arguments, behavior, or output of the public methods.</p> </blockquote> <pre><code>public class Time2 { private int hour; // 0 - 23 private int minute; // 0 - 59 private int second; // 0 - 59 public Time2() {this(0, 0, 0);} public Time2(int hour) {this(hour, 0, 0);} public Time2(int hour, int minute) {this(hour, minute, 0);} // Time2 constructor: hour, minute and second supplied public Time2(int hour, int minute, int second) { if(hour&lt;0||hour&gt;=24) throw new IllegalArgumentException("hour must be 0-23"); if (minute &lt; 0 || minute &gt;= 60) throw new IllegalArgumentException("minute must be 0-59"); if (second &lt; 0 || second &gt;= 60) throw new IllegalArgumentException("second must be 0-59"); this.hour = hour; this.minute = minute; this.second = second; } public Time2(Time2 time) {this(time.getHour(), time.getMinute(), time.getSecond());} // Set Methods // set a new time value using universal time; // validate the data public void setTime(int hour, int minute, int second) { if (hour&lt;0||hour&gt;=24) throw new IllegalArgumentException("hour must be 0-23"); if (minute &lt; 0 || minute &gt;= 60) throw new IllegalArgumentException("minute must be 0-59"); if (second &lt; 0 || second &gt;= 60) throw new IllegalArgumentException("second must be 0-59"); this.hour = hour; this.minute = minute; this.second = second; } public void setHour(int hour) { if (hour &lt; 0 || hour &gt;= 24) throw new IllegalArgumentException("hour must be 0-23"); this.hour = hour; } public void setMinute(int minute) { if (minute &lt; 0 &amp;&amp; minute &gt;= 60) throw new IllegalArgumentException("minute must be 0-59"); this.minute = minute; } public void setSecond(int second) { if (second &lt;= 0 || second &gt; 60) throw new IllegalArgumentException("second must be 0-59"); this.second = second; } public int getHour() {return hour;} public int getMinute() {return minute;} public int getSecond() {return second;} // convert to String in universal-time format (HH:MM:SS) public String toUniversalString() { return String.format( "%02d:%02d:%02d", getHour(), getMinute(), getSecond()); } // convert to String in standard-time format (H:MM:SS AM or PM) public String toString() { return String.format("%d:%02d:%02d %s", ((getHour() == 0 || getHour() == 12) ? 12 : getHour() % 12), getMinute(), getSecond(), (getHour() &lt; 12 ? "AM" : "PM")); } } </code></pre>
<java><methods>
2019-12-15 01:18:34
LQ_CLOSE
59,340,526
.sort() giving me a NonType error for my function
<p>I'm trying to make a function that gives me the average of a list, excluding the maximum and minimum value. I want to sort my list but when I do, I get a 'NonType' error. Here's my code:</p> <pre><code>def ave_no_max_min(DataList): return sum(DataList.sort()[1:-1])/(len(DataList)-2) print(ave_no_max_min([2,4,3,5,11])) ##should return </code></pre>
<python><non-type>
2019-12-15 01:23:00
LQ_CLOSE
59,341,124
One last function before application closes? (Python)
Ok so look, I'm getting desperate since I've already been all over the internet trying to find the answer to this question. so sorry if this has been answered somewhere else, I couldn't find it just give me the link. So basically I have a python file that is constantly using the ```f.write()``` function to write to another text file, however, the script doesn't stop writing to the file until it's closed manually. This is all fine and dandy, except for the fact that any delay greater than 0.01 doesn't seem to save my edits to the text file, so doing a little bit of investigation, an easy fix is the ```f.close()``` function. So what I need is a line of code that can detect once the script has been stopped, and put out one last function before being fully closed.
<python>
2019-12-15 03:57:26
LQ_EDIT
59,341,687
What's the best way to think about this?
<p>I am new to python and I have heard a lot about "Pythonic" work arounds to common tasks. I wrote the following script for a project I'm working on where it needed to pick a random string from a list of strings and break the string into a key and value. The script worked for that purpose but it got me wondering about the way senior developers think about coding. </p> <p>As a senior developer, how would you think about solving a similar problem?</p> <ul> <li><p>What approach would you take in writing this type of script and why? </p></li> <li><p>How would you decide on the modules to use?</p></li> <li><p>What did I do wrong or right and why?</p></li> <li><p>Would you write the code as fast as possible or spend more time on it?</p></li> </ul> <p>'''</p> <pre><code>import random import re def add_list(wordlist): newword = str(re.split("=", random.choice(wordlist))) print(newword) output = open('Logfile.txt', 'a') output.write("\n" + newword) return output add_list(wordlist = ['1=one', '2=two', '3=three', '4=four',]) </code></pre> <p>'''</p>
<python><random>
2019-12-15 06:27:48
LQ_CLOSE
59,342,211
Using time module in Python
<p>I have a text file named as 'time' and want to save the current date and time from the computer in the text file every-time the player plays the game(Snake and ladder). Please help me to figure it. I have tried making a function for it and add the current date in the file and append the new date and time in text file when the user plays the game but an error occurs every-time.</p>
<python><python-3.x><python-2.7>
2019-12-15 08:09:33
LQ_CLOSE
59,342,869
Is this structure valid?
<p>I want to create a compact method tu calculate the summ of the first 20 even numbers and the multiplication of the first 20 odd numbers. is this correct?</p> <pre><code>for(int i=0; i&lt;=20; i++) { (i % 2 == 0) ? (sumEven +=i;) : (productoImpares *= i;) } </code></pre>
<java>
2019-12-15 10:08:57
LQ_CLOSE
59,343,624
Multipurpose with python
<p>I need to improve a script that runs 3 python scripts in parallel at the same time, I have this script below ready, only it is jumping some scripts on the list, I don't know why this is happening.</p> <p>Code:</p> <pre><code>import sys import asyncio scriptspy = [ '/scipts/sp01.py', '/scipts/sp02.py', '/scipts/sp03.py', '/scipts/sp04.py', '/scipts/sp05.py', '/scipts/sp06.py', '/scipts/sp07.py', '/scipts/sp08.py', '/scipts/sp09.py', '/scipts/sp10.py', '/scipts/sp11.py', '/scipts/sp12.py', '/scipts/sp13.py', '/scipts/sp14.py', '/scipts/sp15.py', '/scipts/sp16.py', '/scipts/sp17.py', '/scipts/sp18.py', '/scipts/sp19.py', '/scipts/sp20.py', '/scipts/sp21.py', '/scipts/sp22.py', '/scipts/sp23.py', '/scipts/sp24.py', ] #linux async def main(): task_run= set() while scriptspy: # start 3 scripts while len(task_run) &lt; 3 and scriptspy: script = scriptspy.pop() p = await asyncio.create_subprocess_exec(sys.executable, script) task = asyncio.create_task(p.wait()) task_run.add(task) # wait one and start task_run, task_end = await asyncio.wait(task_run, return_when=asyncio.FIRST_COMPLETED) await asyncio.wait(task_run, return_when=asyncio.ALL_COMPLETED) asyncio.run(main()) </code></pre> <p>Detail S.O Execute: Linux (Ubuntu) Python: 3.7</p>
<python><python-3.x><multithreading>
2019-12-15 11:50:57
LQ_CLOSE
59,343,927
How to read image from firebase using opencv python
Is there any idea for reading image from firebase using OpenCV Python ? Or do I have to download the pictures first and then do the cv.imread function from the local folder ? Is there any way that I could just cv.imread(link_of_picture_from_firebase) ???
<python><firebase><opencv><pyrebase>
2019-12-15 12:34:03
LQ_EDIT
59,345,771
two foreign keys referencing the same primary key.Is it in normal form?
Will the table be in normal form if in a table there are two foreign keys referencing the same primary key from another table?
<sql><database><database-normalization>
2019-12-15 16:23:55
LQ_EDIT
59,346,063
How to have multiple goroutines read the lines of a single file?
<p>I want to read a huge file, say > 1 GB, and have its lines processed by multiple worker goroutines.</p> <p>I'm worried that using a single goroutine (main) for reading the input lines will impose a bottleneck, when using a huge number of worker goroutines.</p> <p>How can I safely have multiple goroutines read the lines of the file? Is it possible split the input file into several chuncks and have each goroutine operate on a separate chunk individually?</p> <p>The following is sample code of having one goroutine read input lines with several worker goroutines processing them:</p> <pre><code>package main import ( "bufio" "fmt" "log" "os" ) func main() { file, err := os.Open("/path/to/file.txt") if err != nil { log.Fatal(err) } defer file.Close() lines := make(chan string) for i := 0; i &lt; 100; i++ { // start 100 workers to process input lines. // the workers terminate once 'lines' is closed. go worker(lines) } scanner := bufio.NewScanner(file) go func() { defer close(lines) for scanner.Scan() { lines &lt;- scanner.Text() } if err := scanner.Err(); err != nil { log.Fatal(err) } }() ... } </code></pre>
<go>
2019-12-15 16:55:30
LQ_CLOSE
59,347,522
A Python Program that picks something from a list
<p>Sorry If there is already a question of this but I didn't find it. So is there function that picks something from a list but with percents like we have a list with a soda, a soup and a water bottle so the program must pick one of these but the chance it would pick the soup is 2% for the soda is 30% and for the water bottle is 68%?</p>
<python>
2019-12-15 19:50:55
LQ_CLOSE
59,349,126
How to implement the whitespace in my python 3.7 and implement In[1]:
**In[1]:** listofNumbers = [1, 2, 3, 4, 5, 6] for number in listofNumbers: print (number), if (number % 2 ==0): print (" is even") else : print(" is odd") print("All done.") I wanted my codes to print 1,2,3,4,5,6 and specific if each is even or odd, but it only brings the figures, no remarks,
<python>
2019-12-15 23:57:10
LQ_EDIT
59,349,954
JAVA EE SAVE ME PLEASE - PRIMEFACE ISSUES NETBEANS
sorry for the awlful error, I have some issue with java ee using netbeans and primefaces.This is my index.xhtml ``` <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" http://primefaces.prime.com.tr/ui> xmlns:p="http://xmlns.jcp.org/jsf/passthrough" template="/webpages/resources/template.xhtml" <h:head> <title>Reservation</title> <h:outputStylesheet name="css/jsfcrud.css"/> <h:outputStylesheet library="resources/css/styles.css"/> </h:head> <h:body> <h3>Reservation Page</h3> <style type="text/css"> .label { width:20%; padding:4px; } .value { width:80%; padding:4px; } .grid { width:100%; } .error { color: red; } .outputLabel { font-weight: bold; } .grid { width:33%; padding:4px; } </style> <h:form> <p:growl id="growl" sticky="true" showDetail="true"/> <p:wizard flowListener="#{userWizard.onFlowProcess}"> <p:tab id="customer" title="Customer Details"> <p:panel header="Customer Details"> <p:messages /> <h:panelGrid columns="2" columnClasses="label, value"> <h:outputText value="Firstname: *" /> <p:inputText value="#{userWizard.user.firstName}" required="true" label="Firstname"/> <h:outputText value="Lastname: *" /> <p:inputText value="#{userWizard.user.lastName}" required="true" label="Lastname"/> <h:outputText value="Age: " /> <p:inputText value="#{userWizard.user.age}" /> <h:outputText value="Birthday: " /> <p:inputText value="#{userWizard.user.birthday}" /> <h:outputText value="Email: " /> <p:inputText value="#{userWizard.user.email}" /> <h:outputText value="Skip to last: " /> <h:selectBooleanCheckbox value="#{userWizard.skip}" /> </h:panelGrid> </p:panel> </p:tab> <p:tab id="address" title="Address"> <p:panel header="Address Details"> <p:messages /> <h:panelGrid columns="2" columnClasses="label, value"> <h:outputText value="Zip Code: " /> <p:inputText value="#{userWizard.user.zipcode}" /> <h:outputText value="Country: " /> <p:inputText value="#{userWizard.user.country}" /> <h:outputText value="Adress: " /> <p:inputText value="#{userWizard.user.adress}" /> <h:outputText value="City: " /> <p:inputText value="#{userWizard.user.adress}" /> <h:outputText value="State: " /> <p:inputText value="#{userWizard.user.adress}" /> <h:outputText value="Skip to last: " /> <h:selectBooleanCheckbox value="#{userWizard.skip}" /> </h:panelGrid> </p:panel> </p:tab> <p:tab id="room" title="Room Selection"> <p:panel header="Room Selection"> <p:messages /> <h:panelGrid columns="3" columnClasses="label, value"> <h:outputText value="Selecione o número do quarto: *" /> <p:inputText value="#{userWizard.user.roomNumber}" required="true" label="Email"/> <h:outputText value="Selecion a dimensão do quarto(10m²,20m²,40m²: " /> <p:inputText value="#{userWizard.user.dimensionRoom}"/> <h:outputText value="Informações adicionais para o quarto: " /> <p:inputText value="#{userWizard.user.info}"/> </h:panelGrid> </p:panel> </p:tab> <p:tab id="reservation" title="Reservation"> <p:panel header="Reservation Selection"> <p:messages /> <h:panelGrid columns="2" columnClasses="label, value"> <h:outputText value="Number of guests?: " /> <p:inputText value="#{userWizard.user.numberGuests}" required="true"/> <h:outputText value="Entre com o dia da sua Reserva: " /> <p:inputText value="#{userWizard.user.reservationDate}"/> <h:outputText value="Entre com a data do seu Check-in: " /> <p:inputText value="#{userWizard.user.checkIn}"/> <h:outputText value="Entre com a data do seu Check-out: " /> <p:inputText value="#{userWizard.user.checkOut}"/> </h:panelGrid> </p:panel> </p:tab> <p:tab id="confirm" title="Confirmation"> <p:panel header="Confirmation"> <h:panelGrid id="confirmation" columns="3" columnClasses="grid,grid,grid"> <h:panelGrid columns="2" columnClasses="label, value"> <h:outputText value="Firstname: " /> <h:outputText value="#{userWizard.user.firstName}" styleClass="outputLabel"/> <h:outputText value="Lastname: " /> <h:outputText value="#{userWizard.user.lastName}" styleClass="outputLabel"/> <h:outputText value="Age: " /> <h:outputText value="#{userWizard.user.age}" styleClass="outputLabel"/> </h:panelGrid> <h:panelGrid columns="2" columnClasses="label, value"> <h:outputText value="Email: " /> <h:outputText value="#{userWizard.user.email}" styleClass="outputLabel"/> <h:outputText value="Adress: " /> <h:outputText value="#{userWizard.user.adress}" styleClass="outputLabel"/> <h:outputText value="Zipcode: " /> <h:outputText value="#{userWizard.user.zipcode}" styleClass="outputLabel"/> </h:panelGrid> <h:panelGrid columns="2" columnClasses="label, value"> <h:outputText value="Country: " /> <h:outputText value="#{userWizard.user.country}" styleClass="outputLabel"/> <h:outputText value="Title " /> <h:outputText value="#{userWizard.user.title}" styleClass="outputLabel"/> <h:outputText value="City: " /> <h:outputText value="#{userWizard.user.city}" styleClass="outputLabel"/> </h:panelGrid> <h:panelGrid columns="2" columnClasses="label, value"> <h:outputText value="State: " /> <h:outputText value="#{userWizard.user.state}" styleClass="outputLabel"/> <h:outputText value="Birthday: " /> <h:outputText value="#{userWizard.user.birthday}" styleClass="outputLabel"/> <h:outputText value="Room Number: " /> <h:outputText value="#{userWizard.user.roomNumber}" styleClass="outputLabel"/> </h:panelGrid> <h:panelGrid columns="2" columnClasses="label, value"> <h:outputText value="Dimension Room: " /> <h:outputText value="#{userWizard.user.dimensionRoom}" styleClass="outputLabel"/> <h:outputText value="Info: " /> <h:outputText value="#{userWizard.user.info}" styleClass="outputLabel"/> <h:outputText value="Number of Guests: " /> <h:outputText value="#{userWizard.user.numberGuests}" styleClass="outputLabel"/> </h:panelGrid> <h:panelGrid columns="2" columnClasses="label, value"> <h:outputText value="Reservation Date: " /> <h:outputText value="#{userWizard.user.reservationDate}" styleClass="outputLabel"/> <h:outputText value="Check-in: " /> <h:outputText value="#{userWizard.user.checkIn}" styleClass="outputLabel"/> <h:outputText value="Check-out: " /> <h:outputText value="#{userWizard.user.checkOut}" styleClass="outputLabel"/> </h:panelGrid> </h:panelGrid> <p:commandButton value="Submit" action="#{userWizard.save}" update="growl" process="@this"/> </p:panel> </p:tab> </p:wizard> </h:form> <br /> <h:link outcome="/customer/List" value="Show All Customer Items"/> </h:body> </html> ``` and my pom.xml I'm actually using maven. ``` <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mycompany</groupId> <artifactId>mavenproject1</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <name>mavenproject1</name> <properties> <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>javax</groupId> <artifactId>javaee-web-api</artifactId> <version>7.0</version> <scope>provided</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> <compilerArguments> <endorseddirs>${endorsed.dir}</endorseddirs> </compilerArguments> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.3</version> <configuration> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.6</version> <executions> <execution> <phase>validate</phase> <goals> <goal>copy</goal> </goals> <configuration> <outputDirectory>${endorsed.dir}</outputDirectory> <silent>true</silent> <artifactItems> <artifactItem> <groupId>javax</groupId> <artifactId>javaee-endorsed-api</artifactId> <version>7.0</version> <type>jar</type> </artifactItem> </artifactItems> </configuration> </execution> </executions> </plugin> </plugins> </build> </project> ``` The error that appears is that a component is undeclared, and asks to add this library xmlns: p = "http://xmlns.jcp.org/jsf/passthrough" but when added it does not resolve and asks to put back in a Infinite loop. [enter image description here][1] [1]: https://i.stack.imgur.com/qtOo8.png
<jsf><primefaces><xhtml>
2019-12-16 02:46:43
LQ_EDIT
59,349,957
How to convert time in utc second and timezone offset in second to date string format in "yyyy-mm-dd" in java8?
I have a date in utc second and its time zone offset in sec. I would like to convert it to daten string in format yyyy-mm-dd using java8 ZoneOffset class. For example time = 1574962442, offset = 3600 --> date string in yyyy-mm-dd
<java><date><java-8><unix-timestamp><timezone-offset>
2019-12-16 02:47:28
LQ_EDIT
59,350,721
how can I run wordpress on GCP cloud run?
according to GCP https://cloud.google.com/wordpress/ but so far cloud run i the best option for no teche person however in order to run cloud run wordpresss must be on a container. using the vM with bitnami wordpress still need some kind technicals and management which don't want to deal with. on the other hand wordpress n App engine standard is doing similar job cloud run with some differences. wordpress app engine vs wordpress cloud run? and if cloud run is much better. how?
<wordpress><google-app-engine><bitnami><google-cloud-run>
2019-12-16 04:52:53
LQ_EDIT
59,351,134
Which entity framework is used in visual studio 2012 with mvc 4 with windows os 7
I have seen there is different option when we add entity framework for database connection,but those options are not in mvc 4 in visual studio 2012. Can anyone tell what is the step by step procedure to use database in visual studio 2012 mvc4 on windows operating system 7
<c#><sql-server><asp.net-mvc><entity-framework><visual-studio-2012>
2019-12-16 05:47:36
LQ_EDIT
59,351,849
How to use a div tag to create a layout and make it responsive
<p>Hi I have tried craeting a layout below</p> <p><a href="https://i.stack.imgur.com/LqFgC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LqFgC.png" alt="enter image description here"></a></p> <p>I have created using a table tag. But the layout is not responsive . I want to use the div tag but i do not know how to do it? I'm placing react component inside those layouts.</p> <p>Any suggestion is helpful.</p>
<html><css><reactjs><sass>
2019-12-16 06:58:43
LQ_CLOSE
59,352,860
Making the for loop append on all the dataset in python
I'm trying to make the for loop append on all the dataset which is from the range of (0,8675) but it keeps getting error just working with 1 row def convert_emoticons(text): for emot in EMOTICONS: text = re.sub(u'('+emot+')', "_".join(EMOTICONS[emot].replace(",","").split()), text) return text text = (dataset['posts'][0]) convert_emoticons(text)
<python><function><for-loop>
2019-12-16 08:28:49
LQ_EDIT
59,353,078
Why should a python variable of type list should be defined first before assigning a value?
<p><code>x = 2</code></p> <p>creates an integer variable. </p> <p><code>y.append(3)</code></p> <p>gives an error message (name 'y' is not defined). </p> <p>In the first one a variable <code>x</code> can be assigned a value without first defining it, why can't we do the same thing with the lists (you have to first define it using <code>l = []</code>). Is this the result of a fundamental design choice in the Python language? Thanks.</p>
<python>
2019-12-16 08:44:47
LQ_CLOSE
59,353,237
php mysql category subcategory list link
<p>I want to like this</p> <p>Category1</p> <p>--Subcat1</p> <p>--Subcat2</p> <p>Category2</p> <p>--Subcat2</p> <p>I have two tables tbl_cat and tbl_subcat</p> <p>tbl_cat(id,cat_name)</p> <p>tbl_subcat(id,<strong>cat_id</strong>,subcat_name) </p> <blockquote> <p>cat_id=tbl_cat.id</p> </blockquote> <p>how to I write the function and display the category and sub-category link </p>
<php><mysql>
2019-12-16 08:55:19
LQ_CLOSE
59,353,837
Split string to array - JavaScript - ES6
Hove I split this string to array with Javascript ES6 Syntax? let dataString = "<p>Lorem ipsum</p> <figure><img src="" alt=""></figure> <p>Lorem ipsum 2</p> <figure><img src="" alt=""></figure>" I want do my array look like this: let dataArray = ["<p>Lorem ipsum</p>", "<figure><img src="" alt=""></figure>", "<p>Lorem ipsum 2</p>", "<figure><img src="" alt=""></figure>"]
<javascript><ecmascript-6>
2019-12-16 09:33:28
LQ_EDIT
59,354,011
Remove text between two square brackets in javascript
<p>How can I change this:</p> <pre><code>This is a string [[remove]] this </code></pre> <p>To:</p> <pre><code>This is a string this </code></pre> <p>I managed to figure out how to remove a string between one set of brackets but I couldn't get it right with two:</p> <pre><code>var myString = "This is my string [remove] this" myString.replace(/ *\[[^\]]*]/, ''); </code></pre>
<javascript><regex>
2019-12-16 09:44:35
LQ_CLOSE
59,355,775
Group by date and count average in JS
<p>I have a dataset with the timestamp and some params. It looks like that: </p> <pre><code>const resp = [ {date: 1576098000, responseBot: 0.47, responseManager: 2.0}, {date: 1576098000, responseBot: 1.50, responseManager: null}, {date: 1576098000, responseBot: 1.05, responseManager: 2.3}, {date: 1576108800, responseBot: 1.00, responseManager: 3.3}, {date: 1576108800, responseBot: 0.60, responseManager: 1.5}, ] ... </code></pre> <p>I need to get a grouped result (by date) and count an average of response (bot and manager). Expected result: </p> <pre><code>[ {date: 1576098000, responseBotAvg: 1.006, responseManagerAvg: 2.15}, {date: 1576108800, responseBotAvg: 0.8, responseManagerAvg: 2.4} ] </code></pre> <p>What is the best way to achieve this result in pure javascript? </p>
<javascript><arrays><group-by><reduce>
2019-12-16 11:31:13
LQ_CLOSE
59,358,206
Calculating mortgage payments
I want to perform a calculation to know all the capital and interest payments of my loans. I managed to calculate for one loan, however, I want to get all the results in a table and probably do the calculation for each one with a for loop. I tried to get some functions that are already in R, but none of them worked. This is a subset of my data: ``` structure(list(ID = c(29347, 159664, 173960, 64643, 64664, 64686 ), Amount = c(2e+06, 2428508.41, 7729095, 11355, 2e+05, 2500000 ), Interest_rate = c(19, 12.5, 10, 8.5, 18, 14), Starting_date = structure(c(1332979200, 1531958400, 1545782400, 1395100800, 1394755200, 1395100800), class = c("POSIXct", "POSIXt"), tzone = "UTC"), Loan_lenght = c(3.002739, 5.002739, 5.005479, 0.49315, 0.49315, 0.99726)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame")) ```
<r><tidyr>
2019-12-16 14:01:36
LQ_EDIT
59,358,632
I'm new to python, why is the colon an invalid syntax?
<p>I'm very new to python, and am trying to build a heads or tails system. But whenever I add the colon to the end of the if statement, it states it as invalid syntax. Though, when I remove the colon, it states invalid syntax for the next line.</p> <pre><code>import random def coinToss ( coinFlip = random.choice([1, 2]) if coinFlip == 1: print("You got Heads!") else print("You got Tails!") ): usrFlip = input("Press Enter to Flip a Coin") if usrFlip == str: coinToss(): </code></pre>
<python>
2019-12-16 14:26:14
LQ_CLOSE
59,359,380
how to extract numbers from a equation given as a string in python?
<p>ex:- <strong>string</strong>="1x-2y-7" <strong>output</strong>=[1,-2,-7]</p> <p>I can get the number using <strong>isnumeric</strong> but I am not able to extract signs out of it </p>
<python><jupyter-notebook>
2019-12-16 15:13:01
LQ_CLOSE
59,361,839
Regex for remove domain in hostname
<p>I am trying to capture only the hostname within this date, but my regex is broken when inside the hostname, there are <code>.</code> because I remove the <strong>hostname domain</strong></p> <p><strong>REGEX</strong></p> <pre><code>^([^;@#.\s]+) </code></pre> <p><strong>DATA</strong></p> <pre><code>srvdata;172.24.154.210 srvnet;10.16.0.1 srvdata2 300 #srvdata3 srvdata3 #srvdata3 srvdata4.domain.com srvdata.4.domain.com </code></pre> <p><strong>OUTPUT</strong></p> <pre><code>srvdata srvnet srvdata2 srvdata3 srvdata4 srvdata </code></pre> <p><strong>DESIRED OUTPUT</strong></p> <pre><code>srvdata srvnet srvdata2 srvdata3 srvdata4 srvdata.4 </code></pre> <p><a href="https://regex101.com/r/KQNbSr/3/" rel="nofollow noreferrer"><strong>REGEX101</strong></a></p>
<python><regex>
2019-12-16 17:46:52
LQ_CLOSE
59,363,120
how to replace single escape char with double using sed
<p>I would like to replace single escape char \ with double \ using sed However when I use</p> <pre><code>`echo $regex | sed 's/\\/\\\\/g'` </code></pre> <p>it returns sed: -e expression #1, char 8: unterminated `s' command is there a solution for this?</p>
<regex><bash><sed>
2019-12-16 19:29:05
LQ_CLOSE
59,364,601
How to properly setState to array of objects?
<p>I have an array ob objects that creates <code>Close</code> buttons depending on how many there are of them. When i click <code>Close</code> button i would expect the array to be updated (removed) then the button element will disappear from screen. </p> <p>I have worked out in <code>console.log</code> but unable to properly do setState :( </p> <p>Example code here: <a href="https://codesandbox.io/s/sharp-kilby-hn2d9" rel="nofollow noreferrer">https://codesandbox.io/s/sharp-kilby-hn2d9</a></p> <p>Any help would be greatly appreciated, i believe it's just the formatting of setState i need to do it properly, but because its array of an objects and so on i just cant figure that one out. </p>
<javascript><arrays><reactjs>
2019-12-16 21:35:30
LQ_CLOSE
59,364,821
How to make item pairs from the same big list in python
<p>For example: [0,1,2,3] expected results [0,1], [0,2], [0,3], [1,2], [1,3], [2,3]</p>
<python><python-3.x>
2019-12-16 21:56:14
LQ_CLOSE
59,365,280
How does Ruby detect a carriage return in a string?
<p>I'm iterating through a large string that has several carriage returns. I'd like my logic to do something every time a carriage return is discovered (create a new ActiveRecord instance with all the string content before the carriage return). </p>
<ruby-on-rails><ruby><string><carriage-return>
2019-12-16 22:43:54
LQ_CLOSE
59,366,878
python for k, g in iterpools.groupby(str): list(g) will change in the 'if' statement
<p>As a newbie, I try to practice the function of groupby and see the result. However, I find a weird phenomenon。</p> <pre><code> str = 'hieeelalaooo' for k, g in groupby(str): print(list(k), list(g)) if True: print(list(k), list(g)) </code></pre> <p>The result shows that list(g) will change in the 'if' statement like below:</p> <pre><code>`['h'] ['h'] ['h'] [] ['i'] ['i'] ['i'] [] ['e'] ['e', 'e', 'e'] ['e'] [] ....` </code></pre> <p>I just can't get it. In my intuition, list(g) should be unchanged rather than becoming a empty list. Could anyone please explain the underlying logic for such change? I am really appreciated for your help.</p>
<python>
2019-12-17 02:38:17
LQ_CLOSE
59,367,657
Setter not working for boolean but work fine in string C#
<p><a href="https://i.stack.imgur.com/K5yV3.png" rel="nofollow noreferrer">Error description</a></p> <p>I don't know why setter is not working for bool variable but working fine with string variable. Is bool requires special setter for it?</p>
<c#><xamarin><getter-setter>
2019-12-17 04:31:09
LQ_CLOSE
59,368,182
PHP script to copy mysql column to another table
<p>Is there any easy way to copy one a column in a table to another table without changing the order ? I am a beginner here. I would be much thankful to you if you could supply in depth answer. </p>
<php><mysql>
2019-12-17 05:42:20
LQ_CLOSE
59,368,816
failed to download file from mysql server
I am new with JSP and servlets. Please help me with my problem. I have done code for uploading multiple files to MySQL database and it is successful. I have one jsp page("**filelist.jsp**") which contains all uploaded files by user. So I want to **Search** particular file using more filter options in jsp. I also tried using filtering and now it is partially completed. I have one ("**Search.jsp**") page where user searched data will be displayed. I also have "**Download**" column in my code so that user can download that file. **But the problem is that I am not able to download particular file from search.jsp page**.i am using netbeans8, tomcat 8. This is my filelist.jsp Page <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <%-- Document : filelist Created on : 22 Oct, 2019, 7:48:04 PM Author : Z0009289 --%> <%@page import="java.sql.DriverManager"%> <%@page import="java.sql.Statement"%> <%@page import="com.servlet.db.DB"%> <%@page import="java.sql.ResultSet"%> <%@page import="java.sql.PreparedStatement"%> <%@page import="java.sql.Connection"%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <% %> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link href="bootstrap.css" rel="stylesheet" type="text/css"> <title>file_list Page</title> <style> tr,td,th{ padding: 20px; text-align: center; } .container { position:"absolute"; padding: 16px 0px; top:0; right:0; display: flex; justify-content: space-between; align-items: center; } form.form-inline{ float: right; } #ddl{ width:150px; } #ddl2{ width:150px; } #cat{ width:175px; } </style> </head> <body> <!-- <form action="" method="POST"> <div class="container"> <div class="form-group"> <div class="input-group"> <input type="text" name="search" class="form-control" placeholder="Search here..." autocomplete="off"/> <button type="submit" value="Search" class="btn btn-primary">Search</button> </div> </div> </div> </form> --> <h3>Search here..</h3> <form action="logout.jsp" align="right"> <input type="submit" value="Logout"/> </form> <form name="empForm" action="search.jsp" method="post"> <div> <table border="1" colspan="2"> <thead> <tr> <th style="alignment-adjust: auto">Z ID:</th> <td><input type="text" name="zid" value="" /></td> </tr> <tr> <th>First Name :</th> <td><input type="text" name="firstname" value="" /></td> </tr> <tr> <th>Last Name:</th> <td><input type="text" name="lastname" value=""/></td> </tr> <tr style="display:none"> <th>Division:</th> <td><input type="text" name="division" value=""/></td> </tr> <tr style="display:none"> <th>Reporting Unit:</th> <td><input type="text" name="reportingunit" value=""/></td> </tr> <tr style="display:none"> <th>Document No.</th> <td><input type="text" name="documentnumber" value=""/></td> </tr> <tr style="display:none"> <th>Document Name:</th> <td><input type="text" name="documentname" value=""/></td> </tr> <tr style="display:none"> <th>Document Uploader:</th> <td><input type="text" name="documentuploader" value=""/></td> </tr> <tr style="display:none"> <th>Document Owner:</th> <td><input type="text" name="documentowner" value=""/></td> </tr> <tr> <th>Document Type</th> <td> <select name="documenttype"> <option value=""></option> <option value="Agreement">Agreement</option> <option value="Contract">Contract</option> <option value="PO">PO</option> <option value="Invoice">Invoice</option> <option value="COA">COA</option> <option value="Lease Deed">Lease Deed</option> <option value="AMC">AMC</option> <option value="Direct Material">Direct Material</option> <option value="Indirect Material/Services">Indirect Material/Services</option> </select> </td> </tr> <tr> <th>Document Category</th> <td> <select name="documentcategory" id="cat"> <option value=""></option> <option value="Customer">Customer</option> <option value="Vendor">Vendor</option> <option value="Internal">Internal</option> </select> </td> </tr> <tr style="display:none"> <th>By Function:</th> <td><input type="text" name="byfunction" value=""/></td> </tr> <tr style="display:none"> <th>Creator:</th> <td><input type="text" name="creator" value=""/></td> </tr> <tr style="display:none"> <th>Modifier:</th> <td><input type="text" name="modifier" value=""/></td> </tr> <tr style="display:none"> <th>Approver:.</th> <td><input type="text" name="approver" value=""/></td> </tr> <tr style="display:none"> <th>Mail Id:</th> <td><input type="text" name="mailid" value=""/></td> </tr> <tr style="display:none"> <th>Added Date:</th> <td><input type="text" name="added_date" value=""/></td> </tr> <tr style="display:none"> <th>Download:</th> <td><input type="text" name="download" value=""/></td> </tr> <tr> <td colspan="3" > <center> <input type="submit" value="Get File(s)" /></center> </td> </tr> </thead> </table> </div> </form> <br><br> <center> <table border="2"> <tr> <th style="width: 20%">ID</th> <th style="width: 20%">First Name</th> <th style="width: 20%">Last Name</th> <th style="width: 20%">File Name</th> <th style="width: 20%">File Path</th> <th style="width: 20%">division</th> <th style="width: 20%">Reporting Unit</th> <th style="width: 20%">Document No.</th> <th style="width: 20%">Document Name</th> <th style="width: 20%">Document Uploader</th> <th style="width: 20%">Document Owner</th> <th style="width: 20%">Document Type</th> <th style="width: 20%">Document Category</th> <th style="width: 20%">By Function</th> <th style="width: 20%">Creator</th> <th style="width: 20%">Modifier</th> <th style="width: 20%">Approver</th> <th style="width: 20%">Z ID</th> <th style="width: 20%">Mail ID</th> <th style="width: 20%">Added Date</th> <th style="width: 20%">Download</th> </tr> <% Connection con = null; PreparedStatement ps = null; ResultSet rs = null; %> <% Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/newfieldsadded","root",""); String sql = "select * from newfiles"; ps = con.prepareStatement(sql); Statement stmt = con.createStatement(); String query = request.getParameter("search"); String data; if(query != null){ data = "select * from newfiles where id like'%"+query+"%' or firstname like'%"+query+"%' or lastname like'%"+query+"%' or filename like'%"+query+"%' or division like'%"+query+"%' or reportingunit like'%"+query+"%' or documentnumber like'%"+query+"%' or documentname like'%"+query+"%' or documentuploader like'%"+query+"%' or documentowner like'%"+query+"%' or documenttype like'%"+query+"%' or documentcategory like'%"+query+"%' or byfunction like'%"+query+"%' or creator like'%"+query+"%' or modifier like'%"+query+"%' or approver like'%"+query+"%' or zid like'%"+query+"%' or mailid like'%"+query+"%'"; } else{ data = "select * from newfiles order by 1 asc"; } rs = stmt.executeQuery(data); while(rs.next()){ %> <tr> <td><%=rs.getInt("id")%></td> <td><%=rs.getString("firstname")%></td> <td><%=rs.getString("lastname")%></td> <td><%=rs.getString("filename")%></td> <td><%=rs.getString("path")%></td> <td><%=rs.getString("division")%></td> <td><%=rs.getString("reportingunit")%></td> <td><%=rs.getString("documentnumber")%></td> <td><%=rs.getString("documentname")%></td> <td><%=rs.getString("documentuploader")%></td> <td><%=rs.getString("documentowner")%></td> <td><%=rs.getString("documenttype")%></td> <td><%=rs.getString("documentcategory")%></td> <td><%=rs.getString("byfunction")%></td> <td><%=rs.getString("creator")%></td> <td><%=rs.getString("modifier")%></td> <td><%=rs.getString("approver")%></td> <td><%=rs.getString("zid")%></td> <td><%=rs.getString("mailid")%></td> <td><%=rs.getTimestamp("added_date")%></td> <td><a href="DownloadServletClass?fileName=<%=rs.getString(4)%>">Download</a></td> </tr> <% } %> </table><br> <a href="index.jsp">Home</a> </center> </body> </html> <!-- end snippet --> [enter image description here][1] This is my Search.jsp page <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <%-- Document : search Created on : 12 Dec, 2019, 4:08:29 PM Author : Z0009289 --%> <%@ page import="java.io.*,java.util.*,java.sql.*"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> <%@ page isELIgnored="false"%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <sql:setDataSource var="emp" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/newfieldsadded" user="root" password="" /> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Search Page</title> </head> <body> <h1>Searched Data</h1> <form name="empForm" action="index.jsp" method="post"> <div> <table border="2" style="width:100%"> <tr> <th style="width:70%">Z ID</th> <th style="width:70%">First Name</th> <th>Last Name</th> <th>Division</th> <th>Reporting Unit</th> <th>Document No.</th> <th>Document Name</th> <th>Document Uploader</th> <th>Document Owner</th> <th>Document Type</th> <th>Document Category</th> <th>By Function</th> <th>Creator</th> <th>Modifier</th> <th>Approver</th> <th>Mail Id</th> <th>Added date</th> <th>Download</th> </tr> <tbody> <% // out.println("select * from newfiles emp where emp.zid like '%"+request.getParameter("zid")+"%' and " // + " emp.firstname like '%"+request.getParameter("firstname")+"%' and" + " emp.lastname like '%"+request.getParameter("lastname")+"%' and" + " emp.documenttype like '%"+request.getParameter("documenttype")+"%' and" // + " emp.documentcategory like '%"+request.getParameter("documentcategory")+"%' "); //out.println("select count(*) from newfiles"); %> <sql:query var="empData" dataSource="${emp}"> select * from newfiles emp where emp.zid like '% <%=request.getParameter("zid")%>%' and emp.firstname like '% <%=request.getParameter("firstname")%>%' and emp.lastname like '% <%=request.getParameter("lastname")%>%' and emp.division like '% <%=request.getParameter("division")%>%' and emp.reportingunit like '% <%=request.getParameter("reportingunit")%>%' and emp.documentnumber like '% <%=request.getParameter("documentnumber")%>%' and emp.documentname like '% <%=request.getParameter("documentname")%>%' and emp.documentuploader like '% <%=request.getParameter("documentuploader")%>%' and emp.documentowner like '% <%=request.getParameter("documentowner")%>%' and emp.documenttype like '% <%=request.getParameter("documenttype")%>%' and emp.documentcategory like '% <%=request.getParameter("documentcategory")%>%' and emp.byfunction like '% <%=request.getParameter("byfunction")%>%' and emp.creator like '% <%=request.getParameter("creator")%>%' and emp.modifier like '% <%=request.getParameter("modifier")%>%' and emp.approver like '% <%=request.getParameter("approver")%>%' and emp.mailid like '% <%=request.getParameter("mailid")%>%' and emp.added_date like '% <%=request.getParameter("added_date")%>%' </sql:query> <c:forEach var="row" items="${empData.rows}"> <tr> <td> <c:out value="${row.zid}" /> </td> <td> <c:out value="${row.firstname}" /> </td> <td> <c:out value="${row.lastname}" /> </td> <td> <c:out value="${row.division}" /> </td> <td> <c:out value="${row.reportingunit}" /> </td> <td> <c:out value="${row.documentnumber}" /> </td> <td> <c:out value="${row.documentname}" /> </td> <td> <c:out value="${row.documentuploader}" /> </td> <td> <c:out value="${row.documentowner}" /> </td> <td> <c:out value="${row.documenttype}" /> </td> <td> <c:out value="${row.documentcategory}" /> </td> <td> <c:out value="${row.byfunction}" /> </td> <td> <c:out value="${row.creator}" /> </td> <td> <c:out value="${row.modifier}" /> </td> <td> <c:out value="${row.approver}" /> </td> <td> <c:out value="${row.mailid}" /> </td> <td> <c:out value="${row.added_date}" /> </td> <td><a href="DownloadServletClass?fileName=<%=request.getParameter(" filename ") %>">Download</a></td> </tr> </c:forEach> </tbody> </table> </div> </form> <br> <center> <a href="index.jsp">Home</a></center> </body> </html> <!-- end snippet --> [1]: https://i.stack.imgur.com/HQh2N.png
<javascript><html><mysql><jsp><servlets>
2019-12-17 06:40:09
LQ_EDIT
59,369,196
Trouble whit pip
Fatal error in launcher: Unable to create process using '"c:\program files (x86)\python38-32\python.exe" "C:\Program Files (x86)\Python38-32\Scripts\pip.exe" install virtualenv venv1'
<python><pip><virtualenv>
2019-12-17 07:10:03
LQ_EDIT
59,369,669
I have got too many sms from my php json sms api
<p>I have tried PHP JSON request on my web site. I use that for SMS sending purposes. But I have got many SMS.</p> <pre><code>&lt;?php // Your code here! // Takes raw data from the request $json = file_get_contents('URL'); // Converts it into a PHP object $data = json_decode($json,true); print_r($data); ?&gt; </code></pre> <p>Are there any other methods to do that instead of this method?</p> <p>I want to send SMS with my back end.</p>
<php><json><api>
2019-12-17 07:47:04
LQ_CLOSE
59,369,999
Download property for link?
<p>There is a following code:</p> <pre><code>var a = document.createElement("a"); a.href = url; a.download = fileName; document.body.appendChild(a); </code></pre> <p>What is property <code>download</code>, how does it work?</p>
<javascript>
2019-12-17 08:12:28
LQ_CLOSE
59,370,921
Checking if two values are approximately the same in python
<p>I have two functions which give me very small numbers. I want to define a <code>IF statements</code> in which If two values are <code>approximately</code> the same print them otherwise <code>pass</code></p> <pre><code>a = (x, y) b = (h, p) If a == b: print(a, b) else: pass </code></pre> <p>for this we cannot use <code>==</code>. How to define it to be close? Because the order of values maybe like <code>a=7e-25</code>, <code>b=1.5e-26</code></p>
<python><numpy><if-statement><approximation>
2019-12-17 09:12:57
LQ_CLOSE
59,371,041
How to delete the folder from a http url using python
<p>i have a wifi enable camera. i can access the image from the ip address while enter in browser. while entering the ip address it shows the list of folders name in the home page. i have to delete one folder. <a href="https://i.stack.imgur.com/FTAtW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FTAtW.png" alt="enter image description here"></a></p> <p>How to delete the 19112300 folder</p>
<python><http><url>
2019-12-17 09:20:36
LQ_CLOSE
59,371,666
sum of values for multiple rows with same name in r
<p>how to perform a sum of values for multiple rows with the same name in r and render a chart in plotly.i have tried a couple of methods like aggregate and tapply, none of them seems to be working for me, could anyone tell me where I am going wrong. </p> <pre><code>library(dplyr) #&gt; #&gt; Attaching package: 'dplyr' #&gt; The following objects are masked from 'package:stats': #&gt; #&gt; filter, lag #&gt; The following objects are masked from 'package:base': #&gt; #&gt; intersect, setdiff, setequal, union library(shiny) library(plotly) #&gt; Loading required package: ggplot2 #&gt; #&gt; Attaching package: 'plotly' #&gt; The following object is masked from 'package:ggplot2': #&gt; #&gt; last_plot #&gt; The following object is masked from 'package:stats': #&gt; #&gt; filter #&gt; The following object is masked from 'package:graphics': #&gt; #&gt; layout cdata1&lt;-data.frame(stringsAsFactors=FALSE, names = c("a", "a", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "c", "c", "c", "d", "d", "d"), values = c(12, 32, 43, 45, 21, 21, 21, 32, 43, 54, 65, 76, 87, 80, 78, 68, 68, 67, 57) ) ui&lt;-fluidPage(fluidRow(plotlyOutput("id1")), fluidRow(plotlyOutput("id2")) ) server&lt;-function(input,output){ output$id1&lt;-renderPlotly({ # a&lt;-aggregate(cdata1$X2014,by=list(cdata1$States.UTs),FUN=sum) # plot_ly(cdata1,x=cdata1$States.UTs,y=cdata1$X2014) cdata1 %&gt;% group_by(grp = rleid(cdata1$names)) %&gt;% summarise(names = first(cdata1$names), values = sum(cdata1$values)) %&gt;% ungroup %&gt;% select(-grp) plot_ly(cdata1,x=cdata1$names,y=cdata1$values) }) } shinyApp(ui,server) </code></pre>
<r>
2019-12-17 09:57:15
LQ_CLOSE
59,372,944
Way to override flex property to manually set width of span in HTML
<p>I wanted to manually set a width of a span to make a circular highlight on an element. But even when I set the width of the span, it stretches up end to end</p> <p>Its parent has flex basis property</p> <pre><code>element.style { flex-basis: 14.2857%; max-width: 14.2857%; overflow: hidden; } </code></pre> <p>Child property</p> <pre><code>background: #006edc; color: white; height: 40px; /* width: 10px; */ -&gt; How to set the width text-align: center; vertical-align: middle; border-radius: 50%; </code></pre> <p>Thank you for your help</p>
<html><css>
2019-12-17 11:07:02
LQ_CLOSE
59,373,086
not able to insert empty integer value in microsoft sql server
INSERT INTO emp(EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) VALUES(7369,'SMITH','CLERK',7902,17-Dec-80,800,'',20) when i run the sql command select * from emp The COMM colums is 0 and not empty. i want the column(COMM) as empty. i have also set the columns as NULL. if need more help will provide more code. why it is inserted as zero and not as blank ? if need more help will provide more code. why it is inserted as zero and not as blank ? if need more help will provide more code. why it is inserted as zero and not as blank ? if need more help will provide more code. why it is inserted as zero and not as blank ? if need more help will provide more code. why it is inserted as zero and not as blank ? if need more help will provide more code. why it is inserted as zero and not as blank ? if need more help will provide more code. why it is inserted as zero and not as blank ?
<sql><sql-server>
2019-12-17 11:15:26
LQ_EDIT
59,374,310
print everything in div tag selenium python3
Hello I am newbie at learning selenium. I am trying to scrape a website which has some info under its div tag like this ``` <div> id="searchResults" class="multiple-view-elements" <span>name</name> <span>info</name> <span>info</name> ---- <span>name</name> ...... ``` my code ``` print ('-------------------------------------------------------------') resp=driver.find_elements_by_id('searchResults').text print (resp) driver.quit() ``` it gives me this error AttributeError: 'list' object has no attribute 'text' what i am doing wrong?
<python-3.x><selenium><selenium-webdriver>
2019-12-17 12:31:29
LQ_EDIT
59,374,795
MS SQL SERVER - DEPARTMENT WISE SALARY WITHOUT USING GROUP BY
CREATE TABLE #Dept ( DeptName VARCHAR(30), Salary INT ) INSERT INTO #Dept VALUES ('A',100),('A',90),('A',80),('A',70),('A',60),('B',80),('B',20),('B',40) EXPECTED OUTPUT: DeptName Salary A 400 B 140
<sql><sql-server><tsql><sql-server-2008><sql-server-2012>
2019-12-17 13:00:32
LQ_EDIT
59,376,748
Assigning element values in an array without knowing the size of the array
<p>During my high school c++ course we were assigned an assignment to write a program that allows the user to input values that would be stored in an array without prompting the user for the array size. So if the user decides to enter 1,2,3 the array size would go from being unknown to three.</p>
<c++><arrays>
2019-12-17 14:51:36
LQ_CLOSE
59,376,774
.NET CORE - DDD + CrossCutting + External API
<p>I am developing a .NET Core project using the DDD, IoC, CrossCutting.</p> <p>The CrossCutting.IoC project, the responsible for register the project dependencies and performing the inversion of control function and this project has the reference of the other projects.</p> <p>Now the need has come to do an external integration by calling an external API. I don't want to escape the design pattern.</p> <p>Which of the following is correct:</p> <ol> <li>Use an interface to integrate and register with IoC</li> <li>Create a project called CrossCutting.Integration</li> <li>None of the options. What is the best option?</li> </ol>
<asp.net-core><.net-core><domain-driven-design><inversion-of-control><cross-cutting-concerns>
2019-12-17 14:52:51
LQ_CLOSE
59,377,616
Access arraylist from another class inside main class
<p>I don't have any idea on how to make this since i'm a new in java. I want to display all my objects in the arraylist of my TimeSlot class into the main class. I've tried few ways like using for (int = 0; i &lt; bookingList.size(); i++) but still can't work. I'm getting nullPointerException so i dont know if there's other way to solve this. Please help.</p> <p>TimeSlot.java</p> <pre><code>import java.util.ArrayList; public class TimeSlot { private String slotName; private ArrayList&lt;Booking&gt; bookingList; public TimeSlot(String sn) { this.slotName = sn; this.bookingList = new ArrayList&lt;Booking&gt;(); Booking booking1 = new Booking("CS1011", "A04", "Aiman"); Booking booking2 = new Booking("CS1012", "A13", "Nazim"); Booking booking3 = new Booking("CS1013", "A06", "Sarah"); Booking booking4 = new Booking("CS1014", "A21", "Majid"); bookingList.add(booking1); bookingList.add(booking2); bookingList.add(booking3); bookingList.add(booking4); } public String getSlotName() { return slotName; } public ArrayList&lt;Booking&gt; getBookingList() { return bookingList; } public boolean isBooking (String bId, String cId, String sId) { boolean isVerifyBooking = false; for(Booking newBooking: bookingList){ if((newBooking.getBookingId().equals(bId)) &amp;&amp; newBooking.getComputerId().equals(cId) &amp;&amp; newBooking.getStudentId().equals(sId)) { return true; } } return isVerifyBooking; } } </code></pre> <p>Main.java</p> <pre><code>public static void main(String[] args) { // TODO Auto-generated method stub Faculty faculty = new Faculty("Computer Science and Technology", ""); Lab lab = new Lab(""); ArrayList&lt;Computer&gt; computerList = new ArrayList&lt;Computer&gt;(); ArrayList&lt;Booking&gt; isBookingList = new Booking(null, null, null).getBookingList(); if (option.equals("1")) { System.out.println("\nChoose day: "); String days = sc.next(); System.out.println("\nChoose date: "); String date = sc.next(); boolean isValidDay = lab.verifyDate(days, date); if (isValidDay) { Day day = new Day(days, date); System.out.println("\nBooking date: " + day.getDay() + " " + day.getDate()); System.out.println("\nPlease select a computer (A01 ~ A40): "); String cId = sc.next(); System.out.println(isBookingList.size()); } } else if (option.equals("2")) { // I want to display it here for (Booking booking: isBookingList) { System.out.println(booking.getBookingList()); } } </code></pre>
<java>
2019-12-17 15:41:25
LQ_CLOSE
59,378,119
Javascript - nested dictionary from array of strings separated with dots
<p>I have to <strong>translate</strong> an array <strong>to</strong> nested dictionary.</p> <p>In case i have a string array. each string combined from numbers that seprated by dots, and each number means a key in the translated dictionary. (except the last number)</p> <p>e.g.</p> <p>i have this array: <code>array = ["5.1.1.1","5.1.1.2","5.1.1.3",..."5.2.1.2","5.2.1.4"..."1.1.1.1"..."1.2.1.3"]</code></p> <p>and i need output to be this:</p> <pre><code>var output = { '5': { '1': { '1': [1,2,3], '2': [1] }, '2':{ '1': [2,4], '2': [1] } }, '1': { '1':{ '1':[1,2,5], '2':[1] }, '2':{ '1':[2,3] } } }; </code></pre> <p>i have an opposite function, which get a nested dictionary and her output is an array.</p> <p>link: <a href="https://stackoverflow.com/a/59191937/7593555">https://stackoverflow.com/a/59191937/7593555</a></p> <p>Thanks for helping :).</p>
<javascript><angular><typescript>
2019-12-17 16:12:26
LQ_CLOSE
59,378,272
How to change column names from numbers to names
<p>I have a dataframe which looks like this:</p> <p><a href="https://i.stack.imgur.com/5Arqi.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5Arqi.jpg" alt="dataframe"></a></p> <p>I want to change the columnnames, for example: "2018-12-31 00:00:00" to "year_2018". How can I do that?</p>
<python><python-3.x><pandas><dataframe>
2019-12-17 16:22:42
LQ_CLOSE
59,378,401
How can i different json element with 2 parts in java script
``` Example json var json={ list:{ c1:"BTC", c2:"ETH", c3:"DOGE", c4:"LTC", c5:"BSV", c6:"XRB", c7:"SRB", c8:"WAVE", c9:"LINK", c10:"EOS" } } ``` **°I want that there is 10 element in this json i want that it can dive this json in 2 part in first part it will show first 5 element and in 2nd part it will show remaining element. So total will be 10 element in 2 parts. How can i do that with java script?**
<javascript>
2019-12-17 16:30:40
LQ_EDIT
59,379,304
Bash issue with numbers in specific format
(Need in bash linux)I have a file with numbers like this 1.415949602 91.09582241 91.12042924 91.40270349 91.45625033 91.70150341 91.70174342 91.70660043 91.70966213 91.72597066 91.72876783 91.73986459 91.75429779 91.76781464 91.77196659 91.77299733 abcdefghij 91.7827827 91.78288651 91.7838959 91.7855 91.79080605 91.80103075 91.8050505 (1)1st I need to remove 91. from all numbers in the list (2)then need to delete all numbers which don't have length =10 (3)then need to delete all numbers which not start with 6 or 7 or 8 or 9 Any way possible I can do these 3 steps?
<linux><awk><grep>
2019-12-17 17:29:27
LQ_EDIT
59,380,066
angular guard not returning data
I'm using google maps API to get maxLat,maxLng,minLat,minLng and then I want to resolve data from the database before create the component, this is for SEO metas and description the problem is, that the guard is resolving the data, but not resolving the component my app-routing.module.ts my GuardService.ts ```` @Injectable({ providedIn: 'root' }) export class BusquedaGuardService implements CanActivate { componentForm = { locality: 'long_name', administrative_area_level_2: 'short_name', administrative_area_level_1: 'short_name' }; ubicacion: string maxLng minLng maxLat minLat constructor(private http: HttpClient, private router: Router, @Inject(PLATFORM_ID) private platformId: Object, private ngZone: NgZone, private mapaService: MapaService, private mapsAPILoader: MapsAPILoader) { } async getBounds() { let promise = new Promise((res, rej) => { this.mapsAPILoader.load().then(() => { this.ngZone.run(() => { let autocompleteService = new google.maps.places.AutocompleteService(); autocompleteService.getPlacePredictions( { 'input': this.ubicacion, 'componentRestrictions': { 'country': 'cl' }, }, (list, status) => { if (list == null || list.length == 0) { // console.log("No results"); } else { let placesService = new google.maps.places.PlacesService(document.createElement('div')); placesService.getDetails( { placeId: list[0].reference }, (detailsResult: google.maps.places.PlaceResult, placesServiceStatus) => { let direccion = '' let contador = 0 for (var i = 0; i < detailsResult.address_components.length; i++) { var addressType = detailsResult.address_components[i].types[0]; if (this.componentForm[addressType]) { var val = detailsResult.address_components[i][this.componentForm[addressType]]; // $(`#${addressType}`).value = val; if (addressType == 'locality') { direccion = direccion + val contador++ } else { if (contador == 0 && addressType == "administrative_area_level_2") { direccion = direccion + val contador++ } else { if (contador == 0 && addressType == "administrative_area_level_1") { direccion = direccion + val } else { direccion = direccion + ", " + val } } } } } this.mapaService.setDireccion(direccion) let e = detailsResult.geometry.viewport let lat = e[Object.keys(e)[0]] let lng = e[Object.keys(e)[1]] // console.log(lat, lng) this.maxLng = lng[Object.keys(lng)[1]] this.minLng = lng[Object.keys(lng)[0]] this.maxLat = lat[Object.keys(lng)[1]] this.minLat = lat[Object.keys(lng)[0]] let bounds = { maxLat: this.maxLat, maxLng: this.maxLng, minLat: this.minLat, minLng: this.minLng } this.mapaService.setBounds(this.maxLng, this.minLng, this.maxLat, this.minLat) this.mapaService.setLatLng(detailsResult.geometry.location.lat(), detailsResult.geometry.location.lng()) console.log('aqui') console.log(`${ipMarco}Instalaciones/Bounds/${this.maxLng}/${this.minLng}/${this.maxLat}/${this.minLat}`) res(bounds) // return this.http.get(`${ipMarco}Instalaciones/Bounds/${this.maxLng}/${this.minLng}/${this.maxLat}/${this.minLat}`).pipe( // map((res: any) => { // console.log(res) // return of(true) // }), // catchError(error => { // console.log('aqui') // console.log(error) // this.router.navigateByUrl('') // return of(false) // }) // ) } ) } } ); }) }) }) let bounds = await promise console.log(bounds) return bounds } canActivate(route: ActivatedRouteSnapshot): Observable<any> { // return of(true) // console.log('aqui') if (route.queryParams['ubicacion']) { this.ubicacion = route.queryParams['ubicacion'] if (this.ubicacion != undefined) { if (this.ubicacion != "") { return from(this.getBounds()).pipe( switchMap((bounds: any) => { return this.http.get(`${ipMarco}Instalaciones/Bounds/${bounds.maxLng}/${bounds.minLng}/${bounds.maxLat}/${bounds.minLat}`).pipe( map((res: any) => { console.log(res) return of(true) }), catchError(error => { console.log('aqui') console.log(error) this.router.navigateByUrl('') return of(false) }) ) }) ) } } } } } ```` ```` const routes: Routes = [ { path: '', component: InicioComponent }, { path: 'busqueda', component: BusquedaComponent, canActivate: [BusquedaGuardService], resolve: { data: BusquedaResolveService } }, ]; @NgModule({ imports: [RouterModule.forRoot(routes, { scrollPositionRestoration: 'enabled', })], exports: [RouterModule] }) export class AppRoutingModule { } ```` my resolve.service.ts ```` @Injectable({ providedIn: 'root' }) export class BusquedaResolveService { constructor(private mapaService:MapaService, private http:HttpClient) { console.log('nose') } resolve(route: ActivatedRouteSnapshot) { let maxLng = this.mapaService.getBoundsUnaVez().maxLng let minLng = this.mapaService.getBoundsUnaVez().minLng let maxLat = this.mapaService.getBoundsUnaVez().maxLat let minLat = this.mapaService.getBoundsUnaVez().minLat console.log(maxLng,minLng,maxLat,minLat) return this.http.get(`${ipMarco}Instalaciones/Bounds/${maxLng}/${minLng}/${maxLat}/${minLat}`); } } ````
<angular><google-maps-api-3><rxjs><angular-router-guards>
2019-12-17 18:26:10
LQ_EDIT
59,380,152
How to run python code in hostgator every 30 minutes?
<p>I have hostgator shared plan. Need to put a python file in the web-host and make it run every 30 minutes.</p> <p>It is a long script, but please use a simple code instead to explain for example: a=1 a=a+1</p>
<python><linux><web-hosting>
2019-12-17 18:32:32
LQ_CLOSE
59,381,063
Cannot fetch data from mongo with java
i trying to fetch some data from mongo with netbeans but i get this error java.lang.IllegalStateException: state should be: open I have tried everything. This is the line that crashes: Document doctor = doctors.find(new Document("doctor_name", DocName.getText())).first(); Connects successfully and the collection exists. Dunno what else to do
<java><mongodb>
2019-12-17 19:42:02
LQ_EDIT
59,381,881
Cannot figure out "Unexpected token" in React
<p>I cannot figure out what the error means on line 42:18 Could someone explain, please.</p> <p><strong>Error Message:</strong></p> <blockquote> <p>Line 42:18: Parsing error: Unexpected token</p> </blockquote> <pre><code>render() { return ( &lt;div className="FlexContainer NavbarContainer"&gt; &lt;ul className="NavBar"&gt; &lt;div className="mobilecontainer LeftNav"&gt; &lt;h2 className="BrandName LeftNav mobileboxmenu inline"&gt;Kommonplaces&lt;/h2&gt; &lt;div className="hamburger inline" onClick={this.showDropdownMenu}&gt;&lt;img alt="menubtn" src={hamburger}&gt;&lt;/img&gt;&lt;/div&gt; { this.state.displayMenu ? ( &lt;/div&gt; This line is 42 &lt;Dropdown/&gt; &lt;li className="RightNav"&gt;&lt;Link to="/"&gt;Host Your Space&lt;/Link&gt;&lt;/li&gt; &lt;li className="RightNav"&gt;&lt;Link to="/"&gt;About Us&lt;/Link&gt;&lt;/li&gt; &lt;li className="RightNav FarRight"&gt;&lt;Link to="/"&gt;Contact Us&lt;/Link&gt;&lt;/li&gt; &lt;li className="RightNav"&gt;&lt;Link to="/"&gt;Sign Up&lt;/Link&gt;&lt;/li&gt; &lt;li className="RightNav"&gt;&lt;Link to="/"&gt;Login&lt;/Link&gt;&lt;/li&gt; &lt;/ul&gt; ): ( null ) } &lt;/div&gt; ); } } export default MobileDropdown; </code></pre>
<javascript><reactjs>
2019-12-17 20:49:57
LQ_CLOSE
59,386,024
call function in another aws lambda using existing call
Please refer the code snippet below: import awsgi import json from flask import ( Flask, jsonify, request ) app = Flask(__name__) @app.route('/') def index(): return jsonify(status=200, message='OK') @app.route('/tester') def tst(): rule = request.url_rule if 'tester' in rule.rule: return {'status':200, 'message':'test'} def lambda_handler(event, context): test = (awsgi.response(app, event, context)) for key, value in test.items(): if key == 'message': call = value return { 'body': json.dumps(test) } Now in call variable we have value 'test'. This 'test' is also the name of a method in another lambda that I want to call. can someone please help me with this Thanking You
<python><amazon-web-services><flask><aws-lambda>
2019-12-18 05:34:02
LQ_EDIT
59,388,443
Converting A Non-Vuetify Element To Vuetify
<p>I am using a 3rd party payment processor that inserts text inputs into my form. The rest of my form is styled with vuetify (v-text-field). How can I convert a non-vuetify element into vuetify's version of it if the element gets added programmatically (i.e. I don't have control of the text field getting added since this is a 3rd party script)</p>
<vue.js><vuetify.js>
2019-12-18 08:52:46
LQ_CLOSE
59,391,027
Error Invoking 'Customize'. Details: Object reference not set to an instand on an object
I'm using visual studio 2017 I have a popupmenu on my designer view where I have added a list of popup menu items. When I try to customize the menu items by clicking on popupmenu and then the customize button. Instead of displaying the popupmenu items it displays an error message saying "Error Invoking 'Customize'. Details: Object reference not set to an instand on an object". What can I do to solve this? I have no idea on what to do. Attached to this is a picture of the error message. [error message][1] [1]: https://i.stack.imgur.com/OZs8Q.png
<visual-studio><winforms><devexpress>
2019-12-18 11:25:59
LQ_EDIT
59,394,175
Regex for python that puts quotation marks around all 6-12 digit numbers in a text file
<p>I currently have the following regex that identifies 6-12 numbers:</p> <pre><code>regex_did = re.compile(r"\b\d{6,12}\b") </code></pre> <p>What would be the correct approach to put all matches between two quotation marks. For example <code>123456</code> should be replaced with <code>"123456"</code>.</p>
<python><regex>
2019-12-18 14:28:24
LQ_CLOSE
59,394,652
How can I convert this code into HTML only?
<p>how can I convert this HTML+CSS code into HTML only? I'm trying to use this in an email, so the CSS won't work.</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;style&gt; #u168 { z-index: 34; background-color: #57E8E8; padding-bottom: 7px; position: relative; margin-right: -10000px; margin-top: 345px; width: 48.58%; left: 27.15%; } #u186-5 { z-index: 37; min-height: 23px; background-color: transparent; color: #131E2E; font-size: 18px; line-height: 22px; position: relative; margin-right: -10000px; margin-top: 6px; width: 92.06%; left: 2.65%; } #u174 { z-index: 35; background-color: #57E8E8; padding-bottom: 8px; position: relative; margin-right: -10000px; margin-top: 384px; width: 48.58%; left: 27.15%; } #u186-2,#u189-2 { font-weight: bold; } #u177 { z-index: 36; background-color: #57E8E8; padding-bottom: 8px; position: relative; margin-right: -10000px; margin-top: 423px; width: 48.58%; left: 27.15%; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="clearfix grpelem" id="u168"&gt;&lt;!-- group --&gt; &lt;div class="clearfix grpelem" id="u186-5"&gt;&lt;!-- content --&gt; &lt;p&gt;User: &lt;span id="u186-2"&gt;test&lt;/span&gt;&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="clearfix grpelem" id="u174"&gt;&lt;!-- group --&gt; &lt;div class="clearfix grpelem" id="u189-5"&gt;&lt;!-- content --&gt; &lt;p&gt;Password: &lt;span id="u189-2"&gt;test&lt;/span&gt;&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/html&gt; </code></pre>
<html><css>
2019-12-18 14:55:39
LQ_CLOSE
59,395,890
Intend not work in Recycleview.onclicklistener
This is my Adapter class i need to click the Recycleview list and go to the next page but Intend is not work in this class the app gets crashed how do i work with the intend in this ... package com.onebook.locationsaver; import android.app.Activity; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.provider.ContactsContract; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView.ViewHolder; import java.util.ArrayList; import java.util.Collections; import java.util.List; import static android.content.ContentValues.TAG; import static androidx.core.content.ContextCompat.startActivity; public class SaveListAdapter extends androidx.recyclerview.widget.RecyclerView.Adapter<SaveListAdapter.ViewHolder> { Context context; public List<DatabseMode> databasemodelist; private DatabseMode databseMode; ArrayList<DatabseMode> newlist =new ArrayList<>(); Context a; public SaveListAdapter(Context context, List<DatabseMode> databasemodelist) { this.databasemodelist=databasemodelist; for (int i = databasemodelist.size() - 1; i >= 0; i--) { newlist.add(databasemodelist.get(i)); this.a=context; } } @NonNull @Override public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext()); View listItem= layoutInflater.inflate(R.layout.recycle_view_icon, parent, false); ViewHolder VH=new ViewHolder(context,listItem) { @Override public String toString() { return super.toString(); } }; return VH; } @Override public void onBindViewHolder(@NonNull ViewHolder holder, final int position) { databseMode= (newlist.get(position)); holder.name.setText(databseMode.getname()); holder.detail.setText(databseMode.getdetail()); /*holder.layout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(SaveListAdapter.this,"Item is selected",Toast.LENGTH_LONG).show(); *//* Intent intent=new Intent(a.getApplicationContext(),LocationEdit.class); intent.putExtra("potition",getItemId(position )); a.startActivity(intent);*//* } });*/ } @Override public int getItemCount() { return databasemodelist.size(); } public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView name,detail; public LinearLayout layout; private Context context; List<DatabseMode> databasemodelist; public ViewHolder(Context context,View itemView) { super(itemView); this.name = (TextView) itemView.findViewById(R.id.textView); this.detail=itemView.findViewById(R.id.textview00); this.context=context; itemView.setOnClickListener(this); //layout= (LinearLayout) itemView; } @Override public void onClick(View v) { int position=getLayoutPosition(); DatabseMode databseMode=databasemodelist.get(position); Intent intent=new Intent(context,LocationEdit.class); intent.putExtra("id",databseMode.getname()); context.startActivity(intent); Toast.makeText(context,"this the text",Toast.LENGTH_SHORT).show(); } } } The above is the adapter for recycleview package com.onebook.locationsaver; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.view.View; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import java.util.ArrayList; import java.util.List; public class LocationList extends AppCompatActivity { private RecyclerView recyclerViewsavedata; private RecyclerView.Adapter getdataadapter; private List<DatabseMode> databasemodelist; private DatabaseHelper databaseHelper ; ListView listView; private Context context; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.locationlist); databasemodelist =new ArrayList<>(); databaseHelper =new DatabaseHelper(this); recyclerViewsavedata=findViewById(R.id.recyclerView); recyclerViewsavedata.setHasFixedSize(true); recyclerViewsavedata.setLayoutManager(new LinearLayoutManager(this)); databasemodelist=databaseHelper.getAllCotacts(); //listView.setAdapter(new Listviewadapter(LocationList.this,databasemodelist)); getdataadapter=new SaveListAdapter((Activity) context,databasemodelist); recyclerViewsavedata.setAdapter(getdataadapter); recyclerViewsavedata.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(LocationList.this,"This item is selecton",Toast.LENGTH_SHORT).show(); } }); } } The above is the Recycleview class ane one help me please i'm struggle on this for 4 days onclick in the recycle view is not working in my applilation
<java><android><android-studio><android-layout><android-fragments>
2019-12-18 16:03:22
LQ_EDIT
59,396,069
Insert line in a specfic line in a file
<p>I have a very simple question but I don't find the answer ...</p> <p>I have a file (data.txt) it contains </p> <pre><code>A B C D E F </code></pre> <p>I just want to make function to insert line where I want in this file.</p> <p>Like : Insert('Bouh', 3)</p> <p>Render :</p> <pre><code>A B C D Bouh E F </code></pre> <p>Any idea please ?</p>
<python>
2019-12-18 16:14:20
LQ_CLOSE
59,396,710
How can I make an Array of Objects from n properties of n arrays in JS?
<p>I have two arrays like this:</p> <pre class="lang-js prettyprint-override"><code>const opciones = ['A', 'B', 'C', 'D']; const valoracion = [true, false, false, false]; </code></pre> <p>And the, I want to create a new Array of Objects from these two arrays, like this:</p> <pre class="lang-js prettyprint-override"><code>const respuestas = [ {opc: 'A', val: true}, {opc: 'B', val: false}, {opc: 'C', val: false}, {opc: 'D', val: false}, ] </code></pre>
<javascript>
2019-12-18 16:49:06
LQ_CLOSE
59,400,459
Getting "best-guess" coordinates from a location name in Python
<p>I'm looking for a way to take a rough location string (ex. "Buddy's Pub in City, State"), and convert it to the best-guess set of coordinates. I've looked at GeoPy and Google's Geocoding API, but they are not exactly what I'm looking for. Any help would be appreciated.</p>
<python><location><coordinates><geocoding><estimation>
2019-12-18 21:53:23
LQ_CLOSE
59,400,475
How to add style to webp images
<p>my code looks like</p> <pre><code>&lt;picture&gt; &lt;source type="image/webp" srcset="img/photo.webp"&gt; &lt;source type="image/jpg" srcset="img/photo.jpg"&gt; &lt;img src="img/photo.jpg" alt=""&gt; &lt;/picture &gt; </code></pre> <p>I want to add class to this picture so I can use border-radius. how can I do that?</p>
<html><css><webp>
2019-12-18 21:55:11
LQ_CLOSE
59,401,276
Me not understanding do while loops
<p>So i tried to make my first console aplication but it came to a bit of a bummer since i dont understand how a do while loop works</p> <pre><code>#include &lt;iostream&gt; int balance = 100; int pay = 30; int awnser; // Variables for the awnsers int withdrawal; int a = 1; int main() { do { std::cout &lt;&lt; "\n Whats the action you wanna do? \n 1 = Check balance \n 2 = Withdraw money \n 3 = Deposit money \n 4 = Check transaction history \n 5 = Exit \n"; std::cout &lt;&lt; " "; std::cin &gt;&gt; awnser; if (awnser == 1) { std::cout &lt;&lt; balance &lt;&lt; " Euros\n \n"; } if (awnser == 2) { std::cout &lt;&lt; "How much do you wanna with draw?\n"; std::cin &gt;&gt; withdrawal; if (withdrawal &gt; balance) std::cout &lt;&lt; "You dont have that much money.\n \n"; else { std::cout &lt;&lt; "Your current balance is: " &lt;&lt; balance - withdrawal; } } if (awnser == 3) { std::cout &lt;&lt; "We know you dont have enymore daam money you beggar so dont even try that\n \n"; } if (awnser == 4) { } if (awnser == 5) { std::cout &lt;&lt; "Enter 0 to exit or 1 to go back\n"; std::cin &gt;&gt; a; } else if (a == 1) { std::cout &lt;&lt; "\n"; return 1; } } while (a == 1); } </code></pre> <p>I thought it would get back to the top since no other "if" requierements were met and just give me the "Whats the action you wanna take again" but it just exits out so what am i doing wrong?</p>
<c++><loops>
2019-12-18 23:15:20
LQ_CLOSE
59,402,452
How to calculate Min Max of Map<Strib,float>
[enter image description here][1] How to find Min max of Keys of a Map<String,float> [1]: https://i.stack.imgur.com/mbQ09.png
<java><dictionary><max><min>
2019-12-19 02:12:56
LQ_EDIT
59,403,593
kernel module problem in commercial software
<p>The security software I'm building contains a kernel module. because the kernel must process the packet.</p> <p>Do not use DKMS because it is commercial software.</p> <p>If the kernel version goes up, insmod doesn't work.</p> <p>What should I do? Do you have a good idea?</p>
<c><linux-kernel><kernel-module><insmod><commercial-application>
2019-12-19 05:09:06
LQ_CLOSE
59,404,138
Macbook won't stay as using Python3
When I change the alias for python using ***alias python='python3'*** in terminal, the python version will be changed to python3. But, when I close Atom and come back to the app later, it has gone back to python2. Can someone explain this please?
<python><python-3.x><bash>
2019-12-19 06:13:10
LQ_EDIT
59,404,719
I am trying to convert String date in long in android studio
I AM CONVERTING STRING DATE INTO LONG BUT I AM NOT UNDERSTANDING HOW TO RETURN THE LONG VALUE and how to convert a string into long and store in room database ``` package com.example.mybugetssimple; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class DateConverter { public static long dateCon(String string_date){ string_date = "12-December-2012"; SimpleDateFormat f = new SimpleDateFormat("dd-MMM-yyyy"); try { Date d = f.parse(string_date); long milliseconds = d.getTime(); return milliseconds; } catch (ParseException e) { e.printStackTrace(); } return 1; } } ```
<java><android><string><date><long-integer>
2019-12-19 07:03:50
LQ_EDIT
59,405,115
Put a set of characters into list in python
<p>Essentially I want to put characters inside a list so I can make the for loop work.</p> <p>Example characters (supposedly listed individually vertically. not like this showing as one line) N/A N/A None Test Dev</p> <p>I want to put these characters into a list like below a = [N/A, N/A, None, Test, Dev]</p> <p>Reason is when I use for loop into these characters (let's say there are all inside "test_report". For loop is not working because it is reading the "test_report" as like this:</p> <pre><code>N / A N / A N o n e </code></pre> <pre><code>count = 0 for i in test_report: if i == "Test": count += 1 return count </code></pre>
<python>
2019-12-19 07:32:28
LQ_CLOSE