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,499,245
using Rstudio, how to import xlsx file larger than 100MB?
<p>How to work with excel file larger than 100 MB, I already imported but it doesn't running the shiny app?</p>
<r><shiny><readxl>
2019-12-27 10:21:27
LQ_CLOSE
59,499,943
"starts with" does not work (python regex)
<p>I have this string:</p> <pre><code>m = 'Film/6702-BRINGING-UP-BABY" da' </code></pre> <p>and the following regax, that tries to find words that start with 'd':</p> <pre><code> movie = re.findall(r'^d.*', m) print(movie) </code></pre> <p>the result is:</p> <pre><code>[] </code></pre> <p>and I can not understand why - there is a match in the string('da'), so why wont it find it? </p> <p>I an working with pycharm, python 3.6</p>
<python><regex>
2019-12-27 11:13:56
LQ_CLOSE
59,501,312
Remove empty string from list (Spark Dataframe)
<p>Current Dataframe</p> <pre><code>+-----------------+--------------------+ |__index_level_0__| Text_obj_col| +-----------------+--------------------+ | 1| [ ,entrepreneurs]| | 2|[eat, , human, poop]| | 3| [Manafort, case]| | 4| [Sunar, Khatris, ]| | 5|[become, arrogant, ]| | 6| [GPS, get, name, ]| | 7|[exactly, reality, ]| +-----------------+--------------------+ </code></pre> <p>I want that empty string from the list removed. This is test data actual data is pretty big, how can I do this in pyspark?</p>
<apache-spark><pyspark>
2019-12-27 13:12:03
LQ_CLOSE
59,502,524
Python is not recognized as internal or external command
<p>even though i have added the path variable i am unable to run the command </p> <p>cmd <a href="https://i.stack.imgur.com/lfi7U.png" rel="nofollow noreferrer">1</a></p> <p>path variable <a href="https://i.stack.imgur.com/daf87.png" rel="nofollow noreferrer">2</a></p>
<python><cmd>
2019-12-27 15:01:17
LQ_CLOSE
59,503,468
Prevent bootstrap form to submut with "Enter"
I can not prevent the form to submit if the user press `ENTER` on an input. I found [that way](https://stackoverflow.com/questions/895171/prevent-users-from-submitting-a-form-by-hitting-enter) but I have some taginputs that need to trigger the `ENTER` key to allow free values. Here is a snippet with the code. **Q: How can I prevent the `ENTER` key to submit my form without broke the taginputs ?** **Q+ : can someone explain me why `$event.keyCode == 13` in my `preventSubmitOnKey` function, whereas it is `undefined` in my `submitForm` function ?** Thanks a lot in advance! <!-- begin snippet: js hide: true console: true babel: false --> <!-- language: lang-js --> $(document).ready(function() { // I can not use that //$('#myForm').on('keydown', preventSubmitOnKey); $('#myForm').on('submit', submitForm); }); function preventSubmitOnKey($event) { console.log('key pressed!', $event.keyCode); // show 13 on 'ENTER' if ($event.keyCode == 13) { $event.preventDefault(); } } function submitForm($event) { let invalidForm = false; $event.preventDefault(); // Don't refresh the page console.log('key', $event.charCode, $event.keyCode); // show 'undefined' .. let key = $event.charCode || $event.keyCode || 0; if (key == 13) { $event.stopPropagation(); return; } const $form = $(this); $form.addClass('was-validated'); if (!this.checkValidity()) { $event.stopPropagation(); return; } // some other process... const data = { client: $form.find('#clientList').val(), firstname: $form.find('#contactFirstname').val(), lastname: $form.find('#contactLastname').val(), } console.log('Submitting', data); // call my own API } <!-- language: lang-css --> /** * up/down arrow devant les collapse */ [data-toggle="collapse"] .fas:before { content: "\f139"; margin-right: 5px; } [data-toggle="collapse"].collapsed .fas:before { content: "\f13a"; } /** * Override Bootstrap CSS : ".btn" et "button" * -> text-align: center; */ legend>[data-toggle="collapse"] { text-align: left; width: 100%; } <!-- language: lang-html --> <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-1/css/all.min.css" integrity="sha256-4w9DunooKSr3MFXHXWyFER38WmPdm361bQS/2KUWZbU=" crossorigin="anonymous" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.bundle.min.js" integrity="sha384-6khuMg9gaYr5AxOqhkVIODVIvm9ynTT5J4V1cfthmT+emCG6yVmEZsRHdxlotUnm" crossorigin="anonymous"></script> <form id="myForm" novalidate="novalidate"> <fieldsed class="contactInfo"> <legend> <button class="btn actilan-test" type="button" data-toggle="collapse" data-target="#contactCollapse" aria-expanded="true" aria-controls="contactCollapse"><i class="fas" aria-hidden="true"></i>Contact</button> </legend> <div class="collapse show" id="contactCollapse" data-parent="#myForm"> <div class="input-group input-group-sm mb-1"> <div class="input-group-prepend"><span class="input-group-text" id="clientListLabel">Client</span></div> <select class="custom-select" id="clientList" name="client" aria-describedby="clientListLabel"> <option value="1">One</option> <option value="2" selected="selected">Two</option> </select> <div class="input-group-append"> <button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" id="dropdownMenuButton">Mode</button> <div class="dropdown-menu" aria-labelledby="dropdownMenuButton"> <button class="dropdown-item" type="button" id="btnAuto" disabled="disabled">Auto</button> <button class="dropdown-item" type="button" id="btnManuel">Manuel</button> </div> </div> </div> <div class="input-group input-group-sm mb-1"> <div class="input-group-prepend"><span class="input-group-text" id="contactFullnameLabel">Nom et Prénom</span></div> <input class="form-control" type="text" id="contactFirstname" name="contactFirstname" aria-label="Contact firstname" aria-describedby="contactFullnameLabel" placeholder="Prénom" required="required"> <input class="form-control" type="text" id="contactLastname" name="contactLastname" aria-label="Contact lastname" aria-describedby="contactFullnameLabel" placeholder="Nom" required="required"> <div class="input-group-append"> <button class="btn btn-danger" type="button" id="btnCancelContact"><i class="fas fa-user-minus"></i></button> </div> <div class="invalid-feedback">Ce champ doit contenir une valeur</div> </div> </div> </fieldsed> <button class="btn btn-success mb-3" type="submit" id="btnSubmit" value="Submit!">Envoyer</button> </form> <!-- end snippet -->
<javascript><jquery><forms><form-submit><enter>
2019-12-27 16:28:56
LQ_EDIT
59,504,264
Downcasting a slice of interfaces to a sub-interface slice
<p>I'm trying to get better at using interfaces in Go to describe specific functionality, and using interface composition to write better, more understandable code. I ran into this problem which seems like it would be a common use case of go interfaces, yet I can't seem to figure out the proper syntax to use for this application. Here's some code to help explain what I am trying to do:</p> <pre><code>// Initializable is an interface to an object that can be initialized. type Initializable interface { Initialize() error } // InitializeAll initializes an array of members. func InitializeAll(members []Initializable) error { for _, member := range members { err := member.Initialize() if err != nil { return err } } return nil } // Host is an interface to an object providing a set of handlers for a web host. type Host interface { Initializable Hostname() string RegisterHandlers(router *mux.Router) } // ConfigureHosts configures a set of hosts and initializes them. func ConfigureHosts(hosts []Host) (*mux.Router, error) { err := InitializeAll(hosts) // compiler error here } </code></pre> <p>This is the error: <code>cannot use hosts (type []Host) as type []Initializable in argument InitializeAll</code>.</p> <p>My initial thought was that I was missing some sort of type downcast, which I know works for single interface objects, but had difficulty casting an array. When I tried doing <code>err := InitializeAll(hosts.([]Initializable))</code>, I got the following error: <code>invalid type assertion: hosts.([]Initializable) (non-interface type []Host on left)</code>.</p> <p>I'd appreciate any ideas as it comes to the design of this code example, and perhaps any suggestions as to proper syntax or some refactoring that I could do to solve this problem. Thanks!</p>
<go>
2019-12-27 17:45:40
LQ_CLOSE
59,505,676
How can I call a method from another class with constructors?
<p>I have two classes with a constructor. How can I call a method from one class to another?</p>
<java>
2019-12-27 20:21:06
LQ_CLOSE
59,505,953
Can anyone help me with the below code as it is working fine without flask in local system but not with FLASK?
<p>Code is running fine with local system but I'm getting the following error whenever I try to submit data to my Flask form:</p> <p>Error: Method Not Allowed The method is not allowed for the requested URL.</p> <p>Relevant parts of my code are as follows:</p> <pre><code>pytesseract.pytesseract.tesseract_cmd = 'C:\\Users\\Abhi\\AppData\\Local\\Programs\\Python\\Python37-32\\Lib\\site-packages\\pytesseract\\Tesseract-OCR\\tesseract.exe' #Poppler executable file is mandatory to load PDFTOPPMPATH = r"C:\Users\Abhi\Downloads\poppler-0.68.0_x86\poppler-0.68.0\bin\pdftoppm.exe" PDFFILE = "C:\\Users\\Abhi\\rep.pdf" subprocess.Popen('"%s" -png "%s" out' % (PDFTOPPMPATH, PDFFILE)) app = Flask(__name__) @app.route('/', methods=['POST']) def predict(): im = Image.open("out-2.png") rgb_im = im.convert('RGB') rgb_im.save('m.jpg') im = Image.open("m.jpg") text1 = pytesseract.image_to_string(im, lang = 'eng') with open("report.txt","w") as f: f.write(text1) para = ["Emissivity","Refl. temp.","Distance","Relative humidity","Atmospheric temperature","Transmission"] f=open('report.txt') lines=f.readlines() #lines.remove("\n") for i in range(0,len(lines)): if "jpg" in lines[i]: end1 = i-1 if "MEASUREMENTS (°C)" in lines[i]: start1 = i+1 if "Report" in lines[i]: end2 = i-1 if "Transmission" in lines[i]: trans = i+1 #print(str(start1) + " " + str(end1)+" " +str(trans) + " " + str(end2)) for i in range(start1-1,trans): return str(lines[i]) if __name__ == '__main__': #p = int(os.getenv('PORT', 5000)) #app.run(debug = True, port=p, host='0.0.0.0') #app.run() app.run(debug=True, use_reloader=False) </code></pre>
<flask><jupyter-notebook><python-tesseract>
2019-12-27 20:56:59
LQ_CLOSE
59,505,966
Confirmation Email for publishing pdf
<p>I have a question about developing a webapi. I want to send someone an email with an confirmation Link and If he clicks on it he should be redirected to a thanks page and get a second email with a pdf. </p> <p>Unfortunatly I have no idea how to create the confirmation link. I can use every web language as php and node js.</p>
<php><node.js><html-email><email-confirmation><webapi>
2019-12-27 20:57:56
LQ_CLOSE
59,508,036
Cannot invoke equals(string) on the primitive type char
<p>In the if statement in my User class it says cannot invoke equals(String) on the primitive type char what is the problem?</p> <p><a href="https://i.stack.imgur.com/R4lDe.png" rel="nofollow noreferrer">My rock paper scissors code</a></p>
<java><if-statement><project>
2019-12-28 04:10:47
LQ_CLOSE
59,508,277
Hi everyone, when i make the math of any number * 1% it gives me a long number, i wanted to cut it down to 2 decimal C# WPF conversion
<p>My question here is how can i convert the result of the math into a two decimal result?{ private void BtnAjoutInteret_Click(object sender, RoutedEventArgs e)//When i press the ok button</p> <pre><code> try { for (int i = 1; i &lt; clients.ListesClients.Count; i++)// For all the bank clients add //one percent to the sum why is it so hard to post a question on stackoverflow { double interet = .01; clients.ListesClients[i].Balance = (clients.ListesClients[i].Balance * interet) + (clients.ListesClients[i].Balance); clients.AjustementCompte(clients.ListesClients[0]);//once the one percent is added use the methode to add the new balance to the txtfile. } MessageBox.Show("Transaction accepter"); LviewListeClients.Items.Refresh(); } catch (Exception) { MessageBox.Show("erreur 5 "); return; } } public void AjustementCompte(Client Nouvelle)//This is the method to add the new balance { //listeClients.Add(NouvelleTransaction); StreamWriter Writer = new StreamWriter(filename); foreach (Client client in ListesClients) { Writer.WriteLine($"{client.ID};{client.TypeDeCompte};{client.Balance}"); } Writer.Close(); } } </code></pre>
<c#><wpf>
2019-12-28 05:03:47
LQ_CLOSE
59,509,247
Why is my Javascript Switch Statement is not working?
<p>So, firstly i wrote the input prompt to achieve data ( don't know what kind of data is this? Number? ) then i calculate it with function and return it. I intend to categorize the calculation result and return it to user as an comment and status. But it won't work. Is it because the variable i used isn't right and the data type is false? Help me please.</p> <p>Here is my code :</p> <pre><code>userName = prompt("Please enter your name: "); alert("Welcome to BMI Calculator, " + userName + "!"); bodyHeight = prompt("Please enter your body height in centimeter :"); bodyHeight = bodyHeight / 100; alert("Your height is : " + bodyHeight +" meter"); bodyWeight = prompt("Please enter your body weight in kilogram :"); alert("Your body weight is : " + bodyWeight + " kilogram"); confirm("Do you wish to calculate your ideal weight?"); function idealWeight(){ return bodyWeight / (bodyHeight * bodyHeight); } var idealWeight = idealWeight(); idealWeight = idealWeight.toFixed(2); idealWeight = Number(idealWeight); switch (idealWeight){ case idealWeight &lt; 18.5: alert("You are too skinny. Eat a lot man!"); break; case 18.5 &lt; idealWeight &lt; 25: alert("You have a normal weight. Keep in the pace"); break; case 25 &lt; idealWeight &lt; 30: alert("You are overweight. Lower it a little!"); break; case idealWeight &gt; 30: alert("You are totally obessed. I know a gym near here"); break; } alert("Your ideal weight is: " + idealWeight); let key = userName + " BMI Value"; localStorage.setItem(key,idealWeight); </code></pre>
<javascript>
2019-12-28 08:21:47
LQ_CLOSE
59,509,602
JSON to C# class issue
<p>I'm new to JSON and I'm trying to convert JSON data to C# class, but I always get errors when converting to C# entity class. Can someone tell me how to properly convert the following JSON data to C# class? Thank you very much! orz</p> <pre><code>[ { "place_id":121943890, "licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright", "osm_type":"way", "osm_id":195289214, "boundingbox":["28.0650511","28.0769594","112.9936342","113.0111091"], "lat":"28.07081905", "lon":"113.002623874342", "display_name":"Changsha", "class":"amenity", "type":"university", "importance":0.11100000000000002, "icon":"https://nominatim.openstreetmap.org/images/mapicons/education_university.p.20.png", "geojson":{ "type":"Polygon", "coordinates":[ [ [112.9936342,28.0740059], [112.9957532,28.0699078], [112.9968442,28.0691153], [112.9970274,28.0689822], [113.0003451,28.0669209], [113.0012613,28.0650511], [113.0111091,28.0676428], [113.0096377,28.0717303], [113.0084561,28.0746411], [113.0074304,28.0769594], [113.0015116,28.0756923], [113.0011744,28.0756201], [112.9936342,28.0740059] ] ] } } ] </code></pre>
<c#><json>
2019-12-28 09:23:29
LQ_CLOSE
59,509,863
In ES6, export let m = 1; and m =1 expoort m ; why the former is true, the latter is false?
``` export let m = 1; ``` ``` let m =1; expoort m; ``` I know the export of ES6 Module need to be an interface. The former export an interface,and the latter export number 1. I want to know why the former export an interface? I guess priority of operations, but I am not sure. Thanks.
<javascript>
2019-12-28 10:02:54
LQ_EDIT
59,510,005
How to link one JS file to two HTML files?
<p>I have two HTML files, both are linked to one JS file. The first HTML file can be manipulated by the js but the other way around for the second one. Does this mean I need separate JS files for the two? </p>
<javascript><html>
2019-12-28 10:23:36
LQ_CLOSE
59,510,084
How to display an element on hovering a different element
<p>I know this question has been asked many times but I could not find the answer based on my requirement. The screenshot here is from flat icon. So when i hover an icon two icons appear which I can click. How to achieve that?<a href="https://i.stack.imgur.com/XquMH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XquMH.jpg" alt="Screenshot of the example"></a></p>
<html><css>
2019-12-28 10:33:38
LQ_CLOSE
59,510,225
create a sitting arrangement using javascript(node.js)
<p>I have given a row of seats. Each seat is either occupied by a woman (denoted by xx) or a man (denoted by xy).</p> <p>The objective is to find the minimum number of seat exchanges required such that the men and women are seated alternately.</p> <p><strong>Input Format</strong></p> <p>The first line of input consists of an integer <code>t</code> denoting the number of test cases. <code>t</code> test cases follow. Each test case consists of two lines. The first line of each test case consists of an integer n denoting the number of seats. Second line consists of n space separated tokens, each token denoting the occupant of that particular seat.</p> <p><strong>Output Format</strong></p> <p>For each test case, print the number of seat exchanges required. If an alternate seating is impossible, print -1.</p> <p><strong>Sample Input</strong></p> <pre><code>5 3 xx xx xx 2 xx xy 4 xx xx xy xy 8 xx xx xy xy xy xx xx xy 7 xx xy xx xy xx xy xy </code></pre> <p><strong>Sample Output</strong></p> <pre><code>-1 0 1 2 3 </code></pre> <p>Constraints 1 &lt;= t &lt;= 1000</p> <p>1 &lt;= n &lt;= 10000</p> <p><strong>Explanation</strong> For xx xx xy xy, one can exchange seat 1 with seat 4 giving xy xx xy xx giving an alternate seating arrangement.</p>
<javascript>
2019-12-28 10:51:54
LQ_CLOSE
59,510,556
Why is my javascript calculator not working?
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Calculator</title> <style> input { height:100px; width:150px; border-radius:10px; border-style:none; background-color:black; color:white; } .abcde /*for display purposes*/ { background-color:blue; height:100px; width:608px; border-radius: 10px; color:white; font-size:100px; } </style> <h1>Basic calculator</h1> </head> <body> <script> // function clearfunc() // { // document.getElementById("abcd").innerHTML="0"; // } function show(id) { if(id=="zero") document.getElementById("abcd").innerHTML="0"; else if(id=="one") document.getElementById("abcd").innerHTML="1"; else if(id=="two") document.getElementById("abcd").innerHTML="2"; else if(id=="three") document.getElementById("abcd").innerHTML="3"; else if(id=="four") document.getElementById("abcd").innerHTML="4"; else if(id=="five") document.getElementById("abcd").innerHTML="5"; else if(id=="six") document.getElementById("abcd").innerHTML="6"; else if(id=="seven") document.getElementById("abcd").innerHTML="7"; else if(id=="eight") document.getElementById("abcd").innerHTML="8"; else if(id=="nine") document.getElementById("abcd").innerHTML="9"; else if(id=="clear") document.getElementById("abcd").innerHTML=""; } function afterPlus(id) { var whichOperator=""; if(id=="equal") { b=Number(document.getElementById("abcd").innerHTML); switch(whichOperator) { case "plus": document.getElementById("abcd").innerHTML=(a+b); break; case "minus": document.getElementById("abcd").innerHTML=(a-b); break; case "mul": document.getElementById("abcd").innerHTML=(a*b); break; case "divide": document.getElementById("abcd").innerHTML=(a/b); break; default: document.getElementById("ans").innerHTML=b; } } else { whichOperator=id; //eg i need + - * and / to be got a=Number(document.getElementById("abcd").innerHTML); } } </script> <div class="abcde" id="abcd"> </div> <input type="button" value="0" id="zero" onclick="return show(this.id)"> <input type="button" value="1" id="one" onclick="return show(this.id)"> <input type="button" value="2" id="two" onclick="return show(this.id)"> <input type="button" value="+" id="plus" onclick="return afterPlus(this.id)"> <br> <input type="button" value="3" id="three" onclick="return show(this.id)"> <input type="button" value="4" id="four" onclick="return show(this.id)"> <input type="button" value="5" id="five" onclick="return show(this.id)"> <input type="button" value="-" id="minus" onclick="return afterPlus(this.id)"> <br> <input type="button" value="6" id="six" onclick="return show(this.id)"> <input type="button" value="7" id="seven" onclick="return show(this.id)"> <input type="button" value="8" id="eight" onclick="return show(this.id)"> <input type="button" value="*" id="mul" onclick="return afterPlus(this.id)"> <br> <input type="button" value="9" id="nine" onclick="return show(this.id)"> <input type="button" value="C" id="clear" onclick="return show(this.id)"> <input type="button" value="=" id="equal" onclick="return afterPlus(this.id)"> <input type="button" value="/" id="divide" onclick="return afterPlus(this.id)"> </body> </html> i think i have done everything fine. expected output-: i press 1. 1 is displayed through function show(id) now 1 is in paragraph id="abcd" then user presses + it's id="plus" is passed to function afterplus(id). i check if id==equals or not. if the id!=equal, then store a=previous value as a number as well as the operator as a string. else if id==equal then, i need to save b as the past number. then switch case will run, the operator id =(+ * / -) will be used in switch case and the proper calculation will be done.
<javascript><html>
2019-12-28 11:42:52
LQ_EDIT
59,510,604
opening directory without know its name : Linux shell
Im writting a script in which user inputs the directory in which he wants to find a specific string inside .txt files, but I dont know how to open every directorys inside the given directory withot knowing their names. For example this is a directory which user specifies: Project/ AX/include/ ax.txt bx.txt AX/src/ ax.txt bx.txt BY/include/ ay.txt by.txt BY/src/ ay.txt by.txt
<linux><bash><shell><directory-listing>
2019-12-28 11:48:33
LQ_EDIT
59,513,562
Why does Python return this?
<p>If <code>my_string = "This is MY string!"</code>, why does <code>print(my_string[0:7:5])</code> return "Ti" and not "T i" because there is a space between 'This' and 'is'?</p>
<python><python-3.x>
2019-12-28 18:08:22
LQ_CLOSE
59,514,158
Can i use Meteor.js WITHOUT any React and Angular and Blaze? I want use my own library
<p>Can i use Meteor.js <strong>WITHOUT</strong> any React and Angular and Blaze? I want use my own library</p>
<angular><reactjs><user-interface><blaze>
2019-12-28 19:23:47
LQ_CLOSE
59,514,307
How to make javascript execute a php file
<p>In where do i add when the timer gets to 0 it exectues a php file for example joined.php and how would i make it so that it also counts days</p> <pre><code> &lt;script&gt; var myreset = [21,37,00]; // at what time to reset - 19:40:00 var mycountdown = startCountdown(); function startCountdown(){ var enddate = calculateEndDate(); return setInterval(function(){tickTock(calculateStartDate(),enddate)}, 1000); } function calculateStartDate(){ //this needs to be edited if using the server time return new Date(); } function calculateEndDate(){ var enddate = new Date(); enddate.setHours(myreset[0]); enddate.setMinutes(myreset[1]); enddate.setSeconds(myreset[2]); return enddate; } function tickTock(startdate, enddate){ var diff = enddate.getTime() - startdate.getTime(); d = diff &gt;= 0 ? diff : diff + 24*3600*1000; var h = Math.floor(d / 3600 / 1000); var m = Math.floor(d / 60 / 1000) - 60*h; var s = Math.floor(d / 1000) - 3600*h - 60*m; printCountdown(h,m,s); } function pluralize(word,count){ return (count &gt; 1) ? word+'s ' : word+' '; } function printCountdown(h,m,s){ var t = h + pluralize(' hour',h)+ m+pluralize(' minute',m)+ s + pluralize(' and second',s); $('#mycountdown').html(t); } &lt;/script&gt; </code></pre>
<javascript><php>
2019-12-28 19:43:12
LQ_CLOSE
59,515,884
What goes in to the parentheses of studentList.addStudent()?
<p>So I have a <strong>GUI</strong> class with the <code>addStudent()</code> method that is meant to call the method: <code>addStudent(Student aNewStudentObj)</code> of the <strong>Manager</strong> class to then create an object of the <strong>Student</strong> class using the information inputted by the user. This object is then meant to be stored in the Linked List that is in the <strong>Manager</strong> class. </p> <p>My question is, what goes in the parentheses of the <code>addStudent()</code> method that is located in the <strong>GUI</strong> class if anything is meant to go in there? </p> <p>I have literally tried everything that I could think of and now I am at the point of losing my hair so all help possible would very much be appreciated. Please. </p> <p>I believe all required code is below but if you need the full <strong>GUI</strong> class, let me know. I also have a <strong>Module</strong> class but I don't think that will be necessary for this question.</p> <p><code>addStudent()</code> method from <strong>GUI</strong> class below</p> <pre><code>public void addStudent() { Manager studentList = new Manager(); studentList.addStudent(); &lt;----------------- What goes in those brackets? } </code></pre> <p><strong>Student</strong> class below</p> <pre><code>public class Student { private String firstName; private String surname; private String email; private int yearOfStudy; private int studentId; private Queue&lt;Module&gt; mods = new LinkedList&lt;&gt;(); public String getFirstName() { return firstName; } public String getSurname() { return surname; } public String getEmail() { return email; } public int getYearOfStudy() { return yearOfStudy; } public int getStudentId() { return studentId; } public String print() { return "Student ID: " + studentId + "\n" + "First Name: " + firstName + "\n" + "Surname: " + surname + "\n" + "Email: " + email + "\n" + "Year of Study: " + yearOfStudy; } public void addModule(int id, String mCode, int mMark) { if (mods.size() == 4) { mods.remove(); } Module module = new Module(); mods.add(module); } //this method returns the module list of this student sorted by marks public String getModulesSortedByMarks(int id) { Object[] sortedMods; sortedMods = mods.toArray(); Arrays.sort(sortedMods); String sortedModulesList = ""; for (int i = 0; i &lt; sortedMods.length; i++) { sortedModulesList = "\n" + ((Module) sortedMods[i]).print(); } return sortedModulesList; } } </code></pre> <p><strong>Manager</strong> class below</p> <pre><code>public class Manager { List&lt;Student&gt; studs = new LinkedList&lt;&gt;(); public void addStudent(Student aNewStudentObj) { studs.add(aNewStudentObj); } public void displayStudent(int studentId) { System.out.println(studs.get(studentId)); } public void displayMarks(int studentId) { Student marks = new Student(); marks.getModulesSortedByMarks(studentId); } public void deleteStudent(int studentId) { studs.remove(studentId); } public void displayAll() { for (Student student : studs) { student.print(); System.out.println(); } } } </code></pre>
<java><linked-list>
2019-12-28 23:55:50
LQ_CLOSE
59,515,929
Create Shapes on a website given an input in Javascript
<p>Suppose I have an array in Javascript with integer values: <code>[10, 20, 30, 40, 50]</code>. My goal is to have rectangles side by side that have a width of 10 pixels and a height of the pixels specified in the array. In this case, I would have a rectangle 10 pixels by 10 pixels. Right of the 10x10 rectangle is a rectangle 10x20 and then 10x30 and so on and so forth. What would I code in the HTML, CSS, and JS file to make this. Right now, the only idea I can think of is an HTML table with shapes in it. The picture below is an example of the output I would like:</p> <p><a href="https://i.stack.imgur.com/p2iLD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p2iLD.png" alt="enter image description here"></a></p>
<javascript><html><css>
2019-12-29 00:08:16
LQ_CLOSE
59,516,654
Some array elements do not engage in newly chunked, different string length element array
I am trying to convert a string array into new string array, changing the word count of each elements by appending sibling items accordingly. But the problem I am having is some part of previous array is not converting as required. **Here is my code so far :** ``` $text_array = ['He needs to cultivate in order', 'to be at the fourth level of the', 'Martial Body Stage. Does he have inner energy?"', 'Everyone jeered, laughed, and taunted.', 'Qin Yun turned deaf ear to their taunts.', 'His eyes were filled with sincerity as he', 'looked at Yang Shiyue and said, "Teacher,', 'I only formed my elemental energy this morning.', 'I still not familiar with the control of', 'my elemental energy and inner energy."', 'After the empress heard the jeers from the', 'crowd, she let out a sigh of relief and', 'sneered, "This is only a little bit of', 'inner Qi that you forced out.', 'You have not yet stepped', 'into the fourth level', 'of the Martial Body realm and have no', 'chance of breaking through. embarrass yourself!']; $last_converted_index = 0; $new_string_array = []; $single_valid_length_string = ''; foreach (array_slice($text_array, $last_converted_index) as $item) { if (str_word_count($single_valid_length_string . $item) < 30) { $single_valid_length_string .= $item . ' '; $last_converted_index++; } else { $new_string_array[] = $single_valid_length_string."<br><br>"; $single_valid_length_string = ''; } } echo implode($new_string_array); ``` Any help would be appreciable.
<php><arrays><chunks>
2019-12-29 03:29:00
LQ_EDIT
59,521,129
Rolling Regression OLS Statsmodels
https://www.statsmodels.org/dev/examples/notebooks/generated/rolling_ls.html So running the from statsmodels.regression.rolling import RollingOLS command but says module ModuleNotFoundError: No module named 'statsmodels.regression.rolling' anyone else having this problem?
<python><statsmodels>
2019-12-29 16:20:23
LQ_EDIT
59,521,936
i have a list index of range eror
This code work for the first line in the document but fail in the second trial , and i don't know why . i tied to see in similar question but i don't found solution ``` carac=":" fichier = open("test", "r") for i in range(2): time.sleep(0.5) chaine = fichier.readline().split(carac) print(chaine[0]) driver = webdriver.Chrome(r'C:\Users\bh\Downloads\chromedriver') driver.get('https://www.twitter.com/login') username_box = driver.find_element_by_class_name('js-username-field') username_box.send_keys(chaine[0]) password_box = driver.find_element_by_class_name('js-password-field') password_box.send_keys(chaine[1]) ``` i have this error ``` Traceback (most recent call last): File "C:/Users/Hicham/PycharmProjects/test/twitter-retweet.py", line 199, in <module> password_box.send_keys(chaine[1]) IndexError: list index out of range ```
<python><selenium>
2019-12-29 17:59:46
LQ_EDIT
59,527,370
getting java.lang.IllegalArgumentException: width and height must be > 0 error while initializing Mat in android
I am trying to initialize Mat and this is my code Mat imgRgba = new Mat(); final Bitmap bitmap = Bitmap.createBitmap(imgRgba.width(), imgRgba.height(), Bitmap.Config.RGB_565); Utils.matToBitmap(imgRgba, bitmap); I have tried this too Bitmap.createBitmap(imgRgba.cols(), imgRgba.rows(), Bitmap.Config.RGB_565); but when I am going to run my app I am getting crash and exception is this Stack trace: java.lang.IllegalArgumentException: width and height must be > 0 at android.graphics.Bitmap.createBitmap(Bitmap.java:969) at android.graphics.Bitmap.createBitmap(Bitmap.java:948) at android.graphics.Bitmap.createBitmap(Bitmap.java:915) at com.jmr.agency.banking.ui.facerecognition.FRAddPersonPreviewActivity.onCameraFrame(FRAddPersonPreviewActivity.java:156)
<android><opencv><mat>
2019-12-30 07:47:29
LQ_EDIT
59,528,014
Getting an error in a program to encrypt text using Caesar Cipher (Python)
Caesar Cipher is a simple way of encryption that shifts a character a number of places in front of it. For example, ABC with a Rotation of 1 would be BCD. In this program, however, the list of all characters include special characters in a random order, i.e. ```1234567890-=qwertyuiopasdfghjklzxcvbnm,./~!@#$%^&*()_+|\\{}[]:;\'"QWERTYUIOPASDFGHJKLZXCVBNM``` Thus, it is more of a custom cipher but following the principle of Caesar Cipher, the code can be tested by using the 2 functions I have made (encode() and decode()) on the same text, and if the output given is the same as the input, it means that it works. I get an output for some rotation numbers, but some numbers, like 70, give me an error. The code I have written is: ``` characters = '`1234567890-=qwertyuiopasdfghjklzxcvbnm,./~!@#$%^&*()_+|\\{}[]:;\'"QWERTYUIOPASDFGHJKLZXCVBNM' # All characters in a string, no specific order key_raw = 70 # One of the keys that gives me an error. def encode(text, key): # Function that takes in two inputs: Text and key, which is the number of characters to shift forward output, text = '', str(text) limit = len(characters) while key > limit: key -= limit # This is my attempt to simplify the key for i in text: if i in characters: output += characters[characters.index(i)+key] # If i is in characters, the rotated character is concatenated to the output else: output += i # Otherwise, it directly adds the text return output def decode(text, key): # Same thing, except key is subtracted from the index of i in key, as to decrypt it output, text = '', str(text) limit = len(characters) while key > limit: key -= limit for i in text: if i in characters: output += characters[characters.index(i)-key] else: output += i return output print(encode('Why do I get String_Index_Out_Of_Range?', key_raw)) ``` Please let me know where I made an error and add possible improvements, thank you!
<python><encryption>
2019-12-30 08:51:44
LQ_EDIT
59,532,664
failed to deploy Travis CI `Python`
I got the below error when tried to run the build in `travis`. I'm new to travis and following some websites to create the builds for `Python` project. ```=========================== 2 passed in 0.02 seconds =========================== The command "coverage run -m pytest test.py" exited with 0. 3.23s$ coverage html -d docs/report/coverage/ The command "coverage html -d docs/report/coverage/" exited with 0. after_success 0.17s$ coveralls dpl_0 1.25s$ rvm $(travis_internal_ruby) --fuzzy do ruby -S gem install dpl invalid option "--token=" failed to deploy ``` Any insights will be helpful and i saw `secure` keyword in `.travis.yml` page and may i know what is it and it's use. How to generate the `secure` key in windows?
<python><python-3.x><travis-ci>
2019-12-30 14:49:15
LQ_EDIT
59,534,999
How to tell PHP to use SameSite=None for cross-site cookies?
<p>According to the article here <a href="https://php.watch/articles/PHP-Samesite-cookies" rel="noreferrer">https://php.watch/articles/PHP-Samesite-cookies</a> and PHP documenation at <a href="https://www.php.net/manual/en/session.security.ini.php" rel="noreferrer">https://www.php.net/manual/en/session.security.ini.php</a>, There are only 2 possible config options for this new feature, added in PHP 7.3:</p> <ol> <li>session.cookie_samesite=Lax</li> <li>session.cookie_samesite=Strict</li> </ol> <p>Yet, according to the Chrome console, this needs to be set to "None":</p> <blockquote> <p>A cookie associated with a cross-site resource at URL was set without the <code>SameSite</code> attribute. It has been blocked, as Chrome now only delivers cookies with cross-site requests if they are set with <code>SameSite=None</code> and <code>Secure</code>. You can review cookies in developer tools under Application>Storage>Cookies and see more details at URL and URL.</p> </blockquote> <p>Because of this, I can no longer set cross-site cookies. What is the workaround?</p>
<php><session><cookies><session-cookies><php-7.3>
2019-12-30 18:05:24
HQ
59,535,331
How Display 3 Posts in one Loop ??? Laravel
<pre><code> &lt;?php $i=1; ?&gt; &lt;?php $dayes = DB::table('days')-&gt;where('Doc',$item-&gt;id)-&gt;get(); ?&gt; @foreach($dayes as $DAY) &lt;?php $timess = DB::table('times')-&gt;where('days_id',$DAY-&gt;id)-&gt;get(); ?&gt; @foreach($timess as $timer) &lt;div class="table-times"&gt; &lt;/div&gt; &lt;?php $i++; ?&gt; &lt;/div&gt; @endforeach @endforeach </code></pre> <p>i need to display class table-times 3 in one loop </p>
<laravel>
2019-12-30 18:31:48
LQ_CLOSE
59,536,464
Can anyone help me with my SQL statement?
I assigned the code below to an commandbutton. When i execute it, it returns an error(3061) CurrentDb.Execute "INSERT INTO tblVerlof(Aanmaakdatum, VerlofDatum, VerlofReden, Aantal, me.VerlofPoule, Notitie, Status)VALUES(now(), me.startdatum, 2, me.txturen, me.verlofpoule, me.txttitel, 2)" Is someone able to assist me in this endevor
<sql><vba><ms-access>
2019-12-30 20:24:19
LQ_EDIT
59,536,489
AWS Subnet CIDR in confliction
<p>What's IP does not conflict with 172.31.0.0/16. I'm not a networking guy and would like to get this resolved. I'm getting this error. CIDR Address overlaps with existing Subnet CIDR: 172.31.0.0/20</p>
<amazon-web-services><subnet>
2019-12-30 20:27:04
LQ_CLOSE
59,539,391
Is there any library to convert seconds to days/hours/miniutes in java?
<p>I just want to convert seconds to proper time format.</p> <p>e.g. if it is 30 seconds, then it is just displayed as 30 seconds. if it is 80 seconds, it will be displayed as 1 minute 20 seconds It is similar when it is larger than one hour and one day.</p> <p>Of course it is simple to implement by myself, just just wonder whether there's any existed library I can leverage. Thanks</p>
<java><time>
2019-12-31 03:58:13
LQ_CLOSE
59,540,607
Store \ in java string variable(Special Character)
<h1>I want to store \ in a string variable #</h1> <p>String var= "\" ;</p> <pre><code>public class Main { public static void main(String[] args) { String var="\" System.out.println(var); } } </code></pre>
<java>
2019-12-31 06:47:06
LQ_CLOSE
59,542,248
Problem with Python Task that contains variable count
<p>CAN YOU HELP ME WITH THIS PYTHON TASK====1.based on the variable: str1="one two three twenty one thirty one fifty one" and the help of one or more string management methods, you are asked to check if it contains more than twice the string 'one'. If yes, then the program should say "More than Two". IF not , then the program should say "There are fewer than two" </p>
<python>
2019-12-31 09:38:19
LQ_CLOSE
59,543,150
Can I configure my browser to let my web app receive a right-click instead of the browser itself?
<p>I want to be able to use a right-click in a single page (react) app. Every time I right click, the browser handles it instead of letting my app handle it. This seems to happen with Chrome and Safari. Is there a way to tell either browser to pass the right-click to the web app?</p>
<reactjs><browser><right-click>
2019-12-31 10:56:42
LQ_CLOSE
59,543,209
Sorting Multidimensional slices in golang
Wanted to sort a nested slice (asc to desc) based on int values ,however the slice remains unaffected. Below is the short snippet of what I was trying. ``` type Rooms struct { type string total string } CombinedRooms := make([][]Rooms) // sort by price for i, _ := range CombinedRooms { sort.Slice(CombinedRooms[i], func(j, k int) bool { netRateJ, _ := strconv.Atoi(CombinedRooms[i][j].Total) netRateK, _ := strconv.Atoi(CombinedRooms[i][k].Total) return netRateJ < netRateK }) } ``` The Slice CombinedRooms remains unaffected even after the sorting func.
<sorting><go>
2019-12-31 11:02:07
LQ_EDIT
59,543,371
wpf binding not refreshing if equals and gethashcode (NO IPROPERTYCHANGED NEEDED!)
<p>My WPF binding is not working because my viewmodel has overwritten Equals and GetHashCode. If i comment it out (region Object-Stuff), everything works fine.</p> <p>Further info about my reasons: All my viewmodels have an Id. I load data with Id=1 and set the datacontext. Later i reload the data (same id, but other properties can have changed), i reset the datacontext and nothing happens (DataContextChanged-event is raised). And for everybody who want to mark this as duplicate... No, i did not forget the INotifyPropertyChanged-Interface. The binding is refreshed when the datacontext is set, this has nothing to do with INotifyPropertyChanged.</p> <p>Has anybody an idea how to refresh the datacontext? (by the way, set it to null and then to my new viewmodel is not an solution because the regulation is that a views datacontext is never null). Here is some small demo code to reproduce this. Window.xaml:</p> <pre><code>&lt;Grid&gt; &lt;Button Content="Button1" HorizontalAlignment="Left" Margin="565,84,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/&gt; &lt;TextBox HorizontalAlignment="Left" Height="23" Margin="206,173,0,0" TextWrapping="Wrap" Text="{Binding Text}" VerticalAlignment="Top" Width="120"/&gt; &lt;Button Content="Button2" HorizontalAlignment="Left" Margin="565,138,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_1"/&gt; &lt;Button Content="Button3" HorizontalAlignment="Left" Margin="565,191,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_2"/&gt; &lt;/Grid&gt; </code></pre> <p>Window.xaml.cs:</p> <pre><code> private void Button_Click(object sender, RoutedEventArgs e) { ViewModel vm = new ViewModel { Id = 1, Text = "Button1" }; DataContext = vm; } private void Button_Click_1(object sender, RoutedEventArgs e) { ViewModel vm = new ViewModel { Id = 1, Text = "Button2" }; DataContext = vm; } private void Button_Click_2(object sender, RoutedEventArgs e) { ViewModel vm = new ViewModel { Id = 1, Text = "Button3" }; DataContext = vm; } </code></pre> <p>ViewModel:</p> <pre><code>class ViewModel { public int Id { get; set; } public string Text { get; set; } #region Object-Stuff public override int GetHashCode() { return Id.GetHashCode(); } public override bool Equals(object obj) { ViewModel other = obj as ViewModel; if ((object)other == null) { return false; } return Id == other.Id; } public virtual bool Equals(ViewModel other) { if ((object)other == null) { return false; } return Id == other.Id; } #endregion } </code></pre>
<wpf><binding><equals><gethashcode>
2019-12-31 11:17:07
LQ_CLOSE
59,543,782
Increment State Count in Mapping Function
Goal is to increment the count in the mapping function while keeping track of the new value in state. "charlie" isn't updating, even on re-renders of the component, and subsequent runs of mapData. Meanwhile, every re-render/run of mapData continues to print the updated count outside "charlie". My code looks roughly like this: const [data, setData] = useState([]) const [count, setCount] = useState(0) const mapData = (apiData) => { const dataMapped = apiData.map((pic, index) => { return ( setCount(prevState => (prevState+1)) <div className="charlie">{count}</div> ) }) setData(prevState => ([...prevState, ...dataMapped])) } return { <div> <div>{count}</div> {/* shows updated count every render */} <div>{data}</div> {/* shows 0 every render*/} </div> }
<javascript><reactjs><react-hooks>
2019-12-31 11:52:43
LQ_EDIT
59,547,011
Why is Hackerrank showing segmentation error for the following C code?
<p><strong>Hackerrank Problem Description:</strong></p> <p>You are given the pointer to the head node of a linked list and an integer to add to the list. Create a new node with the given integer. Insert this node at the tail of the linked list and return the head node of the linked list formed after inserting this new node. The given head pointer may be null, meaning that the initial list is empty.</p> <p><strong>Input Format</strong></p> <p>You have to complete the SinglyLinkedListNode insertAtTail(SinglyLinkedListNode head, int data) method. It takes two arguments: the head of the linked list and the integer to insert at tail. You should not read any input from the stdin/console.</p> <p>The input is handled by code editor and is as follows: The first line contains an integer , denoting the elements of the linked list. The next lines contain an integer each, denoting the element that needs to be inserted at tail.</p> <p><strong>Constraints</strong></p> <p><strong>Output Format</strong></p> <p>Insert the new node at the tail and just return the head of the updated linked list. Do not print anything to stdout/console.</p> <p>The output is handled by code in the editor and is as follows: Print the elements of the linked list from head to tail, each in a new line.</p> <p><strong>Sample Input</strong></p> <p>5 141 302 164 530 474</p> <p><strong>Sample Output</strong></p> <p>141 302 164 530 474</p> <p><strong>Explanation</strong></p> <p>First, the linked list is NULL. </p> <p>After inserting 141, the list is 141 -> NULL.</p> <p>After inserting 302, the list is 141 -> 302 -> NULL.</p> <p>After inserting 164, the list is 141 -> 302 -> 164 -> NULL.</p> <p>After inserting 530, the list is 141 -> 302 -> 164 -> 530 -> NULL. </p> <p>After inserting 474, the list is 141 -> 302 -> 164 -> 530 -> 474 -> NULL, which is the final list.</p> <p><strong>My code:</strong></p> <pre><code>#include &lt;assert.h&gt; #include &lt;limits.h&gt; #include &lt;math.h&gt; #include &lt;stdbool.h&gt; #include &lt;stddef.h&gt; #include &lt;stdint.h&gt; #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; char* readline(); typedef struct SinglyLinkedListNode SinglyLinkedListNode; typedef struct SinglyLinkedList SinglyLinkedList; struct SinglyLinkedListNode { int data; SinglyLinkedListNode* next; }; struct SinglyLinkedList { SinglyLinkedListNode* head; }; SinglyLinkedListNode* create_singly_linked_list_node(int node_data) { SinglyLinkedListNode* node = malloc(sizeof(SinglyLinkedListNode)); node-&gt;data = node_data; node-&gt;next = NULL; return node; } void print_singly_linked_list(SinglyLinkedListNode* node, char* sep, FILE* fptr) { while (node) { fprintf(fptr, "%d", node-&gt;data); node = node-&gt;next; if (node) { fprintf(fptr, "%s", sep); } } } void free_singly_linked_list(SinglyLinkedListNode* node) { while (node) { SinglyLinkedListNode* temp = node; node = node-&gt;next; free(temp); } } // Complete the insertNodeAtTail function below. /* * For your reference: * * SinglyLinkedListNode { * int data; * SinglyLinkedListNode* next; * }; * */ //This is the required function which I have written SinglyLinkedListNode* insertNodeAtTail(SinglyLinkedListNode* head, int data) { SinglyLinkedListNode *newNode = (SinglyLinkedListNode*)malloc (sizeof(SinglyLinkedListNode)); SinglyLinkedListNode *p = head; while(p-&gt;next!=NULL){ p=p-&gt;next; } newNode-&gt;data = data; newNode -&gt;next = p-&gt;next; p -&gt;next = newNode; return head; } int main() { FILE* fptr = fopen(getenv("OUTPUT_PATH"), "w"); SinglyLinkedList* llist = malloc(sizeof(SinglyLinkedList)); llist-&gt;head = NULL; char* llist_count_endptr; char* llist_count_str = readline(); int llist_count = strtol(llist_count_str, &amp;llist_count_endptr, 10); if (llist_count_endptr == llist_count_str || *llist_count_endptr != '\0') { exit(EXIT_FAILURE); } for (int i = 0; i &lt; llist_count; i++) { char* llist_item_endptr; char* llist_item_str = readline(); int llist_item = strtol(llist_item_str, &amp;llist_item_endptr, 10); if (llist_item_endptr == llist_item_str || *llist_item_endptr != '\0') { exit(EXIT_FAILURE); } SinglyLinkedListNode* llist_head = insertNodeAtTail(llist-&gt;head, llist_item); llist-&gt;head = llist_head; } char *sep = "\n"; print_singly_linked_list(llist-&gt;head, sep, fptr); fprintf(fptr, "\n"); free_singly_linked_list(llist-&gt;head); fclose(fptr); return 0; } char* readline() { size_t alloc_length = 1024; size_t data_length = 0; char* data = malloc(alloc_length); while (true) { char* cursor = data + data_length; char* line = fgets(cursor, alloc_length - data_length, stdin); if (!line) { break; } data_length += strlen(cursor); if (data_length &lt; alloc_length - 1 || data[data_length - 1] == '\n') { break; } alloc_length &lt;&lt;= 1; data = realloc(data, alloc_length); if (!line) { break; } } if (data[data_length - 1] == '\n') { data[data_length - 1] = '\0'; data = realloc(data, data_length); } else { data = realloc(data, data_length + 1); data[data_length] = '\0'; } return data; } </code></pre> <p><strong>Output:</strong> Core was generated by `./Solution'. Program terminated with signal SIGSEGV, Segmentation fault.</p>
<c>
2019-12-31 17:32:03
LQ_CLOSE
59,547,407
What does "*&n" mean in double-pointer c++?
<p>here it is the code that the teacher gave me to solve in a quiz. can you explain to me what is the *&amp;n do or print out?</p> <p>first of all: is it even possible to have such a thing?</p> <pre class="lang-cpp prettyprint-override"><code>int x = 5; int* p = &amp;x; int** n = &amp;p; std::cout &lt;&lt; *&amp;n; </code></pre>
<c++>
2019-12-31 18:23:19
LQ_CLOSE
59,547,630
What are the random non-hexadecimal characters in a sequence of hexadecimals?
<p>I have a sequence of characters from an rdf file I opened with python.</p> <pre><code>...\x00\x08\x00\x00\x80\xdc\xc0\x00\t{\x00\x00\xa3p\x00\xe2\xc00... </code></pre> <p>I understand that these are hexadecimals. However, there are some that do not compute as hexadecimals, such as xa3p. What are they and why are they here. And what is \t? Tab?</p>
<python-3.x><hex><rdf>
2019-12-31 18:56:16
LQ_CLOSE
59,548,189
Regex to test an expression
<p>I have this expression:</p> <pre><code>/width*$/.test(oldStyle) </code></pre> <p>And oldStyle has this inside of it:</p> <pre><code>width:90%;height:inherit;padding-left:20px; </code></pre> <p>The expression should return true as i have tested it in a online JavaScript regex expression tool.</p> <p>Why is this returning false?</p> <p>Can i use this expression the way i have coded?</p>
<javascript><regex>
2019-12-31 20:22:28
LQ_CLOSE
59,548,488
How to take particular key value pairs from json array
<p>I have a large amount of data in JSON array format. A shorter version of which is as shown below</p> <pre><code>[{"Item": "Item1", "Unit CP": 100, "Unit SP": 150, "Quantity": 1, "TotalSP": 150}, {"Item": "Item2", "Unit CP": 50, "Unit SP": 70, "Quantity": 7, "TotalSP": 490}, {"Item": "Item3", "Unit CP": 1000, "Unit SP": 900, "Quantity": 1, "TotalSP": 900}, {"Item": "Item4", "Unit CP": 200, "Unit SP": 500, "Quantity": 2, "TotalSP": 1000}, {"Item": "Item5", "Unit CP": 300, "Unit SP": 311, "Quantity": 3, "TotalSP": 933}, {"Item": "Item6", "Unit CP": 750, "Unit SP": 755, "Quantity": 2, "TotalSP": 1510}] </code></pre> <p>i want to get a JSON array of objects with keys "Item" and "Unit SP" only i.e</p> <pre><code>[{"Item": "Item1", "Unit SP": 150}, {"Item": "Item2", "Unit SP": 70}, {"Item": "Item3", "Unit SP": 900}, {"Item": "Item4", "Unit SP": 500}, {"Item": "Item5", "Unit SP": 311}, {"Item": "Item6", "Unit SP": 755}] </code></pre> <p>Is there a simpler way to do so in javascript without parsing through the whole array? Thanks in advance </p>
<javascript><arrays><json>
2019-12-31 21:14:50
LQ_CLOSE
59,549,056
If number have inside number string
<p>i want to find stable number if have inside long number in database with php.</p> <p>For example: </p> <pre><code>Stable number: 150 Number list: 1568940, 545198650, 15580 </code></pre> <p>Can i find number of inside that number list. </p> <p>Like this: </p> <pre><code> (1)(5)6894(0) = 150 have that 150 string 545(1)986(5)(0) = 150 have that 150 string (1)(5)58(0) = 150 have that 150 string </code></pre> <p>is it possible? </p>
<php><mysql>
2019-12-31 23:11:00
LQ_CLOSE
59,549,059
The server cannot started because one or more of the ports are invalid [TomCat in Eclipse]
<p>When i open my file list-student.jsp. I experienced the following error: "Starting Tomcat v9.0 Server at localhost has encountered a problem. The server cannot be started because one or more of the ports are invalid. Open the server editor and correct invalid ports."</p> <p>I tried to go server tab and change the port from 8080 to different number, but it doesnt work. I had the same problem before and i changed 8080 to another number liked 8181 and it worked, but today, even i tried to change port number and the problem cant be fixed. Please see some pictures below for your reference <a href="https://i.stack.imgur.com/NTmYW.png" rel="noreferrer">Changing port number</a></p>
<jsp><tomcat><servlets>
2019-12-31 23:11:45
HQ
59,549,226
What does control input do?
<p>I’m trying to learn vanilla JavaScript using JavaScript30 and on a video I was watching, there was a statement saying document.queryselectorAll(’.controls input’); I’ve tried looking this up, but I cannot find it anywhere. Can anyone tell me what this means?</p>
<javascript><css>
2020-01-01 00:02:06
LQ_CLOSE
59,550,699
I don't know what i did wrong, the program returns some weird and incomplete string
I was tring to to write a function that deletes whitespaces from a string but the output is not reasonable at all. I need help fam! char * deleteSpace(char *String, int n) { int i; char *withoutSpaces; withoutSpaces = calloc(n, sizeof (char)); for (i = 0; i < n - 1; i++) { if (String[i] == ' ') withoutSpaces[i] = String[++i]; else withoutSpaces[i] = String[i]; } return withoutSpaces; }
<c><arrays><string><algorithm>
2020-01-01 07:22:24
LQ_EDIT
59,551,022
whats does if(variable ) means in c language?
I m currently preparing for gate , I have come across a question #include<stdio.h> main() { static int var=6; printf("%d\t",var--); if(var) main(); } output is 6 5 4 3 2 1 i wanna know why it terminated after 1??
<c><if-statement>
2020-01-01 08:31:58
LQ_EDIT
59,553,010
Regex for specific characters
<p>I'm trying to refactor this piece of code:</p> <pre><code>if(!RenamePCTextBox.Text.Any(c =&gt; c == '\\' || c == '/' || c == ':' || c == '*' || c == '?' || c == '"' || c == '&lt;' || c == '&gt;' || c == '|' || c == '.' || c == ' ' || c == ',' || c == '~' || c == '!' || c == '@' || c == '#' || c == '$' || c == '%' || c == '^' || c == '&amp;' || c == '\'' || c == '(' || c == ')' || c == '{' || c == '}' || c == '_' || c == '[' || c == ']') &amp;&amp; !String.IsNullOrEmpty(RenamePCTextBox.Text)) { LabelCanUsePCName.Content = "You can use this name"; LabelCanUsePCName.Foreground = Brushes.DarkGreen; } </code></pre> <p>I would like to know if there is way to write it in regex expression? I think this code looks realy ugly this way. Or what would be better aproach for this?</p> <p>I need to disable only characters above, another other character wanna leave for usage (like "-" for example).</p>
<c#><regex>
2020-01-01 13:38:05
LQ_CLOSE
59,553,430
I want to display variables in table format that should be perfectly align in python
<p>I want to make a table in python</p> <pre><code>+----------------------------------+--------------------------+ | name | rank | +----------------------------------+--------------------------+ | {} | [] | +----------------------------------+--------------------------+ | {} | [] | +----------------------------------+--------------------------+ </code></pre> <p>But the problem is that I want to first load a text file that should contain domains name and then I would like to making a get request to each domain one by one and then print website name and status code in table format and table should be perfectly align. I have completed some code but failed to display output in a table format that should be in perfectly align as you can see in above table format.</p> <p>Here is my code </p> <pre><code>f = open('sub.txt', 'r') for i in f: try: x = requests.get('http://'+i) code = str(x.status_code) #Now here I want to display `code` and `i` variables in table format except: pass </code></pre> <p>In above code I want to display code and i variables in table format as I showed in above table.</p> <p>Thank you</p>
<python>
2020-01-01 14:42:22
LQ_CLOSE
59,553,720
Error when trying to install a module using pip,
I am attempting to download the discord.py module using pip, but I keep getting a syntax error like this ```>>> py -3 -m pip install -U discord.py File "<stdin>", line 1 py -3 -m pip install -U discord.py ^ SyntaxError: invalid syntax``` I made sure pip was installed and tried downloading the module from the .whl file directly only to receive a syntax error in the same place.
<python>
2020-01-01 15:30:44
LQ_EDIT
59,554,242
Is it possible to do this?
Admittedly im not a great coder ------------------------------------ So Im making a project for school and Its a dice game, This snippet of my code is like a catch 22 I need to define a variable otherwise it flags, so I do this but then every time the button is run it changes the value to zero instead of increasing it. > if Rollnop1 == 0 : > Userscore1 = Randomnumber > print ("User 1 ",Userscore1 ) > Rollnop1 = Rollnop1+1 #But this changes it so it will go to the next players roll, every > #time the button is pressed it changes the variable back to 0 ``` #========================================================================================# def gamerun(): global Player global usernamestr global passwordstr global usernamestr2 global passwordstr2 Rollnop1 = 0 def roll2(): Rollnop2 = 0 Randomnumber = random.randint(2,12) print ("Console: Random Number 2 = ",Randomnumber) if Rollnop2 == 0 : Userscore2 = Randomnumber print ("User 2 ",Userscore2 ) def roll1(): Rollnop1 = 0 #Need to define this here otherwise It wont work Randomnumber = random.randint(2,12) print ("Console: Random Number = ",Randomnumber) if Rollnop1 == 0 : Userscore1 = Randomnumber print ("User 1 ",Userscore1 ) Rollnop1 = Rollnop1+1 #But this changes it so it will go to the next players roll, every #time the button is pressed it changes the variable back to 0 else: roll2() actdicegame = Tk() gamerunl0 = Label(actdicegame, text = usernamestr, fg = "black") gamerunl0.pack() gamerunl1 = Label(actdicegame, text = "Roll The Dice", fg = "black") gamerunl1.pack() gamerunb1 = Button(actdicegame, text="ROLL",fg="Black", command=roll1)#Register Butto gamerunb1.pack() actdicegame.geometry("350x500") print ("Console: GUI RUNNING 1") actdicegame.mainloop() #========================================================================================# ```
<python>
2020-01-01 16:40:57
LQ_EDIT
59,554,473
Files missing in Google Cloud Platform
<p>I'm surprised to learn that all my files under the home directory got deleted. Please help.</p> <p>This is on my Google cloud service. I use to see files via ssh and/or gcloud command line. Now, I see all files under my HOME gone.</p> <p>That's very disappointing.</p>
<file><google-cloud-platform>
2020-01-01 17:09:55
LQ_CLOSE
59,555,185
How do I correctly use GGPLOT in R?
<p>I am trying to plot a CSV file in GGPLOT in R, but I'm still very new to R… </p> <p>The goal is to plot a bar chart with countries on one axis (Column A(Country) and a comparison of 4 values (Columns b-e (col.b, col.c, col.d, col.e) </p> <p>right now I have: </p> <pre><code>library(ggplot2) dataset &lt;- read.csv("[path]/dataset.csv") ggplot(data=dataset, aes (x=Country, y=col.b, col.c, col.d, col.e, fill=)) + geom_col(stat="identity") + scale_fill_manual("legend", values = c("black", "orange", "blue", "green" )) </code></pre> <p>I seem to have trouble to get it to actually colour the bars for me and also it also shows col.b as far as I can tell. How should it look instead? </p>
<r><ggplot2>
2020-01-01 18:47:36
LQ_CLOSE
59,555,244
Javascript - combine two arrays in every possible way
<p>If I have two arrays:</p> <pre><code>var arrOne = ['a','b','c'] var arrTwo = ['1','2','3'] </code></pre> <p>How can I get a new array from this that will mix every value like so:</p> <pre><code>var result = ['a1','a2','a3','b1','b2','b3','c1','c2','c3'] </code></pre>
<javascript>
2020-01-01 18:57:27
LQ_CLOSE
59,555,578
How can I get a specific field within my table where the ID is the max id?
<p>I'm not sure how to create an sql procedure to get a JobID as LastJobID where the ID is the max.</p> <p>My procedure looks like this as of right now : <code>`SELECT MAX( ID ) as LastJobID FROM jobs;`</code></p> <p>But I need something like this: <code>`SELECT JobID as LastJobID FROM jobs where MAX( ID );`</code></p> <p>The latter gives me an error.</p> <p>My table consists of a unique auto incremented ID, JobID and other attributes as well. I just need to get the JobID from the Max( ID ) because the JobID's are Alpha numeric so getting the MAX( JobID ) won't get me correct results.</p> <p>Sorry if this is hard to understand, but if anyone has an idea of a procedure that would let me do this, I would greatly appreciate it!</p>
<mysql>
2020-01-01 19:44:40
LQ_CLOSE
59,555,840
How do I extract a javascript variable from a .js file with python?
<p>I'm trying to extract the JSON data in the variable chartData. This is stored in a .js file which generates a chart for my solar system. I want to extract this data so i can store it in a separate database.</p> <p>However I cant seem to find a way how to extract the JSON data with python.</p> <p>This is the .js file.</p> <pre><code>var chartData = { "labels": [ "1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"], "datasets": [ { "strokeColor":" rgba(64,178,83,1.0)", "fillColor":" rgba(64,178,83,.5)", "data": [ 15.101000,9.819000,9.966000,19.634000,18.403000,17.015000,20.356000,20.645000,5.443000,14.542000,13.513000,9.774000,15.053000,16.870000,10.582000, 15.139000,7.230000,9.019000,18.687000,16.074000,17.183000,23.353000,22.248000,22.762000,22.458000,20.809000,18.034000,12.810000,15.627000,21.057000, 19.589000] } ] } var max = 25; var steps = 5; var input = document.getElementById("inputId"); input.setAttribute("min", "2019-02"); input.setAttribute("max", "2020-01"); input.setAttribute("value", "2019-08"); document.getElementById("labelValueId").innerHTML = " 498.812kWh 08.2019"; document.getElementById("buttonPrevId").disabled = false; document.getElementById("buttonNextId").disabled = false; var myBar = new Chart(document.getElementById("canvasId") .getContext("2d")) .Bar(chartData, { "pointDot": false, "datasetFill": false, "scaleOverride": true, "scaleLabel": "&lt;%=value%&gt; kWh", "scaleSteps": steps, "scaleStartValue": 0, "scaleStepWidth": Math.ceil(max / steps), "scaleLineColor":" rgba(170,170,170,1.0)", "scaleFontColor":" rgba(170,170,170,1.0)", "scaleGridLineColor":" rgba(68,68,68,1.0)"}); </code></pre>
<javascript><python>
2020-01-01 20:23:09
LQ_CLOSE
59,556,049
Just starting looking into python, Want to as about beautiful soup
So I was trying to get the web crawling element in Google drive. What I want is the date the file was modified. And I use F12 to find the elements, got the following selector body > div.ndfHFb-c4YZDc.ndfHFb-c4YZDc-AHmuwe-Hr88gd-OWB6Me.ndfHFb-c4YZDc-vyDMJf-aZ2wEe.ndfHFb-c4YZDc-i5oIFb.ndfHFb-c4YZDc-TSZdd > div.ndfHFb-c4YZDc-MZArnb-b0t70b.ndfHFb-c4YZDc-MZArnb-b0t70b-L6cTce > div.ndfHFb-c4YZDc-MZArnb-bN97Pc.ndfHFb-c4YZDc-s2gQvd > div.ndfHFb-c4YZDc-MZArnb-Tswv1b-nUpftc > div:nth-child(1) > div.ndfHFb-c4YZDc-MZArnb-BKwaUc-bN97Pc > div > div:nth-child(6) > div.ndfHFb-c4YZDc-MZArnb-BKwaUc-V67aGc.ndfHFb-c4YZDc-MZArnb-Tswv1b-V67aGc In order to do so I created following code using BS4. from bs4 import BeautifulSoup as bs import requests req= requests.get ('https://drive.google.com/file/d/12_Lu1VHQI-yjvCPEwUhjonRyGHEczpRc/view') base= req.text print(base) Find_ver=Sr.select('body > div.ndfHFb-c4YZDc.ndfHFb-c4YZDc-AHmuwe-Hr88gd-OWB6Me.ndfHFb-c4YZDc-vyDMJf-aZ2wEe.ndfHFb-c4YZDc-i5oIFb.ndfHFb-c4YZDc-TSZdd > div.ndfHFb-c4YZDc-MZArnb-b0t70b.ndfHFb-c4YZDc-MZArnb-b0t70b-L6cTce > div.ndfHFb-c4YZDc-MZArnb-bN97Pc.ndfHFb-c4YZDc-s2gQvd > div.ndfHFb-c4YZDc-MZArnb-Tswv1b-nUpftc > div:nth-child(1) > div.ndfHFb-c4YZDc-MZArnb-BKwaUc-bN97Pc > div > div:nth-child(6) > div.ndfHFb-c4YZDc-MZArnb-BKwaUc-V67aGc.ndfHFb-c4YZDc-MZArnb-Tswv1b-V67aGc' ) print (Find_ver) But this keeps printing [] null dict, any help?
<html><beautifulsoup><python-requests>
2020-01-01 20:58:10
LQ_EDIT
59,556,363
Handling window pop up with selenium
<p>I am currently working on a bot that logs into instagram, I currently have the script to log in and turn on notifications but when then I get a window pop the code does not click on allow. I have been stuck for quite some time. Thank you in advance for your help. <a href="https://i.stack.imgur.com/M1P9L.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M1P9L.png" alt="Window Popup"></a></p> <pre><code>def allow_noti(): allow_noti = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[contains(.,'Turn On')]"))) allow_noti.click() allow_browser = WebDriverWait(browser, 10).until(EC.element_to_be_clickable((By.XPATH, '//* [text()="Allow"]'))).click() allow_browser.click() </code></pre>
<python-3.x><selenium><selenium-webdriver>
2020-01-01 21:46:19
LQ_CLOSE
59,556,527
Can someone explain me this? It's about arrays and some handling of an if statement inside of array
<p>I don't understand the part of the if statement in this piece of code. And is it possible to write this with using if and else if?</p> <pre><code>int klein(int A[], int n, int&amp; i, int X) { int j; int kl = -1; i = -1; for(j = 0; j &lt; n; j++) { if(A[j] &gt; X &amp;&amp; (kl == -1 || A[j] &lt; X)) { i = j; kl = A[j] ; } } return kl; } </code></pre>
<c++>
2020-01-01 22:14:40
LQ_CLOSE
59,556,658
Python Class property question about how check if the name is isalpha() in the setter?
can anyone help me out with this requirement? I have been trying to fix it, but not succefful. I would really appreciate if someone can help me out thanks. name: property returns capitalized name and setter checks the name isalpha() and if true store the name in the object otherwise store ‘Unknown’ eid: property returns eid zero filled up to 4 spaces and setter will assign ‘9999’ if length is zero, otherwise store the eid. here is my code. class Employee: def __init__(self, name, eid): self.name = name self.eid = eid def set_name(self, name): if name.isalpha(): self.__name = name else: self.__name = 'Unknown' def set_eid(self, eid): if self.eid.isalpha(): self.eid = eid else: self.eid = "9999" def get_name(self): return self.name def get_eid(self): return self.eid def __str__(self): return "%s: %s " % (self.eid, self.name) def main(): empName = input('Name') eid = input('Id') employeeInfo = Employee(empName, eid) print(employeeInfo.__str__()) main()
<python><python-3.x><properties>
2020-01-01 22:35:47
LQ_EDIT
59,557,427
Quick Pandas Exercise
<p>I have a dataset like this:</p> <pre><code>ID Type Value 01 A $10 01 B $12 01 C $14 02 B $20 02 C $21 03 B $11 </code></pre> <p>I want to convert this into:</p> <pre><code>ID TypeA TypeB TypeC 01 $10 $12 $14 02 $0 $20 $21 03 $0 $11 $0 </code></pre> <p>The only solution that I have is bunch of if-loops but don't have a few-liner. Can anyone help me with this python (pandas) problem?</p> <p>Thanks</p>
<python><pandas>
2020-01-02 01:21:57
LQ_CLOSE
59,557,597
Initialized array by indices of elements in ascending order
<p>I have 2 arrays in C program. A1, A2 with size 1500, 780 respectively. Type of each array is integer (int). How can I initialized A1 by the indices of elements in ascending order, A2 - by the indices too, but in descending order?.</p> <pre><code>int A1[1500] int A2[780] </code></pre>
<c>
2020-01-02 01:58:03
LQ_CLOSE
59,557,688
Why does golang time function fail on certain dates
<p>I have checked the other suggestions for fixing this problem and they don't work.</p> <p>The current code seems to work until you enter a different date and then I get random failures like below.</p> <p>The code is as follows:</p> <pre><code>yy, mm, dd = 11, 27, 2019 s_yy, s_mm, s_dd = 11, 1, 2019 e_yy, e_mm, e_dd = 1, 1, 2020 input := fmt.Sprintf("%d-%d-%d", yy, mm, dd) input += "T15:04:05.000-07:00" t, _ := time.Parse("2006-01-02T15:04:05.000-07:00", input) input_s := fmt.Sprintf("%d-%d-%d", s_yy, s_mm, s_dd) input_s += "T15:04:05.000-07:00" t_s, _ := time.Parse("2006-01-02T15:04:05.000-07:00", input_s) input_e := fmt.Sprintf("%d-%d-%d", e_yy, e_mm, e_dd) input_e += "T15:04:05.000-07:00" t_e, _ := time.Parse("2006-01-02T15:04:05.000-07:00", input_e) fmt.Println("t = ", t, " t_s = ", t_s, " t_e", t_e) </code></pre> <p>The result is the following:</p> <p>t = 2019-12-27 15:04:05 -0700 -0700 t_s = 0001-01-01 00:00:00 +0000 UTC t_e 0001-01-01 00:00:00 +0000 UTC</p> <p>Any Help would be a help Thanks in advance.</p>
<go>
2020-01-02 02:15:59
LQ_CLOSE
59,558,072
I want a table cell to completely cover up the entire screen in ios Swift?
The problem here is I want the UITable cell to fully take the view of the cell and once I swipe down the other cell has to appear. What I have here is the other cell also appears on the same UITable screen. As you can see the title of the other news also can be seen in the UITableView. I want the first data to cover up the entire screen and once I swipe down the next data(title,image,description) has to be added. [enter image description here][1] [1]: https://i.stack.imgur.com/KtX0d.png
<ios><swift><uitableview>
2020-01-02 03:43:26
LQ_EDIT
59,559,083
How to use string C data type in PIC C Compiler
How to use `string` in [CCS](https://ccsinfo.com/forum/viewtopic.php?p=205898)? I tried: ``` #include<string.h> ``` >But I still have error with it: ``` string myString = "My String"; // Error ```
<c++><c><pic>
2020-01-02 06:20:05
LQ_EDIT
59,559,433
Java is the front end technology and php is the back end technology. how could I connect both?
<p>My company is suppose to create an android application along with it's website. I will be handling the website part. So I need to use php as both app's and site's back end. For site i know to do with php. But for app, how could i connect java and php? </p>
<java><php><backend>
2020-01-02 06:55:21
LQ_CLOSE
59,561,032
rails, how to get specific string from a sentences
i want to ask what is best method on rails to get specific string from a sentences? example i have "My working time is: 3 hours and the job is finished" "Bla2 time is: 6 hours and the job is still pending" "Bla bla bla time is: 7 hours and the job is finished" i want to take the number after words "time is: " so the output is only number like: 3, 6, 7 any idea how to do it? Thanks
<ruby>
2020-01-02 09:32:12
LQ_EDIT
59,561,105
create a variants of products
Im looking for an **efficient way** to group a different types of products variants. I have this json file, and inside each product I have an different type of attributes. **attributes:** [ {title: color, labels: [{title: red}, {title: blue}]}, {title: brand, labels: [{title: nike}, {title: rebook}]}, {title: size, labels: [{title: 38}, {title: 40}] ] and it can have more/less attributes. **I need to create an efficient function that will return:** variants: [ 'red nike 38', 'red nike 40', 'blue nike 38', 'blue nike 40', 'red rebook 38', 'red rebook 40', 'blue rebook 38', 'blue rebook 40' ] pls help :D
<javascript><json><object>
2020-01-02 09:37:40
LQ_EDIT
59,561,158
How git manage to store the files branch wise?
<p>Suppose, In my repository, I have two branches i.e Master and development. I've created the development branch from master and now I added some new files to the development branch and after committing those changes on local, I switched to the <strong>Master branch</strong>. Now, here we don't see the new files which we had added on the development branch but when I switch back to the development branch, I'll able to see the new files. <strong>How git manage to store the files branch wise?</strong></p>
<git>
2020-01-02 09:42:20
LQ_CLOSE
59,562,621
Retrieving Data from PHP table
<p>I have data in MYSQL database and I want to display a record per page on my website. How would I do this?</p> <p>The URL would correspond to each record</p> <p>Thank you!</p>
<php>
2020-01-02 11:32:14
LQ_CLOSE
59,563,034
Pythod Code to Print multiple user input string in one string
<p>I have a python code below:</p> <pre><code>import os import glob NumberofAlphabets = input('Enter Number of Alphabets:') NF = int(NumberofAlphabets) Input = 1 while Input &lt; NF+1: AlphabetName = input('Enter Alphabet Name:') tempF += AlphabetName Input += 1 print(tempF) </code></pre> <p>i want result like this:- </p> <p>Enter Number of Alphabets: 2<br> Enter 1 Alphabet Name: a<br> Enter 2 Alphabet Name: b<br> Result is a b</p>
<python>
2020-01-02 12:01:22
LQ_CLOSE
59,565,141
Do importable libraries exist for common mathematical operations (e.g. min, max and mean) in C or C++?
<p>I'm a Python programmer starting to learn C / C++. One issue I'm finding, however, is that the C languages seem to lack a lot of "basic" mathematical operations. For example, even finding the min, max or mean of an array.</p> <p>Consider finding the maximum value of an array as an example. I appreciate this is an "easy" task and I can write a simple loop that goes through the whole array and compares each element to the current maximum-found value, replacing this maximum with the current element if it exceeds it. However, it's annoying in each project I'm working on to have to define such commonly used functions.</p> <p>Therefore, I wonder if there are widely used / accepted C &amp; C++ libraries for such mathematical operations (i.e. similar to numpy for Python), which would save time and limit the chance of me introducing bugs by re-writing commonly used algorithms?</p> <p>More generally, would this be considered bad practice in C/C++ programs - do such programmers simply expect to see everything coded up from first principles?</p> <p>Thanks</p>
<python><c++><c><max><shared-libraries>
2020-01-02 14:37:34
LQ_CLOSE
59,565,871
How can I validate email in this PHP contact form?
<p>is there a way to validate an email in this form without rewriting it completely? It'd be great if I could just add something to this. I'm new to PHP and this form is taken from mmtuts video. If you know how to help, I'd be glad if you did.</p> <pre><code>&lt;?php if (isset($_POST['submit'])) { $name = $_POST['name']; $number = $_POST['number']; $subject = $_POST['subject']; $mailFrom = $_POST['mail']; $message = $_POST['message']; $mailTo = "misavoz@seznam.cz"; $headers = "From: ".$mailFrom; $txt = "Pan/í ".$name." vám poslal/a zprávu. Telefonní číslo: ".$number."\n\n".$message; mail($mailTo, $subject, $txt, $headers); header("Location: index.php?mailsend"); } </code></pre>
<php><validation><email><contact-form>
2020-01-02 15:28:10
LQ_CLOSE
59,566,508
How should we upgrade from AngularJS 1.6.4 to the latest Angular version?
<p>I'm working on a quite large enterprise software application (web-based). We're using Angular 1.6.4 since ... forever. Due to different reasons, we want to / have to upgrade from this old version to a new Angular version. I'm thinking of Angular 8 (?).</p> <p>First off, I noticed that there is Angular-CLI. Is this the new way to use Angular? I've also found an official <a href="https://update.angular.io/#2.0:8.0" rel="nofollow noreferrer">Angular Update guide</a>. But this only ranges from version 2.0 (and we're using 1.6.4).</p> <p>Due to the size of our application, it will probably take weeks to months to upgrade everything. What is the best way to release this? I disklike on "big" update which moves everything from 1.6.4 to >8.0. </p> <p>I'm a little bit lost, to be honest. It would be awesome if someone could push me in the right direction. :)</p> <p>Have a good day!</p>
<javascript><html><angularjs><angular>
2020-01-02 16:15:27
LQ_CLOSE
59,568,452
Swift Detect Every Time Device Orientation Changes
<p>I'm creating an iPhone game in Xcode with the latest version of Swift. Why I'm asking this question is when the user flips the phone and changes the orientation, is there any way I can detect that, so I can change the placing, size, etc. of things?</p>
<swift>
2020-01-02 18:44:16
LQ_CLOSE
59,568,511
Cannot convert LocalDate to Timestamp
<p>I'm trying to convert a LocalDate to Timestamp but it keeps saying: <code>valueOf(java.lang.String) in Timestamp cannot be applied to (java.time.LocalDateTime)</code></p> <p>What I'm doing:</p> <pre><code>LocalDate date = LocalDate.of(year, month+1, day); Timestamp ts = Timestamp.valueOf(date.atTime(LocalTime.MIDNIGHT)); </code></pre> <p>Year, month and day are from a DatePicker.</p>
<java><timestamp><localdate>
2020-01-02 18:48:52
LQ_CLOSE
59,568,983
I need complete C++ Implementation of General Tree with arbitrary number of nodes
I am googling from the last two days to find complete C++ implementation of general tree but I only found the binary tree implementation that is why I am posting my question here.
<c++><data-structures><tree>
2020-01-02 19:32:13
LQ_EDIT
59,569,078
Get Azure DevOps server (on-premise) data using Power Bi desktop connector
I want to show analytics using power bi desktop from my azure devops server which is deployed on premise but unable to connect while the error shows analytics extension is not available for on premise server of devops. I also found the Odata endpoint method but is it possible to do it using connector? Please suggest.
<azure-devops><powerbi>
2020-01-02 19:40:34
LQ_EDIT
59,570,474
How to increase The maximum size of one packet in MySQL Server
<p>**While trying to import full world database to mysql server i have occurred error attached , ** <a href="https://i.stack.imgur.com/NAQON.png" rel="nofollow noreferrer"> Screen</a> @Bogir[rus] have found solution for Me but i still want to share how to resolve this problem.</p> <p>Open mysql shell and enter SET GLOBAL max_allowed_packet=1073741824; (where "1073741824" is maximum size in kb)</p>
<mysql>
2020-01-02 21:50:16
LQ_CLOSE
59,570,532
How to remove all fields from a Javascript object that match a regex?
I have the following JS object: let obj = { 'a': 1, 'a-gaboom': 1, 'b': 1, 'b-gaboom': 1 } I want to delete all fields that end with "gaboom". I could do it with `delete obj.a-gaboom; delete obj.b-gaboom`, but is there a way to do it with a regex?
<javascript><regex><algorithm><object>
2020-01-02 21:56:54
LQ_EDIT
59,571,268
How can i find excactly how many lowercases come after an uppercase?
For example: "He Is a small man" has 2 lowercases come after an uppercase. I have tried google but i haven't found anything similar there.
<python>
2020-01-02 23:21:11
LQ_EDIT
59,571,302
expand an array of arrays to an array of objects
<p>I have an array of arrays and I need to make the first member in each nested array into a key, and make an array of objects from the rest. Where each odd member after the first is key and an even member is value.</p> <p>See the example: note that the original nested arrays always have an odd number or members (or even after you remove the first member to make it our new key) </p> <pre><code>//ORIGINAL var arr = [ [first, a, b, c, d],[second, e, f, g, h, i, j],[third,...] ] // DESIRED RESULT var obj = [ {first: [{a:b}, {c:d}]}, {second: [{e:f}, {g:h}, {i:j}]}, {third: ...} ] </code></pre>
<javascript>
2020-01-02 23:25:48
LQ_CLOSE
59,573,246
I want to know about print type explicitly
<p>Print type like %s, %d, %x, %p, ... I understand these things roughly. But when I have to choose one of these, I can't pick similar two of these. For example, when I try to print address of variable, I can have %p or %08X, they will be certainly different in special case. I want to know definition of these print type in order to make reasonable decision. I couldn't find any resource in C standard.</p>
<c>
2020-01-03 04:34:57
LQ_CLOSE
59,574,228
How to randomise text in c#?
<p>I want to make a c# program which generates random numbers, but I can't find how to. The code I've come up with so far:</p> <pre><code>using System; namespace DigitalDice { class Program { static void Main(string[] args) { Console.WriteLine("[1]"); } } } </code></pre> <p>I just need a way to make random words, the example I'm looking for is how to randomise with 2 different outputs, then I can change it to how I like it.</p>
<c#>
2020-01-03 06:39:43
LQ_CLOSE
59,576,606
How to unzip abc.txt.gz file in react js?
- hi i am having problem to read a .gz file compressed by *php code:* - i am using $compressed = gzcompress('Compress me', 9); in php for compressing in .gz - In php i am able to uncompress, but *i dont know if there is any way to read .gz file in react js*. I am new to this. **Thanks in advance.**
<reactjs>
2020-01-03 10:07:05
LQ_EDIT
59,578,071
How to extract linked images out of a html page with PHP/regexp
<p>I'm looking for some PHP code or a rexeg expression (i'm not that skilled about regexp) to extract from a html file just the linked images. In other words, just the chunk of html that looks like:</p> <pre><code>&lt;a href=...&gt;&lt;img src=...&gt;&lt;/a&gt; </code></pre> <p>I know how to extract images and links separately </p> <pre><code>$links = $dom-&gt;getElementsByTagName('a'); $images = $dom-&gt;getElementsByTagName('img'); </code></pre> <p>but not how to extract the two tags one inside the other. I have also not found anything by googling it. So is it maybe uncommon or very difficult what I want to do? </p> <p>Could you help me? Thanks.</p>
<php><html><regex><image><extract>
2020-01-03 11:46:50
LQ_CLOSE
59,578,789
I want to check whether the user has entered something
<p>I am facing a problem that is is follows: a] How to check whether the user has entered something against the scanf statement. b] How to run a part of code repeatedly without goto function or what is the replacement for goto.</p>
<c>
2020-01-03 12:38:19
LQ_CLOSE
59,578,857
Regex on numbers - python
<p>I am new to regex and I need some help please. I have a dataframe in which I got column with amount, which is in most cases something like 869,850.0 and I need only rows where the number is ending with 950.00 or 999.00 I dont need something like 999.1 . I did not came up with any idea how to filer these values in pandas. </p> <p>So I am trying to apply match with regex and because I am new to this I only know how to get number unit . something like [^.]*. but I dont know how to apply if and how to continue, can someone please help me?</p>
<python><regex><pandas>
2020-01-03 12:42:46
LQ_CLOSE
59,579,700
How to write very complex SQL in a clean and maintainable way?
<p>I'm in the database migration project.</p> <p>I have to write very complex SQL in a maintainable way. The previous query is almost spaghetti.</p> <p>I wanna make a view in the database but I have no authority. </p> <p>So what I am thinking about is making a bridged database that is from the query result of the database. </p> <p>After that, I made views in the bridged database. </p> <p>is it inefficient? or is there any nice way to deal with a complex database queries?</p>
<java><sql><oracle>
2020-01-03 13:47:27
LQ_CLOSE
59,579,929
Branching Systems Differences
<p>There are 3 different branching systems <em>Feature Branch, Release Branch,</em> and <em>Hotfix Branch</em></p> <p>What is the difference between them and what are they used for?</p>
<git>
2020-01-03 14:04:55
LQ_CLOSE
59,579,958
JavaScript How to declare 16 length array with default 0 value quick?
<p><code>let array1 = Array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);</code> how to make like this array with shortest way ? is it possible to make shorter way ? thank you for your answers.</p>
<javascript><arrays>
2020-01-03 14:06:12
LQ_CLOSE
59,581,370
How do I convert a list to Uppercase
I am new to coding and I need help with this coding problem . my problem is that I need to convert the "letter_guessed" input to lower case ,if its upper case and if the uppercase letter is already exists inside the list as a lower case it will return false but I cant get to do it . I have tried using isupper(),upper ,islower(), lower() in many ways , I am pretty sure that I am doing something wrong with "if" but cant get it right been stuck on it for two days . Thanks in advance !! def check_valid_input(letter_guessed, old_letters_guessed): while True: """ will work only if you enter one letter and do not contain special letters other then the abc and if its all ready been entered it will show false """ if len(letter_guessed) == 1 and letter_guessed not in old_letters_guessed : """if the letter is one letter and not already inside old_letter_guessed only then continue """ old_letters_guessed.append(letter_guessed) print("True") letter_guessed = input(" : ") else: """ if its wrong input will print False Try again and if the input is correct it will go back to " if " """ #old_letters_guessed.append(letter_guessed) print(False, 'Try again') old_letters_guessed.sort() print('->'.join(old_letters_guessed)) letter_guessed = input(" : ") #if letter_guessed is letter_guessed.isupper() new = input() old = [] check_valid_input(new,old)
<python><python-3.x>
2020-01-03 15:42:22
LQ_EDIT
59,581,476
Why is reinitializing a variable out of method in class is an error? Why cant compiler just read and reassign the value to it?
<p>Like here why reinitializing variable i is an error?</p> <pre><code>class deleteme { int i=5; i=33; public static void main(String args[]) { } } </code></pre>
<java>
2020-01-03 15:49:51
LQ_CLOSE
59,581,515
String objects and storage
<p>How many objects will be created in the following code and where they will be stored?</p> <pre><code>String s = "abc"; // line 1 String s1 = new String("abc"); // line 2 String str1 = new String("efg"); //line 3 </code></pre>
<java><string><heap-memory><string-pool>
2020-01-03 15:52:52
LQ_CLOSE
59,584,551
If dictionary value exists multiple times in list of dicts, delete specific dict from list
<p>I have a function that returns a list of dictionaries like this:</p> <pre><code>[{'Status': 'Deleted', 'Name': "My First Test"}, {'Status': 'Modified', 'Name': "My First Test"}] </code></pre> <p>As you can see, "My First Test" is in there twice. Normally this wouldn't be an issue, however, based on what I know about what's happening on the back-end, the only dict that I <em>actually</em> want is the "Modified" dict.</p> <p>Essentially, I'm looking for a way to say "if dict['Status'] == 'Modified' and dict['Status'] == 'Deleted' for the same Name, delete the one with the 'Deleted' status."</p>
<python><list><dictionary>
2020-01-03 19:51:53
LQ_CLOSE
59,585,763
How much do you have to pay for publishing apps?
<p>I saw you have to pay a developer fee to publish your apps on the google play store and the app store. For the app store you pay $99 and for the google play store $25. But do you have to pay this amount for each app you publish ? Or is this for your account once in a lifetime or do you have to pay this amount each year ?</p> <p>Thanks in advance !</p>
<android><ios><google-play><app-store><publish>
2020-01-03 21:51:24
LQ_CLOSE