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,761,587
Is this a bug with the python OR operator?
<p>When I run the following code:</p> <pre><code>i = None O = ['n', 'y', 'No', 'Yes'] while i not in O: i = input('Yes or No?\n') if i == 'y' or 'Yes': print('Yes') if i == 'n' or 'No': print('No') </code></pre> <p>The output is n Yes No</p> <p>Should the code only be displaying No as the output since the first if statement was false? Or am I not understanding something?</p> <p>Thank you</p>
<python><operators>
2020-01-16 00:48:49
LQ_CLOSE
59,762,675
re.findall not finding all, only some. How could this be?
<p>I have a text file containing five websites. In each of these websites are multiple amazon links, in which my goal is to collect all of them. However, one of the five websites uses "amzn.to" to lead to the amazon link instead of "amazon.com", which I initially thought was solvable by just using this:</p> <pre><code>any(re.findall(r'(amazon.com|amzn.to)', str, re.IGNORECASE)) </code></pre> <p>There's supposed to be ten <code>amzn.to</code> links included in my overall list of amazon links but only two are found.</p> <p>Here's my entire code:</p> <pre><code>import requests import re from bs4 import BeautifulSoup from collections import OrderedDict file_name = raw_input("Enter file name: ") filepath = "%s"%(file_name) with open(filepath) as f: listoflinks = [line.rstrip('\n') for line in f] raw_links = [] for i in listoflinks: html = requests.get(i).text bs = BeautifulSoup(html) possible_links = bs.find_all('a') for link in possible_links: if link.has_attr('href'): raw_links.append(link.attrs['href']) amazon_links = [] for str in raw_links: if (any(re.findall(r'(amazon.com|amzn.to)', str, re.IGNORECASE))) and (str not in amazon_links): amazon_links.append(str) for i in amazon_links: print i print len(amazon_links) </code></pre> <p>I know it works, but not as well as I'd like it to. Please help me pinpoint the problem.</p>
<python><regex><web-scraping><beautifulsoup>
2020-01-16 03:34:12
LQ_CLOSE
59,764,552
date conversion for YY-Monthtext to MM/DD/YYYY
receiving date as 19-May need to convert as '05/01/2019', 19-June to '01/06/2019' in MsSQL, i have tried various date conversion but it didnt worked, help me please
<sql><sql-server><tsql>
2020-01-16 07:09:12
LQ_EDIT
59,765,299
Finding maximum value in a dictionary Python
<p>the input I have given is </p> <ul> <li>BatmanA,14</li> <li>BatmanB,199</li> <li>BatmanC,74</li> <li>BatmanD,15</li> <li>BatmanE,9</li> </ul> <p>and the output i expect is the highest value and i get something else this is my code below i have tried other methods too pls help thanks.</p> <pre><code>N = int(input("Enter the number of batsman : ")) d = {} for i in range(0,N): batsman = input("enter the batsman values " ).split(',') d[batsman[0]] = batsman[1] v = list(d.values()) k = list(d.keys()) print(k[v.index(max(v))]) </code></pre>
<python-3.x>
2020-01-16 08:08:04
LQ_CLOSE
59,765,623
fetch api returns `function text() { [native code] }`
<p>im new with fetch api and i've got a tiny problem.</p> <pre><code>document.getElementById('getText').addEventListener('click',function(){ fetch('text.txt') .then(function(res){ return res.text }).then(function(data){ document.body.innerHTML += `&lt;br&gt;&lt;br&gt;${data}` }) .catch(function(err){ console.log(err) }) }) </code></pre> <p>this is my code. it returns this: <code>function text() { [native code] }</code> i want it to returns the content not this. i dont know what should i do !? sorry for asking a dumb question. thanks</p>
<javascript><html><promise><fetch-api>
2020-01-16 08:33:29
LQ_CLOSE
59,767,181
php sort array of version strings
<p>I would like to sort an array of version strings in php.</p> <p>Input would be something like this:</p> <pre><code>["2019.1.1.0", "2019.2.3.0", "2019.2.11.0", "2020.1.0.0", "2019.1.3.0", "2019.3.0.0"] </code></pre> <p>What is the easiest way to sort this? Sorting the strings as is does not work, because that would put the "2019.2.11.0" before "2019.2.3.0" and that is of course not what I want.</p> <p>Result should be</p> <pre><code>["2019.1.1.0", "2019.1.3.0", "2019.2.3.0", "2019.2.11.0", "2019.3.0.0", "2020.1.0.0"] </code></pre>
<php>
2020-01-16 10:06:42
LQ_CLOSE
59,769,269
pandas read_table columns issue
I can't seem to figure out how to display all columns in this .data file. I can only display two separate columns when I'd like to display all ten. I've attached an image with what I've tried. I've been looking over for the documentation, but nothing seems to fit. I've also attached an image with how I'd like the data to display in jupyter notebook. Any help would be appreciated. Thanks [how I'd like to display the data][1] [what I've tried so far][2] [1]: https://i.stack.imgur.com/W2cIW.jpg [2]: https://i.stack.imgur.com/hbiku.png
<python><pandas><jupyter-notebook>
2020-01-16 12:00:56
LQ_EDIT
59,769,773
Add id's to <p> using javascript or jQuery or Angular
I have a HTML document which is dynamically generated. It has a bunch of <p> tags which has text in it. I am trying to select the <p> when user clicks on that specific text. Unfortunately I am not allowed to add id's to the '<p>' tags which I could use to select the specific block of test. So I need to find a way to dynamically add id's to the <p> tags using javascript or jQuery or angular. I have seen some solutions which uses jQuery .attr("id", "newId") but it needs a selector and I don't know what to use as a selector. Can anyone suggest something.
<javascript><jquery><html><angular>
2020-01-16 12:30:35
LQ_EDIT
59,769,929
How to add number with variable name?
<p>Hi I want to change the variable name like stop1, stop2, stop3 etc in a loop. I tried using for loop with stop + i but it didnt work Please help</p>
<javascript><angular><typescript>
2020-01-16 12:39:48
LQ_CLOSE
59,771,960
I made a login system but when I run it, it comes up with an unexpected result can you ether fix it or improve it?
<p>i have repentantly started object oriented on python so I made a login system but when I run it, it comes up with an unexpected result at the end</p> <p>it was supposed to print "login successful" but doesn't and comes up with "login failed" even though it print the value both in module and the file and they look identical but it outputs that they are not? does anyone know why this happens</p> <pre><code>firstname="food"#given veriables lastname="boyyyyyy"#given veriables username=firstname+lastname#given veriables password="errrorrr"#given veriables thislist = ["rusty_sword", "cloth_shirt", "wooden_shield","health_potion"]#given veriables demon_kill=0#given veriables potion_number=5#given veriables gold=10#given veriables area=0#given veriables thisdict = {"username": firstname+lastname,"password": password,}#creates dictionary print(thisdict)#shows dictionary class saving:#creates class called saving def __init__(self,info,equipment_w,equipment_a,equipment_s,equipment_p,demon_kill_obj,potion_number_obj,gold_obj,area_obj):#creates objetcs self.thisdict=thisdict#sets objects values self.equipment_w=equipment_w#sets objects values self.equipment_a=equipment_a#sets objects values self.equipment_s=equipment_s#sets objects values self.equipment_p=equipment_p#sets objects values self.demon_kill_obj=str(demon_kill_obj)#sets objects values self.potion_number_obj=str(potion_number_obj)#sets objects values self.gold_obj=str(gold_obj)#sets objects values self.area_obj=str(area_obj)#sets objects values def fileing(self):#creates objetcs f=open(self.thisdict["username"]+" personalgame save.txt","a")#opens files from dictionary f.truncate(0)#sets file as empty f.write(self.thisdict["username"]+"\n")#writes in file using objects f.write(self.thisdict["password"]+"\n")#writes in file using objects f.write(self.equipment_w+"\n")#writes in file using objects f.write(self.equipment_a+"\n")#writes in file using objects f.write(self.equipment_s+"\n")#writes in file using objects f.write(self.equipment_p+"\n")#writes in file using objects f.write(self.demon_kill_obj+"\n")#writes in file using objects f.write(self.potion_number_obj+"\n")#writes in file using objects f.write(self.gold_obj+"\n")#writes in file using objects f.write(self.area_obj)#writes in file using objects f.close#closes file kkkk=saving(thisdict,thislist[0],thislist[1],thislist[2],thislist[3],demon_kill,potion_number,gold,area)#takes info from class and saves it to kkkk kkkk.fileing() f=open(thisdict["username"]+" personalgame save.txt","r")#opens the file lines=f.readlines()#sets points in the file to seperate veriables print(username)#shows you what username is in veriables print(lines[0])#show you what username is in the file if str(username)==str(lines[0]):#compares the the two veriables print("login sucessfull") else: print("login falied") </code></pre>
<python>
2020-01-16 14:38:41
LQ_CLOSE
59,772,775
Sending a variable in python payload - http client
<p>I'm trying to send a variable in python using a payload created by postman, I tried using {{}} and it didn't work for me, the place where I need the variable is indicated as VARIABLE_SPOT, please let me know what I did wrong in order to send a variable and not a text.</p> <pre><code>payload = "{\r\n \"some_key\": \"VARIABLE_SPOT\",\r\n } </code></pre>
<python><httprequest><postman>
2020-01-16 15:21:00
LQ_CLOSE
59,773,235
Encrypt a String in Python That Just Can Decrypt with str encrypted with
<p>I Want To Encrypt User Passwords With Their Password <br /> I Mean That The Encrypted String <br /> Can Only Decrypt With The Main Password User Entered</p> <blockquote> <p>User Entered 12345 for Password <br /> The Encrypted Value Only Can Decrypt With 12345 Key</p> </blockquote>
<python><encryption>
2020-01-16 15:45:02
LQ_CLOSE
59,773,289
Java embedded database with about 500 million of records
<p>In my Java application I need to use some kind of embedded DB (SQL or NoSQL doesn't matter), which is able to hold about 500 millions of records (mostly single table, but splittion to more tables is not an issue). The number of records is the key part. The task is simple: check if such string is in DB if not insert it. Also the DB will not be under heavy load. I've been thinking about Derby, H2, Hypersonic DB, HSQLDB or ... . Could you suggest?</p> <p>Thanks</p> <p>Pat</p>
<java><embedded-database>
2020-01-16 15:47:30
LQ_CLOSE
59,774,046
how fetch data beetwin two dates with axios
How fetch data between two dates with axios ? I tried this but without success : ``` const res = axios.get("/activities", { params: { date: { gte: startDate, lte: endDate }, user: id } }); ```
<javascript><axios>
2020-01-16 16:31:42
LQ_EDIT
59,775,356
R: If function, if value in vector > 0, then replace with number
I try to performe the Cowles-Jones-Test in R. Basically, I don't know how to write a script, in which I can check, if a value within my vector is bigger than zero or not (for every single value in this vector). If it's bigger than zero, it should replace this number with an one, if not, than a zero. Couldn't find anything so far and would appreciate some help
<r><if-statement><finance><random-walk>
2020-01-16 17:57:08
LQ_EDIT
59,777,715
Java enum for loop
<p>I have to count how many time enum START was written in enum class. What's wrong with my code?</p> <pre><code>public class Main { public static void main(String[] args) { int count = 0; for (Secret dir : Secret.values()) { if (Secret.START == dir) { count += 1; } } System.out.println(count); } } /* /// At least two constants start with STAR enum Secret { STAR, CRASH, START // ... } */ </code></pre>
<java><enums>
2020-01-16 20:59:17
LQ_CLOSE
59,779,069
Comparing table with sql/tsql in sql server 2012
I have Four tables in sql server 2012, table1, table2, table3, and a (resultant/output table) table4 1) table1 is truncated and loaded with new data daily. 2) table1 columns col1,col2,col3 are similar to table2 columns col7,col18,col9 and table1 columns col1,col2,col3 are similar table3 col9,col11,col7 Problem --- loop table1 to check for every row (col1,col2,col3) matches any row in the table2 (col7,col18,col9) then add row in table4 containing information table1.col1,table1.col2,table1.col3, table2.col6,table3.col1,table3.col7 and a column to indicate its an update if row (col1,col2,col3) in table1 does not exist in table2 add row in table4 containing information table1.col1,table1.col2,table1.col3, table2.col6,table3.col1,table3.col7 and a column to indicate its an addition if row (col7,col18,col9) in table2 does not exist in table1 add row in table4 containing information table1.col1,table1.col2,table1.col3, table2.col6,table3.col1,table3.col7 and a column to indicate its an deletion 1) return table4 as result How can we do this with SQL/TSQL only.
<sql><sql-server><tsql>
2020-01-16 23:00:59
LQ_EDIT
59,779,998
Split DateTime into Combination of String and Date in Java
<p>I hit API that will return date in datetime type. The example of the return is "1994-12-03T12:00:00" and I want to modify the return become "Pca19941203". The return will be apply in csv file. I do the modification in Java. Is there some ways to do that ?</p>
<java><api><csv>
2020-01-17 01:17:55
LQ_CLOSE
59,780,093
Python: Making dataframe in pandas
<p>Is there a way where I can make my data frame (using pandas) like this? <a href="https://i.stack.imgur.com/d6B2N.png" rel="nofollow noreferrer">expected data frame format</a></p>
<python><pandas><dataframe>
2020-01-17 01:33:21
LQ_CLOSE
59,780,766
PHP Warning: mail(): Found numeric header
<p>I am using following script to send email through PHP. However, I am getting error <code>"PHP Warning: mail(): Found numeric header (4) in /home/....public_html/.../sendemail.php on line 16"</code> Any help please.</p> <p><strong>PHP Script</strong></p> <pre><code>&lt;?php $name = @trim(stripslashes($_POST['name'])); $from = @trim(stripslashes($_POST['email'])); $subject = @trim(stripslashes($_POST['subject'])); $message = @trim(stripslashes($_POST['message'])); $to = 'xxxxx@xmail.com'; $headers = array(); $headers[] = "MIME-Version: 1.0"; $headers[] = "Content-type: text/plain; charset=UTF-8"; $headers[] = "From: {$name} &lt;{$from}&gt;"; $headers[] = "Reply-To: &lt;{$from}&gt;"; $headers[] = "Subject: {$subject}"; $headers[] = "X-Mailer: PHP/".phpversion(); mail($to, $subject, $message, $headers); die; </code></pre>
<php><email>
2020-01-17 03:24:40
LQ_CLOSE
59,780,821
Is there a way to automatically select an Entrybox in tkinter?
<p>My GUI is structured such that I have a main class, and each page of my GUI, of which I can navigate between, is instantiated whenever I call it. One of my pages has an entry box, but i have to manually move my cursor and select the entry box to begin typing. Is there a way for the entry box to automatically be selected when I call that page?</p> <p>Seems like an interesting problem</p>
<python><python-3.x><tkinter>
2020-01-17 03:32:16
LQ_CLOSE
59,784,866
On Unix server: Java is unable to parse currency symbol(£,€) from json to .csv file
Below is my JSON: Test": [ { "A": "X;DOS533", "B": "FCA BANK SPAEUR1.5BN21MAR2019", "C": null, "D": "AA BB EUR1.5BN", "E": "€1.5BN Test LN BNK €100M 12M", "Ccy": "EUR", "TypeCode": "TML " } And below is the row from .csv file generated in unix box. 4243842|Test:ABC|Active||6||FFTIAIT||Internal|X;DOS5KT|FCA BANK SPAEUR1.5BN21MAR2019|?1.5BN Test LN NWM ?100M 12M|TML| Here € sign get replace with ?(question mark). Same issue i face while converting pound (£) from .csv to .bcp file. Need help to solve this. Thanks.
<csv><unix><bcp>
2020-01-17 09:49:16
LQ_EDIT
59,785,266
Ruby on Rails CRUD and Association example
<p>I am beginner on rails. I want to list Brands-Products list. Brands and products must be association. I dont know what to do. Please suggest me example like this. </p>
<ruby-on-rails><ruby><crud>
2020-01-17 10:13:13
LQ_CLOSE
59,785,609
Search for duplicates inside an array
<p>I am trying to find duplicates inside an array. my array looks like: </p> <pre><code>['LM_Auto', 'LM_Auto', 'LM_Op', 'LM_Op'] </code></pre> <p>and much longer with a few thousand of these pairs. </p> <pre><code>def clear_stemmed_LM(collection): i = 0 ele = i+1 for i in collection: for ele in collection: if i == ele: del collection[ele] return collection </code></pre> <p>the error says the list indices must be integers or slices not strings. How can I compare strings in an array? </p> <pre><code>[if x+1 for in x range] #Idea </code></pre> <p>or something similar like this? </p>
<python><arrays><string><string-comparison>
2020-01-17 10:32:19
LQ_CLOSE
59,786,172
What to use instead of WCF in .NET Core?
<p>Windows 10, .Net Core 3.1 </p> <p>How to do the processes communication on the same computer in .NET Core 3.1? I used WCF for these purposes when I used .NET Framwork earlier, but .NET Core hasn't WCF. I would not want to use the file system and <code>FileSystemWatcher</code> or write windows services for these purposes...</p>
<c#><.net-core>
2020-01-17 11:07:31
LQ_CLOSE
59,787,717
Can't convert Int in String
<p>I have a textbox where i write a int. I want to use this textbox to construct my object.</p> <p>Main.cs :</p> <pre><code>private void SauvegarderMoto_Click(object sender, EventArgs e) { try { Moto maMoto = new Moto( maMarque.Text = lesMarques.SelectedItem.ToString(), monModele.Text = lesModeles.SelectedItem.ToString(), monMoteur.Text = lesMoteurs.SelectedItem.ToString(), maCylindree.Text = lesCylindrees.SelectedItem.ToString(), monAnnee.Text = Convert.ToInt32(lesAnnees.Text) ); MessageBox.Show("Moto enregistrée avec succès !", "Information"); tabControl1.SelectTab(MaMoto); } catch(Exception) { MessageBox.Show("Il manque des informations !", "Information"); } } </code></pre> <p>Thanks for help </p>
<c#><string><int>
2020-01-17 12:49:07
LQ_CLOSE
59,791,411
What is the bug in this code Can anyone help me out to get the correct output
As a freelancer I picked up a Project but I got stuck with this one can anyone help me out to get this code code to get the dezired output. The Code is : n = int(input('\n Enter Your Value of N : ')) answer = [[1]] for i in range(2, n+1): t = ([i]*((2*i)-3)) answer.insert(n,t) for a in answer: a.insert(0,i) a.append(i) answerfinal = [] for a in answer: answerfinal.append("".join(str(a))) for a in answerfinal: print(a) The Dezired output is to be like This : Input : 5 Output : 555555555 544444445 543333345 543222345 543212345 543222345 543333345 544444445 555555555 Please help me out to get this code corrected as this is my work can anyone help????
<python><python-3.x>
2020-01-17 16:34:12
LQ_EDIT
59,791,668
Creating a code to perform hundreds of google searches and extract publication date
<p>Using python, how can I create a script to performing hundreds of google searches to gather the publication dates of the first link.</p>
<python><google-search>
2020-01-17 16:50:34
LQ_CLOSE
59,791,994
This simple If statment send me an SyntaxError: invalid syntax on Python 3.6 need help Thank
elephant_weight = 3000 ant_weight = 0.1 If elephant_weight > ant_weight: square() File "c:/Users/AIRWEBDEV/Documents/exercice.py", line 37 If elephant_weight > ant_weight: ^ SyntaxError: invalid syntax
<python><python-3.x><if-statement><error-handling>
2020-01-17 17:13:50
LQ_EDIT
59,792,270
Getting an error when trying to use Openpyxl
I'm getting a Traceback (most recent call last) error when trying to use openpyxl: The only line of code i have is ''' import openpyxl ''' ``` 'Traceback (most recent call last): File "C:/Users/rwarke/PycharmProjects/Helloworld/HelloWorld.py", line 1, in <module> import openpyxl File "C:\Users\rwarke\PycharmProjects\Helloworld\openpyxl\__init__.py", line 6, in <module> from openpyxl.workbook import Workbook File "C:\Users\rwarke\PycharmProjects\Helloworld\openpyxl\workbook\__init__.py", line 4, in <module> from .workbook import Workbook File "C:\Users\rwarke\PycharmProjects\Helloworld\openpyxl\workbook\workbook.py", line 7, in <module> from openpyxl.worksheet.worksheet import Worksheet File "C:\Users\rwarke\PycharmProjects\Helloworld\openpyxl\worksheet\worksheet.py", line 24, in <module> from openpyxl.cell import Cell, MergedCell File "C:\Users\rwarke\PycharmProjects\Helloworld\openpyxl\cell\__init__.py", line 3, in <module> from .cell import Cell, WriteOnlyCell, MergedCell File "C:\Users\rwarke\PycharmProjects\Helloworld\openpyxl\cell\cell.py", line 27, in <module> from openpyxl.styles import numbers, is_date_format File "C:\Users\rwarke\PycharmProjects\Helloworld\openpyxl\styles\__init__.py", line 4, in <module> from .alignment import Alignment File "C:\Users\rwarke\PycharmProjects\Helloworld\openpyxl\styles\alignment.py", line 5, in <module> from openpyxl.descriptors import Bool, MinMax, Min, Alias, NoneSet File "C:\Users\rwarke\PycharmProjects\Helloworld\openpyxl\descriptors\__init__.py", line 3, in <module> from .base import * File "C:\Users\rwarke\PycharmProjects\Helloworld\openpyxl\descriptors\base.py", line 12, in <module> from openpyxl.utils.datetime import from_ISO8601 File "C:\Users\rwarke\PycharmProjects\Helloworld\openpyxl\utils\datetime.py", line 12, in <module> from jdcal import ( ModuleNotFoundError: No module named 'jdcal' ``` Can someone please let me know what i need to do here? Is it an error with the installation Thanks,
<python><openpyxl>
2020-01-17 17:32:15
LQ_EDIT
59,794,748
Go generate only scans main.go
<p>I am having some trouble using go generate to generate a grpc server when running go generate from the root of my project directory.</p> <p>When I run <code>go generate -v</code> it only returns <code>main.go</code>. However, the directives are defined in one the subpackages. If I run <code>go generate</code> in the sub package it works as expected. I expected the imports to ensure that <code>go generate</code> would find the subpackages and run the directives.</p> <p>The project has the following structure:</p> <pre><code>cmd/ root.go run.go pkg/ subpkg/ protobuf/ proto1.proto subpkg.go main.go </code></pre> <p>Contents of subpkg.go</p> <pre><code>//go:generate protoc -I ./protobuf --go_out=plugins=grpc:./protobuf ./protobuf/proto1.proto package subpkg </code></pre> <p>Contents of main.go:</p> <pre class="lang-golang prettyprint-override"><code>package main import ( "fmt" "os" "my-project/cmd" ) func main() { if err := cmd.RootCommand.Execute(); err != nil { fmt.Println(err) os.Exit(1) } } </code></pre> <p>In the run.go package, I import the package subpkg.</p> <p>How do I ensure go generate can be run from the root of the project and execute all directives in all sub packages.</p>
<go><go-generate>
2020-01-17 20:54:43
LQ_CLOSE
59,798,146
Kubernetes cluster for docker image
i have docker image , i need to create a Kubernetes cluster from one node. don't have knowledge in Kubernetes, this is the first time to create it. how can i do it with the simplest way? Thanks
<kubernetes>
2020-01-18 06:36:38
LQ_EDIT
59,799,245
Math/Rand in GoLang
<p>hello <strong>Golang</strong> devs I am learning golang and I am using the <strong>Math/Rand</strong> package. I am curious why I am getting the same result on:</p> <pre><code>// always returning 81 rand.Intn(100) </code></pre>
<go><math><random>
2020-01-18 09:36:31
LQ_CLOSE
59,799,612
How can i duplicate an HashMAP with duplicate values
so i need to create new hashmaps that contain only the duplicate values of my first hashmap Original map: {Player1=Hello, Player2=Hi, Player3=Hi, Player4=Hello, Player5=Hello} Hello map: {Player1=Hello,Player4=Hello, Player5=Hello} Hi map: {Player2=Hi, Player3=Hi} what is best way to do? Thanks !!
<java><dictionary><hashmap>
2020-01-18 10:27:37
LQ_EDIT
59,802,628
Is it possible to open a specific app page by mail link?
<p>I'm developing an hybrid application by using Angular and Ionic and I need to setup a "reset password" flow: once the user clicks on a "reset password" button they receive a mail link to reset.</p> <p>If the mail link is clicked and the user has the app installed I'd like to open the app and show a password creation page. Is this possible? Does it work on both ios and android?</p>
<angular><cordova><ionic-framework><ionic4><capacitor>
2020-01-18 16:38:50
LQ_CLOSE
59,806,713
2 instance of class , but seems they are the same
<p>I am expecting obj1 and obj2 will have different deck.cards, why they are the same, how do I make them 2 instance?</p> <pre><code>class deck: cards ={} def __init__(self, key, value): self.cards[key]=value return &gt;&gt;&gt; obj1 = deck("a", "1") &gt;&gt;&gt; obj2 = deck("b", "2") &gt;&gt;&gt; print (obj1.cards, obj2.cards) {'a': '1', 'b': '2'} {'a': '1', 'b': '2'} </code></pre>
<python><class><instantiation>
2020-01-19 02:46:25
LQ_CLOSE
59,807,290
Why is my C program skipping over if statements?
<p>I am a new coder and have no idea what I am doing please help!</p> <p>The code is reading and taking inputs just fine until it reaches the scanf(" %c", &amp;i);then it skips to the Amount print seemingly ignoring my if statements.Is there somthing wrong with my use of scanF?</p> <p>Here is the code:</p> <pre><code>#include &lt;stdio.h&gt; int main(){ printf("BANK ACCOUNT PROGRAM!\n--------------------\n"); char W,F,A,i,D; int t=1; double b,d; while (t=1){ printf("Enter the old balance:\n"); scanf(" %lf", &amp;b); printf(" %lf", b); if(b&gt;=0) { printf("Enter the transactions now!\n Enter an F for the transaction type when you are finished.\n"); printf("Transaction Type (D=deposit, W=withdrawal, F=finished):\n"); scanf(" %c", &amp;i); if(i=F){ printf("Your ending balance is"); printf(" %lf", b); printf("\n Program is ending!"); return 0; } if(i=W){ printf("Amount:"); scanf(" %f", &amp;d); b= b-d; printf(" %f",b);} } if(b&lt;0); { printf("The balance must be maintained above zero!\n"); } } return 0; } </code></pre>
<c>
2020-01-19 05:00:11
LQ_CLOSE
59,808,392
whats the advantages to use react js in asp.net core project?
<p>I want to build an accounting application by asp.net core and I want to know is that better to use react js for my app UI or there is no difference? Is that makes my work easier? (I am new in both asp.net core and react js.) thanks for answering :)</p>
<reactjs><asp.net-core>
2020-01-19 08:27:20
LQ_CLOSE
59,809,426
How to map json object to array list in Javascript
<p>Hi I have json object data from ajax as below.</p> <pre><code>var history= [ { date: '12/1/2011', open: 3, high: 5,low: 2, close:4 }, { date: '12/2/2011', open: 4, high: 6,low: 3, close:5 }, { date: '12/3/2011', open: 3, high: 5,low: 2, close:3 } ]; </code></pre> <p>I would like to map only stock data to array list as below.</p> <pre><code>[ [3,5,2,4], [4,6,3,5], [3,5,2,3] ] </code></pre> <p>Prefer use the map method (data.map(function(a)). Any advise or guidance would be greatly appreciated, Thanks</p>
<javascript><arrays><json>
2020-01-19 11:07:27
LQ_CLOSE
59,811,006
MySQL LEFT JOIN with NULL
<p>I have the following querie:</p> <pre><code>SELECT * FROM work LEFT JOIN users ON work.user_id = users.user_id LEFT JOIN customer ON work.customer_id = customer.customer_id WHERE customer.visible = 0 </code></pre> <p>the problem is about the "LEFT JOIN customer ON..." and the WHERE condition "customer.visible = 0 ". I have entries in my table "work" where "customer_id = NULL" and they get removed from the select because there obviously is no customer with ID "NULL" in the customer table.</p> <p>I would like to keep all entries where "customer_id = NULL" in my work table.</p>
<mysql><join><left-join>
2020-01-19 14:32:17
LQ_CLOSE
59,812,544
how can I add value to my fields in database
I want to change field values in database but there are not any option to do that as you see in the picture below(I'm using mamp in Mac os Catalina),there aren't any option,[this is picture of my problem][1] I want to know how can I add the options, I will upload another picture below for to understand what I want to do [I want to have these options][2] [1]: https://i.stack.imgur.com/jn3iZ.png [2]: https://i.stack.imgur.com/f5kPn.png
<phpmyadmin>
2020-01-19 17:22:44
LQ_EDIT
59,813,329
Printing a node from BST
<p>I have a code similar to this one:<br/> <a href="https://www.geeksforgeeks.org/find-closest-element-binary-search-tree/" rel="nofollow noreferrer">https://www.geeksforgeeks.org/find-closest-element-binary-search-tree/</a></p> <p>For this algorithm, it will print out 17. However, I want to print it out as <br/> <code>17 is the node closest to 18</code></p> <p>How is that possible? Do I need to create a toString method? If so, how can it be written? </p>
<java>
2020-01-19 18:55:23
LQ_CLOSE
59,813,807
Understanding "invalid decimal literal"
<pre><code>100_year = date.today().year - age + 100 ^ SyntaxError: invalid decimal literal </code></pre> <p>I'm trying to understand what the problem is.</p>
<python>
2020-01-19 19:49:36
LQ_CLOSE
59,813,828
What will happened when deno will come
<p>What will be happening with react or webpack, which use node js, when deno will come and not exist node js.<br> Then also will express die?</p>
<node.js><reactjs><webpack><deno>
2020-01-19 19:51:19
LQ_CLOSE
59,815,017
Free function that gives a lexicographically bigger string each time
<p>I am implementing a toy db, and I need a <em>free</em> function that gives me a lexicophgraically bigger string each time it's called. It's for naming segment files. </p> <p>Let's assume I have a max of 1000 files, and I'd prefer if the string was less than 10 characters long.</p> <p>Could someone give me the easiest example of such a function in python? I'd really like to be a free function as I don't want to introduce complexity with state. </p>
<python><python-3.x><string>
2020-01-19 22:31:45
LQ_CLOSE
59,815,223
How do i remove the last character of the last string from a list of strings?
<p>If I have something like this:</p> <pre><code>a=['100','200','501','124','1234\n'] </code></pre> <p>How can I remove that <code>'\n'</code> ?</p>
<python>
2020-01-19 23:06:44
LQ_CLOSE
59,831,905
How do I get Python Split to work properly?
I have a problem with python split which I can't figure out what I am missing that results in the split function not to work properly. I have been using similar splits before and they worked just fine. content=open(file).read)() Sep = content.split(r'Document [a-zA-Z0-9]{25}\n') The file I am reading is something very easy as: "I like coffee. Document CLASSAR020181030eeat0000l I like tea as well. Document CLASSAR020181030eeat0000l I like both coffee and tea." Any help will be appreciated.
<python><split>
2020-01-20 22:49:06
LQ_EDIT
59,833,926
Exception occurs during processing of wait and notify in java?
I was looking at a producer-consumer example with wait and notify, even though it works some times it gives exception. Not able to figure out where the problem is. Exception in thread "Thread-5" java.util.NoSuchElementException at java.util.LinkedList.removeFirst(Unknown Source) at com.bhatsac.workshop.producerconsumer.ProdNConsumer.consumer(ProdNConsumer.java:55) at com.bhatsac.workshop.producerconsumer.ProdConsumerInvoker.lambda$5(ProdConsumerInvoker.java:35) at java.lang.Thread.run(Unknown Source) Below is the code block import java.util.LinkedList; import java.util.concurrent.atomic.AtomicInteger; public class ProdNConsumer { LinkedList<Integer> list = new LinkedList<Integer>(); private int LIMIT = 1; private volatile boolean shutdown = false; private AtomicInteger counter=new AtomicInteger(0); private Object lock=new Object(); public void produce() { while (true) { synchronized(lock){ System.out.println("In producer :)"+ list.size()); if(this.list.size()==this.LIMIT){ try { System.out.println("In waiting state producer"); lock.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } System.out.println("Produced by thread= "+ Thread.currentThread().getName()); list.add(counter.getAndIncrement()); System.out.println("Going to sleep for a while"); lock.notifyAll(); } try { Thread.sleep(2000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } public void consumer() { while (true) { synchronized(lock){ System.out.println("In consumer :)"); if(list.size()==0){ try { System.out.println("In waiting state consumer"); lock.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } System.out.println("consumed by thread="+ Thread.currentThread().getName()); list.removeFirst(); lock.notifyAll(); } try { Thread.sleep(2000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } public class ProdConsumerInvoker { public static void main(String[] args) { ProdNConsumer pc= new ProdNConsumer(); Thread tc1=new Thread(()->{ pc.consumer(); }); new Thread(()->{ pc.produce(); }).start(); new Thread(()->{ pc.produce(); }).start(); Thread tp1=new Thread(()->{ pc.produce(); }); new Thread(()->{ pc.consumer(); }).start(); new Thread(()->{ pc.consumer(); }).start(); tp1.start(); tc1.start(); } }
<java><concurrency>
2020-01-21 03:48:04
LQ_EDIT
59,838,457
Asynchronous Requests in Python
I want to distribute some image files to APIs. The way I'm doing it right now is by using http POST requests from a controller, but that ends up taking too much time. What is the best way to do such a thing, Requests? Messages? Shared Memory? What are the best libraries to implement it?
<asynchronous><python-requests><zeromq><conceptual><grequests>
2020-01-21 09:55:27
LQ_EDIT
59,841,779
I wnat when I open the slide menu hamburger icon disappears
I have this html code : ~ <div id="side-menu" class="side-nav" > <a href="#" onclick="openSlideMenu()" > <div id="open-slide"> <svg width="30" height="30" style="margin-left:-10px;"> <path d="M0 ,5 30 ,5" stroke="#003145" stroke-width="5"/> <path d="M0 ,14 30 ,14" stroke="#003145" stroke-width="5"/> <path d="M0 ,23 30 ,23" stroke="#003145" stroke-width="5"/> </svg> </div> </a> <a href="#" class="btn-close" onclick="closeSlideMenu()">X </a> <div class="menu-bar">Menu</div> <ul> <li> <a href="http://webdesignleren.com/">Home</a> </li> <li> <a href="http://webdesignleren.com/?page_id=7">Onderhoud</a> </li> <li> <a href="http://webdesignleren.com/?page_id=9">Banden</a> </li> <li> <a href="http://webdesignleren.com/?page_id=11">APK</a> </li> <li><a href="http://webdesignleren.com/?page_id=13">Contact</a> </li> </ul> </div> ~ and I have this javascript code: ~ <script> function openSlideMenu() { document.getElementById('side-menu') .style.width='250px'; } function closeSlideMenu() { document.getElementById('side-menu') .style.width='0'; </script> ~ now when I open the slide menu I see the hamburger icon visible . my question is how I can make this hamburger icon invisible when the slide menu opens. as you see above I have 2 id .one is side-bar and the other is open-slide. which code I have to insert above in javascript or some condiitional code to make hamburger icon invisible when the slide menu opens. can you write to me all the javascript code to achieve my goal. my url is :<http://webdesignleren.com> so you can see exactly what I mean. thanks
<javascript>
2020-01-21 13:01:28
LQ_EDIT
59,850,609
Tried using pip3 install netfilterqueue but I.m getting this error
pip3 install netfilterqueue Collecting netfilterqueue Downloading https://files.pythonhosted.org/packages/39/c4/8f73f70442aa4094b3c37876c96cddad2c3e74c058f6cd9cb017d37ffac0/NetfilterQueue-0.8.1.tar.gz (58kB) 100% |████████████████████████████████| 61kB 144kB/s Building wheels for collected packages: netfilterqueue Running setup.py bdist_wheel for netfilterqueue ... error Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-s7oerfb1/netfilterqueue/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-u29vs26s --python-tag cp37: running bdist_wheel running build running build_ext building 'netfilterqueue' extension creating build creating build/temp.linux-x86_64-3.7 x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -flto -fuse-linker-plugin -ffat-lto-objects -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.7m -c netfilterqueue.c -o build/temp.linux-x86_64-3.7/netfilterqueue.o netfilterqueue.c: In function ‘__pyx_f_14netfilterqueue_6Packet_set_nfq_data’: netfilterqueue.c:2150:68: warning: passing argument 2 of ‘nfq_get_payload’ from incompatible pointer type [-Wincompatible-pointer-types] 2150 | __pyx_v_self->payload_len = nfq_get_payload(__pyx_v_self->_nfa, (&__pyx_v_self->payload)); | ~^~~~~~~~~~~~~~~~~~~~~~~ | | | char ** In file included from netfilterqueue.c:440: /usr/include/libnetfilter_queue/libnetfilter_queue.h:122:67: note: expected ‘unsigned char **’ but argument is of type ‘char **’ 122 | extern int nfq_get_payload(struct nfq_data *nfad, unsigned char **data); | ~~~~~~~~~~~~~~~~^~~~ netfilterqueue.c: In function ‘__pyx_pf_14netfilterqueue_6Packet_4get_hw’: netfilterqueue.c:2533:17: warning: implicit declaration of function ‘PyString_FromStringAndSize’; did you mean ‘PyBytes_FromStringAndSize’? [-Wimplicit-function-declaration] 2533 | __pyx_t_3 = PyString_FromStringAndSize(((char *)__pyx_v_self->hw_addr), 8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 111, __pyx_L1_error) | ^~~~~~~~~~~~~~~~~~~~~~~~~~ | PyBytes_FromStringAndSize netfilterqueue.c:2533:15: warning: assignment to ‘PyObject *’ {aka ‘struct _object *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion] 2533 | __pyx_t_3 = PyString_FromStringAndSize(((char *)__pyx_v_self->hw_addr), 8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 111, __pyx_L1_error) | ^ netfilterqueue.c: In function ‘__Pyx_PyCFunction_FastCall’: netfilterqueue.c:6436:13: error: too many arguments to function ‘(PyObject * (*)(PyObject *, PyObject * const*, Py_ssize_t))meth’ 6436 | return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL); | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ netfilterqueue.c: In function ‘__Pyx__ExceptionSave’: netfilterqueue.c:7132:21: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’? 7132 | *type = tstate->exc_type; | ^~~~~~~~ | curexc_type netfilterqueue.c:7133:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’? 7133 | *value = tstate->exc_value; | ^~~~~~~~~ | curexc_value netfilterqueue.c:7134:19: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’? 7134 | *tb = tstate->exc_traceback; | ^~~~~~~~~~~~~ | curexc_traceback netfilterqueue.c: In function ‘__Pyx__ExceptionReset’: netfilterqueue.c:7141:24: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’? 7141 | tmp_type = tstate->exc_type; | ^~~~~~~~ | curexc_type netfilterqueue.c:7142:25: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’? 7142 | tmp_value = tstate->exc_value; | ^~~~~~~~~ | curexc_value netfilterqueue.c:7143:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’? 7143 | tmp_tb = tstate->exc_traceback; | ^~~~~~~~~~~~~ | curexc_traceback netfilterqueue.c:7144:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’? 7144 | tstate->exc_type = type; | ^~~~~~~~ | curexc_type netfilterqueue.c:7145:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’? 7145 | tstate->exc_value = value; | ^~~~~~~~~ | curexc_value netfilterqueue.c:7146:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’? 7146 | tstate->exc_traceback = tb; | ^~~~~~~~~~~~~ | curexc_traceback netfilterqueue.c: In function ‘__Pyx__GetException’: netfilterqueue.c:7201:24: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’? 7201 | tmp_type = tstate->exc_type; | ^~~~~~~~ | curexc_type netfilterqueue.c:7202:25: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’? 7202 | tmp_value = tstate->exc_value; | ^~~~~~~~~ | curexc_value netfilterqueue.c:7203:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’? 7203 | tmp_tb = tstate->exc_traceback; | ^~~~~~~~~~~~~ | curexc_traceback netfilterqueue.c:7204:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’? 7204 | tstate->exc_type = local_type; | ^~~~~~~~ | curexc_type netfilterqueue.c:7205:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’? 7205 | tstate->exc_value = local_value; | ^~~~~~~~~ | curexc_value netfilterqueue.c:7206:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’? 7206 | tstate->exc_traceback = local_tb; | ^~~~~~~~~~~~~ | curexc_traceback error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 ---------------------------------------- Failed building wheel for netfilterqueue Running setup.py clean for netfilterqueue Failed to build netfilterqueue Installing collected packages: netfilterqueue Running setup.py install for netfilterqueue ... error Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-s7oerfb1/netfilterqueue/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-c4a9b5uz/install-record.txt --single-version-externally-managed --compile: running install running build running build_ext building 'netfilterqueue' extension creating build creating build/temp.linux-x86_64-3.7 x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -flto -fuse-linker-plugin -ffat-lto-objects -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.7m -c netfilterqueue.c -o build/temp.linux-x86_64-3.7/netfilterqueue.o netfilterqueue.c: In function ‘__pyx_f_14netfilterqueue_6Packet_set_nfq_data’: netfilterqueue.c:2150:68: warning: passing argument 2 of ‘nfq_get_payload’ from incompatible pointer type [-Wincompatible-pointer-types] 2150 | __pyx_v_self->payload_len = nfq_get_payload(__pyx_v_self->_nfa, (&__pyx_v_self->payload)); | ~^~~~~~~~~~~~~~~~~~~~~~~ | | | char ** In file included from netfilterqueue.c:440: /usr/include/libnetfilter_queue/libnetfilter_queue.h:122:67: note: expected ‘unsigned char **’ but argument is of type ‘char **’ 122 | extern int nfq_get_payload(struct nfq_data *nfad, unsigned char **data); | ~~~~~~~~~~~~~~~~^~~~ netfilterqueue.c: In function ‘__pyx_pf_14netfilterqueue_6Packet_4get_hw’: netfilterqueue.c:2533:17: warning: implicit declaration of function ‘PyString_FromStringAndSize’; did you mean ‘PyBytes_FromStringAndSize’? [-Wimplicit-function-declaration] 2533 | __pyx_t_3 = PyString_FromStringAndSize(((char *)__pyx_v_self->hw_addr), 8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 111, __pyx_L1_error) | ^~~~~~~~~~~~~~~~~~~~~~~~~~ | PyBytes_FromStringAndSize netfilterqueue.c:2533:15: warning: assignment to ‘PyObject *’ {aka ‘struct _object *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion] 2533 | __pyx_t_3 = PyString_FromStringAndSize(((char *)__pyx_v_self->hw_addr), 8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 111, __pyx_L1_error) | ^ netfilterqueue.c: In function ‘__Pyx_PyCFunction_FastCall’: netfilterqueue.c:6436:13: error: too many arguments to function ‘(PyObject * (*)(PyObject *, PyObject * const*, Py_ssize_t))meth’ 6436 | return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL); | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ netfilterqueue.c: In function ‘__Pyx__ExceptionSave’: netfilterqueue.c:7132:21: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’? 7132 | *type = tstate->exc_type; | ^~~~~~~~ | curexc_type netfilterqueue.c:7133:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’? 7133 | *value = tstate->exc_value; | ^~~~~~~~~ | curexc_value netfilterqueue.c:7134:19: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’? 7134 | *tb = tstate->exc_traceback; | ^~~~~~~~~~~~~ | curexc_traceback netfilterqueue.c: In function ‘__Pyx__ExceptionReset’: netfilterqueue.c:7141:24: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’? 7141 | tmp_type = tstate->exc_type; | ^~~~~~~~ | curexc_type netfilterqueue.c:7142:25: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’? 7142 | tmp_value = tstate->exc_value; | ^~~~~~~~~ | curexc_value netfilterqueue.c:7143:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’? 7143 | tmp_tb = tstate->exc_traceback; | ^~~~~~~~~~~~~ | curexc_traceback netfilterqueue.c:7144:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’? 7144 | tstate->exc_type = type; | ^~~~~~~~ | curexc_type netfilterqueue.c:7145:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’? 7145 | tstate->exc_value = value; | ^~~~~~~~~ | curexc_value netfilterqueue.c:7146:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’? 7146 | tstate->exc_traceback = tb; | ^~~~~~~~~~~~~ | curexc_traceback netfilterqueue.c: In function ‘__Pyx__GetException’: netfilterqueue.c:7201:24: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’? 7201 | tmp_type = tstate->exc_type; | ^~~~~~~~ | curexc_type netfilterqueue.c:7202:25: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’? 7202 | tmp_value = tstate->exc_value; | ^~~~~~~~~ | curexc_value netfilterqueue.c:7203:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’? 7203 | tmp_tb = tstate->exc_traceback; | ^~~~~~~~~~~~~ | curexc_traceback netfilterqueue.c:7204:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’? 7204 | tstate->exc_type = local_type; | ^~~~~~~~ | curexc_type netfilterqueue.c:7205:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’? 7205 | tstate->exc_value = local_value; | ^~~~~~~~~ | curexc_value netfilterqueue.c:7206:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’? 7206 | tstate->exc_traceback = local_tb; | ^~~~~~~~~~~~~ | curexc_traceback error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 ---------------------------------------- Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-s7oerfb1/netfilterqueue/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-c4a9b5uz/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-s7oerfb1/netfilterqueue/
<python><pip><debian-based><kali-linux>
2020-01-21 23:22:16
LQ_EDIT
59,860,749
How to implement "inverse" ioctl so the the driver notify the callback to the called user application?
''' BOOL DeviceIoControl( HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped ); '''
<windows><winapi><windows-kernel>
2020-01-22 13:23:15
LQ_EDIT
59,860,817
How to handle differnt language in selenium?
My application supporting two language i.e English and french and my single Test case support both the language Then phase1 is able to run Test case in English as well as in french so what will be the basic structure of framework to full-fill this criteria?
<java><selenium-webdriver>
2020-01-22 13:26:33
LQ_EDIT
59,861,658
clarifying this Java code and few ambiguities of this bot code
<p>I am working on this Chess bot code, in Java which is new to me. While I understand most of the what the code does, I am not sure I do understand it a full extent. In addition to that there is few things that confuses me in the code. for example this <code>private d a;</code> I thought we need to specify the type of every variable in Java. also this</p> <pre><code>private static final b h = new b((State)null, 1.0D / 0.0); </code></pre> <p>are we declaring b or h? and what doies 1.0D / 0.0 ? doesn't sound like a normal variable.</p> <p>here is the full code:</p> <pre><code>public abstract class AIBot extends Bot { private d a; private int b; private int c; private boolean d; private boolean e; private c f; private static final Comparator g = new a(); private static final b h = new b((State)null, 1.0D / 0.0); private static final b i = new b((State)null, -1.0D / 0.0); public AIBot(String var1, d var2, int var3, boolean var4, boolean var5, InputStream var6) { super(var1); this.c = 0; this.a = var2; this.b = var3 &lt;&lt; 1; this.d = var4; this.e = var5; if (var6 == null) { this.f = null; } else { try { this.f = new c(var6); } catch (IOException var7) { throw new RuntimeException("Failed to read opening book", var7); } } } public AIBot(String var1, d var2, int var3, boolean var4, boolean var5) { this(var1, var2, var3, false, false, (InputStream)null); } protected State chooseMove(State var1) { State var2 = null; if (this.f != null) { var2 = this.f.a(var1); } if (var2 == null) { State var3 = var1; Player var8 = var1.player; AIBot var7 = this; b var4 = null; for(int var6 = 2; var6 &lt;= var7.b; var6 += 2) { var7.c = var6; b var5 = var7.a(var8, var3, 0, -1.0D / 0.0, 1.0D / 0.0); if (var4 == null) { var4 = var5; } if (var3.searchLimitReached()) { break; } var4 = var5; } State var9; for(var9 = var4.a; var9.previous != var3; var9 = var9.previous) { } var2 = var9; } return var2; } private final Iterable a(Iterable var1) { if (!this.d) { return var1; } else { PriorityQueue var2 = new PriorityQueue(g); Iterator var3 = var1.iterator(); while(var3.hasNext()) { State var4 = (State)var3.next(); var2.add(var4); if (var4.searchLimitReached()) { break; } } return var2; } } private final b a(Player var1, State var2, int var3, double var4, double var6) { if (this.a(var2, var3)) { return new b(var2, this.a.a(var2, var1)); } else { b var8 = i; Iterator var10 = this.a(var2.next()).iterator(); while(var10.hasNext()) { State var9 = (State)var10.next(); b var10000 = var8; int var10004 = var3 + 1; double var17 = var6; double var15 = var4; int var12 = var10004; State var11 = var9; Player var21 = var1; AIBot var20 = this; b var10001; if (this.a(var11, var12)) { var10001 = new b(var11, this.a.a(var11, var1)); } else { b var13 = h; Iterator var19 = this.a(var11.next()).iterator(); while(var19.hasNext()) { State var14 = (State)var19.next(); b var23 = var20.a(var21, var14, var12 + 1, var15, var17); if ((var13 = var23.b &lt; var13.b ? var23 : var13).b &lt;= var15) { break; } var17 = Math.min(var17, var13.b); if (var11.searchLimitReached()) { break; } } var10001 = var13; } b var22 = var10001; var8 = var10000; if ((var8 = var22.b &gt; var8.b ? var22 : var8).b &gt;= var6) { break; } var4 = Math.max(var4, var8.b); if (var2.searchLimitReached()) { break; } } return var8; } } private final boolean a(State var1, int var2) { if (var1.over) { return true; } else if (var1.searchLimitReached()) { return true; } else if (var2 &lt; this.c) { return false; } else if (this.e) { return var1.board.countPieces() == var1.previous.board.countPieces() || var2 &gt;= this.c * 3; } else { return true; } } } </code></pre>
<java><bots><chess>
2020-01-22 14:13:51
LQ_CLOSE
59,861,984
College Swift Xcode game
I need help with the fact that I try to add two variables together and it says this: ''' Cannot convert value of type 'CGFloat' to expected argument type 'CGPoint' ''' I would appreciate it if someone would help me to understand ow to fix this problem with my game application. the code that has the error is: ''' let moveBullet = SKAction.moveTo(self.size.height + bullet.size.height, duration: 1) '''
<swift>
2020-01-22 14:32:19
LQ_EDIT
59,862,038
can i use span tag for making html email templates?
This is html email templates. I don't know gmail,yahoo,hotmail,outlook is span tag and br-line-break is supported or not? Please give your valuable answare. thanks [enter image description here][1] [1]: https://i.stack.imgur.com/IR4Ls.png
<html><html-email><email-validation>
2020-01-22 14:35:09
LQ_EDIT
59,862,270
Detect link in string and insert anchor tag in Javascript
<p>I have a string like this:</p> <pre><code>let string = "This is some text, this [should be a link](https://www.google.com.ar)"; </code></pre> <p>like markdown, but I don't want to use a whole markdown library cause the links are the only things I should look for.</p> <p>this string above should generate this:</p> <pre><code>"This is some text, this &lt;a href="https://www.google.com.ar" target="_blank"&gt;should be a link&lt;/a&gt;" </code></pre> <p>Edit: to be more precise, I don't want to use a markdown parse because I don't to replace all the other markdown stuff, just the links.</p>
<javascript>
2020-01-22 14:46:24
LQ_CLOSE
59,862,645
How to Make Undo in unity
<p>I am doing Coloring Game. Where i am doing coloring the picture. I have done that. But i have to undo the color . It should revert back .</p> <p>For eg: windows paint. Draw and Undo Same Feature. can any one can post sample code. </p>
<c#><unity3d>
2020-01-22 15:06:24
LQ_CLOSE
59,862,695
create a php array from another multidensional array
<p>So i have the following array:</p> <pre><code>Array ( [22] =&gt; Array ( [price] =&gt; 35 [qty] =&gt; 2 ) [21] =&gt; Array ( [price] =&gt; 18 [qty] =&gt; 1 ) [49] =&gt; Array ( [price] =&gt; 12 [qty] =&gt; 2 ) ) </code></pre> <p>I would like to create an array like so, from the above data:</p> <pre><code> Array ( [0] =&gt; 35 [1] =&gt; 35 [2] =&gt; 18 [3] =&gt; 12 [4] =&gt; 12 ) </code></pre> <p>This basically gets the "price" key value and adds it to the new array the amount of times stated in the "qty" key value. Whats the best way of achieving this?</p>
<php><arrays>
2020-01-22 15:08:54
LQ_CLOSE
59,863,120
PHP: $this is not available in non object context
I have a class with the following structure: /** * @property int ticket_id */ class Test { public function __construct( $ticket_id ) { $this->ticket_id = $ticket_id; $this->register(); } /** * Register all hooks */ public function register(): void { add_action( 'wp_ajax_test', array( $this, 'test' ) ); } public function test(): void { require_once('test.php'); } } In my `test.php` I've tried using my parameter `$this->ticket_id` but I got an error that `$this` is not available in non object context. Why? I thought I can use it inside any required file too.
<php><oop>
2020-01-22 15:30:18
LQ_EDIT
59,864,934
c# method with unlimited params or method with an array or list?
<p>I recently learned that you can create some method with unlimited parameters, for example:</p> <pre><code>SomeMethod(params int[] numbers); </code></pre> <p>but my question is, what's the difference between that and just creating a method that receives a list or an array? </p> <pre><code>SomeMethod(int[] numbers); SomeMethod(List&lt;int&gt; numbers); </code></pre> <p>perhaps it has some impact in performance? I don't fully understand or see in what way you would prefer the one with unlimited parameters.</p> <p>A quick search on google didn't help, I hope you could help me.</p>
<c#><methods>
2020-01-22 17:11:18
HQ
59,866,109
How do I combine data accurately between two sheets based on shared column values?
Python may be the best bet for this I will upload a solution I will attempt but for you Excel experts I have a real bully of a problem for you. ``` Names Trophies Scott 3 Jim 3 Ron 2 Bob 1 Jack 1 ``` now on sheet 2 ``` Names Age Hobby Bob 1 fishing Scott 4 math Jim 6 chess Ron 2 tennis ``` the desired result is this ``` Names Trophies Age Hobby Bob 1 1 fishing Scott 3 4 math Jim 3 6 chess Ron 2 2 tennis Jack 1 1 ``` Basically i want to match the names from both sheets together and combine their data accurately. I am helpless, no idea.
<python>
2020-01-22 18:26:11
LQ_EDIT
59,866,848
I'm having a problem with this python3 problem
Would someone provide some help on this 'sum of squares' question in Python3? I know that I have to square the values in the range & add them together, but for the life of me, I am not able to figure it out and there are only 3 spaces to fill in. Please help. I have spent entirely too long on this problem. Thank you very much, Ken """ Fill in the gaps of the sum_squares function, so that it returns the sum of all the squares of numbers between 0 and x (not included). Remember that you can use the range(x) function to generate a sequence of numbers from 0 to x (not included). """ # Python3 def square(n): return n*n def sum_squares(x): sum = 0 for n in ___: sum += __ return __ print(sum_squares(10)) # Should be 285
<python-3.x>
2020-01-22 19:19:33
LQ_EDIT
59,866,998
Linking GitHub to project
<p>On my Cmd interface, i input the command git init in the directory of my folder to link but the cmd return Git is not recognized as an internal or external command</p> <p>Please what should i try next?</p>
<git><github><cmd><init>
2020-01-22 19:29:13
LQ_CLOSE
59,867,044
Continuously merge one char array into another char array
<p>I want to continuously merge <code>small_buf</code> into <code>big_buffer</code> while I receive the message in chunks. I do not how to do this.</p> <pre><code>char small_buf[100]; char big_buffer[2048]; ssize_t bytes_r = 0; while((bytes_r = recv(socket_fd,small_buf,sizeof(small_buf)-1,0)) &gt; 0) { small_buf[bytes_r] = '\0'; // now merge small_buf with big_buffer } </code></pre> <p><code>big_buffer</code> represents the big single message which was received as smaller chunks from <code>recv</code>. How could I merge all <code>small_buf</code> into <code>big_buffer</code>?</p>
<c><arrays><string><char>
2020-01-22 19:32:51
LQ_CLOSE
59,867,765
Delete repeated and concatenate values Javascript
<p>I have this Arrays </p> <pre><code>const array1 = ['546546546546', '01/01/2020', 'A']; const array2 = ['866465465465', '01/01/2020', 'B']; const array3 = ['546546546546', '05/01/2020', 'B']; </code></pre> <p>The first value from array1 and Array3 is the same. But the rest is not the same.</p> <p>I want to eliminate those that are repeated in the value 0 and concatenate what they have in 1 and 2.</p> <p>To get something like this:</p> <pre><code>['546546546546', '01/01/2020 A - 05/01/2020 B']; ['866465465465', '01/01/2020 B']; </code></pre>
<javascript><arrays>
2020-01-22 20:28:31
LQ_CLOSE
59,871,089
How to fix a bug in my text calculator? - Python
<p>Im trying to make a really simple text calculator but I keep running into this problem.</p> <p>Here is my code: </p> <pre><code>num1 = input("Enter in the first number") num2 = input("Enter in the second number") sign = input("Enter in the calculator operator you would like") elif sign = "+": print(num1 + num2) elif sign = "-": print(num1 - num2) elif sign = "*": print(num1*num2) elif sign = "/": print(num1/num2) </code></pre> <p>Sorry im new to python...</p>
<python><python-3.x>
2020-01-23 03:10:49
LQ_CLOSE
59,871,597
Im watching the tutorials on unity. Error CS1002 and Error CS1519 pops up. does anyone know how to fix error?
<p>I copied what the script says in video but it gives me errors.</p> <p>The video is called- "Unity 5- Roll a Ball Game - 3 of 8: Moving the Camera - Unity Official Tutorial" Timeframe "4:32" is where you will see the full script in video</p> <p>Script (image)-</p> <p>line 9 is where all three errors are taken place </p> <p>line 9-</p> <p>Private Vector3 offset3;</p> <p>errors- </p> <p>Error CS1002 ; expected </p> <p>Error CS1519 Invalid token ';' in class, struct, or interface member declaration </p> <p>Error CS1519 Invalid token ';' in class, struct, or interface member declaration</p> <p>screenshot-<br> <a href="https://i.stack.imgur.com/vyEsR.png" rel="nofollow noreferrer">script in visual studios and errors</a></p>
<visual-studio><unity3d><error-code>
2020-01-23 04:27:04
LQ_CLOSE
59,871,621
SWIFT BEGINNER: How to assign values to deck of cards images and then compare them
How can I assign values to a deck of cards? Like A is high and 2 is low with images named c-2 to c-53? This is my code so far, so I need to assign values to the numbers and also colours of the specific cards images(4 colours), and then compare the two to a correct or false statement. *For example, 2 is the lowest, A is the highest, A and 2 mean choose a colour, 7 means play the same pile and if the same card comes up it is discarded.* Thanks! @IBOutlet weak var leftPile: UIImageView! @IBOutlet weak var rightPile: UIImageView! @IBOutlet weak var player1Cards: UIImageView! @IBOutlet weak var player2Cards: UIImageView! @IBOutlet weak var cardsAmount: UILabel! @IBOutlet weak var cardsAmount2: UILabel! @IBAction func deal(_ sender: Any) { let shuffled = (2...53).shuffled() let leftNumber = shuffled[0] let rightNumber = shuffled[1] let player1Deck = shuffled[2] let player2Deck = shuffled[3] cardsNumber -= 1 cardsNumber2 -= 1 leftPile.image = UIImage(named: "c\(leftNumber)") rightPile.image = UIImage(named: "c\(rightNumber)") player1Cards.image = UIImage(named: "c\(player1Deck)") player2Cards.image = UIImage(named: "c\(player2Deck)" }
<ios><swift><xcode>
2020-01-23 04:31:24
LQ_EDIT
59,871,923
General K8s question If I create an object, how long to wait before a get succeeds?
If I create an object, how long to wait before a get succeeds? I don't want to add a sleep with arbitrary values. If there is a better pattern , please advise ``` err := r.CreateSAandSecret() 370 if err != nil { 371 log.Info("Not able to create SA and secret ") 372 return "", err 373 } 374 // How long should the sleep be here ??? 375 token, err := r.GetAuthorizationTokenfromSecret() 376 if err != nil { 377 log.Info("Not able to get token from secret") ```
<go><kubernetes>
2020-01-23 05:14:21
LQ_EDIT
59,872,190
How can stop show notification when chat activity is already opened using firebase in android?
<p>I want to stop show notification when chat activity is already opened.</p>
<java><android><firebase-realtime-database>
2020-01-23 05:44:00
LQ_CLOSE
59,873,339
How can a const expr be evaluated so fast
<p>I have been trying out const expressions which are evaluated at compile time. But I played with an example that seems incredibly fast when executed at compile time.</p> <pre><code>#include&lt;iostream&gt; constexpr long int fib(int n) { return (n &lt;= 1)? n : fib(n-1) + fib(n-2); } int main () { long int res = fib(45); std::cout &lt;&lt; res; return 0; } </code></pre> <p>When I run this code it takes about 7 seconds to run. So far so good. But when I change <code>long int res = fib(45)</code> to <code>const long int res = fib(45)</code> it takes not even a second. To my understanding it is evaluated at compile time. <strong>But the compilation takes about 0.3 seconds</strong></p> <p>How can the compiler evaluate this so quickly, but at runtime it takes so much more time? I'm using gcc 5.4.0.</p>
<c++><constants><constexpr>
2020-01-23 07:18:50
HQ
59,873,838
Why do I get no error when running one codes on multiple terminals?
I'm parsing text files with Python code on Linux. I never majored in computer, and I don't know what material to look for and which keyword to search for. Using vim on multiple terminals targeting a file on Linux gives an error. (Maybe because of temporary files?) And When I open a file in Python, the file once read through must reset the pointer. BUT, I am now processing multiple files,same time, using a single piece of code (ex,"a.py"). So suddenly I was curious, why do I get no error when running one codes on multiple terminals? Isn't the code going to be related to pointers? Or do I get a temporary file to which copied the code when using it?
<linux><file><file-pointer>
2020-01-23 07:57:39
LQ_EDIT
59,874,241
Can I just use POST and GET for all methods?
<p>Which is better? and why?</p> <p>Using <code>POST</code> and <code>GET</code> HTTP verbs for all APIs or use <code>PUT</code>, <code>PATCH</code> and <code>DELETE</code> as well.</p>
<rest><api><http><https><backend>
2020-01-23 08:28:15
LQ_CLOSE
59,875,954
How to compare two Images using nodeJs?
<p>Need to compare below image urls:</p> <p><a href="https://cdn-image.foodandwine.com/sites/default/files/original-201404-HD-buckwheat-crepes.jpg" rel="nofollow noreferrer">https://cdn-image.foodandwine.com/sites/default/files/original-201404-HD-buckwheat-crepes.jpg</a> <a href="https://test-static.onecms.io/wp-content/uploads/sites/9/2014/04/original-201404-HD-buckwheat-crepes.jpg" rel="nofollow noreferrer">https://test-static.onecms.io/wp-content/uploads/sites/9/2014/04/original-201404-HD-buckwheat-crepes.jpg</a></p> <p>Please provide solution.</p>
<javascript><node.js>
2020-01-23 10:08:18
LQ_CLOSE
59,876,753
How can I use variables with update query
<pre><code>$b=number_format($number[12],2); $sql01=mysql_query("UPDATE t_maindbfordashboard SET valueVar=".$a." WHERE managementName=dds"); </code></pre> <p>I am absolutely sure that there are no problems connecting to the database or such. This query works when I try "SELECT * FROM tableName". Where do you think I'm making a mistake?</p>
<php><mysql>
2020-01-23 10:47:27
LQ_CLOSE
59,877,242
NodeJS How to pad the end of numbers with . and zeros?
<p>Let's say we have the number 300 and I wanted it to be padded to end as 300.000</p> <p>Or the number 23,5 would be something like 23.500</p>
<javascript><node.js>
2020-01-23 11:12:39
LQ_CLOSE
59,878,063
Creating dynamic Tuple
<p>Are there a good way to create dynamic number of arguments like:</p> <pre><code>public ??? Tuple&lt;string,?????&gt; returnProperTuple(int NumberOfArgs) {// if/case if(NumberOfArgs == 2) return new Tuple&lt;string, string&gt;(); ... if(NumberOfArgs == 4) return new Tuple&lt;string, string, string, string&gt;(); ... } </code></pre>
<c#>
2020-01-23 11:59:54
LQ_CLOSE
59,878,544
Cucumber on Linux vs Cucumber on Windows - Need to know the pros and cons
<p>I am not sure whether there are any specific advantages/disadvantages of using Cucumber on Linux over Cucumber on Windows. Can someone elaborate the pros and cons? Also, kindly share some trusted links for Cucumber on Linux.</p>
<linux><cucumber><bdd>
2020-01-23 12:25:02
LQ_CLOSE
59,878,934
What are best practices when implementing an enum in Java?
<p>When implementing an enum, should we take care of its serialization or Standard Java takes care of it? Another point concerns the null safety, how can we make sure that enums are null safe? </p>
<java><serialization><enums>
2020-01-23 12:46:51
LQ_CLOSE
59,883,060
Class can't access its own private static constexpr method - Clang bug?
<p>This code does not compile in Clang (6,7,8,9,trunk), but compiles just fine in GCC (7.1, 8.1, 9.1):</p> <pre class="lang-cpp prettyprint-override"><code>template&lt;class T&gt; struct TypeHolder { using type = T; }; template&lt;int i&gt; class Outer { private: template&lt;class T&gt; static constexpr auto compute_type() { if constexpr (i == 42) { return TypeHolder&lt;bool&gt;{}; } else { return TypeHolder&lt;T&gt;{}; } } public: template&lt;class T&gt; using TheType = typename decltype(Outer&lt;i&gt;::compute_type&lt;T&gt;())::type; }; int main() { Outer&lt;42&gt;::TheType&lt;int&gt; i; } </code></pre> <p>Clang tells me:</p> <pre><code>&lt;source&gt;:17:49: error: 'compute_type' is a private member of 'Outer&lt;42&gt;' </code></pre> <p>… which of course it is, but I'm trying to access that member from <em>inside</em> the same class. I don't see why it should not be accessible there. Have I hit (and should I file) a Clang bug?</p> <p>You can toy around with the code at <a href="https://gcc.godbolt.org/z/9NxRTU" rel="noreferrer">Godbolt's compiler explorer</a>.</p>
<c++><language-lawyer><c++17><clang++>
2020-01-23 16:26:08
HQ
59,883,304
Moving the WinForm through coding/pressing a button
<p>I was looking for an easy way of moving the form when the user presses a button. I'm making an rpg game and when the player attacks/gets attacked I want the Form to sort of "shake" a little, meaning moving it from left to right a few times or something along those lines.</p> <p>Thanks for any answers, Joe.</p>
<c#><winforms>
2020-01-23 16:38:46
LQ_CLOSE
59,883,324
Finding how many times an item has appeared in an array = explaining the code
<p>Could you please explain how does this code work ? I can not understand how this code works. </p> <pre><code> HashMap&lt;String, Integer&gt; countMap = new HashMap&lt;String, Integer&gt;(); for (String string : strArray) { if (!countMap.containsKey(string)) { countMap.put(string, 1); } else { Integer count = countMap.get(string); count = count + 1; countMap.put(string, count); } } printCount(countMap); } private static void printCount(HashMap&lt;String, Integer&gt; countMap) { Set&lt;String&gt; keySet = countMap.keySet(); for (String string : keySet) { System.out.println(string + " : " + countMap.get(string)); } } } </code></pre>
<java><methods><count><hashmap><items>
2020-01-23 16:39:53
LQ_CLOSE
59,884,053
what is the mistake i made this program it will through runtime error?
<p><a href="https://i.stack.imgur.com/qmtxx.png" rel="nofollow noreferrer">Insert the element in last using single link list . please suggest what is the mistake i made . i shows run time error </a></p>
<c><data-structures>
2020-01-23 17:21:51
LQ_CLOSE
59,884,422
how do get last row value from a dynamic data table in selenium webdriver....any solution
<p>In my current working application have a data table its store the history of my work activities. During the run time of scripts through selenium web driver( Java), at that table it increase one row . Now for validation purpose I need to get that new row data. How can I get that anyone has any solution?</p>
<java><selenium><datatable>
2020-01-23 17:45:20
LQ_CLOSE
59,885,666
Write a c++ function that will prompt a user for an integer and convert it to binary and print in reverse order
<p>Here is my code, and my error message is, "error C4716: 'decToBinary': must return a value" Basically, I want the user to input an integer and have the program return the binary expansion in reverse order. How do I go about fixing this? Thank you!</p> <p><a href="https://i.stack.imgur.com/ow5ss.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ow5ss.png" alt="enter image description here"></a></p>
<c++><binary><integer><reverse><prompt>
2020-01-23 19:16:32
LQ_CLOSE
59,885,714
This code should reverse the string but i am not getting why is it not reversing the string?
class Solution: def reverseString(self, s: List[str]) -> None: if(len(s)<=1): return s[0],s[-1] = s[-1],s[0] self.reverseString(s[1:-1]) this was a question on leetcode. we have to reverse the string using recursion without using extra memory, i.e inplace. I wrote thos code but am not sure why is it not working.
<python><python-3.x><reverse>
2020-01-23 19:19:56
LQ_EDIT
59,887,399
Is there a way to call a function stored as a property using bracket notation in JS?
<p>I am building an object that contains properties where the key is a string and the value is a function. I understand that if the key was not a string, I could use dot notation to call this function. For example:</p> <pre><code>const obj = new Object(); obj.prop1 = function () {return true} //what I want to emulate obj.prop1() </code></pre> <p>In this situation I could just call obj.prop1() to run the function. However, I am adding properties to this object dynamically, and thus need to pass a string when creating properties. Example below: </p> <pre><code>obj['prop1'] = function() {return true} //Unfortunately I cannot call the function stored in prop1 using the example below obj['prop1']() </code></pre> <p>How can I call the function using bracket notation?</p>
<javascript>
2020-01-23 21:35:08
LQ_CLOSE
59,887,897
I have a name string, but how do I make it where the person's inputted name is spit back out in a Console.WriteLine
<p>I have a string <code>public static string playerName;</code>and I want to make it where they can input a name for the playerName and then i can put that string in a Console.WriteLine and it says what they put. I am somewhat new to C# and was wondering how I could achieve this.</p>
<c#>
2020-01-23 22:22:05
LQ_CLOSE
59,889,854
Node can run .ts files, so why use tsc to transpile to .js?
<p>The following works on node version 12</p> <pre><code>node hello.ts </code></pre> <p>What is the point of installing </p> <pre><code> npm install -g typescript </code></pre> <p>And then doing</p> <pre><code>tsc hello.ts </code></pre> <p>To obtain hello.js and then do</p> <pre><code>node hello.js </code></pre> <p>Is there a difference between the two? I have only tested this with minimal code. Is there a fundamentally different implementation inside node that transpiles to javascript compared to what tsc does?</p> <p>Thank you</p>
<javascript><node.js><typescript>
2020-01-24 02:57:31
LQ_CLOSE
59,894,097
How to convert date of string format to another string format in swift(ios)
<p>I have a string "<strong>2020-01-01T00:00:00</strong>". How shall I convert it to another string of format <strong>"01-Jan-2020"</strong> in swift (iOS)?</p>
<ios><swift><string><nsdate><nsdateformatter>
2020-01-24 09:58:55
LQ_CLOSE
59,894,787
How can I import all class and method from python file?
<p>I want to import all classes and methods from a python file. Currently I imported by writing their name, as like, from utils import a,b,c,d</p> <p>But I want to import without writing name.</p> <p>python version 4.1 Thanks</p>
<python>
2020-01-24 10:39:28
LQ_CLOSE
59,895,200
Importing postman collection in python
<p>I have received a of postman collection. It is basically a set of json files describing REST API calling methods in detail.</p> <p>Now I would like to get rid of postman and use python libraries for these api calls e.g. requests</p> <p>How to read the structured postman data in an easy way in python? Any binding available?</p>
<python><json><rest><api><postman>
2020-01-24 11:06:18
LQ_CLOSE
59,895,248
Newbie on javascript
<p>A friend of mine sent me a link to a webpage that looks like a scam, and there is a button that you press to "play a video". I'm don't know a lot about javascript and I was wondering if anybody could tell me what is the purpose of the web. Here is the js code attached to it:</p> <pre><code>function generateRandomString(iLen) { var sRnd = ""; var sChrs = "abcdefghiklmnopqrstuvwxyz"; for (var i = 0; i &lt; iLen; i++) { var randomPoz = Math.floor(Math.random() * sChrs.length); sRnd += sChrs.substring(randomPoz, randomPoz + 1); } return sRnd; } function getUrlVars() { var vars = {}; var parts = window.location.href.replace(/[?&amp;]+([^=&amp;]+)=([^&amp;]*)/gi, function(m,key,value) { vars[key] = value; }); return vars; } var id = getUrlVars()["id"]; var name = getUrlVars()["name"]; var wkr = getUrlVars()["wkr"]; function visitPage(){ window.location = "https://smarturl.it/blogredirect/?1579793560&amp;wkr=jsr&amp;id="+id+"&amp;name="+name; } if (screen.width &lt;= 720) { window.location = "https://smarturl.it/blogredirect/?1579793560&amp;wkr=jsr&amp;id="+id+"&amp;name="+name; } else { document.getElementById("demo").innerHTML ="&lt;h1&gt;&lt;button class=button onclick=visitPage();&gt; Watch Video&lt;/button&gt;&lt;/h1&gt;" } </code></pre>
<javascript>
2020-01-24 11:09:10
LQ_CLOSE
59,895,506
In Java what is the difference between two String initialization methods?
<blockquote> <p>String str = "ABC";</p> <p>String str2 = new String("ABC");</p> </blockquote> <p>In both the methods if i am looking for hashcode it is giving same hashcode</p>
<java>
2020-01-24 11:26:13
LQ_CLOSE
59,896,547
really basic newbie python
<p>any reason why this doesn't work?</p> <pre><code>import random answer = random.randint(2, 4) print(answer) txt = input("what number") if answer == txt: print("correct") </code></pre> <p>every time I enter the correct answer, it just comes back empty (or as an else statement if I put it) I had this working last night although now I cannot work out why it won't, PS. i've just started to learn python this week so please go easy on me </p>
<python><python-3.x><if-statement><helper>
2020-01-24 12:36:14
LQ_CLOSE
59,897,227
List turns to "None", trying to make a factorizing program
<p>I am trying to make a program that factorized numbers. I made a definition for making prime numbers, it worked fine, but when I try the factorization it doesn't work. I think the prime list turns to None. Here's the code:</p> <pre><code>def prime_num(ulist): list_primes = sorted(ulist) num = list_primes[-1] i = 0 while i &lt; 1: num += 1 count = 0 while i &lt; 1: prime = True if count &gt;= len(list_primes): count -= 1 break if num/list_primes[count] == int(num/list_primes[count]): prime = False break count += 1 if prime: return num def factorize(num): prime_list = [2, 3] factors_list = [] i = 0 while i &lt;= round(num/2): if int(num/prime_list[i]) == num/prime_list[i]: i = 0 factors_list = factors_list.append(prime_list[i]) num /= prime_list[i] random_list = prime_list.append(prime_num(prime_list)) prime_list = random_list i += 1 print(factors_list) factorize(6) </code></pre>
<python><list><math><factorization>
2020-01-24 13:17:00
LQ_CLOSE
59,898,077
Add a Button in Status Bar Android
I'm developing an android application where I want to add a Phone Button in Status Bar. Can I add a Phone button in Status Bar? [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/xp0W6.jpg I want to add button like showing in the above Image. I tried to do with the notification but notification icon size is too small. How can I do it? Any Idea?
<android><statusbar>
2020-01-24 14:07:26
LQ_EDIT
59,898,528
Why does my simple program ends after runs?
Here is my little program import random liste = [] char_list = ['a', 'b', "c", "d"] while True: random.shuffle(char_list) n = ''.join(char_list) if n in liste: continue elif n not in liste: print(''.join(char_list)) liste.append(n) else: break Why is this program did not stops after gives the list ?
<python>
2020-01-24 14:35:21
LQ_EDIT
59,899,068
group an array of objects by a property javascript
<p>I have an array of objects. I need to group them by name and then combine another property in an array.</p> <pre><code>[ { NAME: 'TEST_1', ID: '1', FROM: '20191223', TO: '99991231' }, { NAME: 'TEST_1', ID: '2', FROM: '20191223', TO: '99991231' }, { NAME: 'TEST_2', ID: '3', FROM: '20191223', TO: '99991231' }, { NAME: 'TEST_2', ID: '4', FROM: '20191223', TO: '99991231' }, ] </code></pre> <p>Any my output will be:</p> <pre><code>[ { NAME: 'TEST_1', ID: '[1, 2]', FROM: '20191223', TO: '99991231' }, { NAME: 'TEST_2', ID: '[3, 4]', FROM: '20191223', TO: '99991231' }, ] </code></pre>
<javascript>
2020-01-24 15:07:10
LQ_CLOSE