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,658,643
java.lang.ArrayIndexOutOfBoundsException: length=1; index=1 when trying to read csv
<p>I have problem when trying to read the csv file, the error appears like this : <code>java.lang.ArrayIndexOutOfBoundsException: length=1; index=1</code> . I have tried searching in StackOverflow, the error appears same as above.</p> <p>Code :</p> <pre><code>private void readCSVFile(String csvNameFile) { try { File readFolderCSV = new File(Environment.getExternalStorageDirectory() + "/Download/" + csvNameFile); CSVReader csvReader = new CSVReader(new FileReader(readFolderCSV.getAbsoluteFile())); String[] nextLine; while((nextLine = csvReader.readNext()) != null) { Log.e("TAG", nextLine[0] + nextLine[1] + nextLine[2] + nextLine[3] + nextLine[4]); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(MasterUoM.this, "The specified file was not found", Toast.LENGTH_SHORT).show(); } } </code></pre> <p>MyCSVFile :</p> <p><img src="https://i.stack.imgur.com/TRU71.png" alt="1"></p>
<java><android><opencsv>
2020-01-09 06:54:37
LQ_CLOSE
59,659,146
Could not import PILLOW_VERSION from PIL
<p>While importing, Python(anaconda) gives the following error:</p> <pre><code>ImportError: cannot import name 'PILLOW_VERSION' from 'PIL' </code></pre> <p>I tried removing <code>pillow</code> and then <code>conda install</code> but the error persists. Please help</p>
<python><anaconda><python-imaging-library>
2020-01-09 07:32:19
HQ
59,661,042
What do * (single star) and / (slash) do as independent parameters?
<p>In the following function definition, what do the <strong>*</strong> and <strong>/</strong> account for?</p> <pre><code>def func(self, param1, param2, /, param3, *, param4, param5): print(param1, param2, param3, param4, param5) </code></pre> <p><em>NOTE: Not to mistake with the single|double asterisks in *args | **kwargs (<a href="https://stackoverflow.com/questions/36901/what-does-double-star-asterisk-and-star-asterisk-do-for-parameters">solved here</a>)</em></p>
<python><python-3.x><function>
2020-01-09 09:39:41
HQ
59,663,607
how to know CSS-class of current node, JS
I wanted to do little menu for navigation in nodes.I have a model of site where i training in js. And my problem, how to display class of node in results block. I looked that i can display only a node name or a node type, but it's very uncomfortable and i just think if classes is all named that it's will be more convenient way for display.Please give a recommendation for my code.In the end, I want to add that I am only learning English, and because of this, there may be some errors. Thank you.[It's my HTML code][1] and [my Js code][2](some functions not yet done). [1]: https://i.stack.imgur.com/5g4ye.png [2]: https://i.stack.imgur.com/r5p00.png
<javascript><html>
2020-01-09 12:05:29
LQ_EDIT
59,665,437
How can I store an object File that only exists in memory as a file inside of my storage system?
<p>My programm has just recieved an <em>Object</em> that is instance of <em>File</em>. How can I save said Object as a file? I want the file to be stored in a human readable format which is why just writing the Object into a new file like <a href="https://stackoverflow.com/questions/2744962/load-store-objects-in-file-in-java">here</a> wont do the trick.</p> <p>I also can't just copy the file like <a href="https://www.journaldev.com/861/java-copy-file" rel="nofollow noreferrer">here</a> because the file I allready know only exists in Memory, hence if I set it as source it wont be recocnized.</p>
<java><file>
2020-01-09 13:49:04
LQ_CLOSE
59,665,617
How to fetch array within array python
<pre><code>array = [['eric', '12', '12'], ['ted', '12', '102']] n = input("name\n&gt;&gt;") if n in array: print(array) else: print("error") </code></pre> <p>When I input 'eric' as n I want to program to print array[0] and if I enter 'ted' I want to program to output to contents of array[1]. How do I do this?</p>
<python><arrays>
2020-01-09 13:58:52
LQ_CLOSE
59,665,621
Databricks error when trying to load a module using apache spark
<p>I'm using a notebook within Databricks. The notebook is set up with python 3 if that helps. Everything is working fine and I can extract data from Azure Storage. However when I run:</p> <p><code>import org.apache.spark.sql.types.StructType</code></p> <p>I get the error message </p> <p><code>ImportError: No module named 'org'</code></p> <p>Does anyone know how I would go about fixing this? Is this something to do with the notebook being in python? </p> <p>I've only just started using Databricks today so apologies if this is a silly question - I couldn't find anything online that helped. </p> <p>I did try to run <code>import org.py.spark.sql.types.StructType</code> but that didn't work either. </p> <p>Thanks</p>
<python><azure><apache-spark><databricks>
2020-01-09 13:59:08
LQ_CLOSE
59,665,734
Combine two lists in a specific order
I am working in Python, and I want to combine two lists and have one list in the end, but in a specific way. Below I will just provide an example but the dataset I am working on is much bigger. List 1 1.1 1.1 1.1 1.1 1.2 1.2 1.2 1.2 List 2 2.1 2.1 2.1 2.1 2.2 2.2 2.2 2.2 Combined List 1.1 1.1 1.1 1.1 2.1 2.1 2.1 2.1 1.2 1.2 1.2 1.2 2.2 2.2 2.2 2.2 Essentially, I want every 4 values to change the list I am importing values from. Take the first 4 from List 1 then take the next 4 from List 2, and then go back to List 1 etc. Any help would be welcome, thank you!
<python><python-3.x><list>
2020-01-09 14:04:54
LQ_EDIT
59,666,924
my navigation bar when I include it appears above
<p>my navigation bar when I include it appears above.</p> <p><a href="https://i.stack.imgur.com/4CoAU.png" rel="nofollow noreferrer">my navigation bar in separate file</a></p> <p><a href="https://i.stack.imgur.com/4giKH.png" rel="nofollow noreferrer">my navigation bar where I want to include</a></p>
<android><xml>
2020-01-09 15:10:58
LQ_CLOSE
59,669,922
How to format this date string format "2018-03-30T14:36:10.093" into Date in Swift
<p>I'm trying to get the Date object for this string format "2018-03-30T14:36:10.093" in Swift, but I don't get it. It is not ISO8601 because of that point after the number 10.</p> <p>Any solutions?</p>
<swift><date><dateformatter>
2020-01-09 18:13:54
LQ_CLOSE
59,671,356
AngularJS select
> <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <body> <div ng-app="myApp" ng-app="myFruitsApp" ng-controller="myCtrl"> <p>Select a car:</p> <select ng-model="selectedCar" ng-options="x.model for x in cars"> </select> <select ng-model="selectedFruit" ng-options="y.type for y in fruits"> </select> <h1>You selected: {{selectedCar.model}}</h1> <h1>fruits:: {{selectedFruit.type}}</h1> </div> <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) { $scope.cars = [ {model : "Ford Mustang"}, {model : "Fiat 500"}, {model : "Volvo XC90"} ]; }); </script> <script> var app2 = angular.module('myFruitsApp',[]); app2.controller('myCtrla', function($scope){ $scope.fruits = [ {type: "apple"}, {type: "oranges"}, {type: "pear"} ]; }); </script> </body> <!-- end snippet --> > Hello. I am trying to more than one select in one div. But first select getting own list and can show up but second and other cannot. I couldnt manage that. I added script link.
<javascript><angularjs>
2020-01-09 20:05:14
LQ_EDIT
59,673,626
How to make a method for downloading a jasper report on Spring Boot?
<p>I made a jasper report, and all the fields, get the list of objects I need to pass on to it. Just don't know how to continue.</p>
<java><spring-boot><jasper-reports>
2020-01-09 23:36:19
LQ_CLOSE
59,675,035
Spring Boot Admin: No option to refresh configuration
<p>I am trying to integrate spring-boot-admin with an existing project which is using actuator and spring cloud config server. I am able to change the external property file and send a post request to <strong>/refresh</strong> endpoint from postman. It works fine and I can see updated value in client app. I have disabled all security for actuator endpoints for now to try spring-boot-admin. My problem is that, I can not see any option to change and refresh configuration in spring-boot-admin UI. I have created an issue but there is no update as of now so thought of sharing this problem here. All the details are available here. Does anyone have any idea what I have missed?</p> <p><a href="https://github.com/codecentric/spring-boot-admin/issues/1344" rel="nofollow noreferrer">https://github.com/codecentric/spring-boot-admin/issues/1344</a></p> <p>Before doing a downvote please have a look at the above link. Let me know if need any more details.</p>
<spring-boot><spring-boot-actuator><spring-boot-admin>
2020-01-10 03:10:00
LQ_CLOSE
59,677,109
i need to know where i m wrong in json object to POST using idhttp in delphi,source gives socket error 14001,WITH OBJ JSO NO PARAM MESSAGE FOR POST
jso := TlkJSONobject.Create;//(data) as TlkJSONobject; jso.Add('InvoiceNumber', ''); jso.Add('POSID', '910441'); jso.add('USIN', ePOSNo.Text); jso.add('DATETIME', eDate.Text); IdHTTP1.Request.Accept := 'application/json'; IdHTTP1.Request.ContentType := 'application/json'; { Call the Post method of TIdHTTP and read the result into TMemo } Memo1.Lines.Text := IdHTTP1.Post('http://localhost;8524/api/IMSFISCAL/GetInvoiceNumberByModel', JSO); jso cannot be passed as t stream need help on it
<json><delphi><post><indy><idhttp>
2020-01-10 07:24:18
LQ_EDIT
59,677,844
optimized way to sort array of objects in order of another array values in javascript
<p>I have a array of ids and array of objects. </p> <pre><code>var ids = [4, 2, 5, 8] var objs = [ {"id": 2, "name": "a"}, {"id": 4, "name": "b"}, {"id": 8, "name": "c"}, {"id": 5, "name": "d"} ] </code></pre> <p>I want to sort <code>objs</code> in order of values given in <code>ids</code> array.<br> so sorted objs should be </p> <pre><code>[ {"id": 4, "name": "a"}, {"id": 2, "name": "b"}, {"id": 5, "name": "c"}, {"id": 8, "name": "d"} ] </code></pre>
<javascript><arrays><sorting>
2020-01-10 08:23:06
LQ_CLOSE
59,678,205
Why does a count formula return 0 when the range of cells are linked to another sheet?
<p>I am trying to count a range of cells that have text in and ignore 0 that is in some of these cells. All of these cells have a link to another cell sheet within the same workbook and so are returning 0 if the linked cell has nothing entered. I have tried COUNTIF, COUNTA and SUMPRODUCT but all return 0</p>
<excel>
2020-01-10 08:48:01
LQ_CLOSE
59,678,881
how to write the list of array values to the txt file (list of file names)
**I have list of values(file names), i just splitted and assigned to the variable now i need to write the 2 set of file names to the individual files.** //Split the Files var Alternated = Files .Select((name, index) => new { name, index }) .GroupBy(item => item.index % 2, item => item.name) .Select(group => group.ToList()) .ToArray(); //Assigning alternate files to the variable var C1 = Alternated[0]; var C2 = Alternated[1]; // Check if file already exists. If yes, delete it. string filepath = FilePath; string filepath2 = FilePath2; if (File.Exists(filepath) || File.Exists(filepath2)) { File.Delete(filepath); File.Delete(filepath2); } using (FileStream fs = File.Create(filepath)) { StreamWriter sw = new StreamWriter(fs); C1.ForEach(r => sw.WriteLine(r)); } using (FileStream fs1 = File.Create(filepath1)) { StreamWriter sw1 = new StreamWriter(fs1); C2.ForEach(r => sw.WriteLine(r)); }
<c#><linq>
2020-01-10 09:32:42
LQ_EDIT
59,678,988
Conversion of PDF to XML using Machine Learning
<p>I was given a work to convert PDF to XML. In XML, I have to display some values which are in PDF. And I was asked to use Python-3 and Machine Learning to extract the values.</p> <p>Any Suggestions or ideas on how to create an ML model to extract info from PFDs.</p> <p><strong>Problem in Detail :</strong> if i have a pdf having values, for example : </p> <p>emp id : 10000 name : raam</p> <p>Then i have to extract the empid and name from PDF and display them to XML document.</p> <p><strong>Note : The model should be able to process thousands of PDFs and convert them to XML docs.</strong></p> <p>Thank U...</p>
<python><machine-learning><deep-learning><computer-vision><data-science>
2020-01-10 09:38:32
LQ_CLOSE
59,679,188
Why instance variables are not initialized before constructor creation. What happens if they are initialized at the class loading itself
<p>As we know Constructor purpose is to initialize instance variables, what if they are initialized before itself...does that effect the code..</p>
<java><c#>
2020-01-10 09:49:10
LQ_CLOSE
59,681,344
How to check that all elements in a list are unique
<p>How can i write a program to check that all elements in a list are unique. I have a list that is entered by the user and i would like the program to check that the elements are unique, if they are, say list=[1,2,3,4,5], then the program continues. If not, say list=[1,2,3,4,5,5,5], then the user must reenter the list. Thankyou </p>
<python><list><loops><pairwise>
2020-01-10 12:05:29
LQ_CLOSE
59,681,916
How to convert java to kotlin
<p>We are trying to convert java code to Kotlin and are having a hard time figuring out how to do it. Any help or recommendations are welcome. Thanks!</p> <pre><code> private void runTextRecognition() { FirebaseVisionImage image = FirebaseVisionImage.fromBitmap(mSelectedImage); FirebaseVisionTextRecognizer recognizer = FirebaseVision.getInstance() .getOnDeviceTextRecognizer(); mTextButton.setEnabled(false); recognizer.processImage(image) .addOnSuccessListener( new OnSuccessListener&lt;FirebaseVisionText&gt;() { @Override public void onSuccess(FirebaseVisionText texts) { mTextButton.setEnabled(true); processTextRecognitionResult(texts); } }) .addOnFailureListener( new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { // Task failed with an exception mTextButton.setEnabled(true); e.printStackTrace(); } }); } </code></pre> <p>The above code is what we are trying to convert to Kotlin.</p>
<java><kotlin>
2020-01-10 12:40:57
LQ_CLOSE
59,684,360
What happen in background memory point of view when we move one branch to another branch of same project in git...?
<p>What happen in background memory point of view when we move one branch to another branch of same project in git, Where the commit store???</p>
<git><github><commit><checkout>
2020-01-10 15:12:41
LQ_CLOSE
59,685,753
How to replace all numbers in a string with custom string in python?
<p>I want to replace all the numbers in a given string with <code>Mat(number)</code>.For example the string <code>A*256+B*12+C*256</code> after conversion must look like this <code>A*Mat(256)+B*Mat(12)+C*Mat(256)</code>.<strong>How can I perform this in python 3?</strong>.</p>
<python><python-3.x><string><replace>
2020-01-10 16:45:13
LQ_CLOSE
59,686,435
Hello, I am beginner in C++ and have this kind of problem . It gives me multiply errors
<p>In this code, I try to explain the rules by which a person can get the driving license.. However, it gives me such errors like "expected primary-expression before ‘)’ token", "‘else’ without a previous ‘if’", " expected ‘;’ before ‘cout’", "expected primary-expression before ‘else’ " and "expected ‘)’ before ‘else’"</p> <pre><code>int age = 90; int ageAtLastExam = 16; bool isNotIntoxicated = true; if(age &lt; 16)); //if you are`enter code here` older or equal to 1 and younger than 16, you cannot drive cout &lt;&lt; "You can't drive" &lt;&lt; endl; else(age &gt;= 80 &amp;&amp; ((age &gt; 100) || ((age - ageAtLastExam) &gt; 5))) ///if your age is greater than 100, we are not going to allow you to the exam, but if you are older or equal to 80, you will have to take an exam every five years cout &lt;&lt; "You can't drive" &lt;&lt; endl; else cout &lt;&lt; "You can drive" &lt;&lt; endl; </code></pre>
<c++>
2020-01-10 17:32:02
LQ_CLOSE
59,686,969
How to have an Event on setScene
How can I make a custom Event that triggers on `Stage.setScene()`? In my code, the button switches the Scenes and that works fine. However I would like to extend the Stage to have an additional Event that is triggered when a button or possibly any other Element triggers a setScene. Example: ```sql package sample; import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.stage.Stage; public class Main extends Application { public static void main(String[] args) { Application.launch(args); } @Override public void start(Stage stage) { Group g1 = new Group(); Button b1 = new Button("2"); g1.getChildren().setAll(b1); Scene scene1 = new Scene(g1, 50, 50); Group g2 = new Group(); Button b2 = new Button("1"); g2.getChildren().setAll(b2); Scene scene2 = new Scene(g2, 50, 50); stage.setScene(scene1); stage.setTitle("JavaFX Application Life Cycle"); b1.setOnAction(actionEvent -> { System.out.println("1"); stage.setScene(scene2); }); b2.setOnAction(actionEvent -> { System.out.println("2"); stage.setScene(scene1); }); stage.show(); } }
<java><javafx>
2020-01-10 18:13:25
LQ_EDIT
59,687,763
Changing a variable outside of a for loop
<p>I am writing a program where I am accessing an object in a list using a for loop. I want to be able to change a variable outside of a for loop from within the loop. Code snippet below:</p> <pre><code>member_found = False # default value for member in self._members: if member_id == member.get_account_ID(): member_found = True </code></pre> <p>In PyCharm, I am getting a notification that says "Local variable 'member_found' value is not used." When I run this code, it doesn't seem to produce any errors, but I want to make sure the variable outside the for loop is actually being changed.</p> <p>I can always make the default value an empty list and append the list, but I would rather use booleans if possible.</p>
<python><pycharm>
2020-01-10 19:17:38
LQ_CLOSE
59,690,582
how do I centralize (center) a navigation bar?
``` <div class="topnav" align="middle"> <a href="http://actividad.csjpr.xyz>Actividad</a> <a href="http://clase.csjpr.xyz">Clase</a> <a href="http://club.csjpr.xyz">Club</a> <a href="http://comite.csjpr.xyz">Comite</a> <a href="htt://competencia.csjpr.xyz">Competencia</a> <a href="http://deporte.csjpr.xyz">Deporte</a> <a href="http://oficina.csjpr.xyz">Oficina</a> <a href="http://organizacion.csjpr.xyz">Organización</a> <a href="http://programa.csjpr.xyz">Programa</a> ``` **This is what I currently have. I'd like to centralize it because it is automatically appearing on the left. Thank you.**
<html>
2020-01-11 00:20:21
LQ_EDIT
59,691,183
No overload for method 'ReadLine' arguments when only 1 argument is given
<p>I am trying to read the first line in a file, but I keep getting this error every time I do sr.ReadLine(1); and I can not find an answer to this error. My code:</p> <pre><code>using (StreamReader sr = new StreamReader(DataStore)) { string Conent; Conent = sr.ReadLine(1); }; </code></pre>
<c#><file>
2020-01-11 02:38:53
LQ_CLOSE
59,691,488
Problem with allocating memory in c++ and pointers
<p>So I am learning dynamic memory allocation nowadays and stuck in a problem(if it is).</p> <pre><code>int *p; p=(int*)calloc(5,sizeof(int)); </code></pre> <p>According to my intution p should point to memory location of 5*4 = 20byte and these 20bytes only belong to p. for *(p+0), <em>(p+1)....</em>(p+4) everything is fine. but when i do *(p+5) or *(p+12)=100; This should give me an error as i have exceeded the memory block allocated to *p.</p> <p>The confusion is : Why we need to even allocate memory when we can just do like :</p> <pre><code>int *p int s[]={1,2,3} p=&amp;s[0] //and then make an array of length &gt; s *(p+4)=....something </code></pre> <p>In every article i am seeing they are allocating memory before assigning . what's the need. I hope u understand my confusion.</p>
<c++><c><pointers><malloc><c++14>
2020-01-11 03:52:29
LQ_CLOSE
59,692,061
Retrieve request in entity
For some translation purpose, I need to retrieve the request in my entities. I tried to do what is [written here][1] but it's not working with entities. /** * AccessoryType constructor. * * @param RequestStack $requestStack */ public function __construct(RequestStack $requestStack) { $this->request=$requestStack->getCurrentRequest(); } I get the following error message (which is to be excepted I guess...) > Too few arguments to function App\Entity\Map::__construct(), 0 passed in /var/www/sphere/src/Controller/MapController.php on line 34 and exactly 1 expected Any suggestion to retrieve the request within an entity? [1]: https://symfony.com/doc/current/service_container/request.html
<php><symfony><oop><autowired>
2020-01-11 05:58:04
LQ_EDIT
59,695,139
why array variable is getting updated
<p>I wrote this code and a part of this is not written by me and I'm not able to understand how a function is updating my <code>arrayData</code>?</p> <pre><code>#include &lt;iostream&gt; using namespace std; int *insert(int arr[], int size, int elem, int pos); int main() { // Create a array int arrayData[50] = {0}; // Insert data for (int i = 0; i &lt; 10; i++) { arrayData[i] = i + 1; } int elem = 40, pos = 5, size = 10; // insert the element insert(arrayData, size, elem, pos); // show the data for (int i = 0; i &lt; size + 1; i++) { cout &lt;&lt; arrayData[i] &lt;&lt; " "; } return 0; } int *insert(int arr[], int size, int elem, int pos) { size++; // shift elements forward for (int i = size; i &gt;= pos; i--) arr[i] = arr[i - 1]; // insert x at pos arr[pos - 1] = elem; return arr; } </code></pre> <p>OUTPUT: <code>1 2 3 4 40 5 6 7 8 9 10</code></p>
<c++><function><pointers>
2020-01-11 14:05:05
LQ_CLOSE
59,697,822
Problem with CORS : Browser and CURL work but XMLHttpRequest don't
<p>A web server runs on my local network. Let's say on: <a href="http://192.168.1.12" rel="nofollow noreferrer">http://192.168.1.12</a></p> <p>When I visit this url with a browser, it's working fine.</p> <p>When I visit this url with curl (zsh), it's working too:</p> <p><code>curl -s "http://192.168.1.12/"</code></p> <p>But when I try with javascript with XMLHttpRequest:</p> <pre><code>var x = new XMLHttpRequest(); x.open("GET", "http://192.168.1.12/", true); x.send(null); </code></pre> <p>it fails (error message translated): CORS header "Access-Control-Allow-Origin" is missing.</p> <p>I cannot modify the server behavior, but I think I don't need to because it's working with curl. What should I add to my javascript code to make it work?</p>
<javascript><xmlhttprequest><cors>
2020-01-11 19:17:01
LQ_CLOSE
59,699,482
X = Y = Lists vs Numbers
<p>In python : I have 2 pieces of code behaving different when I modify values:</p> <p>X = Y = Number</p> <pre><code>x = y = 2 x = 3 print(x) print(y) Output: 3 2 </code></pre> <p>X = Y = [List]</p> <pre><code>x = y = ['a','b'] x[0] = 'd' print(x) print(y) Output: ['d', 'b'] ['d', 'b'] </code></pre> <p><strong>Why don't LISTS respect the original value of variable Y if X is changed?</strong> </p>
<python><list>
2020-01-11 23:09:43
LQ_CLOSE
59,699,838
Python: rise over run slope calculator that outputs to feet and inches
I'm a first term Computer Science student, I'm attempting to write a rise over run calculator that can function as a construction calculator. Recieving input in feet and inches and outputs the slope in feet and inches to the nearest 1/16th. what I have now can take an input in inches converted into a decimal and output the slope in the same format. import sys while (1): print ("Enter the rise and run in inches to calculate slope.") a = (input("First measurement is: ")) if (a == "stop"): print ("goodbye") sys.exit() a= float (a)**2 b = float (input("second measurement is: "))**2 c = (float (a) + float (b))**(1/2) print ("Slope is:", c,("inches"))
<python>
2020-01-12 00:09:57
LQ_EDIT
59,699,928
How to replace between certain text
<p>Ok i have some text like below:</p> <p>&amp; leftsidetext sometext rightsidetext &amp; %leftsidetext sometext rightsidetext%</p> <p>Now i want to replace replacetext inside sometext just in: &amp; leftsidetext sometext rightsidetext &amp;</p>
<javascript><regex>
2020-01-12 00:28:24
LQ_CLOSE
59,700,337
powershell is detecting syntax error that's right
I'm watching this youtube tutorial on how to make a video game, and now we're converting it to exe, and this is my setup code to convert the game to exe (not the game's code itself): import cx_Freeze executables = [cx_Freeze.Executable("pygame sentdex.py")] cx_Freeze.setup( name="A bit racey", options={"build_exe": {"packages":["pygame"], "include_files":["car.png"]}} #if you have other included files put them here. like fonts. executables = executables) When I use windows power shell to try convert, this happens: PS C:\Users\Damon Tattersfield\Desktop\video game\code\python codes> python setup.py build File "setup.py", line 9 executables = executables) ^ SyntaxError: invalid syntax PS C:\Users\Damon Tattersfield\Desktop\video game\code\python codes> it keeps saying the e in executables is wrong, even though it works fine for the youtuber, and I've changed it to capitol e, removed, retyped it, but it's saying it's a syntax error, when I'm 99% sure it's not. this is the youtubers link by the way: https://www.youtube.com/watch?list=PLQVvvaa0QuDdLkP8MrOXLe_rKuf6r80KO&v=EY6ZCPxqEtM How do I fix? thanks...
<python><pygame><cx-freeze>
2020-01-12 01:54:42
LQ_EDIT
59,700,383
batch file code to detect 32-bit vs 64-bit office not working
<p>I'm trying to put together a batch file that would select the appropriate bit version of executables when run by the user. I found this code on stackoverflow: <a href="https://stackoverflow.com/questions/35820375/batch-file-check-office-architecture-version">Batch file check office architecture version</a> The problem is that it does not work when I paste it into a text file on my desktop and rename it .bat in my virtual machine that has 64-bit Office 2010 installed: it claims it is 32-bit, the default value set in the code. Not being adept in checking registry entries, I'm wondering if there isn't a ready-made version out there somewhere that actually works. I'm also wondering why there isn't a simple way to determine this. I would have thought that this is something that Microsoft would make easily accessible to developers. </p>
<batch-file><64-bit><32-bit>
2020-01-12 02:09:16
LQ_CLOSE
59,700,748
How to define folder colors in powershell?
<blockquote> <p>Can put colors in directory like this image?</p> </blockquote> <p><a href="https://i.stack.imgur.com/tseWs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tseWs.png" alt="Console color settings"></a></p> <p><a href="https://devblogs.microsoft.com/commandline/new-experimental-console-features/" rel="nofollow noreferrer">devblogs.microsoft</a></p>
<powershell>
2020-01-12 03:45:28
LQ_CLOSE
59,701,341
Programming language R: Create a function. This Function converts one matrix to another matrix such that every odd number are 3 times of that number
<p>[1 2] -->[3 2]<br> [3 5] -->[9 15]</p> <p>Please help me solve it. The above is an example(both are 2*2 matrices)</p>
<r>
2020-01-12 05:53:43
LQ_CLOSE
59,702,026
i got this error : Parse error: syntax error, unexpected ';'
<p>please help me with this error i could not find the solution. here's the code :</p> <pre><code>public function store_image($id) { $db = connection(); $if ($db-&gt;connect_errno == 0) { $sql = "SELECT * from car where id='$id'"; $res = $db-&gt;query($sql); while ($row = $db-&gt;fetch_assoc($res)) { $pic = $row['pic']; } header("content_type: image/jpg"); } } </code></pre> <p>the error says "Parse error: syntax error, unexpected ';'" on this line :</p> <pre><code>$sql = "SELECT * from car where id='$id'"; </code></pre> <p>thanks in advance</p>
<php><mysql>
2020-01-12 08:05:43
LQ_CLOSE
59,702,935
how to decode a base64 email with php?
i'm trying to docode my messege with base 64 decode method does anybody know hoe to do it or may be via php funcion??? <?php class Gmail { public function __construct($client) { $this->client = $client; } public function readLabels() { $service = new Google_Service_Gmail($this->client); // Print the labels in the user's account. $user = 'me'; $results = $service->users_labels->listUsersLabels($user); $the_html = ""; if (count($results->getLabels()) == 0) { // print "No labels found.\n"; $the_html .= "<p>No labels found</p>"; } else { // print "Labels:\n"; $the_html .= "<p>labels</p>"; foreach ($results->getLabels() as $label) { // printf("- %s\n", $label->getName()); $the_html .= "<p>" . $label->getName() . "</p>"; } return $the_html; } } /** * Get list of Messages in user's mailbox. * * @param Google_Service_Gmail $service Authorized Gmail API instance. * @param string $userId User's email address. The special value 'me' * can be used to indicate the authenticated user. * @return array Array of Messages. */ public function listMessages() { $service = new Google_Service_Gmail($this->client); // Print the labels in the user's account. $userId = 'me'; $pageToken = null; $messages = array(); $opt_param = array(); $messagesResponse = array(); $i = 0; do { if ($i == 5) break; $i++; try { if ($pageToken) { $opt_param['pageToken'] = $pageToken; } $messagesResponse = $service->users_messages->listUsersMessages($userId, $opt_param); if ($messagesResponse->getMessages()) { $messages = array_merge($messages, $messagesResponse->getMessages()); $pageToken = $messagesResponse->getNextPageToken(); } } catch (Exception $e) { print 'An error occurred: ' . $e->getMessage(); } } while ($pageToken); foreach ($messages as $message) { print 'Message with ID: ' . $message->getId() . '<br/>'; $msg = $service->users_messages->get($userId, $message->getId()); echo "<pre>" . var_export($msg->payload->parts[1]->body->data->base64_decode, true) . "</pre>"; } return $messages; } }
<php><base64><decode><gmail-api>
2020-01-12 10:34:34
LQ_EDIT
59,704,480
how to create python alert box without using Tkinter
I need to create a message box in python without using python Tkinter library so that i can use that before using exit() function this will display the message and ans soon as user press okay user gets out of program.
<python><windows><alert><message><box>
2020-01-12 13:51:29
LQ_EDIT
59,705,057
How can I display opening (bottom aligned) quotation marks in Java? (Android Studio)
is it possible to display in a TextView a bottom aligned quotation mark [like this][1] in Android Studio(3.5.3) with java? [1]: https://i.stack.imgur.com/9qSFM.jpg
<java><android><textview><quotation-marks>
2020-01-12 14:57:47
LQ_EDIT
59,706,076
How to access Plugin Data from Wordpress using Wordpress Rest API
<p>I'm creating a fundraising site similar to gofundme.com using Wordpress. I want to get the data stored from a WP Plugin via WP Rest API using ReactJS, Is there a way to access the data within the Plugin?</p>
<reactjs><wordpress><wordpress-rest-api>
2020-01-12 16:54:36
LQ_CLOSE
59,706,400
playercontrols.cs(11,26): error CS1513: ; expected
<p>playercontrols.cs(11,26): error CS 1513: }expected I started making games 2 days ago. Now im making my first game and I have error. I don't know how to solve this problem this is my script:</p> <pre><code>using System.Collections; using System.Collections.Generic; using UnityEngine; public class playercontrols : MonoBehaviour { public Rigidbody2D rb; public Transform groundCheck; public float groundCheckRadius; public LayerMask whatIsGround; private bool onGround; // Start is called before the first frame update void Start(){ rb= GetComponent&lt;Rigidbody2D&gt;(); } // Update is called once per frame void Update(){ rb.velocity = new Vector2(1,rb.velocity.y); onGround = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, whatIsGround); if (Input.GetMouseButtonDown(0) &amp;&amp; onGround); { rb.velocity=new Vector2(rb.velocity.x, 3); } } </code></pre>
<c#><unity3d>
2020-01-12 17:32:50
LQ_CLOSE
59,707,453
How to create custom date in JS and Ruby backend?
<p>I have a backend Ruby and front-end JS. In the database I put a date field as an integer, now when I fillup my date field with an input like this <strong>12/11/20</strong> it shows just first number <strong>12</strong> in created form, but when I write all numbers together like this <strong>121120</strong> it put exactly <strong>121120</strong>. What have I change to have my date shown in a normal way like <strong>12/11/20</strong>?</p>
<javascript><ruby-on-rails><ruby><reactjs><react-redux>
2020-01-12 19:36:27
LQ_CLOSE
59,707,478
beautifulsoup scrapping table, name of links missing :
Trying to scrap a table with beautifulSoup that looks like this : [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/EzX6i.png I used the following code : import requests response=requests.get(url,headers=headers) soup=BeautifulSoup(response.content, 'html.parser') columns = ['Pname','MP','FG','FGA','FG%','3P','3PA',"3P%", 'FT','FTA','FT%','ORB','DRB','TRB','AST','STL','BLK','TOV','PF','PTS',"+/-"] stat_table=soup.find_all('table',class_ = "sortable stats_table") stat_table=stat_table[0] body=[] for row in stat_table.find_all("tr"): for cell in row.find_all('td'): body.append(cell.text.split(' ')) the output only starts at MP and all the names, I guess since they are links are lost. How can I fix this ?
<python><web-scraping><beautifulsoup>
2020-01-12 19:39:24
LQ_EDIT
59,707,899
Is there any reason why declaring a variable default outside of a method would be better or worse than defining a default in a no-arg constructor
<p>Is there any reason to one way over the other?</p> <pre><code>public ExampleClass{ private exampleVariable = 1; public ExampleClass(){ } } </code></pre> <p>over</p> <pre><code>public ExampleClass{ public ExampleClass(){ private exampleVariable = 1; } } </code></pre>
<java><variables><memory>
2020-01-12 20:36:33
LQ_CLOSE
59,707,978
SQL - display by query the table, groups of rows as columns
i am trying to take range of codes in one column and display their results under one column per catgory<br> <br> example of my table <br> ID | TEST_NUM | RESULT | <BR> 1 | R1 | 33 |<BR> 1 | R2 | 31 |<BR> 1 | C1 | 24 |<BR> 1 | C2 | 19 |<BR> by quert from table above i am trying to get the next table: <BR><br> ID | TEST_NUM OF R ONLY | R RESULTS | C RESULTS | <BR> 1 | R1 | 33 | 24 <BR> 1 | R2 | 31 | 19 <BR>
<sql>
2020-01-12 20:47:26
LQ_EDIT
59,708,394
Bought a PowerBi premium P1 with report Server, but still we are not able to open shared reports without Pro
**My company has bought a PowerBi premium P1 with report Server, but still we are not able to open shared reports without Pro.** I have tried using Power bi App to open the shared reports but is asking to get the pro licences. We all are on same mail domain, using same SQl data base and all have access to SQl data. Please suggest a solution for it.
<powerbi><report><powerbi-desktop>
2020-01-12 21:50:44
LQ_EDIT
59,709,735
Flutter: Should I use Bloc, or should I use redux?
<p>Hello I am new to flutter and is intertwined if I should use Bloc for State Management or redux. I am having a restaurant POS app where I state management is a must. I have a good experience with redux but Bloc has been recommended for flutter. </p> <p>My Question is:</p> <p>1.) Should I switch to Bloc or remain using redux where I am comfortable?</p> <p>2.) What would be the pros and cooons of the two?</p> <p>3.) Which of the are more scalable and mantainable?</p> <p>Thanks for the replies.</p>
<flutter><redux><bloc>
2020-01-13 01:52:52
LQ_CLOSE
59,710,793
How to get these image in my page in responsive for every device?
<p><a href="https://i.stack.imgur.com/Jz4Wv.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Jz4Wv.jpg" alt="I want these images in my page to be responsive for every device. Please help wit div col thing. "></a></p> <p>I want these images in my page to be responsive for every device. Please help wit div col thing. </p>
<php><html><css><user-interface><bootstrap-4>
2020-01-13 05:00:36
LQ_CLOSE
59,710,810
How to upload multiple PDF files to server using alamofire? #Swift 4 #IOS
<p>How to upload multiple PDF files to server using third party library in swift 4 ?</p>
<ios><swift><xcode><alamofire>
2020-01-13 05:04:00
LQ_CLOSE
59,711,298
Why mutex is not working with 2 threads sharing resource c++?
I want to test a scenario where I check weak_ptr for validity and return shared_ptr. between checking and returning if some other thread delete the shared_ptr we would face exception. I tried to simulate same scenario using windows sleep or cout but it seems to be not working. code is as follows: #include <iostream> #include <thread> #include <windows.h> #include <mutex> using namespace std; mutex m; struct Block { int * p_ = nullptr; Block() { p_ = new int[10000]; refCount_++; } int refCount_; }; struct Weak_ptr { Block * p_ = nullptr; Weak_ptr() { p_ = new Block(); } void Addref() { p_->refCount_++; } void release() { delete[] p_; p_ = nullptr; cout << "\nptr deleted\n"; } }; void funct1(int x, Weak_ptr *ptr) { cout << "\nin thread 1 \n"; cout << "\nSleep thread 1\n"; //Sleep(x) for (int i = 0; i < x; i++) cout << "."; cout << "\nAwake thread 1\n"; ptr->release(); } void funct2(int x, Weak_ptr *ptr) { m.lock(); cout << "\nin thread 2 \n"; if (ptr->p_) { cout << "\nptr checked \n"; //Sleep(x) for (int i = 0; i < x; i++) cout << "|"; cout << "\nusing ptr in t2\n"; ptr->Addref(); } else { cout << "\ncheck succeeded \n"; } m.unlock(); } int main() { Weak_ptr s; thread t1(&funct1, 2000, &s); thread t2(&funct2, 4000, &s); t1.join(); t2.join(); }
<c++><multithreading><mutex><stdthread>
2020-01-13 06:06:47
LQ_EDIT
59,711,548
Gimbal Lock Problem while rotating around 3 axes. [UNITY3D]
I'm trying to do rotation on all of the 3 axes. I have three buttons for each axis, say user pressed X. Then the object should return 90 degrees around X axis. But looks like I cannot get rid of the gimbal lock situation whatever I do. Now I have private void rotateMe(){ if (x) transform.rotation *= Quaternion.AngleAxis(90, new Vector3(1, 0, 0)); else if (y) transform.rotation *= Quaternion.AngleAxis(90, new Vector3(0, 1, 0)); else if (z) transform.rotation *= Quaternion.AngleAxis(90, new Vector3(0, 0, 1)); } This too still gives me gimbal lock problem. How do I get rid of the gimbal lock problem?
<c#><unity3d>
2020-01-13 06:34:40
LQ_EDIT
59,714,178
How to check if a column has only NA values?
<p>I have a data frame with 30k observations but i think one of my columns has only NA values. How to check if that specific column has only NA values or not because having so much observation i can check them without code.</p>
<r>
2020-01-13 09:54:46
LQ_CLOSE
59,714,419
i am not getting the error for the regularizer?
model = Sequential() model.add(Conv2D(32, kernel_size=(3, 3), kernel_regularizer=regularizers.l2(w_l2), input_shape=input_shape)) model.add(BatchNormalization()) model.add(Activation('sigmoid')) model.add(Conv2D(64, (3, 3), kernel_regularizer=regularizers.l2(w_l2))) model.add(BatchNormalization()) model.add(Activation('sigmoid')) model.add(MaxPooling2D(pool_size=(2, 2))) model.add(Dropout(0.25)) model.add(Flatten()) model.add(Dense(128, kernel_regularizer=regularizers.l2(w_l2))) model.add(BatchNormalization()) model.add(Activation('sigmoid')) model.add(Dropout(0.5)) model.add(Dense(num_classes, activation='softmax')) model.compile(loss=keras.losses.categorical_crossentropy, optimizer=keras.optimizers.Adam(), metrics=['accuracy']) model.summary() [enter image description here][1] [enter image description here][2] the code needed more challenges for the architecture and also I am also working on my own architecture so I asked this as the semantics are changing every day is the presentsymantics ok. [1]: https://i.stack.imgur.com/u8yf0.png [2]: https://i.stack.imgur.com/FS3oF.png
<tensorflow><keras><keras-layer>
2020-01-13 10:08:17
LQ_EDIT
59,714,859
I get a segmentation fault when I compile and try to run this code
<p>This is a part of my code:</p> <pre><code>for(i = 0; i &lt; rows; i++) { for(j = 0; j &lt; columns; j++) { for(k = 0; k &lt; rows - i &amp;&amp; k &lt; columns - j; k++) { if(i + k &gt; rows || j + k &gt; columns) break; if(b-&gt;board[i + k][j + k] == 1) counter++; if(b-&gt;board[i + k][j + k] == 2) counter = 0; if(counter &gt; max_pd) { plh = counter; jkee = j; kkee = k; } } counter = 0; } if(plh &gt; max_pd) { max_pd = plh; plh = 0; for(n = 0; n &lt; 1; n++) { if(i + kkee &gt; rows || jkee + kkee + 1 &gt; columns) break; if(b-&gt;board[i + kkee + 1][jkee + kkee + 1] == 0 &amp;&amp; b-&gt;board[i + kkee][jkee + kkee + 1] != 0) play_pd = jkee + kkee + 1; } } counter = 0; plh = 0; jkee = 0; kkee = 0; } </code></pre> <p>I get a segmentation fault when I try to run this code at the line : </p> <pre><code>if(b-&gt;board[i + kkee + 1][jkee + kkee + 1] == 0 &amp;&amp; b-&gt;board[i + kkee][jkee + kkee + 1] != 0) play_pd = jkee + kkee + 1; </code></pre> <p>However in the exact above line I clearly state that if the numbers put in board are not in there, break.</p> <p>(the board is defined in a struct like this: b->board[rows][columns]) </p>
<c><segmentation-fault>
2020-01-13 10:34:02
LQ_CLOSE
59,715,714
Making My Own CLI(Command Line Interface) Using CMD
<p>In the previous accepted reply I found the following code. <a href="https://codereview.stackexchange.com/questions/41121/making-a-bat-batch-command-line-interface#new-answer?s=0857a55f8b4e43c1a1d4b13236169370">source</a>: <a href="https://codereview.stackexchange.com/questions/41121/making-a-bat-batch-command-line-interface#new-answer?s=0857a55f8b4e43c1a1d4b13236169370">https://codereview.stackexchange.com/questions/41121/making-a-bat-batch-command-line-interface#new-answer?s=0857a55f8b4e43c1a1d4b13236169370</a></p> <h2>Title: Making a .bat batch command-line interface</h2> <pre><code>:: Define all valid commands: make sure there is a space between each command :: and also one at beginning and end set "commands= something echo exit " :input.get :: Clear the existing value in case user hits &lt;Enter&gt; without entering anything set "input=" :: Get the next command set /p "input=COMMAND\&gt;" :: Parse command into command and arguments. for /f "tokens=1* delims= " %%A in ("!input!") do ( REM check if command is valid (not case sensitive) and act accordingly if "!commands: %%A =!" equ "!commands!" ( echo Invalid command: %%A ) else if /i %%A equ exit ( exit /b ) else ( call :%%A %%B ) ) echo( goto input.get :something echo Doing something with Arg1=[%1] and Arg2=[%2] exit /b :echo echo(%* exit /b </code></pre> <p>If I want to add one more command how to do that? like if user write 'pop' then he/she wile get the reply like bellow:</p> <pre><code>You wrote pop </code></pre> <p>Now how can I this by editing this.</p>
<batch-file><cmd><command><command-line-interface>
2020-01-13 11:25:58
LQ_CLOSE
59,716,322
is there any one explain predicate logic to this sentence Some sleepy students do not answer any question
<p>Write a corresponding predicate logic sentences for the following 1. Some sleepy students do not answer any question</p>
<math><artificial-intelligence><predicate><discrete-mathematics>
2020-01-13 12:04:24
LQ_CLOSE
59,716,388
Convert row values as columns in sql server
Table:- CompanyID Lead LeadManager 1 2 3 Required Output:- CompanyID Role RoleID 1 Lead 2 1 Leadmanager 3
<sql><sql-server><tsql><sql-server-2008><sql-server-2012>
2020-01-13 12:08:23
LQ_EDIT
59,716,392
Hot to tell Symfony http_client to read .htccess
I have a php application made in symfony, it needs this .htaccess to to work: RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] RewriteCond %{HTTP:Authorization} ^(.*) RewriteRule .* - [e=HTTP_AUTHORIZATION:%1] now I am writing some functional test and looks like the client can't find the controller for the route, this is the code: $response = static::createClient()->request( 'POST', '/api/login_check', [ 'body' => [ 'username' => 'username', 'password' => 'secret123!#' ] ] ); when I run the test I get this error: 2020-01-13T11:53:54+00:00 [error] Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "Unable to find the controller for path "/api/login_check". The route is wrongly configured." at /var/www/html/vendor/symfony/http-kernel/HttpKernel.php line 130 which is exactly the same error I use to have using postman before to add the .htaccess file. Is there a way to make the http_client read the .htaccess file? Or alternatively, how can I get rid of the .htaccess file? thanks
<php><symfony><lexikjwtauthbundle><symfony-http-client>
2020-01-13 12:08:48
LQ_EDIT
59,716,884
Bootstrap 4 - Not breaking like in Bootstrap 3
If I execute the following in bootstrap 3, then everything works as expected. But it does not break correctly in bootstrap 4. Please execute the examples below, the first runs with BS4 then last with BS3. I expect it to look like in BS3. <div id="orange_containers" class=""> <div class="row no-gutters"> <div class="col-sm-6"> <div class="col-sm-3"> <div class="icon"> A </div> </div> <div class="col-sm-9"> <div class="text"> <h4>Test</h4> <p> I'm speaking with myself, number one, because I have a very good brain and I've said a lot of things. If Trump Ipsum weren’t my own words, perhaps I’d be dating it. </p> </div> </div> </div> <div class="col-sm-6"> <div class="col-sm-3"> <div class="icon"> B </div> </div> <div class="col-sm-9"> <div class="text"> <h4>Test</h4> <p> The other thing with Lorem Ipsum is that you have to take out its family. We have so many things that we have to do better... and certainly ipsum is one of them. We are going to make placeholder text great again. Greater than ever before. </p> </div> </div> </div> </div> </div> [Try Bootstrap 4 Example in Bootply][1] Same Example but Bootstrap 3: https://www.bootply.com/i8pRUcI7nz [1]: https://www.bootply.com/CL6AQWfRcz
<twitter-bootstrap><twitter-bootstrap-3><bootstrap-4>
2020-01-13 12:42:30
LQ_EDIT
59,718,045
Why doesn't the read function work in sha1 c++ implementation?
<p>I found this c++ implementation of SHA1 on this page <a href="http://www.zedwood.com/article/cpp-sha1-function" rel="nofollow noreferrer">zedwood.com</a>. Why doesn't the this function work. It says that max has to be a constant. How to get around this problem?</p> <pre><code>void SHA1::read(std::istream &amp;is, std::string &amp;s, int max) { char sbuf[max]; is.read(sbuf, max); s.assign(sbuf, is.gcount()); }`` </code></pre>
<c++><implementation><sha1>
2020-01-13 13:54:56
LQ_CLOSE
59,719,036
If there are some identical row names in Table1 and Table2 table then how to read them in java?
<p>If there are some identical row names in Table1 and Table2 table then how to read them in java? Currently, for reading the column values I use table1.coulmn_name. But it will only return the Table1 column value.</p> <pre><code>Table1 executeQuery(String billId) { ResultSetHandler&lt;Table1&gt; resultHandler = new BeanHandler&lt;Table1&gt;(Table1.class) table1 table1 = run.query("SELECT * FROM Table1 JOIN Table2 ON Table1.payment_id =Table2.payment_id WHERE Table1.bill_id="+billId, resultHandler) return table1 } </code></pre>
<java><sql><jdbc>
2020-01-13 14:58:02
LQ_CLOSE
59,719,502
Mysql: Order an SQL Querry by fastest response Time
So i have a SQL-Querry ``` SELECT number, ResponseTime, TicketCreateTime, round(time_to_sec(timediff(ResponseTime, TicketCreateTime))/60,2) AS FRMins FROM (SELECT TE.id, T.number, T.ticket_id, TE.thread_id, TE.pid, T.created AS TicketCreateTime, TE.created AS ResponseTime, TE.type, TE.staff_id FROM ost_ticket T INNER JOIN ost_thread_entry TE ON T.ticket_id = TE.thread_id WHERE TE.type = 'N' OR TE.type = 'R' AND TE.id IN (SELECT min(id) FROM ost_thread_entry WHERE type = 'N' OR type = 'R' GROUP BY thread_id)) AS FTRT_tbl; ``` [Table][1] But my goal ist to have only one of the number and it should be this one with the lowest FRMins. I tried it in many diffrent ways, but i don't get it right. I'm sorry if this is written a little weird. This is my first post and I honestly have no idea how to ask the question well. [1]: https://i.stack.imgur.com/Z7lM9.png
<mysql><sql>
2020-01-13 15:25:41
LQ_EDIT
59,719,904
Vue Y U NO UPDATE
Working my way learning about Vue. I chose it as the better alternative after looking at React, Angular and Svelte. I have a simple example that its not working probably because I'm not getting/understanding the reactive behaviour of Vue. Plain simple App: > <template> > <div id="app"> > <app-header></app-header> > <router-view/> > <app-footer></app-footer> > </div> > </template> > > <script> > import Header from './components/Header.vue'; > import Home from './components/Home.vue'; > import Footer from './components/Footer.vue'; > export default { > components: { > name: 'App', > 'app-header': Header, > 'app-footer': Footer > } > } Where Home.vue and Footer.vue have plain HTML content on the template. On Header.vue I have: > <template> > <div> > <h1> The Header </h1> > <nav> > <ul> > <li>Curr Player:&nbsp;{{ethaccount}}</li> > > <li>Prop owner:&nbsp;{{propOwner}}</li> > > </ul> > </nav> > > <hr> > </div> > > </template> > > <script> > > > export default { > data() { > return { > ethaccount: "N/A", > propOwner: "N/A" > } > }, > methods: { > > update() { > > var ethaccount = "0xAAAAAA123456789123456789123456789"; > console.log("ETH Account: " + ethaccount); > > var propOwner = "0xPPPPPPPPPPP987654321987654321"; > console.log("Prop Account: " + propOwner); > } > > }, > mounted() { > this.update() > } > }; > </script> But I'm unable to get the header updated and unable to find what I'm doing wrong. Help.
<vue.js>
2020-01-13 15:52:31
LQ_EDIT
59,720,077
why is this happening, How do I correct this "mistake"?
<p><a href="https://i.stack.imgur.com/DksIU.png" rel="nofollow noreferrer">enter image description here</a></p> <p>And also when I try to start in the same code the application on the phone stops responding I think the error would be in some code of the connection but I'm not sure because I'm very noob in this question</p> <p>And another question, is my connection correct?</p> <pre><code>public class ConexaoClass { String classs = "com.mysql.jdbc.Driver"; String url = "jdbc:mysql://localhost:3306/bd_tela"; String un = "admin"; String pass = "96960409w"; @SuppressLint("NewApi") public Connection CONN(){ StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); Connection conn = null; String connURL = null; try{ Class.forName(classs); conn = DriverManager.getConnection(url, un, pass); conn = DriverManager.getConnection(connURL); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } return conn; } </code></pre>
<java>
2020-01-13 16:04:33
LQ_CLOSE
59,720,523
Iterate over nth amount of indexes in an array of objects
<p>i am trying to return the sum of the <strong>first 4</strong> grid values from the object below (expected output <strong>5</strong>)</p> <pre><code>[ { "id": 1, "grid": 1 }, { "id": 2, "grid": 2 }, { "id": 3, "grid": 1 }, { "id": 4, "grid": 1 }, { "id": 5, "grid": 1 } ] data.map(item =&gt; { console.log(item.grid); }); </code></pre> <p>Relatively new with .map, I would usually use a forwhile iterator but wondered if someone could suggest a more es6 style pattern for solving the problem.</p>
<javascript>
2020-01-13 16:31:57
LQ_CLOSE
59,720,601
unable to import django
<p><a href="https://i.stack.imgur.com/HWaIk.png" rel="nofollow noreferrer">the error that is happening</a></p> <p>I have installed the django version 3.0.2 all running but idk what could be the problem</p>
<python><django><import>
2020-01-13 16:36:33
LQ_CLOSE
59,720,838
Postgres column doesn't exist error on update
<p>I am trying to run the query below but I am getting an error <strong>ERROR: column "test.pdf" does not exist</strong> . I dont know why I am getting this error. I search for various links on stackover but none solved my problem like this <a href="https://stackoverflow.com/questions/33614625/postgresql-query-column-does-not-exist/33614701">PostgreSQL query -- column does not exist</a>, <a href="https://stackoverflow.com/questions/30764963/postgres-error-updating-column-data">Postgres error updating column data</a>. Please help me find the problem. </p> <p>bill is a type string field in bills table.</p> <pre><code>update bills set bill = "test.pdf" where id=3; </code></pre>
<sql><postgresql>
2020-01-13 16:53:23
LQ_CLOSE
59,722,448
get responseText in ajax
<p>I just want to get ajax feedback</p> <pre><code>var result = $.ajax({ url : 'linkAPI', type : 'get', dataType: 'JSON' }); console.log(result); </code></pre> <p>and only responseTEXT appears.</p> <pre><code>Console.log(result.responseText); </code></pre> <p>// undefined</p>
<javascript><json><ajax><api><object>
2020-01-13 18:47:24
LQ_CLOSE
59,723,618
How would I generate a random and unique title in cpp
<p>im kind of new to cpp coding. Anyway I was wondering how I would add random and unique titles to my program that change every time I open it, EG: If i sent a friend a file it might be called <strong>2377213</strong> the first time he opens it but then second time: <strong>234h234j23bg43v202</strong></p> <p>So it's randomized Would it be possible to do with this and if so how? </p> <p><code>SetConsoleTitleA();</code></p>
<c++>
2020-01-13 20:22:51
LQ_CLOSE
59,724,910
I need to get results from one minus another in range numbers with python
<p>Hi i need to make a code to get a results betwen two numbers. I have start number 1000. I want to get all numbers from 1000 - 500 in a desired range like I give in example. </p> <p>I need one number minus another than minus one more time and loop this in range of numbers. Like I give you in example.</p> <p>1000 - 10 = 990 Than I need number 990 - 40 = 950 and all that in loop till 500. I need to have code to do this. </p> <pre><code>1000, 990 950, 940 900, 890 850, 840 800, 790 750, 740 700, 690 650, 640 600, 590 550, 540 </code></pre> <p>I tried with this</p> <pre><code>import math x = 1000 y = 10 z = x-y d = 40 print(x, z, sep=', ') </code></pre> <p>When I tried with range </p> <pre><code>for x in range(1000, 500, -40): print(x) </code></pre> <p>I get this </p> <pre><code>1000 960 920 880 840 800 760 720 680 640 600 560 520 </code></pre> <p>I don't know how to mix this two and get what I need. Can someone to direct me how to do this?</p>
<python><python-3.x><math>
2020-01-13 22:11:22
LQ_CLOSE
59,725,568
Is there a way to change a buttons text using Selenium Python (MacOS)?
I want to basically do a temporary edit to a webpage (like how people do it using inspect element) but have it done automatically using selenium. For example this is an image from google.ca : https://imgur.com/nAVquUF I simply want to change the text of "Gmail" and "Images" into whatever I want. I only have this so far: ``` from selenium import webdriver from selenium.webdriver.common.keys import Keys browser = webdriver.Chrome('/Users/--------/Downloads/chromedriver') browser.get("https://google.ca/") x = browser.find_element_by_id('Gmail') ``` **Is there a way I can do this?**
<javascript><python><selenium><selenium-webdriver><webdriver>
2020-01-13 23:18:08
LQ_EDIT
59,730,492
sorting list by specific property
<p>I need to sort list of items by its priority(ascending order) ?</p> <pre><code> var priorityIssuesList = [ { name: "Danger", status: "RED", priority:4}, { name: "Moderate", status: "BLUE", priority:2}, { name: "Safe", status: "GREEN",priority:1}, {name: "Warning", status: "Yellow",priority:3} ] </code></pre> <p>sorting should be in ascending order or status</p> <pre><code>[ {"name":"Safe","status":"GREEN","priority":1}, {"name":"Moderate","status":"BLUE","priority":2}, {"name":"Warning","status":"Yellow","priority":3}, {"name":"Danger","status":"RED","priority":4} ] </code></pre> <p>what is the best way to do this?</p>
<javascript><typescript>
2020-01-14 09:03:05
LQ_CLOSE
59,734,535
how to convert the date format 'YYYY-MM-DD' to ddMMyy in pyspark?
<p>I tried to convert the date format 2018-07-12 to ddMMyy using to_date but i get null after converting the dateformat</p> <pre><code>df = spark.createDataFrame([('2018-07-12',)], ['Date_col']) df = df.withColumn('new_date',to_date('Date_col', 'ddMMyy')) </code></pre> <p>I need to use this logic to convert the dataframe column. I am new to the spark programming and tried lot of solutions but nothing helps.</p> <p>I need to concat the ddMMyy from one column and hhss from other column</p> <p>Any help please?</p>
<pyspark><date-format>
2020-01-14 13:15:25
LQ_CLOSE
59,735,956
How do I create a function that can generically calculate product in any object's set of values?
<p>I'm tasked with trying to create a function that will return the product of key value pairs of any given array.</p> <pre><code>function productOfValues(someObject) { //write your code here! **return [testObject.a * testObject.b * testObject.c];*** } let testObject = { 'a': 5, 'b': 12, 'c': 3 } productOfValues(testObject) </code></pre> <p>The asterisked line above indicates the code I've tried to implement, but it does not work. Additionally, to complete this question, I'm supposed to write the function more generically so that the function will calculate the product of <i>any</i> object created. Kind of lost here. </p>
<javascript><arrays><function>
2020-01-14 14:38:20
LQ_CLOSE
59,738,893
establishing a virtually bigger display buffer via code
I don't know if this is a programming question but it is a issue that may be possible to solve via code. Given my little knowledge about how the display processing pipeline in our computers really work, I had the idea that the pixels on the monitor are allocated space in a memory buffer somewhere and this buffer size depends on the size of our screen. So, can we fake the computer into thinking that we have a bigger monitor than we actually have and take the advantage for instance screencasting at a larger resolution than we already have?
<graphics><screen-resolution><monitor>
2020-01-14 17:27:10
LQ_EDIT
59,739,218
operations in methods dont get saved to my variable
This is my first time using stackoverflow. IDK if i am doing it right. So anyways, i am trying to make calculator on Java. I am not sure how to explain my problem. operations in methods dont get saved. when i try to add number, it doesnt apply to last state of it. it applies to first number i gave. can you help me? ``` import java.util.Scanner; public class gelismishesap { public static void toplam(int k) {Scanner a = new Scanner(System.in); System.out.print(k + " + "); for(int i = 0; i<1; i++) { int b = a.nextInt(); k += b; System.out.println(k); } } public static void cikarma(int k) { Scanner a = new Scanner(System.in); System.out.print(k + " - "); for(int i = 0; i<1; i++) { int b = a.nextInt(); k -= b; System.out.println(k); } } public static void carpma(int k) { Scanner a = new Scanner(System.in); System.out.print(k + " x "); for(int i = 0; i<1; i++) { int b = a.nextInt(); k *= b; System.out.println(k); } } public static void bolme(int k) { Scanner a = new Scanner(System.in); System.out.print(k + " / "); for(int i = 0; i<1; i++) { int b = a.nextInt(); k /= b; System.out.println(k); } } public static void main(String[] args) { Scanner a = new Scanner(System.in); System.out.print("Sayı girin: "); int anasayi = a.nextInt(); System.out.println(anasayi); while(true) { String b = a.nextLine(); if(b.equals("q")) { break; } if(b.equals("a")) { toplam(anasayi); } if(b.equals("b")) { cikarma(anasayi); } if(b.equals("c")) { carpma(anasayi); } if(b.equals("d")) { bolme(anasayi); } } } } ```
<java>
2020-01-14 17:49:00
LQ_EDIT
59,739,246
std::string == operator not working in code
<p>So I am making a simple calculator using c++ which inputs a string from the user and takes that input as the operation.</p> <pre><code>std::cout&lt;&lt;"Enter your operation: "; std::string operation; std::cin&gt;&gt;operation; while(operation != string("+")|| operation != string("-") || operation != string("*")) { std::cout&lt;&lt;"Invalid operation! Please enter a valid one: "; std::cin&gt;&gt;operation; } </code></pre> <p>However no matter what I input, I get the error message "Invalid operation! Please enter a valid one: ". Please help me out here, thanks!</p>
<c++><string><loops>
2020-01-14 17:51:02
LQ_CLOSE
59,739,725
I have some error in my code while running it ! plz Fix my error
[NEED HELP]( https://1drv.ms/w/s!An7kEWyTDHfzsRui8rYvBT8Dap2H?e=LWaxWt "I am doing my Assessment Task plz help me to complete my Assessment project link"): <br>**NEED HELP TO FIX MY ERROR to complete my Assessment project <br/> - why my code isn't running any error fix it - i have give a link of my project help me to complete it import java.util.Scanner; class MAPCalculator{ double map; double sbp; double dbp; public MAPCalculator(){ //no code needed } public double value(double sbp, double dbp){ this.sbp=sbp; this.dbp=dbp; return map; } public String category(double map){ //What to do in this function how to sent string String High="High"; String Low="Low"; String Normal="Normal"; return High; } } class Assignment2{ public static void main(String[] args){ double sbp[]= new double[5]; double dbp[]= new double[5]; double map; Scanner sc = new Scanner(System.in); for(int i=0;i<5;i++){ for(int j=0;j<5;j++){ System.out.print("Enter the Value of SBP(systolic blood pressure) "+(i+1)+"::->> "); sbp[i]=sc.nextInt(); System.out.print("Enter the Value of DBP(diastolic blood pressure) "+(i+1)+"::->> "); dbp[j]=sc.nextInt(); map = (sbp[i]+2*dbp[j])/3; } } MAPCalculator obj = new MAPCalculator(); obj.doublevalue(map); System.out.println("The MAP(mean arterial pressure) is::->>"+map+ "mm HG"); } }
<java><project>
2020-01-14 18:28:09
LQ_EDIT
59,740,964
My regex will not work if applied to a multiline xml schema
<p>I've written a regex to alter some XML nodes - taking a generic node name and replacing it instead with the nodes attribute value like so: Regex</p> <pre><code>&lt;custom-attribute attribute-id="(.*)?"\s*(&gt;*)(.*?)&lt;/custom-attribute&gt; </code></pre> <p>for the following xml:</p> <pre><code>&lt;custom-attribute attribute-id="isNewtest"&gt;false&lt;/custom-attribute&gt; </code></pre> <p>using replace regex</p> <pre><code>&lt;$1&gt;$3&lt;/$1&gt; </code></pre> <p>gives output of</p> <pre><code>&lt;isNewtest&gt;false&lt;/isNewtest&gt; </code></pre> <p>which is what I am looking for - however - once more than one node is introduced into the schema - e.g</p> <pre><code>&lt;custom-attribute attribute-id="isNewtest"&gt;false&lt;/custom-attribute&gt; &lt;custom-attribute attribute-id="isAnotherNewtest"&gt;false&lt;/custom-attribute&gt; </code></pre> <p>and I run the regex, the output is:</p> <pre><code>&lt;isNewtest"&gt;false&lt;/custom-attribute&gt; &lt;custom-attribute attribute-id="isAnotherNewtest&gt;false&lt;/isNewtest"&gt;false&lt;/custom-attribute&gt; &lt;custom-attribute attribute-id="isAnotherNewtest&gt; </code></pre> <p>which is not what I was expecting, I was hoping for:</p> <pre><code>&lt;isNewtest&gt;false&lt;/isNewtest&gt; &lt;isAnotherNewtest&gt;false&lt;/isAnotherNewtest&gt; </code></pre> <p>I'm obviously missing something to do with searching through more than one node at a time or multiline selector? - Can someone point me in the right direction please? I've got to restructure a 20,000 line xml doc and not relishing the idea of doing it manually line by line..</p>
<regex><xml><schema>
2020-01-14 20:01:48
LQ_CLOSE
59,743,494
How to compare a string with a struct (which include strings too)?
<p>so im working on my project and i have problem.</p> <p>This is my struct:</p> <pre><code>struct adminst { string usernameadmin; int passwordadmin; </code></pre> <p>and its another function:</p> <pre><code>void adminlogin() { string username, password; adminst Username[100]; cout &lt;&lt; "Please enter your username"; cin &gt;&gt; username; ifstream admin("adminha.txt"); for (int i = 1; i &lt; 100; i++) { admin &gt;&gt; Username[i].usernameadmin; if ((Username[i].compare(username)) &lt; 0) } </code></pre> <p>and i also used:</p> <pre><code>strcmp( Username[i],usernameadmin) == 0 </code></pre> <p>but didnt get any answers. I would be happy if you fix my code.</p>
<c++>
2020-01-15 00:04:24
LQ_CLOSE
59,745,009
Vector how might looks in Java
<pre><code>vector&lt;int&gt; g[100001]; main() { int n, m, v1, v2; cin &gt;&gt; n &gt;&gt; m; for(int i = 1; i &lt;= m; i++) { cin &gt;&gt; v1 &gt;&gt; v2; g[v1].push_back(v2); g[v2].push_back(v1); } } </code></pre> <p>Here is code in C++. <strong>I was wondering how can be implemented this part of using Collections in java</strong></p> <pre><code> g[v1].push_back(v2); g[v2].push_back(v1); </code></pre>
<java><c++><collections>
2020-01-15 04:07:57
LQ_CLOSE
59,745,938
How to apply dark or night mode in a blog or website?
<p>I want html js, java and css for dark mode or night mode, that is not going to off on on refreshing the page, and remains dark or light or night mode until again button pressed.</p>
<nightwatch>
2020-01-15 06:10:37
LQ_CLOSE
59,746,160
Why the variable (line 6) get a space in white ? ( Nivel : Begginer Workflow Runestone )
1.''' x = 1 ''' # initialize x print(x) 2. ''' x = x + 1 # update x ''' 3. ''' print(x) for n in range(4): ''' 4. ''' n= n+1 ''' 5. ''' print("nmap -n -Pe 10.0.2 ",n) ''' # Why the variable get a space in white ? 6. ''' print("nmap -n -PE 10.0.2.",n) ''' Why this line is equal than previous line ''' 7. print("Range imprime :", x,"el número exacto") #con respecto al anterior lista ''' ***Thanks All!*** > Don´t exist bad questions. Only bad answers > ( Anybody told it )
<python-3.x><python-3.6>
2020-01-15 06:31:56
LQ_EDIT
59,749,080
why I get this return value?
<p>Today I was practicing some return types, and put this code:</p> <pre><code>def funcion(numero): return numero print(funcion) </code></pre> <p>And the output is</p> <pre><code>&lt;function funcion at 0x7fc48554f950&gt; </code></pre> <p>but the weirdest thing is that each time I try to run the code it appears other output with different digets/numbers at the end, except 0x7fc48554f950 will be 0x7f8658401950 for example.</p> <p>I was wondering why this happens? The output from python 2.7.x and 3.6.5 are different as well, which would be and awalys with the beginning and ea0.</p>
<python><python-3.x>
2020-01-15 10:04:40
LQ_CLOSE
59,749,936
how to sum up values of single dimentional array having same key in php
<p>For example: if strArr is ["B:-1", "A:1", "B:3", "A:5"] then your program should return the string A:6,B:2.</p> <p>Your final output string should return the keys in alphabetical order. Exclude keys that have a value of 0 after being summed up. Examples Input: array("X:-1", "Y:1", "X:-4", "B:3", "X:5") Output: B:3,Y:1</p>
<php><arrays>
2020-01-15 10:55:46
LQ_CLOSE
59,752,343
what this function do: void (*pfunc[3])();
I have this code line in my code. what the function do? uint32_t Var1 = 1, Var2 = 2, Var3 = 3; void (*pfunc[3])(); pfunc[0] = Var1; pfunc[1] = Var2; pfunc[2] = Var3;
<c><pointers><function-pointers>
2020-01-15 13:22:58
LQ_EDIT
59,752,670
Python: Row wise operation in a list of lists
<p>I have a list of lists</p> <pre><code>[[1,2,3,4,5], [6,7,8,9,10], [11,12,13,14,15], [16,17,18,19,20]] </code></pre> <p>How do I create a list that subtracts the next row item from the current row item in this case: (7-2),(12-7),(17-12) to get a another list</p> <pre><code>[5,5,5] </code></pre>
<python>
2020-01-15 13:43:04
LQ_CLOSE
59,753,810
Is there a way to handle generic function in go
<p>I am new to go, and wanted to implement a scheduler that will recieve tasks(i.e interval + handler). I got stuck in the part where I should get the handlers as go is a static language(I can't get a generic function signature). I came up with the following solution: each "handler" func will get wrapped by empty-interface:</p> <pre><code>type GenericFunc interface{} add_task(GenericFunc(my_func), p1, p2,...) </code></pre> <p>which will result in the following struct as for saving the handler and its params:</p> <pre><code>type Task struct { handler reflect.Value params []reflect.Value ... } </code></pre> <p>Tasks execution would be invoked by:</p> <pre><code>func (t *Task) execute() { t.handler.Call(t.params) } </code></pre> <p>My question is this the right way to treat generic functions or is there a more idiomatic solution I'm missing? thx.</p>
<go><generic-method><reflect>
2020-01-15 14:47:56
LQ_CLOSE
59,754,405
(Python with Selenium) Find XPath on page
Can anyone know how I can find the XPath button on the page https://freerice.com/game in the upper right corner? I write a program in python with selenium and I would like him to click this button.
<javascript><python><selenium><xpath>
2020-01-15 15:17:45
LQ_EDIT
59,755,846
Adding multiple component inside AppComponent in agular
<p>I am wondering is it possible to add multiple components like Component1 , Cmponent2 inside AppComponent like below code but it seems not working am i missing anything ?(ignore this so complaining )ajxbajcbjascjajcabcajbcbajbcajbcjbascbjajbcjacbacjajcacbacbjabcajbcbjabcjajbcabjcjbacbjajbcbajcbjajbcabjcajbcbacbjajbcbjacbjabjcbjacbjajbcajbcbjacbjajbcbjabjcbjacbja</p> <pre><code>import { Component,Directive,ElementRef, APP_BOOTSTRAP_LISTENER } from '@angular/core'; @Component({ selector: 'app-root', template: ` &lt;second-component&gt; test second &lt;/second-component&gt; &lt;third-component&gt; test third &lt;/third-component&gt; `, styles: [` `] }) export class AppComponent { } @Component({ selector: 'second-componet', template: ` &lt;h1&gt; test &lt;/h1&gt; `, styles: [` `] }) export class SecondCompoent{ } @Component({ selector: 'third-componet', template: ` &lt;h1&gt; test &lt;/h1&gt; `, styles: [` `] }) export class ThirdCompoent{ } </code></pre>
<angular><typescript>
2020-01-15 16:36:29
LQ_CLOSE
59,758,750
Why do I get dir: command not found on Mac when there is some files in that directory?
<p>I try to see the files that are in my Desktop. So I move into the directory of my desktop. Then I write: dir in Terminal and it says: -bash: dir: command not found What could possibly be the problem? Because obviously there are many files there.</p>
<command-line><terminal><directory><command-line-interface>
2020-01-15 20:00:16
LQ_CLOSE
59,759,202
REGEX - How can I return text between two strings
<p>Link <a href="https://regex101.com/r/7j7eWy/1" rel="nofollow noreferrer">Regex101</a> I am using (FD.*?)FD however I am missing every second expression - see regex. Any ideas?</p>
<regex>
2020-01-15 20:38:02
LQ_CLOSE
59,759,612
C# Syntax beyond me, a beginner
<p>Okay, so still very new to C#, so sorry if this is obvious...</p> <p>There is some code I can't follow that was created by someone who is much better at C#than I am.</p> <p>We have a class, call it "CC", and it has a number of fields, one of which is "FORM_NBR".</p> <p>So, in a nutshell:</p> <pre><code>public class CC { public CC(); //Many, many fields... ... public long FORM_NBR { get; set; } ... } </code></pre> <p>At some point, an object is created...</p> <pre><code>CC c = new CC(); </code></pre> <p>and then this line is called:</p> <pre><code>c.FORM_NBR = c.FORM_NBR.GetCheckDigit(' '); </code></pre> <p>Now, there is this function deep in the library we inherited:</p> <pre><code>public static short GetCheckDigit(this long nFormNbr, char chFormTypCd) { short nCkDgt = 0; // Default to 0 switch (chFormTypCd) { //Many, many cases... ... default: nCkDgt = CalculateCheckDigit(nFormNbr); break; } return nCkDgt; } </code></pre> <p>My question is this. Being new-ish to C#, how is GetCheckDigit getting called from a long? What is this syntax?</p> <p>I don't even know how I would describe/google this!</p>
<c#>
2020-01-15 21:11:49
LQ_CLOSE
59,759,880
too many values to unpack on dictionary key value iteration
<p>Getting an error <strong>too many values to unpack</strong>. Can anyone help me to solve it?</p> <pre><code>friendship = {'nino': ["tamari", "nika", "lela", "dato"], 'dato': ["tamari", "nino"], 'tamari': ["nino", "dato", "lela"], 'nika': ["nino"], 'lela': ["nino", "tamari"] } def f(**friendship): sia={} for i in friendship.values(): m = min(i) for k,v in friendship.items(): sia.update({k:(len(v))}) low = min(sia.values()) res = [x for x,y in sia if sia.items() if y == low] print(str(res) + " has " + str(low) + " friends") ------ getting an error on this line. print (f(**friendship)) </code></pre>
<python><dictionary><key-value><valueerror>
2020-01-15 21:35:01
LQ_CLOSE
59,760,177
Fetch data from database into checkbox and get the selected values PHP
<p>I am newbie in both PHP and Mysql. I have a table in Mysql named "has" which i store the physical alignments of customers . There are two attributes CustomerID and PyhsicalAilmentName . In sign up screen i want user to select them in a checkbox. I am able to fetch the phsical alignments from database into checkbox with this form code. </p> <pre><code> &lt;form action="includes/signup.inc.php" style="border:1px solid #ccc;width: 50%;margin: 0 auto" method="post" &gt; &lt;div class="container" &gt; &lt;h1&gt;Sign up&lt;/h1&gt; &lt;p&gt;Please fill in this form to create an account.(Your username should start with "C_")&lt;/p&gt; &lt;hr&gt; &lt;input type="text" name="username" placeholder="Name"&gt; &lt;input type="text" name="user_last_name" placeholder="Last Name"&gt; &lt;input type="text" name="uid" placeholder="Username"&gt; &lt;input type="password" name="pwd" placeholder="Password"&gt; &lt;input type="password" name="pwd-repeat" placeholder="Repeat Password"&gt; &lt;input type="text" name="user_weight" placeholder="Weight(in terms of kilogram)"&gt; &lt;input type="text" name="user_length" placeholder="Length(in terms of cm)"&gt; &lt;input type="text" name="user_age" placeholder="Age"&gt; &lt;p&gt; Phsical Alignments&lt;/p&gt; &lt;?php $sql = "select Name from physical_ailment"; $result = mysqli_query($conn,$sql); $i = 0; while($db_row = mysqli_fetch_array($result)){ ?&gt; &lt;input type="checkbox" name="check_list[]"&gt; &lt;?php echo $db_row["Name"]; ?&gt; &lt;br&gt; &lt;?php $i++; } ?&gt; &lt;select name="selected_mem_type" &gt; &lt;?php $sql = "select Name from membership_type"; $result = mysqli_query($conn,$sql); $i = 0; while($DB_ROW = mysqli_fetch_array($result)){ ?&gt; &lt;option&gt; &lt;?php echo $DB_ROW['Name']; ?&gt; &lt;/option&gt; &lt;?php $i++;} ?&gt; &lt;/select&gt; &lt;input type ="text" name="user_card_no" placeholder="Credit Card No"&gt; &lt;input type="date" name="user_card_expire_date" placeholder="Expire Date of Card"&gt; &lt;button type="submit" class="signupbtn" name="signup-submit"&gt; Signup &lt;/button&gt; &lt;button type="submit" class="signupbtn" name="home-submit"&gt; Home &lt;/button&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>Problem is when i intended to get the selected ones with <code>$_POST['check_list']</code>via foreach loop it prints <strong>"on"</strong> according to number of selected checkboxes. If user selects 3 checkboxes in <code>$_POST['check_list']</code> there are 3 elements which is <strong>"on"</strong> . When I select 2 things lets say , and print the <code>$_POST['check_list']</code> with <code>print_r</code> it outputs <code>Array ( [0] =&gt; on [1] =&gt; on [2] =&gt; on )</code> I search a lot but couldn't manage to find solution. Appreciate any help thank you for interest.</p>
<php><html><mysql><checkbox>
2020-01-15 22:00:09
LQ_CLOSE
59,760,826
UnityEngine.Input.GetTouch (System.Int32 index)
<p>This is ment to be an angry birds like slingshot, i need to detect the begining and end of a touch, the script works but when i lift my finger off the screen The error shows up is about line 24 (I put dots next to it). The error only appears if I dont touch the screen, if i touch it it goes away, it comes back when i lift my finger.</p> <pre><code>public class BallShooting : MonoBehaviour { public Rigidbody2D rb; private bool isPressed = false; public bool isDead = false; public bool hasShoot = false; public int Damage; public int BaseDamage = 1; public BoxCollider2D DeathZone; public Transform startingSpot; public GameObject platform; public float releaseTime = .15f; void FixedUpdate() { if (Input.touchCount &gt;= 0 &amp;&amp; isDead == false) { ... if (Input.GetTouch(0).phase == TouchPhase.Began) { // Debug.Log("TouchBegan"); isPressed = true; rb.isKinematic = true; } if (Input.GetTouch(0).phase == TouchPhase.Ended) { // Debug.Log("TouchEnded"); isPressed = false; rb.isKinematic = false; StartCoroutine(Release()); } } if(isPressed &amp;&amp; !hasShoot) { Touch touch = Input.GetTouch(0); Vector3 touchPosition = Camera.main.ScreenToWorldPoint(touch.position); rb.position = touchPosition; } if (isDead) { this.transform.position = new Vector3(startingSpot.position.x, startingSpot.position.y, startingSpot.position.z); isDead = false; DeathZone.enabled = true; } } void OnTriggerEnter2D(Collider2D other) { if(other.tag == "Ground" &amp;&amp; hasShoot == true) { isDead = true; Debug.Log("Dead"); DeathZone.enabled = false; } } IEnumerator Release() { yield return new WaitForSeconds(releaseTime); GetComponent&lt;SpringJoint2D&gt;().enabled = false; hasShoot = true; } } </code></pre>
<c#><unity3d><unity-remote>
2020-01-15 23:06:48
LQ_CLOSE