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
57,206,860
Is there a way to count elements of a JSON column in MySQL?
<p>I have the table <code>answers</code> below corresponding to every new survey submission.</p> <p><a href="https://i.stack.imgur.com/LuZZw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LuZZw.png" alt="enter image description here"></a></p> <p>I would like to get the results as:</p> <pre><code>| rst_id | school_id | q_4_1 | q_4_2 | ... | q_4_43 | +--------+-----------+-------+-------+-----+--------+ | 9 | 101 | 3 | 0 | ... | 3 | </code></pre> <p>Is this even possible in MySQL 5.8?</p> <p>Same question: <a href="https://stackoverflow.com/questions/51464696/count-occurrences-of-items-in-a-mysql-json-field">Count occurrences of items in a MySQL JSON field</a></p>
<mysql>
2019-07-25 16:54:00
LQ_CLOSE
57,207,861
How do i call a macro from from another macro in google sheets
In google sheets, I have a macro that runs until an IFS statement wants to call another macro when true, but I get an error message instead. `enter code here`function BeginTournamentMacro() { `enter code here` var spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); `enter code here`var sheet = spreadsheet.getSheetByName('SIGNUP SHEET').activate(); `enter code here` var COLUMN = 3; `enter code here`var spreadsheet = SpreadsheetApp.getActive(); `enter code here`spreadsheet.getCurrentCell().offset(3, 3, 50, 3).activate(); `enter code here`spreadsheet.getActiveRange().copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_VALUES, false); `enter code here`spreadsheet.getCurrentCell().offset(-1, -1, 48, 4).activate() .sort({column: spreadsheet.getActiveRange().getColumn(), ascending: true}); `enter code here`spreadsheet.getCurrentCell().getNextDataCell(SpreadsheetApp.Direction.DOWN).activate(); `enter code here`spreadsheet.getCurrentCell().offset( 1, 0).activate(); //moves down one row. `enter code here`spreadsheet.getCurrentCell().offset(0, 0, 48, 4).activate(); `enter code here`spreadsheet.getActiveRangeList().clear({contentsOnly: true, skipFilteredRows: true}); `enter code here`spreadsheet.getActiveRange().If Range('B2').value = 10, Then Call Ten; I expected the macro named Ten to run, and then return to run the final 2 rows of code (not shown). Error message: Missing ; before statement. (line 16, file "macros")Dismiss
<javascript><google-apps-script><google-sheets>
2019-07-25 18:04:38
LQ_EDIT
57,211,380
Collapse a doubleColumn NavigationView detail in SwiftUI like with collapsed on UISplitViewController?
<p>So when I make a list in SwiftUI, I get the master-detail split view for "free".</p> <p>So for instance with this:</p> <pre><code>import SwiftUI struct ContentView : View { var people = ["Angela", "Juan", "Yeji"] var body: some View { NavigationView { List { ForEach(people, id: \.self) { person in NavigationLink(destination: Text("Hello!")) { Text(person) } } } Text("🤪") } } } #if DEBUG struct ContentView_Previews : PreviewProvider { static var previews: some View { ContentView() } } #endif </code></pre> <p>I get a splitView if an iPad simulator is in landscape, and the first detail screen is the emoji. But if people tap on a name, the detail view is "Hello!"</p> <p>All that is great.</p> <p>However, if I run the iPad in portrait, the user is greeted by the emoji, and then there is no indication that there is a list. You have to swipe from left to right to make the list appear from the side.</p> <p>Does anyone know of a way to get even a navigation bar to appear that would let the user tap to see the list of items on the left? So that it's not a screen with the emoji only?</p> <p>I would hate to leave a note that says "Swipe in from the left to see the list of files/people/whatever"</p> <p>I remember UISplitViewController had a collapsed property that could be set. Is there anything like that here?</p>
<ios><uisplitviewcontroller><swiftui>
2019-07-25 23:38:14
HQ
57,213,645
splitting a string on a new line into seperate variable
so i have a variable id that outputs ` 1 2 3 4 5 ` i just want to grab the first number 1 and add that as student1.id and the second number as student2.id and so on. currently if i print student1.id i get ` 1 2 3 4 5 ` how would i go about this? i tried doing a for loop but it said it is not iteratable. public class main { /** * Reads a text file containing student data and uses this to populate the student objects * * @param filename Path to the student data file to be read * @return Whether the file was read successfully */ public static boolean readFile(String filename) { File file = new File(filename); try { Scanner scanner = new Scanner(file); while(scanner.hasNextLine()){ String[] words = scanner.nextLine().split(","); addStudent(words[0],words[1],words[2],words[3],words[4],words[5],words[6],words[7],words[8]); // TODO: Finish adding the parameters } scanner.close(); } catch (FileNotFoundException e) { System.out.println("Failed to read file"); } return true; } static void addStudent(String id, String firstName, String lastName, String mathsMark1, String mathsMark2, String mathsMark3, String englishMark1, String englishMark2, String englishMark3) { Student student1 = new Student(); Student student2 = new Student(); Student student3 = new Student(); Student student4 = new Student(); Student student5 = new Student(); student1.id = id; student1.firstname = firstName; student1.lastname = lastName; System.out.println(student1.id); }
<java>
2019-07-26 05:27:12
LQ_EDIT
57,214,667
Is there any tool for monitoring Memory Management?
<p>I know we can check in android studio itself, but i want separate tool for testing.please can any one suggest what are the tools are available for test for android app performance....</p>
<android><android-testing>
2019-07-26 06:57:36
LQ_CLOSE
57,215,400
How to match strings of the form "exclude=1" using regular expression?
<p>I want to use a regular expression to match strings of the form <code>exclude=1</code> where the number should be in the range of 1 to 15. </p> <p>I've tried: <code>str.match("/exclude\=[1-9]|exclude\=1[0-5]/")</code></p> <p>but it does not work.</p> <p>Thank you!</p>
<javascript><regex>
2019-07-26 07:45:18
LQ_CLOSE
57,216,110
The Angular Compiler requires TypeScript >=3.4.0 and <3.5.0 but 3.5.3 was found instead
<p>I'm getting the following error when I do npm run build:</p> <blockquote> <p>The Angular Compiler requires TypeScript >=3.4.0 and &lt;3.5.0 but 3.5.3 was found instead.</p> </blockquote> <p>I've tried following things separately:</p> <blockquote> <p>npm install typescript@">=3.4.0 &lt;3.5.0". Then deleted node_modules and package.json. Run npm install</p> <p>npm update --force. Then deleted node_modules and package.json. Run npm install</p> </blockquote> <p>I'm still getting the error:</p> <p>My package.json contains following dependencies:</p> <pre><code> "dependencies": { "@angular/animations": "8.1.0", "@angular/cdk": "^8.0.2", "@angular/cli": "^8.1.0", "@angular/common": "8.1.0", "@angular/compiler": "8.1.0", "@angular/core": "8.1.0", "@angular/forms": "8.1.0", "@angular/http": "7.2.15", "@angular/material": "^8.0.2", "@angular/platform-browser": "8.1.0", "@angular/platform-browser-dynamic": "8.1.0", "@angular/router": "8.1.0", "@ngx-translate/core": "^11.0.1", "@ngx-translate/http-loader": "^4.0.0", "angular-user-idle": "^2.1.2", "angular2-cookie": "^1.2.6", "core-js": "^2.6.7", "rxjs": "6.5.2", "rxjs-tslint": "^0.1.5", "stream": "0.0.2", }, "devDependencies": { "@angular-devkit/build-angular": "^0.801.0", "@angular/compiler-cli": "8.1.0", "@angular/language-service": "8.1.0", "@types/jasmine": "~3.3.13", "@types/jasminewd2": "~2.0.6", "@types/node": "~12.6.1", "jasmine-core": "~3.4.0", "jasmine-spec-reporter": "~4.2.1", "protractor": "~5.4.2", "ts-node": "~8.3.0", "tslint": "~5.18.0", "typescript": "^3.4.5" } </code></pre> <p>ng --version gives following output:</p> <pre><code>Angular CLI: 8.1.2 Node: 10.16.0 OS: win32 x64 Angular: 8.1.0 ... animations, common, compiler, compiler-cli, core, forms ... language-service, platform-browser, platform-browser-dynamic ... router Package Version ----------------------------------------------------------- @angular-devkit/architect 0.801.2 @angular-devkit/build-angular 0.801.2 @angular-devkit/build-optimizer 0.801.2 @angular-devkit/build-webpack 0.801.2 @angular-devkit/core 8.1.2 @angular-devkit/schematics 8.1.2 @angular/cdk 8.1.1 @angular/cli 8.1.2 @angular/http 7.2.15 @angular/material 8.1.1 @ngtools/webpack 8.1.2 @schematics/angular 8.1.2 @schematics/update 0.801.2 rxjs 6.5.2 typescript 3.5.3 webpack 4.35.2 </code></pre> <p>What could be going wrong here?</p>
<angular><typescript>
2019-07-26 08:31:23
HQ
57,216,364
Why do Django developers use Django builtin admin panel? is it said that must to use instead of a html theme?
<p>I want to develop full functional web application in python django. I want to use bootstrap admin theme to develop admin site. I want to know is it required to use django admin while you are a django developer? or it's just a optional function if some one interested to complete tasks fast?</p>
<python><django><python-3.x><django-admin><django-admin-tools>
2019-07-26 08:46:41
LQ_CLOSE
57,218,205
Android - Cannot resolve symbol Toast
<p>This happens alot to me... I often find code on SO but users do not add the necessary imports.</p> <p>I get <code>Cannot resolve symbol Toast</code></p> <p>I searched the documentation of toast, but I am unable to find the necessary import line. I tried <code>import ui.notifiers.toasts</code> because it is in the URL, but does not work.</p> <p><a href="https://developer.android.com/guide/topics/ui/notifiers/toasts" rel="nofollow noreferrer">https://developer.android.com/guide/topics/ui/notifiers/toasts</a></p>
<java><android>
2019-07-26 10:32:16
LQ_CLOSE
57,219,005
Remove Index [number] from string
<p>Using Typescript I have an array of objects as follows:</p> <pre><code>var errors = [ { name: "Emails[2]", message: "Email is invalid" } { name: "Role", message: "Role is required" } ]; </code></pre> <p>The <code>name</code> can be:<br> 1. A string like <code>"Role</code>".<br> 2. A string followed by brackets and number like <code>"Emails[2]"</code>.</p> <p>In case of (2) I would like to replace <code>"Emails[2]"</code> simply by <code>"Emails"</code>.</p> <p>Every object with <code>name</code>=<code>text[number]</code> would have the <code>name</code> updated to <code>text</code>.</p> <p>How can I do this? </p>
<javascript><typescript>
2019-07-26 11:20:17
LQ_CLOSE
57,219,165
Code to build all possible strings, and find a specific one doesen't work as expected
<p>Part of a task I'm trying to solve is building all possible combinations of letters and whitespace. I'm trying to find a specific String, while building the combinations. I think i implemented the solution well, but my test tells me otherwise.</p> <p>I'm taking the chars from an array and in a for loop I build a String from them, then print the solution. When I built all the combinations of let's say "1 character combinations", then i move on to "2 character combinations". I have a boolean to check if the contents of the StringBuilder is equal to the given String that i want to find. I checked, and the example String was indeed built, but the boolean didn't change.</p> <pre><code>public static void main(String[] args) throws InterruptedException { findString("rxc"); } public static void findString(String string) { boolean isFound = false; String allChars = "abcdefghijklmnopqrstuvwxyz "; char[] sequence = allChars.toCharArray(); int lengthOfExpression = 3; //builder contains 3 whitespaces at the beginning StringBuilder builder = new StringBuilder(" "); int[] pos = new int[lengthOfExpression]; int total = (int) Math.pow(allChars.length(), lengthOfExpression); for (int i = 0; i &lt; total; i++) { for (int x = 0; x &lt; lengthOfExpression; x++) { if (pos[x] == sequence.length) { pos[x] = 0; if (x + 1 &lt; lengthOfExpression) { pos[x + 1]++; } } builder.setCharAt(x, sequence[pos[x]]); } pos[0]++; if (builder.toString() == string) { isFound = true; } System.out.println(builder.toString()); } System.out.println(isFound); } </code></pre> <p>Expected result would be a 'true' printed at the end. Instead, my result is as follows:</p> <p>//lots of lines of combinations omitted</p> <p>r<br> s<br> t<br> u<br> v<br> w<br> x<br> y<br> z </p> <p>false</p>
<java><string><algorithm>
2019-07-26 11:30:17
LQ_CLOSE
57,219,335
How to create a new project on Github, then push the project from my computer
<p>I cannot find the walkthrough I used to check when pushing a new project with git command. I remember logging on to GitHub.com, creating a project. Then do git init, git -add something.. THen i cannot remember the rest of the operations. Can someone give me the list or if the page with the walkthrough URL still exists perhaps send me the link?</p> <p>Searching on GitHub.com and Git-Scm.com</p> <p>git init git add *</p> <p>I expected a new GitHub repo with all files in a folder pushed up to it. The manual is complicated.</p>
<git>
2019-07-26 11:40:06
LQ_CLOSE
57,220,342
Why can companies charge money for their JDK Version despite the GNU GPL v2 of OpenJDK?
<p>OpenJDK is released under the GNU General Public License v2.0 with a classpath exception. If you modify software under such license, you are obliged to release it under the GPL as well. So how come e.g. IBM can charge you for their modified version of the OpenJDK, which mostly includes bugfixes and minor optimizations by changing the existing OpenJDK (which means this doesn't fall under the classpath exception)? Don't they have to release it under the GPL as well which would make it free to use?</p> <p>The only way I could explain this is, that they release the bug fixes and optimizations to OpenJDK delayed to their payed version, but I didn't find any reference stating this to be allowed.</p>
<java><java-11>
2019-07-26 12:43:14
LQ_CLOSE
57,221,426
How do I transfer information between forms?
<p>I am trying to transfer information from form B into form A. Basically formA has a button that opens a new form (form B), and then form B has a textbox where you enter text. Then when you close that form B (via a close button) a textbox in form A should be updated with text inputted in form B.</p> <p>However its not working, textbox in form A is not recieving the text entered in form B, its giving me a null value.</p> <pre><code>//main class of Form A (the one that has to recieve into from Form B) public partial class FormManager : Form { //creating an instance of Form B FormContact contactForm; public string a; public FormManager() { InitializeComponent(); ControlsDisabled(); } private void btnAdd_Click(object sender, EventArgs e) { //trying to fill in a textbox from form B into form A contactForm = new FormContact(); contactForm.Show(); this.Refresh(); txtFname.Text = contactForm.fname; //^^^the main problem, this value is null } private void btnEdit_Click(object sender, EventArgs e) { contactForm = new FormContact(txtFname.Text, txtLname.Text); contactForm.Show(); } //main class of form B(the form that has to give info to form A) public partial class FormContact : Form { public string fname; public string lname; public FormContact() { InitializeComponent(); } private void btnSave_Click(object sender, EventArgs e) { fname = txtFnameA.Text; lname = txtLname.Text; this.Refresh(); this.Close(); } public FormContact(string Fname, string Lname) { InitializeComponent(); txtFnameA.Text = Fname; txtLname.Text = Lname; } } </code></pre>
<c#><winforms>
2019-07-26 13:48:02
LQ_CLOSE
57,223,591
Wait until ajax done before returning the function
<p>I use this code to get a message from the server and print it to the frontend:</p> <pre><code>var message = getMessageFromServer(); $('.result').html(message); function getMessageFromServer() { var result = null; $.ajax({ url: 'index.php', type: 'GET', success: function (msg) { result = msg; } }); return result; } </code></pre> <p>It obviously isn't working because as how javascript works, the line <code>return result</code> is running before the ajax done, therefore my function <code>getMessageFromServer</code> always return null.</p> <p>I have searched all day about this problem and got many answers such as setting async to false, using when done, callback, re-structuring the code to be more ajax-friendly, etc. However, I'm using a framework that won't let me freely re-structuring my code, so I need to make the question myself: <strong>How do I print the message to the frontend with below conditions</strong>:</p> <ul> <li><p>The 2 first lines must not be changed, I need to return the result to <code>message</code>, so it can be print to the frontend.</p></li> <li><p>Not using the <code>async: false</code> because it's bad for user experience.</p></li> <li><p>We can create more method, as long as it is used within the function <code>getMessageFromServer</code></p></li> </ul> <p>P/s: If you're wondering, the framework I'm using is Magento and I'm trying to add a custom validation rule with AJAX, but I the main problem is javascript so I didn't put it into the tags.</p>
<javascript><jquery><ajax>
2019-07-26 16:06:12
LQ_CLOSE
57,224,189
Password box doesn't display since updated to php 7
<p>My web hosting have now decided to use PHP 7 and I'm having issues with some of my pages , managed to fix most but this one is a head scratcher for me. The password box doesn't show but the others box in the same page do? so I can't type the password to register</p> <p>I've noticed the height is defined differently and not sure how to get around it if this is the issue</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?PHP require_once("./include/membersite_config.php"); if(isset($_POST['submitted'])) { if($fgmembersite-&gt;RegisterUser()) { $fgmembersite-&gt;RedirectToURL("thank-you.html"); } } ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"&gt; &lt;head&gt; &lt;meta http-equiv='Content-Type' content='text/html; charset=utf-8' /&gt; &lt;title&gt;Contact us&lt;/title&gt; &lt;link rel="STYLESHEET" type="text/css" href="style/fg_membersite.css" /&gt; &lt;script type='text/javascript' src='scripts/gen_validatorv31.js'&gt;&lt;/script&gt; &lt;link rel="STYLESHEET" type="text/css" href="style/pwdwidget.css" /&gt; &lt;script src="scripts/pwdwidget.js" type="text/javascript"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;!-- Form Code Start --&gt; &lt;div id='fg_membersite'&gt; &lt;form id='register' action='&lt;?php echo $fgmembersite-&gt;GetSelfScript(); ?&gt;' method='post' accept-charset='UTF-8'&gt; &lt;fieldset&gt; &lt;legend&gt;Register&lt;/legend&gt; &lt;input type='hidden' name='submitted' id='submitted' value='1' /&gt; &lt;div class='short_explanation'&gt;* required fields&lt;/div&gt; &lt;input type='text' class='spmhidip' name='&lt;?php echo $fgmembersite-&gt;GetSpamTrapInputName(); ?&gt;' /&gt; &lt;div&gt;&lt;span class='error'&gt;&lt;?php echo $fgmembersite-&gt;GetErrorMessage(); ?&gt;&lt;/span&gt;&lt;/div&gt; &lt;div class='container'&gt; &lt;label for='name'&gt;Your Full Name*: &lt;/label&gt;&lt;br/&gt; &lt;input type='text' name='name' id='name' value='&lt;?php echo $fgmembersite-&gt;SafeDisplay(' name ') ?&gt;' maxlength="50" /&gt;&lt;br/&gt; &lt;span id='register_name_errorloc' class='error'&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class='container'&gt; &lt;label for='email'&gt;Email Address*:&lt;/label&gt;&lt;br/&gt; &lt;input type='text' name='email' id='email' value='&lt;?php echo $fgmembersite-&gt;SafeDisplay(' email ') ?&gt;' maxlength="50" /&gt;&lt;br/&gt; &lt;span id='register_email_errorloc' class='error'&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class='container'&gt; &lt;label for='username'&gt;UserName*:&lt;/label&gt;&lt;br/&gt; &lt;input type='text' name='username' id='username' value='&lt;?php echo $fgmembersite-&gt;SafeDisplay(' username ') ?&gt;' maxlength="50" /&gt;&lt;br/&gt; &lt;span id='register_username_errorloc' class='error'&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class='container' style='height:80px;'&gt; &lt;label for='password'&gt;Password*:&lt;/label&gt;&lt;br/&gt; &lt;div class='pwdwidgetdiv' id='thepwddiv'&gt;&lt;/div&gt; &lt;noscript&gt; &lt;input type='password' name='password' id='password' maxlength="50" /&gt; &lt;/noscript&gt; &lt;div id='register_password_errorloc' class='error' style='clear:both'&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class='container'&gt; &lt;input type='submit' name='Submit' value='Submit' /&gt; &lt;/div&gt; &lt;/fieldset&gt; &lt;/form&gt; &lt;!-- client-side Form Validations: Uses the excellent form validation script from JavaScript-coder.com--&gt; &lt;script type='text/javascript'&gt; // &lt;![CDATA[ var pwdwidget = new PasswordWidget('thepwddiv', 'password'); pwdwidget.MakePWDWidget(); var frmvalidator = new Validator("register"); frmvalidator.EnableOnPageErrorDisplay(); frmvalidator.EnableMsgsTogether(); frmvalidator.addValidation("name", "req", "Please provide your name"); frmvalidator.addValidation("email", "req", "Please provide your email address"); frmvalidator.addValidation("email", "email", "Please provide a valid email address"); frmvalidator.addValidation("username", "req", "Please provide a username"); frmvalidator.addValidation("password", "req", "Please provide a password"); // ]]&gt; &lt;/script&gt; &lt;!-- Form Code End (see html-form-guide.com for more info.) --&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p>
<php><html><css>
2019-07-26 16:50:11
LQ_CLOSE
57,227,583
How to reorder elements using bootstrap 4?
<p>I have a simple section in which I want to display nested elements using bootstrap.</p> <p>Here is what I have so far</p> <p>HTML ;</p> <pre><code>&lt;div class="container"&gt; &lt;div class="row d-flex d-lg-block"&gt; &lt;div class="col-lg-8 order-1 float-left"&gt; &lt;div class="card card-body tall"&gt;2&lt;/div&gt; &lt;/div&gt; &lt;div class="col-lg-4 order-0 float-left"&gt; &lt;div class="card card-body"&gt;1&lt;/div&gt; &lt;/div&gt; &lt;div class="col-lg-4 order-1 float-left"&gt; &lt;div class="card card-body"&gt;3&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>This give me this result</p> <p>desktop version</p> <pre><code>--------- ------ | 2 || 1 | | || | | |------- | || 3 | | || | | |------- | | | | --------- </code></pre> <p>No I want the same but reversed , something like this</p> <pre><code> --------- --- | 1 | | 2 | | | | | ------- | | | 3 | | | | | | | ------- | | ----- </code></pre> <p>mobile version (stacked in order) like this</p> <pre><code> -------- | 1 | | | -------- | 2 | | | | | | | | | | | -------- | 3 | | | -------- </code></pre> <p>I tried to use <code>float-right</code> but unfortunately, it's not working</p> <p>what do I need to change to get what I want?</p>
<html><css><bootstrap-4>
2019-07-26 22:19:31
LQ_CLOSE
57,228,361
QuerySelectorAll(input[type=select]) not working
<p>I am able to select every other type of element on the page except:</p> <pre><code>var elems = querySelectorAll("input[type=select]"); </code></pre> <p>Once I have them, I am applying <code>.disabled</code> in a loop:</p> <pre><code>for (var i = 0; i &lt; elems.length; i++) { elems[i].disabled = true; } </code></pre> <p>This works for all inputs except <code>&lt;select&gt;</code>.</p> <p>Forgive me for this stupid question, but my search results, both here in SO, and on google, are flooded with false hits on "select" in "query<strong>SELECT</strong>orAll().</p> <p>Does anyone know the correct syntax to use to select <code>select</code> elements?</p> <p>Or, if my syntax is correct, why it is not working?</p>
<javascript><html>
2019-07-27 00:50:03
LQ_CLOSE
57,229,382
How to stop Golang from replacing double-quotes with backslashes when executing a DOS command
I am writing a program in Golang that will use Mozilla's Thunderbird email client to send email. The DOS command that should be executed is: ```DOS start "" "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe" -compose "to='CloudCoin@Protonmail.com',subject='Subject1',body='Hello'" -offline ``` My Go code looks like this (command is the DOS command listed above) : ```Go cmd := exec.Command("cmd.exe", "/C", command) ``` But I get an error: ``` Windows cannot find '\\'. Make sure you typed the name correctly, and then try again. ``` It seems that instead of trying to start "" it is trying to start \\\\. How can I keep my double-quotes?
<windows><go><cmd><double-quotes><backslash>
2019-07-27 05:24:29
LQ_EDIT
57,230,014
Multidimensional Arrays with nested for
I can't get this answer Multidimensional arrays, nested(do..while,while,for) char[,] stars = new char[5, 3]; for (int i = 0; i < 5; i++) { for(int x=0;x<3;x++) { stars[i,x]=char.Parse("*"); Console.Write(stars[i, x]); I expect 5 stars then 4 then 3 then 2 then 1
<c#>
2019-07-27 07:15:52
LQ_EDIT
57,230,064
java.lang.IndexOutOfBoundsException: Invalid index 2, size is 2 in android
I have a list of items and for some purpose, I have divided that list into two more ArrayList based on some criteria. When I have added all items of the combined list into 2 separate lists then I am not getting any error but If I add some items of the combined list into 1 and some items into 2 then I am getting an error. Tell me how to resolve "IndexOuOfBoundError." Code: Adding data from combined list to 2 lists if (modelRipeExpiryArrayList.size() > 0) { for (int i = 0; i < modelRipeExpiryArrayList.size(); i++) { if (!(modelRipeExpiryArrayList.get(i).getExpiryDate().equals("")) && modelRipeExpiryArrayList.get(i).getIsRipe() == 1) { explist.add(modelRipeExpiryArrayList.get(i).getItemName() + "@" + modelRipeExpiryArrayList.get(i).getExpiryDate()); ripeList.add(modelRipeExpiryArrayList.get(i).getItemName()); } else if ((modelRipeExpiryArrayList.get(i).getExpiryDate().equals("")) && modelRipeExpiryArrayList.get(i).getIsRipe() == 1) { ripeList.add(modelRipeExpiryArrayList.get(i).getItemName()); } else if (!(modelRipeExpiryArrayList.get(i).getExpiryDate().equals("")) && modelRipeExpiryArrayList.get(i).getIsRipe() == 0) { explist.add(modelRipeExpiryArrayList.get(i).getItemName() + "@" + modelRipeExpiryArrayList.get(i).getExpiryDate()); } } Log.e("TAG", "getInitialized: "+ripeList.size() +"((" +explist.size() ); AdapterExpHome adapterExpHome = new AdapterExpHome(getActivity(), modelRipeExpiryArrayList, explist, HomeFragment.this); RecyclerView.LayoutManager elayoutManager = new LinearLayoutManager(getActivity()); exp_list.setLayoutManager(elayoutManager); exp_list.setItemAnimator(new DefaultItemAnimator()); exp_list.setAdapter(adapterExpHome); adapterExpHome.notifyDataSetChanged(); AdapterHomeRipe adapterHomeRipe = new AdapterHomeRipe(getActivity(), modelRipeExpiryArrayList, ripeList, HomeFragment.this); RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity()); ripe_list.setLayoutManager(layoutManager); ripe_list.setItemAnimator(new DefaultItemAnimator()); ripe_list.setAdapter(adapterHomeRipe); adapterHomeRipe.notifyDataSetChanged(); } Code for Adapter : public class AdapterHomeRipe extends RecyclerView.Adapter<AdapterHomeRipe.MyViewHolder> { Context context; FragmentRipe fragmentRipe; ArrayList<ModelRipeExpiry> modelRipeExpiryArrayList; ModelRipeExpiry modelRipeExpiry; ArrayList<String> ripeList; int qty; public AdapterHomeRipe(Context context, ArrayList<ModelRipeExpiry> modelRipeExpiryArrayList, ArrayList<String> ripeList, HomeFragment homeFragment) { this.context = context; this.modelRipeExpiryArrayList = modelRipeExpiryArrayList; this.ripeList = ripeList; this.fragmentRipe = fragmentRipe; } @NonNull @Override public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { final View itemView = LayoutInflater.from(parent.getContext()) .inflate(R.layout.item_ripe_home, parent, false); return new MyViewHolder(itemView); } @Override public void onBindViewHolder(@NonNull final MyViewHolder holder, final int position) { modelRipeExpiry = modelRipeExpiryArrayList.get(position); Log.e("TAG", "adapterRipe: "+ ripeList.get(position)); // holder.txtRipeVeggie.setText(ripeList.get(position)); if (position % 2 == 0) { holder.layRipe.setBackgroundColor(context.getResources().getColor(R.color.lightGrey)); } else { holder.layRipe.setBackgroundColor(context.getResources().getColor(R.color.white)); } } @Override public long getItemId(int position) { return position; } @Override public int getItemViewType(int position) { return position; } @Override public int getItemCount() { return modelRipeExpiryArrayList.size(); } private static class ViewHolder { } public class MyViewHolder extends RecyclerView.ViewHolder { TextView txtRipeVeggie; RelativeLayout layRipe; LinearLayout layMain; public MyViewHolder(View itemView) { super(itemView); layRipe = (RelativeLayout) itemView.findViewById(R.id.layRipe); txtRipeVeggie = (TextView) itemView.findViewById(R.id.txtRipeVeggie) ; layMain = (LinearLayout) itemView.findViewById(R.id.layMain) ; } } }
<android><android-fragments><android-recyclerview><indexoutofboundsexception>
2019-07-27 07:26:21
LQ_EDIT
57,231,333
Image url convert to transparent background in android studio
i am getting image url from Json, I set it in imageView by using the picasso library. Here i am facing one problem the image i am getting from json on form of URL in not with transparent background ,, so how to make it transparent and then set it to imageview?
<android>
2019-07-27 10:44:53
LQ_EDIT
57,231,680
How to reverse a string using python using for loop? Ex- "Hello World" to "world hello"
How to reverse a string in python using for loop? EX- "HELLO WORLD" to "WORLD HELLO" str="HELLO WORLD"
<python>
2019-07-27 11:29:49
LQ_EDIT
57,235,636
How to store all the numbers in one variable called numbers in python 3
I am a beginner in python and for practice I decided to make a calculator so I need to add numbers to other numbers so numbers must be a variable how can I store all the integer and float numbers into only one variable
<python><python-3.x>
2019-07-27 20:00:13
LQ_EDIT
57,236,221
Exception occurs when trying to deserialize using Json.Net
<p>I am trying to deserialize the following json using Json.Net into C# classes as defined below. I am having this exception:</p> <blockquote> <p>Newtonsoft.Json.JsonSerializationException: 'Could not create an instance of type Viewer.ShapeDto. Type is an interface or abstract class and cannot be instantiated. Path '[0].type', line 3, position 13.'</p> </blockquote> <pre><code>[ { "type":"line", "a":"-1,5; 3,4", "b":"2,2; 5,7", "color":"127; 255; 255; 255", "lineType":"solid" }, { "type":"circle", "center":"0; 0", "radius":15.0, "filled":false, "color":"127; 255; 0; 0", "lineType":"dot" } ] public abstract class ShapeDto { [JsonProperty(PropertyName = "type")] public abstract string Type { get; } [JsonProperty(PropertyName = "color")] public string Color { get; set; } [JsonProperty(PropertyName = "lineType")] public string LineType { get; set; } } public sealed class LineDto : ShapeDto { public override string Type =&gt; "line"; [JsonProperty(PropertyName = "a")] public string A { get; set; } [JsonProperty(PropertyName = "b")] public string B { get; set; } } public sealed class CircleDto : ShapeDto { public override string Type =&gt; "circle"; [JsonProperty(PropertyName = "center")] public string C { get; set; } [JsonProperty(PropertyName = "radius")] public double R { get; set; } [JsonProperty(PropertyName = "filled")] public bool Filled { get; set; } } var settings = new JsonSerializerSettings {TypeNameHandling = TypeNameHandling.All}; var shapes = JsonConvert.DeserializeObject&lt;IList&lt;ShapeDto&gt;&gt;(json, settings); </code></pre>
<c#><json><json.net><deserialization>
2019-07-27 21:32:48
LQ_CLOSE
57,236,239
Recomendation: how to load dynamically a post with laravel
<p>I need a recommendation. I want to have a sidebar with all the titles of the posts and by clicking on any of them that this is loaded with its content in the main section of the page. The idea is that when loading the page not all the contents of each post are loaded, but only when clicking. What system can I use if I am using Laravel?</p> <p><a href="https://i.stack.imgur.com/xHHEn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xHHEn.png" alt="enter image description here"></a></p>
<php><laravel><post><dynamic>
2019-07-27 21:35:30
LQ_CLOSE
57,237,092
Java: How to make a 2D array of a particular object
<p>I have the following class in Java:</p> <pre><code>public class Cell { private int x; private int y; private int g; private int h; public Cell(int x, int y, int g, int h) { this.x = x; this.y = y; this.g = g; this.h = h; } } </code></pre> <p>I want to make a 2D array with each element of the array being of type Cell. However, I am not sure what is the best way to go about doing this. Any insights are appreciated.</p>
<java><oop>
2019-07-28 00:34:54
LQ_CLOSE
57,237,352
What does "unsqueeze" do in Pytorch?
<p>I'm looking at the documentation, and here is their example. I cannot understand how this example corresponds to their explanation: "Returns a new tensor with a dimension of size one inserted at the specified position."</p> <pre><code>&gt;&gt;&gt; x = torch.tensor([1, 2, 3, 4]) &gt;&gt;&gt; torch.unsqueeze(x, 0) tensor([[ 1, 2, 3, 4]]) &gt;&gt;&gt; torch.unsqueeze(x, 1) tensor([[ 1], [ 2], [ 3], [ 4]]) </code></pre>
<python><pytorch><torch><torchvision>
2019-07-28 01:43:43
HQ
57,239,018
why multiple variable assignment in python terminal throwing syntax error?
<p>I am using python terminal and I am trying to do instantiate multiple variable at once . It throws me an error. The code works fine in an IDE . Can someone helps me understand this behaviour.</p> <pre><code>&gt;&gt;&gt; var1 =10 \ ... var21 = 20 \ File "&lt;stdin&gt;", line 2 var21 = 20 \ ^ SyntaxError: invalid syntax </code></pre>
<python>
2019-07-28 08:04:15
LQ_CLOSE
57,240,452
How do I trim space in an input field?
<p>I am using an input field and when someone types in it they can add spaces as general behavior. I do not want anyone to add spaces into the field and even if someone adds one it should trim there and then.</p> <p>Can someone please help on how to achieve this?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;input type="text"&gt;</code></pre> </div> </div> </p>
<javascript><jquery><html><css>
2019-07-28 11:32:49
LQ_CLOSE
57,240,772
Get the mean of numerical columns in a multi-index datafram
I want to calculate the mean of numerical columns in a multi-index datafram, and append the datafram with the new results as a new row. ```python subject 1 subject 2 subject 3… Country 2017 2018 Frq 2017 Score 2018 Score 2017 2018 Frq 2017 Score 2018 Score Argentina 12 22 100 50. 51. 12 22 100 50. 51. Australia 68 13 150 66. 67. 68 13 150 66. 67. ``` I'v tried using this line, But I get a new row full with nan ```python G20.loc['mean'] = G20.mean(axis=0, numeric_only=True) ``` Thanks
<pandas><mean><multi-index>
2019-07-28 12:10:15
LQ_EDIT
57,240,891
Why is '\n' preferred over "\n" for output streams?
<p>In <a href="https://stackoverflow.com/a/8311177/7151494">this</a> answer we can read that:</p> <blockquote> <p>I suppose there's little difference between using <code>'\n'</code> or using <code>"\n"</code>, but the latter is an array of (two) characters, which has to be printed character by character, for which a loop has to be set up, <strong>which is more complex than outputting a single character</strong>.</p> </blockquote> <p><sup><em>emphasis mine</em></sup></p> <p>That makes sense to me. I would think that outputting a <code>const char*</code> requires a loop which will test for null-terminator, which <em>must</em> introduce more operations than, let's say, a simple <code>putchar</code> (not implying that <code>std::cout</code> with <code>char</code> delegates to calling that - it's just a simplification to introduce an example).</p> <p>That convinced me to use</p> <pre><code>std::cout &lt;&lt; '\n'; std::cout &lt;&lt; ' '; </code></pre> <p>rather than</p> <pre><code>std::cout &lt;&lt; "\n"; std::cout &lt;&lt; " "; </code></pre> <p>It's worth to mention here that I am aware of the performance difference being pretty much negligible. Nonetheless, some may argue that the former approach carries intent of actually passing a single character, rather than a string literal that just happened to be a one <code>char</code> long (<em>two</em> <code>char</code>s long if you count the <code>'\0'</code>).</p> <p>Lately I've done some little code reviesw for someone who was using the latter approach. I made a small comment on the case and moved on. The developer then thanked me and said that he hadn't even thought of such difference (mainly focusing on the intent). It was not impactful at all (unsurprisingly), but the change was adopted.</p> <p>I then began wondering <em>how exactly</em> is that change significant, so I ran to godbolt. To my surprise, it showed the <a href="https://godbolt.org/z/p21Yxb" rel="noreferrer">following results</a> when tested on GCC (trunk) with <code>-std=c++17 -O3</code> flags. The generated assembly for the following code:</p> <pre><code>#include &lt;iostream&gt; void str() { std::cout &lt;&lt; "\n"; } void chr() { std::cout &lt;&lt; '\n'; } int main() { str(); chr(); } </code></pre> <p>surprised me, because it appears that <code>chr()</code> is actually generating exactly twice as many instructions as <code>str()</code> does:</p> <pre><code>.LC0: .string "\n" str(): mov edx, 1 mov esi, OFFSET FLAT:.LC0 mov edi, OFFSET FLAT:_ZSt4cout jmp std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp; std::__ostream_insert&lt;char, std::char_traits&lt;char&gt; &gt;(std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp;, char const*, long) chr(): sub rsp, 24 mov edx, 1 mov edi, OFFSET FLAT:_ZSt4cout lea rsi, [rsp+15] mov BYTE PTR [rsp+15], 10 call std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp; std::__ostream_insert&lt;char, std::char_traits&lt;char&gt; &gt;(std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp;, char const*, long) add rsp, 24 ret </code></pre> <p>Why is that? Why both of them eventually call the same <code>std::basic_ostream</code> function with <code>const char*</code> argument? Does it mean that the <code>char</code> literal approach is not only <em>not better</em>, but actually <em>worse</em> than string literal one?</p>
<c++><performance><cout><string-literals>
2019-07-28 12:27:24
HQ
57,241,039
Show max variable price in shop page
<p>I want to display the maximum variation price in woocommerce shop page under product title. </p> <p>I have tried using this code but does not seem to work, only breaks my site instead.</p> <p>add_filter( ‘woocommerce_variable_sale_price_html’, ‘con_show_max_variation_price_only’, 10, 2 ); add_filter( ‘woocommerce_variable_price_html’, ‘con_show_max_variation_price_only’, 10, 2 );</p> <p>function con_show_max_variation_price_only( $price, $product ) {</p> <p>// Main Variation Price $prices = array( $product->get_variation_price( ‘max’, true ), $product->get_variation_price( ‘min’, true ) );</p> <p>$price = $prices[0] !== $prices[1] ? sprintf( __( ‘%1$s’, ‘woocommerce’ ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );</p>
<variables><woocommerce>
2019-07-28 12:46:11
LQ_CLOSE
57,241,265
Is `seqn` the `sequenceA` limited to monad?
sequenceA :: Applicative f => [f a] -> f [a] sequenceA [] = pure [] sequenceA (x:xs) = pure (:) <*> x <*> sequenceA xs and seqn :: Monad m => [m a] -> m [a] and what is its implementation? Since a monad is an applicative, is `seqn` the `sequenceA` limited to monad? Thanks.
<list><haskell><monads><applicative>
2019-07-28 13:16:04
LQ_EDIT
57,241,459
python regex carriage return
<p>please could you help with the regex to get everything unto the ";"..</p> <pre><code>window.egfunc = { name: "test name", type: "test type", storeId: "12345" }; </code></pre> <p>I have the following which works when all the data would be on one line, but as soon as there are returns, it won't work...</p> <pre><code>window.egfunc\s+=\s+(.*); </code></pre>
<python><regex>
2019-07-28 13:40:47
LQ_CLOSE
57,241,984
y_pred = regressor.predict(6.5) not working
""" whenever I am going to predict, I saw an error. I am stuck with the line "y_pred = regressor.predict(6.5)" in the code. I am getting the error: "ValueError: Expected 2D array, got scalar array instead: array=6.5. Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample." """ Any help would be appreciated. Thank you. spyder # SVR # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('Position_Salaries.csv') X = dataset.iloc[:, 1:2].values y = dataset.iloc[:, 2].values # Feature Scaling from sklearn.preprocessing import StandardScaler sc_X = StandardScaler() sc_y = StandardScaler() X = sc_X.fit_transform(X) y = sc_y.fit_transform(y) # Fitting SVR to the dataset from sklearn.svm import SVR regressor = SVR(kernel = 'rbf') regressor.fit(X, y) # Predicting a new result y_pred = regressor.predict(6.5) """ y_pred = regressor.predict(6.5) Traceback (most recent call last): File "<ipython-input-10-5865c008a8c9>", line 1, in <module> y_pred = regressor.predict(6.5) File "C:\Users\achiever\Anaconda3\lib\site-packages\sklearn\svm\base.py", line 322, in predict X = self._validate_for_predict(X) File "C:\Users\achiever\Anaconda3\lib\site-packages\sklearn\svm\base.py", line 454, in _validate_for_predict accept_large_sparse=False) File "C:\Users\achiever\Anaconda3\lib\site-packages\sklearn\utils\validation.py", line 514, in check_array "if it contains a single sample.".format(array)) ValueError: Expected 2D array, got scalar array instead: array=6.5. Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample."""
<python><spyder>
2019-07-28 14:48:21
LQ_EDIT
57,242,487
How can I copy the <td> value(Command column) by clicking the copy button?
<p><a href="https://preview.linuxcommand.dev/" rel="nofollow noreferrer">https://preview.linuxcommand.dev/</a></p> <p>This is my website I'm trying to build, So right now its static and not dynamic, So all are same command you see that. So I want when the copy button on the right side is clicked, It will copy the command text of that column. I don't want to push a different ID of each . Without this, Is there any way to possible?</p>
<javascript><jquery>
2019-07-28 15:47:57
LQ_CLOSE
57,243,141
ERROR: Command errored out with exit status 1 while installing requirements
<pre><code> ERROR: Command errored out with exit status 1: command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ib3vl4vt/web.py/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ib3vl4vt/web.py/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info cwd: /tmp/pip-install-ib3vl4vt/web.py/ Complete output (7 lines): Traceback (most recent call last): File "&lt;string&gt;", line 1, in &lt;module&gt; File "/tmp/pip-install-ib3vl4vt/web.py/setup.py", line 6, in &lt;module&gt; from web import __version__ File "/tmp/pip-install-ib3vl4vt/web.py/web/__init__.py", line 14, in &lt;module&gt; import utils, db, net, wsgi, http, webapi, httpserver, debugerror ModuleNotFoundError: No module named 'utils' ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. </code></pre> <p>While installing requirements.txt in InsecureBankv2/AndroLabServer, I got this errors. Because of these problems, It seems like InsecureBankv2 app won't login to my server.</p> <p>What should I do to solve this problem?</p>
<python><android>
2019-07-28 17:04:12
HQ
57,243,431
Segmentation fault (code dumped) in this line "dets[count].prob[j] = (prob > thresh) ? prob : 0;" in YOLOv3
I want to use YOLOv3 algorithm for detection. I am using intel's DE10 Nano FPGA board with Linux installed. When I built YOLOv3 (from original source) and ran it, I am getting error "Segmentation fault(core dumped)". I did lot of googling and research but none of them helped to fix this issue. I used pre-built weights and configuration files i.e I ran the below command "./darknet detect cfg/yolov3-tiny.cfg yolov3-tiny.weights data/dog.jpg" but got the error as stated above.But the same thing runs with out any hiccups on my computer and several others, but not on my Devboard. Then I started debugging(lot of printf statements) the code from "darknet.py" in "python" directory and found that the error resides in "yolo_layer.c" file line.no.336-> "dets[count].prob[j] = (prob > thresh) ? prob : 0;" in "get_yolo_detections" function. I have no idea how to fix this. Please help. I've followed function to function and file to file to see where the error is from. int get_yolo_detections(layer l, int w, int h, int netw, int neth, float thresh, int *map, int relative, detection *dets) { int i,j,n; float *predictions = l.output; if (l.batch == 2) avg_flipped_yolo(l); int count = 0; for (i = 0; i < l.w*l.h; ++i){ int row = i / l.w; int col = i % l.w; for(n = 0; n < l.n; ++n){ int obj_index = entry_index(l, 0, n*l.w*l.h + i, 4); float objectness = predictions[obj_index]; if(objectness <= thresh) continue; int box_index = entry_index(l, 0, n*l.w*l.h + i, 0); dets[count].bbox = get_yolo_box(predictions, l.biases, l.mask[n], box_index, col, row, l.w, l.h, netw, neth, l.w*l.h); dets[count].objectness = objectness; dets[count].classes = l.classes; for(j = 0; j < l.classes; ++j){ int class_index = entry_index(l, 0, n*l.w*l.h + i, 4 + 1 + j); float prob = objectness*predictions[class_index]; //|||||||error in below line|||||||| dets[count].prob[j] = (prob > thresh) ? prob : 0; //^^--error in the above line(got from debugging) } ++count; } } correct_yolo_boxes(dets, count, w, h, netw, neth, relative); return count; }
<c><image-processing><segmentation-fault><fpga><yolo>
2019-07-28 17:38:09
LQ_EDIT
57,243,658
I writed Random Password Generator in C. But my code erroring. What is the problem? Please send me the solutions. Thanks
I writed Random Password Generator in C. But my code erroring. What is the problem? Please send me the solutions. Thanks... #include <stdio.h> #include <stdlib.h> #include <time.h> int main(){enter code here srand((unsigned int)(time(NULL))); int k_sayi,i; srand((unsigned int)(time(NULL))); char kucuk_harf[26]="abcdefghijklmnoprstuvwxyz"; char buyuk_harf[26]="ABCDEFGHIJKLMNOPRSTUVWXYZ"; char sayilar[11]="1234567890"; char ozel_karakter[13]="!'^+%&/=?_*"; char *pass; printf("Parola kac karakterli olsun?: "); scanf("%d",&k_sayi); pass=(char *)malloc(k_sayi*sizeof(char)); for(i=0;i<k_sayi;i++){ pass[i]=rand()%(sizeof kucuk_harf); } pass[i]='\0'; printf("%s",pass); return 0; }
<c><password-generator>
2019-07-28 18:05:44
LQ_EDIT
57,243,978
Efficient way of parsing string
<p>How would you turn a string that looks like this</p> <p><code>7.11,8,9:00,9:15,14:30,15:00</code></p> <p>into this dictionary entry </p> <p><code>{7.11 : [8, (9:00, 9:15), (14:30, 15:00)]}</code>?</p> <p>Suppose that the number of time pairs (such as <code>9:00,9:15</code> and <code>14:30,15:00</code> is unknown and you want to have them all as tuple pairs.</p>
<python><string><parsing>
2019-07-28 18:47:29
LQ_CLOSE
57,244,026
python regex with multiple separators
<p>I am trying to separate all the images from the following string.</p> <p>how can I get a list of images that start with "comp1/img_" and are either split by a "," or a ";"</p> <pre><code> /*jsonp*/jsonresp({"img_set":"comp1/img_23434;comp1/img_3243r43r,comp1/img_o43nfjr;comp1/img_wjfno43,comp1/img_nrejfner;comp1/img_jrenckerjv,comp1/img_23434k;comp1/img_rkfnk4n"},"fknreff\","); </code></pre> <p>so I would end up with a list like...</p> <pre><code>comp1/img_23434 comp1/img_3243r43r comp1/img_o43nfjr comp1/img_wjfno43 comp1/img_nrejfner comp1/img_jrenckerjv comp1/img_23434k comp1/img_rkfnk4n </code></pre> <p>any help would be appreciated. thanks</p>
<python><regex>
2019-07-28 18:53:13
LQ_CLOSE
57,244,465
Why JavaScript parses data wrongly?
<p>There are two strange things:</p> <ul> <li>day 30 instead of 31?</li> <li><p>it set 13 as time instead of 00?</p> <pre><code>new Date('Dec 31, 2019').toISOString() // '2019-12-30T13:00:00.000Z' </code></pre></li> </ul> <p>Basically what I'm trying to do is to convert original data format into <code>YYYY-MM-DD</code>.</p>
<javascript>
2019-07-28 19:54:02
LQ_CLOSE
57,244,713
Get index in ForEach in SwiftUI
<p>I have an array and I want to iterate through it initialize views based on array value, and want to perform action based on array item index</p> <p>When I iterate through objects</p> <pre class="lang-swift prettyprint-override"><code>ForEach(array, id: \.self) { item in CustomView(item: item) .tapAction { self.doSomething(index) // Can't get index, so this won't work } } </code></pre> <p>So, I've tried another approach</p> <pre class="lang-swift prettyprint-override"><code>ForEach((0..&lt;array.count)) { index in CustomView(item: array[index]) .tapAction { self.doSomething(index) } } </code></pre> <p>But the issue with second approach is, that when I change array, for example, if <code>doSomething</code> does following</p> <pre><code>self.array = [1,2,3] </code></pre> <p>views in <code>ForEach</code> do not change, even if values are changed. I believe, that happens because <code>array.count</code> haven't changed. </p> <p>Is there a solution for this? Thanks in advance.</p>
<swift><swiftui>
2019-07-28 20:26:42
HQ
57,245,693
Notice: Array to string conversion in C:\xampp\htdocs\Employ\index.php on line 36
I want to insert data into the database using form but I'm getting error. What can I do to solve this? My code is follows I've tried several way to bug it but not working $country = mysqli_real_escape_string($conn, $_POST['country']); $zip = mysqli_real_escape_string($conn, $_POST['zip']); $identity =($_FILES['identity']); $fileName = $_FILES['identity']['name']; $fileTmpName = $_FILES['identity']['tmp_name']; $fileSize = $_FILES['identity']['size']; $fileError = $_FILES['identity']['error']; $fileType = $_FILES['identity']['type']; $fileExt = explode('.', $fileName); $fileActualExt = strtolower(end($fileExt)); $allow = array('jpg', 'jpeg', 'png',); if (in_array($fileActualExt, $allow)) { if ($fileError === 0) { if ($fileSize < 1000000) { $fileNameNew = uniqid('', true).".".$fileActualExt; $fileDestination = 'uploads/'.$fileNameNew; move_uploaded_file($fileTmpName, $fileDestination); $sql = "INSERT INTO applicants (name, email, gender, dob, mobile, accounts, occupation, ssn, m_status, address1, address2, city, country, zip, identity) VALUES ('$name', '$email', '$gender', '$dob', '$mobile', '$accounts', '$occupation', '$ssn', '$m_status', '$address1', '$address2', '$city', '$country', '$zip', '$identity')"; $insert = mysqli_query($conn, $sql);
<php><mysql><sql>
2019-07-28 23:26:36
LQ_EDIT
57,245,902
Can someone explain this behavior with Python?
<p>Can someone explain this behavior?</p> <pre><code>print("%.2f" % (model.x[1].value)) X = int(model.x[1].value) print("%.2f" % X) </code></pre> <p>Output:</p> <pre><code>3.00 2.00 </code></pre> <p>Thanks</p>
<python><integer><double>
2019-07-29 00:18:08
LQ_CLOSE
57,246,109
Extract text from specific HTML tag
<p>I'm coding little script and I've faced this problem</p> <p>now I have this HTML code</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="domains"&gt; &lt;ul&gt; &lt;li class="noMessages"&gt; &lt;a href="select-admin-domain.do?domain=ex1.com"&gt;ex1.com&lt;/a&gt; &lt;/li&gt; &lt;li class="noMessages"&gt; &lt;a href="select-admin-domain.do?domain=ex2.com"&gt;ex2.com&lt;/a&gt; &lt;/li&gt; &lt;li class="cpCurrentDomain noMessages"&gt; &lt;a href="select-admin-domain.do?domain=ex3.com"&gt;ex3.com&lt;/a&gt; &lt;/li&gt; &lt;li class="noMessages"&gt; &lt;a href="select-admin-domain.do?domain=ex4.com"&gt;ex4.com&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt;</code></pre> </div> </div> now i want to extract the text from all this html tag using PHP</p> <pre><code>&lt;a href="select-admin-domain.do?domain=ex1.com"&gt;ex1.com&lt;/a&gt; &lt;a href="select-admin-domain.do?domain=ex2.com"&gt;ex2.com&lt;/a&gt; &lt;a href="select-admin-domain.do?domain=ex3.com"&gt;ex3.com&lt;/a&gt; &lt;a href="select-admin-domain.do?domain=ex4.com"&gt;ex4.com&lt;/a&gt; </code></pre> <p>so the output become ex1.com ex2.com etc..</p> <p>i've make this code</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php function GetStr($string,$start,$end){ $str = explode($start, $string); $str = explode($end, $str[1]); echo $str[0]; } $ss= getStr($htmlcode,'&lt;a href="select-admin-domain.do?domain=','"&gt;'); echo $ss;</code></pre> </div> </div> </p> <p>it works good but it only gives me the first output ex1.com and I want to echo all of them not just 1</p>
<php><html><regex>
2019-07-29 01:00:07
LQ_CLOSE
57,246,574
Can a C function modify the value of its input arguments in the calling function?
<p>Can a C function modify the value of its input arguments in the calling function?</p> <p>Could you provide an example.</p>
<c>
2019-07-29 02:30:32
LQ_CLOSE
57,251,951
Calculate total number of levels of nesting paranthesis for each letter in input string
I have input string ``` `(a ( b c ) ( d ( e ) ) )` ``` I want to calculate total number of nested paranthesis for each character ``` for example output should be for a -> 1 b and c and d -> 2 and for e -> 3 ```
<ruby>
2019-07-29 10:31:28
LQ_EDIT
57,252,341
SpringBoot How to find records by nested attributes
<p>I have a <strong>User</strong> model which has certain Attributes as depicted below</p> <pre><code>/** * The Class User. */ @Entity @Table(name = "user") public class User implements UserDetails { /** The Constant serialVersionUID. */ private static final long serialVersionUID = 3961569938206826979L; /** The id. */ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; /** The first name. */ private String firstName; /** The last name. */ private String lastName; /** The username. */ @NotNull @Size(min = 10, message = "username should have atleast 10 characters") private String username; /** The password. */ private String password; /** The email. */ private String email; /** The enabled. */ private boolean enabled; /** The last password reset date. */ private ZonedDateTime lastPasswordResetDate; /** The creation date. */ private ZonedDateTime creationDate; /** The phone number. */ private String phoneNumber; private String deviceId; /** The authorities. */ @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinTable(name = "user_authority", joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "authority_id", referencedColumnName = "id")) private List&lt;Authority&gt; authorities; /** * Gets the id. * * @return the id */ public long getId() { return id; } /** * Sets the id. * * @param id the new id */ public void setId(long id) { this.id = id; } /** * Gets the first name. * * @return the first name */ public String getFirstName() { return firstName; } /** * Sets the first name. * * @param firstName the new first name */ public void setFirstName(String firstName) { this.firstName = firstName; } /** * Gets the last name. * * @return the last name */ public String getLastName() { return lastName; } /** * Sets the last name. * * @param lastName the new last name */ public void setLastName(String lastName) { this.lastName = lastName; } /** * Sets the username. * * @param username the new username */ public void setUsername(String username) { this.username = username; } /* * (non-Javadoc) * * @see org.springframework.security.core.userdetails.UserDetails#getPassword() */ public String getPassword() { return password; } /** * Sets the password. * * @param password the new password */ public void setPassword(String password) { this.password = password; } /* * (non-Javadoc) * * @see * org.springframework.security.core.userdetails.UserDetails#getAuthorities() */ @Override public Collection&lt;? extends GrantedAuthority&gt; getAuthorities() { return authorities; } /* * (non-Javadoc) * * @see org.springframework.security.core.userdetails.UserDetails#getUsername() */ @Override public String getUsername() { return username; } /* * (non-Javadoc) * * @see * org.springframework.security.core.userdetails.UserDetails#isAccountNonExpired * () */ @Override public boolean isAccountNonExpired() { return true; } /* * (non-Javadoc) * * @see * org.springframework.security.core.userdetails.UserDetails#isAccountNonLocked( * ) */ @Override public boolean isAccountNonLocked() { return true; } /* * (non-Javadoc) * * @see org.springframework.security.core.userdetails.UserDetails# * isCredentialsNonExpired() */ @Override public boolean isCredentialsNonExpired() { return true; } /* * (non-Javadoc) * * @see org.springframework.security.core.userdetails.UserDetails#isEnabled() */ @Override public boolean isEnabled() { return enabled; } /** * Gets the email. * * @return the email */ public String getEmail() { return email; } /** * Sets the email. * * @param email the new email */ public void setEmail(String email) { this.email = email; } /** * Gets the last password reset date. * * @return the last password reset date */ public ZonedDateTime getLastPasswordResetDate() { return lastPasswordResetDate; } /** * Sets the last password reset date. * * @param lastPasswordResetDate the new last password reset date */ public void setLastPasswordResetDate(ZonedDateTime lastPasswordResetDate) { this.lastPasswordResetDate = lastPasswordResetDate; } /** * Sets the enabled. * * @param enabled the new enabled */ public void setEnabled(boolean enabled) { this.enabled = enabled; } /** * Sets the authorities. * * @param authorities the new authorities */ public void setAuthorities(List&lt;Authority&gt; authorities) { this.authorities = authorities; } /** * Gets the creation date. * * @return the creation date */ public ZonedDateTime getCreationDate() { return creationDate; } /** * Sets the creation date. * * @param creationDate the new creation date */ public void setCreationDate(ZonedDateTime creationDate) { this.creationDate = creationDate; } /** * Gets the phone number. * * @return the phone number */ public String getPhoneNumber() { return phoneNumber; } /** * Sets the phone number. * * @param phoneNumber the new phone number */ public void setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; } public String getDeviceId() { return deviceId; } public void setDeviceId(String deviceId) { this.deviceId = deviceId; } /* * (non-Javadoc) * * @see java.lang.Object#toString() */ @Override public String toString() { return "User [id=" + id + ", email=" + email + ", firstName=" + firstName + ", lastName=" + lastName + ", password=" + password + ", enabled=" + enabled + ", lastPasswordResetDate=" + lastPasswordResetDate + ", authorities=" + authorities + "]"; } } </code></pre> <p>The <strong>Authority</strong> model has following attributes :</p> <pre><code>/** * The Class Authority. */ @Entity public class Authority implements GrantedAuthority { /** The Constant serialVersionUID. */ private static final long serialVersionUID = -7546748403961204843L; /** The id. */ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; /** The name. */ @Enumerated(EnumType.STRING) private UserRoleName name; /* (non-Javadoc) * @see org.springframework.security.core.GrantedAuthority#getAuthority() */ @Override public String getAuthority() { return name.name(); } /** * Gets the id. * * @return the id */ public long getId() { return id; } /** * Sets the id. * * @param id the new id */ public void setId( long id ) { this.id = id; } /** * Gets the roles. * * @return the roles */ @JsonIgnore public UserRoleName getRoles() { return name; } /** * Sets the roles. * * @param name the new roles */ public void setRoles( UserRoleName name ) { this.name = name; } /** * Sets the name. * * @param name the new name */ public void setName( UserRoleName name ) { this.name = name; } /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { return "Authority [id=" + id + ", name=" + name + "]"; } } </code></pre> <p>Now I need to fetch user whose Role is <strong>ROLE_ADMIN</strong>. So do I first need to fetch the object of <strong>Authority</strong> having role as <strong>ROLE_ADMIN</strong> and then call <strong>findOneByAuthority</strong>, or is there something possible with one function?</p> <p>I am comming from <strong>Django</strong> where fetching a record by nested attributes is very simple? Someone can help me in this?</p>
<java><spring-boot><jpa><orm>
2019-07-29 10:55:29
LQ_CLOSE
57,252,610
Need to Extract multi value key pare using regex
In My Web test project one request return below json in body tag. And I wants to extract all TimeEntryIds of Each FieldItem. using single RegEx extractor (Post porcessors) because I need to pass each TimeEntryid in successive web request. { "InvoiceItemId": 0, "JobId": 9999, "CreatedDate": "0001-01-01T00:00:00Z", "LastUpdatedDate": "0001-01-01T00:00:00Z", "FieldItem": [ { "root": false, "TimeEntryId": 1, "UpdatedDate": "2019-07-19T13:14:29.823Z" }, { "root": false, "TimeEntryId": 2, "UpdatedDate": "2019-07-19T13:14:29.823Z" }, { "root": false, "TimeEntryId": 3, "UpdatedDate": "2019-07-19T13:14:29.823Z" }, { "root": false, "TimeEntryId": 4, "UpdatedDate": "2019-07-19T13:14:29.823Z" } ] } Is there any short cut to get the all Key\Value pare in single RegEx extractor.
<json><regex><jmeter>
2019-07-29 11:12:12
LQ_EDIT
57,253,274
i am stuck about a formula to work out a workbook
i want to work the following. i am using this formula =ARRAYFORMULA(Split(Transpose(Split(Query(Transpose(query(transpose(if(Input!B2:I<>"", ";"&Input!A2:A&"\"&Input!B2:I, )) ,,999^99)),,999^99), ";")), "\")) but it does not give the desired results. Here is the desired output 'Automatically restructure all data from input tab as "Example Output" tab illustrates No rows for "blank" cells in the input tab Use formula(s) only in the first row - i.e. no need to drag cells down the entire sheet, and this tab auto updates when new entry made in Input tab" get the sheets on this link https://docs.google.com/spreadsheets/d/1SY2k_yYb-YLWMUn-AYvxxYZLceOC5iMOjpBIDGhMUks/edit?usp=sharing and give ideas on how to improve the formula or insights into how you can do it differently
<google-sheets><google-sheets-formula><array-formulas><google-sheets-query><google-query-language>
2019-07-29 11:49:52
LQ_EDIT
57,255,351
OOP Inheritance homework (Animal to lion super class inheritance)
<p>I need to: Extend the animal class with a Lion class and have different features(done).</p> <p>Add a field called Liontype class and add a method classifying the lion type per its weight.(Needs to be derived from the superclass)</p> <p>And print it out.</p> <p>There are errors in my code and I've been trying to fix it. Thank for any assistance in advance.</p> <pre><code>public class Animal { private int numTeeth = 0; private boolean spots = false; private int weight = 0; public Animal(int numTeeth, boolean spots, int weight){ this.setNumTeeth(numTeeth); this.setSpots(spots); this.setWeight(weight); } public int getNumTeeth(){ return numTeeth; } public void setNumTeeth(int numTeeth) { this.numTeeth = numTeeth; } public boolean getSpots() { return spots; } public void setSpots(boolean spots) { this.spots = spots; } public int getWeight() { return weight; } public void setWeight(int weight) { this.weight = weight; } } //Extend animal class public class Lion extends Animal{ public Lion (int numTeeth, boolean spots, int weight){ super(numTeeth, spots, weight); //Add new attributes int age = 0; int cubs = 0; } public static void main(String args[]){ //Create lions and assign attributes Lion lion1 = new Lion(); lion1.numTeeth = 12; lion1.spots = 1; lion1. weight = 86; lion1.age = 7; lion1.cubs = 3; //Print attributes System.out.println("Lion1 attributes:"); System.out.println("Number of teeth : " + numTeeth); System.out.println("Number of spots : " + spots); System.out.println("Weight of lion : " + weight + " kgs"); System.out.println("Age : " + age); System.out.println("No of cubs : " + cubs); System.out.println(" "); Lion lion2 = new Lion(); lion2.numTeeth = 16; lion2.spots = 0; lion2. weight = 123; lion2.age = 13; lion2.cubs = 5; System.out.println("Lion2 attributes:"); System.out.println("Number of teeth : " + numTeeth); System.out.println("Number of spots : " + spots); System.out.println("Weight of lion : " + weight + " kgs"); System.out.println("Age : " + age); System.out.println("No of cubs : " + cubs); System.out.println(" "); } public class Liontype{ //Trying to get weight from another class public Integer getWeight() { if (weight &gt; 120) { System.out.println("This lion is a cub"); } else if (weight &gt;= 120 &amp;&amp; weight &lt; 180) { System.out.println("This lion is a female"); } else if (weight &gt;= 180) { System.out.println("This lion is a male"); } } } } Expected outcome: Lion attributes: Number of teeth : 16 Spots : true Weight of lion : 83kgs Age : 13 No of cubs : 3 This lion is a female </code></pre>
<java><inheritance>
2019-07-29 13:52:19
LQ_CLOSE
57,257,925
Java: Constructing a class within an arraylist initialiser causes an error
<p>I've got a constructor that takes a parameter <code>ArrayList&lt;Setting&gt; settings</code>. </p> <p>Now the problem is that I wrote the following call in a subclass:</p> <pre><code>super(new ArrayList&lt;Setting&gt;(){new Setting("", this, 0)}); </code></pre> <p>This causes a lot of errors, the main one being <code>Invalid method declaration; return type required</code>, as well as <code>'{' or ';' expected</code>, <code>Parameter expected</code>, <code>Unexpected token</code> and <code>Constructor Setting() is never used</code>.</p> <p>I tried switching to using regular arrays and it worked fine:</p> <pre><code>super(new Setting[]{new Setting("Exp Only", this, false)}); </code></pre> <p>For now, I'm happy just using regular arrays, however I come across this error rather frequently, is there something I'm doing wrong or is this just the way it is, and if so, why?</p>
<java><arrays><class><arraylist>
2019-07-29 16:29:11
LQ_CLOSE
57,258,270
How to calculate math operations in textBox?
<p><a href="https://i.stack.imgur.com/beWnP.jpg" rel="nofollow noreferrer">App image</a></p> <p>Hi guys, I'm a beginner in programming and I'm trying to make a math game. I don't know how to make a program calculate whats inside of the textbox. When player clicks a button with number or operator, app writes that in a textBox under the buttons. After clicking 'OK' app should compare number on the top(303) with players calculation. Any ideas how to make this work?</p>
<c#>
2019-07-29 16:54:58
LQ_CLOSE
57,258,319
Как выполнить обработку некоторых строк совпадающих с регулярным выражением?
У меня есть таблица вида: id, name(text), characteristics(text), 1, 'ivan', 'lier, tall' 2, 'michailmichail', 'gnorts, wol, rtams' 3, 'sergei', 'smart' Как выполнить функцию обработки строк совпадающие с регулярным выражением, так чтобы в результирующей таблице оставались все значения? Переворачивать значения колонки characteristics если в name имя повторяется несколько раз! Результирующая таблица должна быть: id, name(text), characteristics(text), 1, 'ivan', 'lier, tall' 2, 'michailmichail', 'smart, low, strong' 3, 'sergei', 'smart' Это регулярное выражение проходит проверку но не работает после WHERE '\b(\w+)+\1\b'. И я не знаю как обработать строки совпадающие с re и вывести все значения столбца. Буду благодарен за любую помощь! SELECT name, reverse(characteristics) as characteristics FROM table WHERE name ~* 'regexp'
<sql><regex><postgresql>
2019-07-29 16:57:52
LQ_EDIT
57,258,371
SwiftUI: Increase tap/drag area for user interaction
<p>I've built a custom slider in SwiftUI with a thumb dragger that is 20x20. Everything is working, except the tap target is quite small since it's just the 20x20 view. I'm looking for a way to increase this to make it easier for users to interact with my slider. Is there a way to do this in SwiftUI?</p> <p>I tried wrapping my thumb in <code>Color.clear.overlay</code> and setting the frame to 60x60. This works if the color is solid, like <code>red</code>, but with <code>clear</code> the tap target seems to revert back to visible pixels of 20x20.</p> <p>You can see on this gif I'm able to drag the slider even when clicking outside of the thumb.</p> <p><a href="https://i.stack.imgur.com/KiCiF.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/KiCiF.gif" alt="slider with red background"></a></p> <p>However, as soon as I change the color to <code>clear</code>, this area no longer receives interactions.</p> <p><a href="https://i.stack.imgur.com/Y96SV.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/Y96SV.gif" alt="slider with clear background"></a></p>
<swift><swiftui>
2019-07-29 17:01:44
HQ
57,258,782
store multiple value in same column seprated by comma
<p>String: 23456,16524,84755,98457,06978,05986,73454,34785 </p> <h2>Result</h2> <p>23456</p> <p>16524 </p> <p>84755 </p> <p>98457 </p> <p>06978 </p> <p>05986 </p> <p>73454 </p> <p>34785</p>
<php><mysql>
2019-07-29 17:31:52
LQ_CLOSE
57,260,775
sql to retrieve username and password from 3 tables
i have to retrieve username and password from 3 tables (user1, user2, admin, having username and password in each table) with no foreign keys. ... SqlCommand cmd = new SqlCommand("select * from user1 UNION select * from user2 union select * from admin where username=@username and password=@password", con); ...
<c#><sql-server><select><where-clause>
2019-07-29 20:11:27
LQ_EDIT
57,260,987
Python3: Remove Duplicate Key-Value Pair and Add Array
I have an ordered dictionary and an array of int both of the same index size: ``` Dict = {“A”: “Apple”, “A”: “Ant”, “A”: “Apple”, “B”: “Ball”, “B”: “Beach”, “C”: “Cat, “C”: “Cat”, “D”: “Ball”} Arr = [1, 2, 3, 4, 5, 6, 7, 8] ``` I want to remove duplicates in the dictionary (non-unique key-value pairs) and also sum the ints in the array as such: ``` New Dict = {“A”: “Apple”, “A”: “Ant”, “B”: “Ball”, “B”: “Beach”, “C”: “Cat, “D”: “Ball”} New Arr = [4, 2, 4, 5, 13, 8] ``` Any suggestions on an elegant way to approach this problem?
<python><python-3.x><list><dictionary>
2019-07-29 20:31:29
LQ_EDIT
57,261,024
Python Django Errno 54 'Connection reset by peer'
<p>Having some trouble debugging this. I get this error always when i first start my app up, then intermittently thereafter. Could someone please help me by throwing out some debugging techniques? I've tried using a proxy inspector - to no avail, i didn't see anything useful. I've tried the suggestions about setting my SITE_URL in my django settings. I've tried with and without http:// with and without the port... Here's the unhelpful error:</p> <pre><code>Exception happened during processing of request from ('127.0.0.1', 57917) Traceback (most recent call last): File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 650, in process_request_thread self.finish_request(request, client_address) File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 360, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 720, in __init__ self.handle() File "/Users/ryan/.local/share/virtualenvs/portal-2PUjdB8V/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 171, in handle self.handle_one_request() File "/Users/ryan/.local/share/virtualenvs/portal-2PUjdB8V/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 179, in handle_one_request self.raw_requestline = self.rfile.readline(65537) File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py", line 589, in readinto return self._sock.recv_into(b) ConnectionResetError: [Errno 54] Connection reset by peer </code></pre> <p>The app seems to function properly even with this connection reset but it's been driving me crazy trying to debug.</p>
<python><django><sockets>
2019-07-29 20:34:37
HQ
57,262,742
How to make round corners for image with percent icon?
How to make round corners for image with percent icon? I try to use negative margin for imageView but is not works. Thx. <LinearLayout android:gravity="center_vertical" android:layout_marginTop="15dp" android:layout_gravity="top|center" android:background="@drawable/rounded_background_white" android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content"> <ImageView android:src="@drawable/ic_discount_percent" android:layout_marginLeft="-3dp" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <TextView android:textColor="@android:color/black" android:layout_marginLeft="8dp" android:text="Скидка 10%" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout> [![I need this][1]][1] [![Problem this][2]][2] [1]: https://i.stack.imgur.com/lG63U.png [2]: https://i.stack.imgur.com/0wVM6.png
<android><imageview>
2019-07-30 00:15:12
LQ_EDIT
57,263,872
How to get a variable from array when getting response from api call?
After successfully logging in for a 3rd party API access, using the following code: $response = Requests::post('https://apidomain.com/v3/account/login/api', $headers, $data); When I print: echo '<pre>'; print_r($response); echo '</pre>'; I get the following: Requests_Response Object ( [body] => {"access_token":"blabla",".issued":"2019-07-30T02:47:14.4326684Z",".expires":"2019-08-01T02:47:14.4326686Z"} [raw] => HTTP/1.1 200 OK etc... Now I want to access the access_token as a variable so that I can pass for further processing. I tried to access like: $access_token=$response[body'] and $access_token=$response[1][body'] Unfortunately nothing worked. Any help will be appreciated.
<php>
2019-07-30 03:19:50
LQ_EDIT
57,264,285
Is it possible to convert this curl command to PHP?
<p>Is it possible to convert this curl command to PHP? </p> <pre><code>curl -F file=@filename https://any.website.com/ </code></pre>
<php><curl>
2019-07-30 04:27:25
LQ_CLOSE
57,264,405
Hi.. How to pull a Dockerfile from github (after edited) via Jenkins and run it on a remote server
Let's say I have a public repo (Github), my file looks like that: docker build -t abrakadabra40404 . I changed it to: docker build -t abrakadabra40404111111111 . Now I want Jenkins to pull this file and run it on my server where docker was installed. what should I write in the execute shell ???? *All other configurations have been made
<docker><jenkins>
2019-07-30 04:42:22
LQ_EDIT
57,266,585
What is the right granularity for a microsrevice?
<p>We have a site that compares flight fares and books tickets via API calls to the aggregators who provide us with flight inventory and fares. Payment for tickets happen via API calls to paymentgateways from our site. We have similar capability for hotel booking. Hotel booking and flight booking are implemented as separate services using Lumen. Since hotel booking also uses the same payment gateways as flight, we end up duplicating that code under Hotel Services. May be it is a better idea to convert payment into a separate microservice. The question is, what is the right granularity for a micro service?</p>
<laravel><microservices><lumen>
2019-07-30 07:38:14
LQ_CLOSE
57,269,595
why there is different output for below two codes?
<p>The below program outputs false</p> <pre><code> String s1="a"; String s2="b"; String s3=s1+s2; String s4="ab"; if(s3==s4) { System.out.println("true"); } else { System.out.println("false"); } </code></pre> <p>and this code outputs true</p> <pre><code>String s3="a"+"b"; String s4="ab"; if(s3==s4) { System.out.println("true"); } else { System.out.println("false"); } </code></pre> <p>Shouldn't the output in first case be true? As while creating String s4="ab" there is already an object with value "ab" in the string constant pool.</p>
<java><string>
2019-07-30 10:28:16
LQ_CLOSE
57,270,436
how does 100% - 40 works in java?
how does 100% - 40 works in java ? ```java System.out.println(100% - 40); ``` please explain the steps taken by compiler takes for it to resolve. like I understand % is an operator which takes two operand to work but how it is accepting other operator like "-" minus in this case.
<java><operators><modulo><unary-operator>
2019-07-30 11:19:45
LQ_EDIT
57,272,564
What HTML element for semantic sidenotes?
<p>I like to add responsive sidenotes to my blog posts. Responsive as in: hidden on small viewports, visible in the margin on wide viewports.</p> <p>When hidden on small screens, a visible element ('link') is needed indicating there's more to read. My solution for this so far is: </p> <pre><code>&lt;p&gt;Some sentence with &lt;span class="sidenote" onclick="this.classList.toggle('active');"&gt; underlined text &lt;span class="sidenote__content"&gt; Sidenote content &lt;/span&gt; &lt;/span&gt;, which is clickable on small viewports.&lt;/p&gt; </code></pre> <p>(with added line breaks for readability)</p> <p>With CSS I add asterisks to both the underlined text and the sidenote content to visually connect them on large screens.</p> <p>The problems with this solution are that the <code>sidenote__content</code> correct display depends on CSS. It's shown in readers like Pocket, with:</p> <ul> <li>The sidenote content showing up mid sentence without any visual cues</li> <li>No space between the underlined text and the sidenote content. </li> </ul> <p>I'm hoping that there's a more semantic solution than simple spans. <code>&lt;aside&gt;</code> and <code>&lt;section&gt;</code> can't be used as they're block elements and <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/p" rel="noreferrer">can automatically close</a> the parent's p element.</p> <p>A solution could be to separate the sidenote content from the link. However I'd prefer to keep the set of sidenote and its link as one set or pair, so they can be inserted as such into posts. Splitting them up would require javascript logic to match links with their content and can cause maintenance issues when one half of the set is missing.</p>
<html><semantic-markup>
2019-07-30 13:12:13
HQ
57,272,982
why i can not write subroutine between do and write?
[enter image description here][1] [enter image description here][2]com/UqpSq.png [1]: https://i.stack.imgur. [2]: https://i.stack.imgur.com/El05K.png
<sap><abap>
2019-07-30 13:31:23
LQ_EDIT
57,273,428
Whats going wrong in the attached image?
I'm not able to set the below array of objects to the User class in TypeScript. let user: User[] = [{name: 'Naveen', address: [{'city': 'Bangalore'}]}]; ```class User { private name: string; private address: Address[]; constructor(name: string, address: Address[]) { this.name = name; this.address = address; } public set _name(name: string) { this.name = name; } public get _name() { return this.name; } } class Address { private city: string; constructor(city: string) { this.city = city; } public set _city(city: string) { this.city = city; } public get _city() { return this.city; } } let user: User[] = [{name: 'Naveen', address: [{'city': 'Bangalore'}]}];
<typescript>
2019-07-30 13:55:15
LQ_EDIT
57,274,188
In "h2, h3 a {}", who is a's parent element?
<p>In the following CSS code:</p> <pre><code>h2, h3 a { color: black; } </code></pre> <p>Is a's parent element h3, h2, or both?</p>
<css><inheritance>
2019-07-30 14:35:50
LQ_CLOSE
57,274,992
How to get a default string value from resources in SafeArgs?
<p>I'm just learning a Android NavigationUI, and try set a toolbar title using string default value from Safe Args. But have some problem about it.</p> <p>'String resources' file:</p> <pre><code> &lt;string name="title_add_item"&gt;Add new items&lt;/string&gt; </code></pre> <p>Navigation graph file. Set label as <code>Title: {title}</code> argument.</p> <pre><code>&lt;navigation xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/nav_graph" app:startDestination="@id/mainFragment"&gt; &lt;fragment android:id="@+id/addNewItemFragment" android:name="com.myapplication.AddNewItemFragment" android:label="Title: {title}" tools:layout="@layout/fragment_add_new_item" &gt; &lt;argument android:name="title" app:argType="string" android:defaultValue="@string/title_add_item" /&gt; &lt;/fragment&gt; &lt;fragment android:id="@+id/mainFragment" android:name="com.myapplication.MainFragment" android:label="fragment_main" tools:layout="@layout/fragment_main" &gt; &lt;action android:id="@+id/action_to_add_items_fragment" app:destination="@id/addNewItemFragment" /&gt; &lt;/fragment&gt; </code></pre> <p></p> <p>If <code>{app:argType="string"}</code> I got an error :</p> <pre><code> Caused by: org.xmlpull.v1.XmlPullParserException: unsupported value 'Add new items' for string. You must use a "reference" type to reference other resources. </code></pre> <p>If <code>{app:argType="reference"}</code> app works, but i have a number in title (i think it's a resource id):</p> <p><a href="https://i.stack.imgur.com/iWOIS.png" rel="noreferrer"><img src="https://i.stack.imgur.com/iWOIS.png" alt="enter image description here"></a></p> <p>Of course I can assign the value of the toolbar title in the code by getting it from the arguments. But is it possible to change this code so that the title filled in correctly?</p>
<android><string><androidx><android-navigation><android-safe-args>
2019-07-30 15:17:27
HQ
57,275,987
Access strings which is inside the list
Python list has ['12:30','12:45'] and I want to access the '12:30' for the first iteration and the second iteration I should get '12:45' my_list=['12:30','12:45'] for each_value in my_list: print(each_value[0]) my_list=['12:30','12:45'] for each_value in my_list: print(each_value[0]) The expected result is '12:30' but the acutal output is '1'
<python><python-3.x>
2019-07-30 16:18:25
LQ_EDIT
57,277,345
given a role ARN, you want to find out which stack and region created the role?
Can anyone please provide cli command to get stack name and region of a role created through it
<amazon-web-services><amazon-cloudformation><amazon-iam>
2019-07-30 17:48:10
LQ_EDIT
57,278,221
Why doesn't the following line compile?
<p>I am trying to create an arraylist which can contain any type of object by using a generic with an unbounded wildcard.</p> <pre><code>ArrayList&lt;?&gt; params = new ArrayList&lt;?&gt;(); </code></pre> <p>I do not understand why I receive the following error and I want to know where I am going wrong?</p> <pre><code> required: class or interface without bounds found: ? </code></pre>
<java><generics><arraylist><compiler-errors>
2019-07-30 18:44:41
LQ_CLOSE
57,280,638
Please help me im getting this error: The "data-pay-btn" BUTTON element does not have the specified CSS
Question is: The data-pay-btn BUTTON should have a fixed position, 90% width, solid border of 1px and positioned 20px from the bottom of the viewport. [data-pay-btn]{ position: fixed; width: 90%; border: 1px solid; bottom: 20px; } Im getting this error: The "data-pay-btn" BUTTON element does not have the specified CSS.
<css>
2019-07-30 22:03:56
LQ_EDIT
57,281,376
How to give the object back upon failure?
I have the following code in Rust: ```rust pub struct PropertySet { color: Color, properties: Vec<Box<dyn Property>>, } impl PropertySet { // ... /// This function will panic if a card is added and the set is already full, so /// you should always check the set size first. fn add<T: Property>(&mut self, card: T) { if self.properties.len() + 1 < self.color.set_size() { self.properties.push(Box::new(property)) } else { panic!("The card could not be added to the set; it is full.") } } // ... } ``` This `impl` is for a struct which is intended to hold a list of cards, but has a maximum number of cards that can be added to it. Panicking seems like an unnecessarily drastic response to the error of trying to add a card to a full set, so I would like to return an `Err` instead, but that presents a problem because this method moves `card`. `card` has to be passed by value because this is the only way I can add it to the `Vec`. Is there a way to simply give `card` back to the caller if the method fails, instead of panicking?
<rust>
2019-07-30 23:43:42
LQ_EDIT
57,281,841
setup customizable options for all simple products via db in magento 2
<p>I would like to add the custom option for all simple products via db in magento 2 i can manually import the custom option for the first product one by one but there are 10k+ products so i can't do it. </p> <p>I already check but find nothing, only a paid plugin for this</p>
<magento><product><customization><magento2>
2019-07-31 01:07:09
LQ_CLOSE
57,282,754
I am trying to programme a spin the bottle thing because I want to test myself and have got stuck
I want to create a spin the bottle game because I'm bored and what to test my coding skills (they're not that great ngl). I got this far and wanted to add a feature where the programme asks how many people are playing and then it will change the output to that, for example it asks how many players and you respond with '8' it will then ask for 8 names and pick from those said names. I have tried doing: players = input('How many people are playing?') if player == '2': name1 = input(Who is player 1?') name2 = input('Who is player 2?') elif player == '3' name1 = input(Who is player 1?') name2 = input('Who is player 2?') name3 = input ('Who is player 3?') and so forth '''python import random import time print ('Hello and welcome to spin the bottle generator') name1 = input('Who is player 1?') name2 = input ('Who is player 2?') name3 = input('Who is player 3?') name4 = input ('Who is player 4?') names = [name1, name2, name3, name4] print (names) print ('Spinning') time.sleep(1) print (random.choice(names)) ''' I submitted this code and it asked for the number of players and when i input '4' as a test it didnt go any further :/
<python>
2019-07-31 03:29:47
LQ_EDIT
57,283,465
Open a form inside a dropdown
<p>I want to use html form tag inside a dropdownlist, to create something like google's People Also Ask, but inside of it form for changing information and password and so on.</p>
<javascript><html><css><bootstrap-4>
2019-07-31 04:58:21
LQ_CLOSE
57,285,225
how to assign multiple string resources to single textview in android studio
i have created 3 strings in string resources.every string is having external link in it.basically i am trying to put one sentence in textview which is having 3 outside links in it.but pls tell how to do this in android studio. if we can assign multiple string through XML only that will be best.
<android><android-layout><textview><android-resources>
2019-07-31 07:16:05
LQ_EDIT
57,286,474
I dont know why there is an Object Variable or With-blockvariable missing?
Please help I dont know why ther is an Objekt variable or With-bock varaible missing [In the Picture is the Problem (in German) and the Code ][1] I have all ready googled if I could find anything in the Internet but I didn't [1]: https://i.stack.imgur.com/QovY7.png
<excel><vba>
2019-07-31 08:32:12
LQ_EDIT
57,287,301
What are the possible applications of deque functions in real time use?
<p>Help me learn with the application of real time use of deque functions from collection library, if possible try adding some examples to it . </p> <p>Thank You.</p>
<python><collections><deque>
2019-07-31 09:16:39
LQ_CLOSE
57,287,414
How to get list of all Databases and its respective users list in single query
I have searched online and found few queries where I can list users of current database but I want to return all databases and its respective users list in single query. I am using SQL SERVER 2017. How to do that.
<sql><sql-server><sql-server-2017>
2019-07-31 09:22:31
LQ_EDIT
57,287,429
AccountKit - Message Received contain (DEV MODE)
<p>my problem is message content received contains (DEV MODE). I don't know why. 1 week ago, it's was ok</p>
<android>
2019-07-31 09:23:18
LQ_CLOSE
57,287,845
How can we add multiple user inputs in a single prompt (in javascript)?
<p>I want to take multiple user inputs from user in a single prompt box. How can this be possible?</p>
<javascript>
2019-07-31 09:45:09
LQ_CLOSE
57,290,278
String de Conexao salva em txt
Bom dia, Como faço para o vb.net ler que a string que estou passando esta dentro do arquivo txt? Public Const strConexao As String = "C:\Users\TestFile.txt" Dentro do arquivo txt está a string de conexao com o banco de dados: Data Source=Teste\SQLEXPRESS;Initial Catalog=BDTeste;Integrated Security=True Eu sou novato nisso e não estou conseguindo fazer isso rodar, sei que é duvida de principiante.
<vb.net>
2019-07-31 12:00:47
LQ_EDIT
57,290,613
Why is Python unable to retrieve value of an environment variable even though that variable has value when tested via bash?
<p>I want to use a value from an environment variable. I have set it in the <code>~/.bashrc</code> file and I am able to see that in the new shells and in the current shell(obviously, after <code>source</code>ing it). However, when I import the same variable in Python3 shell(both in the existing and in the new shells), the value returned is always <code>None</code>.</p> <p>I read a lot and found a <a href="https://stackoverflow.com/questions/31993885/why-cant-python-see-environment-variables">relatable answer</a> but it did not solve my problem or rather, I could not understand it.</p> <p>My bashrc file is:</p> <pre><code>SLACK_URL="https://hooks.slack.com/" </code></pre> <p>I am able to see the value in the terminal but not in the Python shell:</p> <pre><code>ubuntu@ip-A.B.C.D:~$ echo $SLACK_URL https://hooks.slack.com/ ubuntu@ip-A.B.C.D:~$ python3 Python 3.6.8 (default, Jan 14 2019, 11:02:34) [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux Type "help", "copyright", "credits" or "license" for more information. &gt;&gt;&gt; import os &gt;&gt;&gt; os.getenv('SLACK_URL') &gt;&gt;&gt; </code></pre> <p>I expect to see the actual variable's value but instead I am getting <code>None</code>.</p>
<python><python-3.x><ubuntu><ubuntu-18.04>
2019-07-31 12:20:09
LQ_CLOSE
57,290,777
How to use PHP If statement comparing to SQL Date and Current Date?
<p>In my SQL Database i have a date column. I want to use a PHP if statement to show some text if the date from the DB equals todays date. Aswell as that, use an else to show something else if the date does not equal today.</p> <p>Running PHP 7</p> <p>I have lost count of what i have tried with this but don't seem to get anywhere.</p> <p>I am fetching the data here:</p> <pre><code> $sql1 = 'SELECT `date` FROM `operations`.`opsroom` ORDER BY `opsroom`.`date` ASC, `opsroom`.`starttime` ASC LIMIT 1'; $nextsession = mysqli_query($conn, $sql1); </code></pre> <p>Later on in the file is where i am using this:</p> <pre><code> &lt;?php while ($row = mysqli_fetch_assoc($nextsession)) { if( $row['date'] == DATE(date)){ echo "BOOKINGS TODAY"; } else { echo "No Bookings"; } } ?&gt; </code></pre> <p>Only error i get at the moment is PHP Warning: Use of undefined constant date - assumed 'date' (this will throw an Error in a future version of PHP)</p>
<php><mysql>
2019-07-31 12:30:06
LQ_CLOSE
57,292,480
How can i change constraints for different screen sizes
Hello I've just started programming and I'm trying to write with code instead of using the storyboard, but the constraints I added do not work at different screen sizes How do I solve this problem
<swift><constraints><size-classes>
2019-07-31 13:55:07
LQ_EDIT
57,293,395
Learning xcode functions and getting wrong output
i am doing a homework assignment, learning how to use functions. i have created a function. and my output is coming out as (function) and not as what it should be ("Stuff") I'm more then positive my code is written correctly but my output is not coming out as the result i need but as (function) not sure what else to try func printsStuff() { prints("Stuff") } print(printsStuff) my output is "function" instead of "stuff"
<swift><function>
2019-07-31 14:41:51
LQ_EDIT
57,294,531
JavaScript Mini-Max Sum - Returns 0
<p>I'm trying to resolve the Mini-Max Sum Challenge from HackerRank. Why my code returns 0? <a href="https://www.hackerrank.com/challenges/mini-max-sum/problem" rel="nofollow noreferrer">https://www.hackerrank.com/challenges/mini-max-sum/problem</a></p> <p>Been trying different codes and still doesn't work.</p> <pre><code>function miniMaxSum(arr) { let maxSum = 0; let minSum = 0; arr.sort(); for (let i = 0; i &lt; arr.leight; ++i) { minSum += arr[i]; } for (let i = 1; i &lt; arr.leight; ++i) { maxSum += arr[i]; } console.log(minSum, maxSum) } </code></pre> <p>I expect a output like 10 14, but the actual output is 0 0.</p>
<javascript><arrays>
2019-07-31 15:43:07
LQ_CLOSE
57,295,340
Please help me with making my array size to get increased, each time there is an input from a user
I am writing data from user's input into a text file in c#, using array. I have tried using array and ArrayList, yet it didn't work. FileStream fs = new FileStream("FirstName.txt", FileMode.Append, FileAccess.Write); StreamWriter w = new StreamWriter(fs); Console.WriteLine("Enter a string"); string str = Console.ReadLine(); string[] thearray = new string[1]; thearray[0] = str; w.WriteLine(thearray[0]); w.Flush(); fs.Close(); It should insert the user's values to the array, and from the array to the text file.
<c#>
2019-07-31 16:30:49
LQ_EDIT
57,296,168
pathlib Path `write_text` in append mode
<p>Is there a shortcut for python <code>pathlib.Path</code> objects to <code>write_text()</code> in append mode? </p> <p>The standard <a href="https://docs.python.org/3/library/functions.html#open" rel="noreferrer"><code>open()</code></a> function has <code>mode="a"</code> to open a file for writing and appending to the file if that file exists, and a <code>Path</code>s <a href="https://docs.python.org/3/library/pathlib.html#pathlib.Path.open" rel="noreferrer"><code>.open()</code></a> function seems to have the same functionality (<code>my_path.open("a")</code>). </p> <p>But what about the handy <code>.write_text('..')</code> shortcut, is there a way to use <code>pathlib</code> to open and append to a file with just doing the same things as with <code>open()</code>? </p> <p>For clarity, I can do</p> <pre class="lang-py prettyprint-override"><code>with my_path.open('a') as fp: fp.write('my text') </code></pre> <p>but is there another way? </p> <p><code>my_path.write_text('my text', mode='a')</code></p>
<python><python-3.x><pathlib>
2019-07-31 17:30:39
HQ
57,296,425
Order of Instantiation
<p>A question I'm having trouble finding the answer to: When my class is instantiated, in what order are it's members instantiated.</p> <p>For example, can I set a member to the value of a member lower in the declaration order? (See code example.)</p> <pre><code>// Can I do the following: class foo { int A = B; int B = 12; } // And this, for class types: class bar { foo X = Y; foo Y = new foo(); } </code></pre>
<c#>
2019-07-31 17:51:03
LQ_CLOSE
57,296,618
How do I write it in MySQLi?
Im quite new to PHP and MySQl and I try to learn how to change a code from PDO to MySQLi. Its about a remember me function with a securitytoken and identifier for a login system that I found in the web. I would like to learn and understand how I can change the code from PDO to MySQLi. I know in MySQLi there is a statement create and prepare, also I have to bind parameters and execute. But in this case, I dont know how to start anyway. Thanks for any help with this. $pdo = new PDO('mysql:host=localhost;dbname=dbname', 'root', ''); if(!isset($_SESSION['id']) && isset($_COOKIE['identifier']) && isset($_COOKIE['securitytoken'])) { $identifier = $_COOKIE['identifier']; $securitytoken = $_COOKIE['securitytoken']; $statement = $pdo->prepare("SELECT * FROM securitytokens WHERE identifier = ?"); $result = $statement->execute(array($identifier)); $securitytoken_row = $statement->fetch(); if(sha1($securitytoken) !== $securitytoken_row['securitytoken']) { die('Maybe a stolen securitytoken.'); } else { //Token was correct //Set an new token $neuer_securitytoken = random_string(); $insert = $pdo->prepare("UPDATE securitytokens SET securitytoken = :securitytoken WHERE identifier = :identifier"); $insert->execute(array('securitytoken' => sha1($neuer_securitytoken), 'identifier' => $identifier)); setcookie("identifier",$identifier,time()+(3600*24*365)); //1 Year valid setcookie("securitytoken",$neuer_securitytoken,time()+(3600*24*365)); //1 Year valid //Loggin the user $_SESSION['id'] = $securitytoken_row['id']; } }
<php><mysqli><pdo>
2019-07-31 18:05:02
LQ_EDIT
57,297,107
Getting multiple values out of a key in hashtable
<p>I have an output from an API which gives multiple value want them to prettify as an indivual output in javascript</p> <pre><code>[ { "key": "Time", "value": "\nTuesday, July 30, 2019 5:34:16 PM\nMonday, July 29, 2019 3:23:20 PM\nMonday, July 29, 2019 1:54:05 PM" } ] </code></pre>
<javascript><json><hashtable>
2019-07-31 18:42:30
LQ_CLOSE
57,298,133
Dicrease the number of if
Hello I have this code using Python : a = ["Porsche", "Google", "Facebook", "Mercedes", "Audi", "Twitter"] if "Porsche" in a: pass if "Google" in a: pass if "Facebook" in a: pass if "Mercedes" in a: pass if "Audi" in a: pass if "Twitter" in a: pass But with this code I have no ideas how can I discrease the number of if. Is there a better way using Python to do ? Thank you very much !
<python><python-3.x><python-2.7>
2019-07-31 20:06:37
LQ_EDIT
57,298,759
How to QUERY perform operation and then UPDATE on entire table
<p>I have a large table with around 10 million rows. I need to take numbers from 2 columns perform some function and then save the result into a 3rd column.</p> <p>Is there an efficient way of doing this? The only way I have been able to do this is to QUERY and save the result into a tuple. Then in a second for loop iterate through the tuple where the result and unique hash is stored and filter by hash and then update. </p> <p>This is very very very slow though! Is there a better way to do this?</p>
<python><sql><postgresql><sqlalchemy>
2019-07-31 20:58:48
LQ_CLOSE