input_text_instruct
stringlengths
288
45.8k
output_text
stringlengths
37
33.2k
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Is space reclaimed when I delete an index at MongoDB?<p>I have looked around the whole documentation but can't figure out if this actually happens or not. If...
<p>No, MongoDB won't automatically release diskspace after collection data or indexes are deleted. Allocating new files is a relatively slow thing compared to other functions in a high-performance databases so MongoDB keeps all previously allocated files open and available by design.</p> <p>If you need to reclaim disk...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: how to setup --max-http-header-size with webpack-dev-server<p>I'm trying to setup my webpack instance with webpack-dev-server. I pass into scripts a setting ...
<p>Problem was in my file webpack-dev-server file. I pass instead <code>webpack-dev-server</code> this line <code>../../node_modules/webpack-dev-server/bin/webpack-dev-server.js</code></p> <pre><code> "dev:windows": "npm run options-to-dev &amp;&amp; env targets=customer &amp;&amp; node --max-http-header-size=100000 ....
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Converting a String to Set<String><p>Sorry for the basic question but I have a Java <code>String</code> that I need to return as part of a method as a <code>...
<p>If you are using Java 9 or newer, use <a href="https://docs.oracle.com/en/java/javase/13/docs/api/java.base/java/util/Set.html#of(E)" rel="noreferrer"><code>Set.of()</code></a>:</p> <pre><code>return Set.of("foo"); </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Decryption Error bad padding<p>I am trying to send encrypted messages between two agents .I have a string that contains information that I convert to bytes e...
<p>use base64 encoding for the output of the encryption, don't use <code>new String()</code> as some byte-values will not be represented correctly as string. so when reversed to bytes again it will not be the correct ciphered value</p> <p>here is what i mean:</p> <pre><code>String msg1="Message from bob 1"; // messag...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: ASP.net cache access causing Collection Modified exception in foreach loop<p>Ok first things first. This is some exception information given by the support t...
<p>This happens because you're working directly with object, locating in cache. Good practise, to avoid those exceptions and other wierd behavior (when you accidentally modify cache object) is working with <em>copy</em> of cache data. And there are several ways of achieving it, like doing <em>clone</em> or some kind of...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to validate mobile Number using data annotation in mvc5<p>I need to validate all the Indian mobile number using data annotation. in my model i use follow...
<p>Try this one hope it will help you.</p> <pre><code>[RegularExpression(@"^([0]|\+91[\-\s]?)?[789]\d{9}$", ErrorMessage = "Entered Mobile No is not valid.")] </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Randomize parts of a puzzle<p>I'm a beginner in java and right now I'm trying to "solve" this puzzle: <a href="http://zetcode.com/tutorials/javagamestutorial...
<p>As you initialize the images you should put it into a <code>List</code> and then use <code>Collections::shuffle</code> to shuffle the <code>List</code>:</p> <pre><code>List&lt;Image&gt; croppedImages = new ArrayList&lt;Image&gt;(4 * 3); for ( int i = 0; i &lt; 4; i++) { for ( int j = 0; j &lt; 3; j++) { ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: javascript function to strip and parse escape sequence from string in order to colorize the escaped string<p>I am passing a string containing one or more esc...
<p>Something like this should get you started:</p> <p><a href="http://jsfiddle.net/8qqyysLc/1/" rel="nofollow">http://jsfiddle.net/8qqyysLc/1/</a></p> <pre><code> var input = "/rThis is Red./bThis is blue.", htmlOutput = ''; function updateDisplay() { document.getElementById('input').innerHTML = input; ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Python rendering 3D, 2D images within a same window<p>I am trying to create a simple robot simulator with 3D + 2D(bird-eye view mini-map) like the below imag...
<p>My strategy for making a 2D mini-map overlay like this is to use <code>glWindowPos2d</code> and <code>glDrawPixels</code>, and I have found it to be very successful. You'll want to turn off common OpenGL features like texturing, lighting, and the depth test. In the following example, <code>minimap_x</code> and <co...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Node novice - purpose of require('express')<p>In the following simple socketIo server, can any node ninja explain the purpose of the very first line. I'm not...
<p>The line:</p> <pre><code>var app = require('express')(); </code></pre> <p>loads the <code>express</code> module (that's what <code>require(...)</code> does) and then calls its constructor to initialize it and then assigns the result into a variable named <code>app</code>. The <code>app</code> variable is then use...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: where is my jquery installed if i use npm in vscode<p>I installed jquery to use it. However, I cannot find the location of jquery that I have installed. wher...
<p>jquery will be present under <code>/node_modules/jquery/dist/jquery.min.js</code> (minified version) if installed locally</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: View Visiblity issue while scrolling of Listview<p>I have a custom listview with textview and imageview and the imageview like checkmark. on OnItemClickListe...
<p>The reason you are seeing that is because the list item views get recycled (this is what <code>convertView</code> is for). When you scroll the <code>ListView</code>, the previous item that scrolls off screen is passed back to your adapter as the <code>convertView</code> for the next position.</p> <p>You need to mak...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Getting JSON From .NET Webmethod, for use in ng-repeat<p>Okay, so I've searched around far and wide and gotten some help. Not the least from this SO answer: ...
<p>It seems that your data are returned as a string and not as an object. You can add an eval in your $http call :</p> <pre><code>$scope.getData = function (item, event) { $http.post('NGTest.aspx/GetGroups', { data: {} }) .success(function (data, status, headers, config) { $scope.data = eval(data.d); }...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: python - how to compare a key of the dictionary with a string character<p>I am new to python and I need to compare a character in string with a key in a dict...
<p>Looks like you're thinking about this strangely. All you need to do is check if the letter is in your <code>score</code> dict, and if it is, to add that number to your total.</p> <pre><code>def compare(word): res = 0 for letter in word: if letter in score: res += score[letter] return...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Issue With Select Statement<p>I am trying to <code>select the top 1</code> of this select query then order <code>DESC</code>, every way I try, it doesn't see...
<p>Your ORDER BY will go at the end, and top 1 at the beginning.</p> <pre><code>SELECT top 1 '$' + CONVERT(VARCHAR(50), CONVERT(MONEY, COALESCE(SUM([amount]), 0)), 1) AS [Total] FROM [myTable] a left join [mySecondTable] b on a.[ID] = b.[ID] left join [myThirdTable c on c.[myNumber] = b.[myNumber] WHERE c.[myName] =...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Converting a string from utf8 to latin1 in NodeJS<p>I'm using a Latin1 encoded DB and can't change it to UTF-8 meaning that I run into issues with certain ap...
<p>Since Node.js v7.1.0, you can use the <code>transcode</code> function from the <code>buffer</code> module:<br /> <a href="https://nodejs.org/api/buffer.html#buffer_buffer_transcode_source_fromenc_toenc" rel="noreferrer">https://nodejs.org/api/buffer.html#buffer_buffer_transcode_source_fromenc_toenc</a></p> <p>For ex...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: When i am trying to run the xml file, browser show me the message Error loading stylesheet: Failure analysis XSLT stylesheet<p>As i described in the title ab...
<p>You had the wrong namespace for <code>xsl</code>. You need to use <code>http://www.w3.org/1999/XSL/Transform</code>:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:template match="/"&gt; &lt;test_info&gt; ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Powershell Multidimensional associative table<p>Greatings, I'm trying to extract WMI informations with Powershell in order to push them in a Mysql DB via PHP...
<p>What you'd probably need is a dictionary and not an array of arrays.</p> <pre><code>$processor = Get-WmiObject Win32_Processor $postprocessor = @{} foreach ($item in $processor){ $itemHash = @{ Name = $item.Name AddressWidth = $item.AddressWidth NumberOfCores = $item.NumberOfCores ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: nodejs/bower Error "toLowerCase"<p>I tried an tried, locally and globally, more than 4 times, but I can't figure out how to install (and configure) nodejs/bo...
<p>Aww man. I got it.</p> <p>I reinstalled all components and bower thows a <code>WARN engine</code> while installing. So I updated node to the latest version.</p> <p>But there was the problem with the shi**y frontend. I just found out that you have to reference a lot of files to get it right. </p> <p>My node versio...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Assigning char member of struct in function in c<p>I have the following linked list code with a prepend add method:</p> <pre><code>#include &lt;stdio.h&gt; ...
<p>You are printing <code>node-&gt;a</code>, a <code>char</code>, using a c string format specifier <code>"%s"</code> so <code>printf()</code> is interpreting your char value as a pointer and things go badly quickly. The char should be printed as <code>"%c"</code>.</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Array Index Overload Bug<p>Why does this code result in the second element of the array being printed as 0, irrespective of the value that was specified in t...
<p>In the <code>Array</code> constructor, immediately after allocating and filling the dynamically allocated buffer at <code>ptr</code>, the buffer is released with </p> <pre><code>delete ptr; </code></pre> <p>All accesses of the buffer at <code>ptr</code> after this point invoke <a href="https://en.cppreference.com/...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Why am i getting 3 bytes instead 1 byte after hexadecimal/string/byte conversion in java?<p>I have this program:</p> <pre><code> String hexadecimal = "AF...
<p>Don't know what exactly you try to achieve. But find below what you are doing.</p> <p><code>Integer.parseInt(hexadecimal.substring(j, j + 2), 16)</code> returns 175 <code>(byte) 175</code> is -81 <code>new String(decimal)</code> tries to create an <code>String</code> from this byte array related to your current cha...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Get category from post nibbleblog script?<p>I want to get correct category link where post has posted!</p> <p>Simple example: <a href="http://news.filmgroun...
<p>For category try to add this to your html</p> <pre><code>&lt;a href="&lt;?php echo Post::category('permalink') ?&gt;"&gt;&lt;?php echo Post::category() ?&gt;&lt;/a&gt; </code></pre> <p>And for tags this should work:</p> <pre><code>&lt;?php $tagLinks = array(); foreach (Post::tags(TRUE) as $tag) { $tagLinks[] ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How can I show all changes at once?<p>Is it possible to view all the changes at once without having to click each time each file?</p> <p>I would like to hav...
<p>No, a scrollable page view of changes is only provided in the web version. In Visual Studio in the <code>Teams</code> -> <code>Changes</code> section it shows the changed files, but one has to <em>click-through</em> them to see the difference.</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Sentry ignores --config path, but only for "start" command<p>I've installed Sentry into a virtualenv located at <code>/www/sentry/</code> and I have a config...
<p>I had the same issue, I found this bug report:</p> <p><a href="https://github.com/getsentry/sentry/issues/1438" rel="nofollow">https://github.com/getsentry/sentry/issues/1438</a></p> <p>This commit fixed it for me: <a href="https://github.com/getsentry/sentry/commit/7629de1102973e4a3930487a3bf126a2f13c6850" rel="n...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Excel vba for each visible cell in A row, insert value in H row ?<p>How do I insert value in the H row based on the visibility status of A row in excel using...
<p>You can use the <code>Row</code> property of each <code>cell</code> in your iteration to map to the correct row in column H</p> <pre><code>Sub Macro1() Dim rng As Range Set rng = Range("A2", Range("A65536").End(xlUp)).SpecialCells(xlCellTypeVisible) For Each cell In rng Range("H" &amp; cell.Row).Val...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Javascript adding number to UInt8Array<p>I have a 2 byte number (0 to 65,536) which I want to add to a UInt8Array. I can add a single byte number by directly...
<p>You have to split your two byte number into two individual bytes. This can be done by bitwise shifting.</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-js lang-js prettyprint-override"><code>var twoBytes = 0xaaf...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Hibernate - DataBase structure modelling<p>I have goal to make DB structure with table filesData, where will be stored information about uploaded files, and ...
<p>Solution is very simple.</p> <p>I've made table framework_files and mapped it with JPA to object <code>FrameworkFiles implements java.io.Serializable</code>. This table have columns <code>linkedObjectID int</code> and <code>linkedObjectName varchar(250)</code>. </p> <p>In another tables, for example - in table pub...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Get commit message on post-commit hook and reuse it<p>Here's my post-commit file:</p> <pre><code>#!/bin/sh unset GIT_INDEX_FILE git --work-tree=../foo2 --g...
<p>You can get the commit message with <code>git show</code>:</p> <pre class="lang-sh prettyprint-override"><code>git show --no-patch --format=%B </code></pre> <p>You can also use STDIN as the commit message when committing:</p> <pre class="lang-sh prettyprint-override"><code>echo "foo" | git commit --file=- </code>...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to count the co-occurrence of two strings in two files using bash?<p>I have two files, file1 and file2 and it is guaranteed that these two files have the...
<p>This should work using gawk</p> <pre><code>awk 'FNR==NR{a[FNR]=gsub(/sentence/,&quot;&quot;)} FNR!=NR{b[FNR]=gsub(/dog/,&quot;&quot;)} END{for(i in a)x+=(a[i]*b[i]);print x}' file file2 </code></pre> <hr /> <h3>Output</h3> <pre><code>4 </code></pre> <hr /> <h3>How it works</h3> <pre><code>FNR==NR </code></...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Java Tomcat initialize a servlet from a thread<p>I have a Tomcat 7 application that starts a Thread at startup and after doing some things I want to call "so...
<p>Here is the solution:</p> <pre><code> private boolean startup() throws ClientProtocolException, IOException { logger.entry(); HttpPost request = new HttpPost("http://.../StartupServlet"); RequestConfig requestConfig = RequestConfig.custom() .setSocketTimeout(30 * 1000) .setConnection...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Getting content from WPF GridViewColumn through Button<p>I have a Button within a GridView within a ListView. When the button is clicked, I would like to get...
<p>Use <code>DataContext</code> of <code>Button</code>as shown below. Please note that here in this example code, I'm using Customer. </p> <pre><code>private void _viewResult(object sender, RoutedEventArgs e) { Button button = sender as Button; Customer cust = button.DataContext as Customer; string sDate ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: TFS 2013 Not Restoring NuGet Packages<p>According to the <a href="http://docs.nuget.org/consume/package-restore/team-build" rel="nofollow">NuGet Documentatio...
<p>The issue turned out to be that we had an internal Nuget package feed. The issue was fixed by adding a nuget.config file to the root of the solution folder:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;configuration&gt; &lt;packageRestore&gt; &lt;add key="enabled" value="True" /&gt; &lt;/...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Adding Fibonacci odd sequence in java<p>I would like to add all the odd numbers in: <code>System.out.print(store + " ");</code> If you got any suggestion pl...
<p>Do you mean that you want to calculate the sum of all the odd numbers?</p> <p>Firstly you haven't declared and initialised <code>febCount</code> so you need to fix that. In this case <code>febCount</code> would be the same as <code>Fibcnt</code>, but you could use <code>feb.length</code> instead.</p> <pre><code>pu...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Lazy loading in Gridview using jquery and webmethod<p>How to use lazy loading in gridview by binding datatable to gridview using webmethod and jquery. A Grid...
<p>This article is helpful for lazy loading in gridview.</p> <p><a href="http://www.aspsnippets.com/Articles/Load-on-demand-data-in-GridView-on-scroll-using-ASPNet-and-jQuery-AJAX.aspx" rel="nofollow">http://www.aspsnippets.com/Articles/Load-on-demand-data-in-GridView-on-scroll-using-ASPNet-and-jQuery-AJAX.aspx</a></p...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Invoke-Command with Computers array, access single array element inside scriptblock<p>I am wondering how to accomplish the following and hope you can help:</...
<p>This works for me:</p> <pre><code>Invoke-Command $ComputerNameArray { $env:computername } </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: OAuth not working after deploying to Azure [ASP.NET MVC]<p>I'm trying to integrate OAuth in my <a href="http://shibpurconnect.azurewebsites.net" rel="nofollo...
<p>I integrated Elmah and able to get the actual reason. It was due to login failure to database.</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Atomic writes with Ghostscript output devices<p>I'm using Ghostscript to convert PDF pages to PNG using the following on the command line:</p> <pre><code>gs...
<p>No, there isn't. Ghostscript opens the file for writing immediately that the page begins. It write the data either in one large lump when the page is complete, or in a series of horizontal stripes (at high page sizes or resolutions).</p> <p>Since it might be writing the page in a series of bands, it has to open the...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Passing an "indirect" object between pages in XMAL/C#<p>I have defined a Player object as follows:</p> <pre><code>public class Player { [Primary...
<blockquote> <p>There's no code on the page that specifies that it has a Player, but I can reference the Player fields in the RosterDetails.xmal file (which is why I call it an "indirect" object)</p> </blockquote> <p>You can reference the Player fields in the <code>RosterDetails.xmal</code> file because you have...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: empty recordset values - sql server 2017<p>I always used this connection string in my codes to connect to sql server:</p> <pre><code>"Driver={SQL Server};Se...
<p>It is best to use OLE DB with ADO classic. ADO is natively a COM-based API and uses the MSDASQL (Microsoft OLE DB Provider for ODBC drivers) on top of the ODBC call-level interface, adding an addition API layer.</p> <p>Windows ships with SQLOLEDB (Microsoft OLE DB Provider for SQL Server) for backwards compatibilit...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to find this url in the html with php?<p>I want to find a specific url in a html page and get it's part. the url is in this page :</p> <pre><code>http:/...
<p>Is this what you are looking for?</p> <pre><code>$url = 'http://download.site2.org/?server=2&amp;apkid=com.rovio.angrybirdsfriends&amp;ver=1.7.0'; $query = parse_url($url, PHP_URL_QUERY); parse_str($query, $params); echo $params['server'], PHP_EOL; echo $params['apkid'], PHP_EOL; echo $params['ver'], PHP_EOL; </c...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Why won't my deploy user use my ssh key?<p>I am trying to fix an ssh key error to work for a deploy user with my RoR Capistrano 3.3.5 project. I have an ubu...
<p>you need to add your public key to the deploy user's authorized_keys file which is located at <code>/home/deploy/.ssh/authorized_keys</code> on the server.</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Do I need to install ALL the service packs for visual studio or just the latest?<p>I have just installed Visual Studio 2013. I am wondering do I need to inst...
<p>In general the official updates are designed to be <em>cumulative</em> such as the last official <a href="http://www.microsoft.com/en-us/download/details.aspx" rel="nofollow noreferrer">update 4</a> where it specifically says:</p> <blockquote> <p>This update is the latest in a cumulative series of feature additions ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: jQuery round number only if decimal is greater than x<p>So I have these two input[text] fields:</p> <pre><code>&lt;input type="text" id="CM" size="2" maxlen...
<p>Try to use reminder to get the first decimal</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>$('#CM').keyup(function() { var $total = ($('#CM').val() * 3) / 2; $('#CM2').val(($total * 10 % 10 &lt;= 3) ? Math...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Can I refer items inside ngRepeat by index, not name<p>What I am looking for, is to replace this:</p> <pre><code>&lt;tr ng-repeat="travel in travelList"&gt;...
<p>No. That's not how JS objects work. <code>someObj[key]</code> is valid syntax, but unless you explicitly set a value for a key (like <code>someObj[0] = 'foo'</code>) then the result is undefined.</p> <p>If you want to iterate over the properties of each <code>travel</code>, you will need a second <code>ng-repeat</c...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Pandas: Row wise count for multiple columns after filter based on condition<p>I have a dataframe <code>df</code> as </p> <pre><code>Decile 2_Con 3_Con...
<p>Did you try:</p> <pre><code>df = df.groupby('Decile').sum() </code></pre> <p>This makes sense because of the 0-1 values, hence, the sum will be the count of non 0 values (rows) for each different decile.</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Having problem in conversion from Recursive solution to DP<p>Given a Binary Tree of size N, find size of the Largest Independent Set(LIS) in it. A subset of ...
<p>You have two states in your function but you are memoizing only one state. Let's say for root x,</p> <p><code>rec(x,true) = 5</code> and</p> <p><code>rec(x,false) = 10</code> .</p> <p>You calculated the <code>rec(x, true)</code> first and saved it in your map "mm" as mm[x] = 5.</p> <p>So when you are trying to g...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: accessing input with special characters in name in angular<p>I have inputs with dynamically assigned names. As a result I have input names like </p> <blockq...
<p>Try this way:</p> <pre><code>medForm['Athlete/Guardian_firstName'].$invalid </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: CSS Tables on Mobile<p>I have very long tables. Now all my content is coming from tinyMCE and my users don't know about those td and td's. So 90% of my table...
<p>I am not sure if I understand your question. </p> <p>You want to have responsive tables for mobile users? If that is the case use <code>width:100%</code> on table and <code>word-wrap: break-word</code> on td's</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: My laravel collective form is not submitting when I click submit<p>I have a form in my blade template when I click submit button nothing is happing it is not...
<p>Your form <code>select</code> element like below: You should not use same name for the select tag and input tag.</p> <pre><code>{{Form::open(['action' =&gt; ['HomeController@addcity'], 'method' =&gt; 'POST']) }} {!! Form::select('city_option', array("CAM" =&gt; "CAM","KL" =&gt; "KL","IPOH" =&gt; "IPOH"),['cla...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Ruby Shoes GUI Secret style not working<p>I am trying to make a login screen in Ruby Shoes. I am using the ask method to get the username and password but I ...
<p>Try it this way</p> <pre><code> button "Login" do username = ask("Enter Username: ") password = ask("Enter Password: ", :secret =&gt; true) end </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Why double.Parse() throws FormatException only through rdp?<p>I have a realy weird error. I have a .Net application, that make an exception while parsing a s...
<p><code>double.Parse</code> uses your <a href="https://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.currentculture%28v=vs.110%29.aspx" rel="nofollow"><code>CurrentCulture</code></a> settings on the <em>current</em> environment by default.</p> <p>Sounds like your remote environment uses a culture ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Not displaying result of two input fields values in React<p>I have to sum two input fields values in react. I have some issues displaying result. How do I s...
<p>While <code>setState()</code> is asynchronous, you should pass a callback function to use the updated state value. For example in your add function:</p> <pre><code>add = () =&gt; { const { number1, number2 } = this.state; this.setState({ total: (parseInt(number1) + parseInt(number2)) }, () =...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: All the bar in bar chart stays at left with very little width<p>I am populating my bar chart with very simple data. But it seems that it stays always left wi...
<p>In time of calling the showMBSLinechart function just call with single array data.Like this</p> <pre><code> showMBSLineChart(this.canvasId, ["counts"], dataSets, "bar", this.area,false,true); </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: VBA Filter Partial String Containing Date<p>I need to filter Col A based on a PARTIAL STRING.</p> <p>The user needs to be able to filter for YEAR only ... o...
<p>This is what I am talking about. </p> <pre><code>Option Explicit Sub ResetFilters() Dim Wks As Worksheet Set Wks = Sheets("Call Log File") With Wks On Error Resume Next If Wks.AutoFilterMode Then Wks.AutoFilterMode = False End If End With End Sub Sub FiltDate()...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Rails rspec render_template error<p>I'm following Hartl's Ruby on Rails tutorial and can't figure out why the following code keep on giving me this error:</p...
<p>Here's a way to solve that problem.</p> <p>Look in your error message for the path of "test_case.rb" and for the line in error:</p> <pre><code>NoMethodError: undefined method `body' for nil:NilClass # /var/lib/gems/1.9.1/gems/actionpack-4.2.0/lib/action_controller/test_case.rb:111:in `assert_template' ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Why does this recursive function for square-roots give the wrong result?<p>I made this tail-recursive function for computing square roots:</p> <p><code>sqrt...
<p>The expression:</p> <pre><code>sqrt x n a = if n == 0 then a else sqrt x (n - 1) (a + x/a) / 2 </code></pre> <p>is parsed as:</p> <pre><code>sqrt x n a = if n == 0 then a else <b>(sqrt x (n - 1) (a + x/a))</b> / 2</code></pre> <p>So the <code>sqrt x (n-1) (a+x/a)</code> is seen as the numerator of a division b...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Mechanicalsoup data not being entered into a form<p>I am trying to enter username and password into a form using mechanicalsoup and it all seems to work corr...
<p>It looks like this login page uses JavaScript, which MechanicalSoup does not support. See this <a href="https://mechanicalsoup.readthedocs.io/en/stable/faq.html#form-submission-has-no-effect-or-fails" rel="nofollow noreferrer">FAQ</a>.</p> <p>The biggest giveaway is that <code>&lt;form id="loginForm" ...&gt;</code>...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Mouse.LeftButton == MouseButtonState.Pressed never returning true<p>I have a Windows Forms Application in C# which monitors if the mouse buttons are being he...
<p>The problem is you're trying to mix two GUI technologies: WinForms and WPF. You've set environment suitable for WinForms but trying to use methods from WPF.</p> <p>You dont need <code>PresentationCore.dll</code> and <code>System.Windows.Input</code>. The desired result can be achieved using <code>System.Windows.For...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How can I convert a type to a class in typescript?<p>I have a class <code>Client</code> and I want to create a new class <code>UpdateClient</code> but omitti...
<p>If all you want is for <code>UpdateClient</code> to be a class constructor that makes instances of <code>Omit&lt;Client, 'client_secret'&gt;</code>, you can write it this way:</p> <pre><code>const UpdateClient: new () =&gt; Omit&lt;Client, 'client_secret'&gt; = Client; </code></pre> <p>The declared type <code>new ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Need help doing multi-threading in C++<p>I'm having trouble getting this function to compile as a thread. Can someone help me out? Thanks</p> <pre><code>cla...
<p>Your function doesn't have the right signature for use with <code>pthread</code>. One option is to create a function like this:</p> <pre><code>void *do_blank(void *args) { struct arg_struct *blank_args = (struct arg_struct *)args; return hwc_blank(blank_args-&gt;h, blank_args-&gt;disp, blank_args-&gt;valu...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Regex that allows characters but fails on a cerain character repetition<p>Hello I have the following regex:</p> <pre><code>^[a-zA-Z0-9,.()\s'#-]*$ </code></...
<p>Add a negative <a href="http://www.regular-expressions.info/lookaround.html" rel="nofollow">lookahead</a> at the start, such as:</p> <pre><code>^(?!.*?[,.()'#-]{2})[a-zA-Z0-9,.()\s'#-]*$ </code></pre> <p>See <a href="https://regex101.com/r/rC6bD5/2" rel="nofollow">test at regex101.com</a></p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Click on index layout works only during list scrolling<p>i created a list with an index on the right side, thanks to <a href="https://github.com/woozzu/Index...
<p>This works in the IndexableListViewActivity of github.</p> <pre><code> mListView.setOnItemClickListener(new OnItemClickListener(){ public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int position, long arg3) { Toast.makeText(IndexableListViewActivity.this, "posi...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Set background/opaque to all JLabels<p>See my code:</p> <pre><code>package hsleiden.webcat.exercise12_08; import java.awt.*; import javax.swing.*; import ...
<ol> <li>You can create your own class that extends JLabel and implements Clonable. You can override the clone method and create as many copies of a JLabel as you want.</li> <li>Spring provides a handy way of doing this with BeanUtils.copyProperties</li> </ol>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: List files affected by the latest git pull<p>The question is similar to this one: <a href="https://stackoverflow.com/questions/424071/how-to-list-all-the-fil...
<p>This is a little bit difficult for several reasons:</p> <ol> <li><code>git pull</code> means <em>run <code>git fetch</code>, then run a second Git command to incorporate whatever got fetched.</em></li> <li>Git does not record here <em>which</em> second command is used. The second command is chosen by whoever ran <c...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to use Madgwick filter<p>There is data from the gyroscope and accelerometer:</p> <pre><code>gyro_xyz = [gyro_x,gyro_y,gyro_z] acc_xyz = [acc_x,acc_y,acc...
<p>you can convert the quaternion to euler angles by using the Quaternion class method <code>to_euler_angles()</code></p> <pre><code>rpy = angles.quaternion.to_euler_angles() print("rpy: ", rpy) </code></pre> <p>hope it answer your question</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Laravel: Controller does not exist<p>I added new controller in /app/controllers/admin/ folder and added the route in /app/routes.php file as well. Then i run...
<p>Did you add autoload classmap to composer.json file? Open your composer.json file and add</p> <pre><code>"autoload": { "classmap": [ "app/controllers/admin", ] } </code></pre> <p>if you add folders inside controllers, you need to add it to composer.json file. Then run</p> <pre><cod...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Angular display value from selected option<p>I wouldlike to display value from selected option into my table :</p> <p>HTML file :</p> <pre class="lang-html...
<p>first of all [value] in option should not be an object you are binding it with object. Try to follow following</p> <pre><code>selectedValue = { Name: '', Matricule: '' } values = [{ Name: "Container A", Matricule: "ABC" }, { Name: "Container B", Matricule: "BCD" }, { Name: "Container...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Background color of tkinter label will not change (python 3.4)<p>I am making a widget with Tkinter in python 3.4. For some reason, I cannot change a label's ...
<p>This bug is caused by the 'aqua' ttk style on Mac OSX. It also breaks 'ttk.Progressbar' when set to 'indeterminate' mode. To fix both issues insert the following code after 'root = Tk()' to change the style ...</p> <pre><code>style = ttk.Style() style.theme_use('classic') # Any style other than aqua. </code></pre...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: C# SQL Insert saying "duplicate variable"<p>The code below is supposed to iterate through a list of components and insert them for a specific bill of materia...
<p>You have your AddWithValue calls inside the foreach loop. Of course this means that at each loop you readd the same parameters with different values.</p> <p>What about declaring them outside the loop and just changing the value inside the loop</p> <pre><code> command.Parameters.Add("@product", SqlDbType.NVarChar...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to get the picker in SwiftUI to output the chosen value?<p>I have a picker in swiftUI that are used to show Units of Measure and convert between them. Th...
<p>try this. (added tags to your text and made your selection value an int)</p> <pre><code>struct ContentView: View { @State private var originalValue = "" @State private var originalUnit = 0 @State private var convertedUnit = "" let lenghtUnits = ["meters", "miles", "yards"] var convertedValue : Double { return...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Would like to display the index of one specific row in a Pandas dataframe<p>I have a dataframe I need to iterate through, I have a method to find the value I...
<p>Since there could be more than one index mapped to your value, you should return a list instead:</p> <pre class="lang-py prettyprint-override"><code>GDP_df.iloc[pos1:, 0:1].index.tolist() </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: remove the index values while converting excel file to text file using python<p>I am using python 3.7 and I wanted to convert <code>.xlsx</code> file into <c...
<p>Adding <code>index = False</code> to your <code>to_string</code> call will prevent the index from being included.</p> <p>If you want tab separated values, instead of <code>to_string</code> you should use <code>to_csv</code> - this function is meant to generate comma separated values, but you can change what charact...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How do I extract all distint values for a specific key inside JSONField in Django running on Postgres?<p><strong>Summary:</strong></p> <p>For a dropdown I n...
<p>The QuerySet to perform required select:</p> <pre><code>Log.objects.filter( # some filtering if required log_meta__origin__isnull=False ).order_by().values_list('log_meta__origin').distinct() </code></pre> <p><code>order_by()</code> is to clear any ordering already present on QuerySet to allow us make <cod...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: scala: fill non-existing case class after leftOuterJoin<p>I have a paired RDD "A" of case class in this format </p> <pre><code>case class MyCaseClass(ID: St...
<p>You're trying create case class object with date field with Date type, but giving to him literal contains number. You need to create <strong>date</strong> object instead of <code>9999-01-01</code>.</p> <pre><code>val format = new java.text.SimpleDateFormat("yyyy-MM-dd") val D = C.map(x =&gt; (x._1, x._2._2.getOrEls...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: python class to print bash colors<p>I have python scripts that will print to screen, and sometimes I want them bold, or green, and sometimes both bold and gr...
<p>Because you're returning a string in the <code>bold</code> and <code>green</code> methods. I think you actually want to return a reference to the <code>colortext</code> object itself. So modify the text in those methods and return <code>self</code>. Also if you want it to print the string when you call it in <code>p...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: object does not contain a definition for Navigated<p>im trying to get a xaml island navigation working in my core wpf app and get the error for:</p> <pre><c...
<p>The <code>Navigated</code> event is on the <code>Frame</code> and not on its <code>Content</code>: </p> <pre><code>ContentFrame.Navigated += On_Navigated; </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Embed Jetty and set default attributes on the ServletContext<p>I would like to embed Jetty into a server app that I am writing. The Embbeded Jetty engine wil...
<p>I figured this out, it turns out you can literally just set the Attribute on the <code>WebAppContext</code>. Later in the <code>Servlet</code> you can retrieve the value with <code>SpecialResource sr = ( SpecialResource ) getServletContext ().getAttribute ( "com.example.SpecialResource" );</code></p> <pre><code>imp...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How does Apache Ant resolve duplicate targets<p>Say I have two targets in ant with the same name in two different build files but, one is imported into the o...
<p>When you assign project names, then you can access the both targets</p> <pre><code>&lt;project name="build1"&gt; &lt;target name="once"&gt; &lt;echo&gt;once&lt;/echo&gt; &lt;/target&gt; &lt;target name="twice"&gt; &lt;echo&gt;twice-a in build.xml&lt;/echo&gt; &lt;/target&gt; &lt;!--...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Removing "selected" atttribute from cloned select options not working in IE<p>I have written a plugin that converts a <code>&lt;select multiple&gt;</code> in...
<p>Use <code>defaultSelected</code> instead of <code>selected</code>, and use <code>prop</code> to set it to null instead of using <code>removeAttr</code>.</p> <p><strong>Example 1:</strong></p> <p>This attempts to clear <code>selected</code>, and the alert still shows the <code>selected</code> options:</p> <p><div ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Linking dropdown to database table and dropdown to textboxes<p>I am trying to link my dropdown that is already linked to one of tables to my textboxes. what...
<p>You Can add attribute to dropdown list something like.</p> <pre><code>for(int i=0;i&lt;dropdownlist.items;i++) { dropdownlist.attributes.add(dropdownlist.items[i].value,//here get the value that you want to show in textbox from datasource or datatable) } </code></pre> <p>on selected index changed.</p> <pre><cod...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Unable to edit S3 object metadata in console or Cyber Duck<p>I am trying to edit the metadata for S3 objects in both Cyber Duck and the AWS Console. Cyber Du...
<p>I figured it out. The files were uploaded as an anonymous user, therefor I could not edit anything about them. I re-uploaded everything with correct credentials and was able to change the metadata.</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to use Regexp in mysql queries?<p>I have a mysql table like following</p> <pre><code>jobno | duration ---------------- 1 | 1 hr 2 | 3 hrs 3 ...
<pre><code>select * from TableName where duration NOT REGEXP '^([^1]|[1-9][0-9]+) hr.*' </code></pre> <p>Try this.This will work.<a href="http://www.sqlfiddle.com/#!2/ba4de/2/0" rel="nofollow"><strong>See here</strong></a></p> <p>For less than <code>3</code> you can use </p> <pre><code>select * from TableName where ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: defaults using Getdate and DateAdd are not working<p>I set up a table yesterday with the following code. the code ran with no error messages reported and the...
<p>You may find the handling of defaults a bit counter-intuitive in SQL Server. The syntax is:</p> <pre><code>DEFAULT constant_expression </code></pre> <p>It so happens that SQL Server <em>extends</em> the definition of <code>constant_expression</code> to include non-deterministic scalar functions, such as <code>get...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Test for compatibility in Matlab<p>I'm working with an open source Matlab toolbox which, according to its creators, is compatible for versions of Matlab over...
<p>This is a common problem. <a href="https://www.mathworks.com/matlabcentral/newsreader/view_thread/152699" rel="nofollow">This page</a> talks of the same problem - claiming that there is no good solution... It does however come with a smart way of searching through the release notes:</p> <ol> <li>Click on the bottom...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to avoid different capture group numbers in a regex?<p>I'm trying to capture an IP address in a log and revert on a hostname if the address is 0.0.0.0.</...
<p>It's unclear from your question which environment/language/regex flavour you're dealing with. But PCRE regexes actually let you do this with the <code>(?|some(capture)|another(capture))</code> syntax:</p> <pre><code>ip=(?|0\.0\.0\.0.*?host=(\S+)|(\d+\.\d+\.\d+\.\d+)) </code></pre> <p><img src="https://www.debuggex...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: how to catch checkbox value within "UL" tag<pre><code>&lt;ul class = "classUL" id = "idUl1"&gt; &lt;li&gt; &lt;label class = "classLabel"&gt; ...
<p><strong>Please have unique IDs in HTML Markup</strong></p> <pre><code>$(document).ready(function(){ $("ul.classUL").each(function(){ $(this).find(".classCheck").each(function(){ console.log($(this).val()); }); }); }); </code></pre> <p>Will give you the value of all checkboxes.</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Java - Parsing json object (end of input at character 0 of ...)<p>I am trying to simply get and parse some json to then be added into a spinner. I simply req...
<p>You are trying to parse a JSONArray as a JSONObject. </p> <p>Try</p> <pre><code>JSONArray jsonArray = new JSONArray(result); </code></pre> <p>instead of </p> <pre><code>JSONObject jObject = new JSONObject(result); </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How do I install JDBC to work in Java 8 on Debian 10?<p>I'm trying to connect into MySQL database on Java 8 using this code, but I'm getting an exception tha...
<p>When calling your java program from command line you should add additional parameter -cp or -classpath with a reference to the JDBC library jar file.</p> <p>Example:</p> <pre><code># Java directory export JAVA_DIR="/usr/java8_64" # Classpath export CLASSPATH="/usr/lib/mysql-connector-java.jar" # Start applicati...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to use different sub queries with SQL MERGE<p>Can we pass different sub queries in SQL MERGE for inserting and updating data?</p> <pre><code> MERGE Tab...
<p>Try the following:</p> <pre><code>WITH S AS ( SELECT B.ColumnA, B.ColumnB, B.ColumnC FROM ( SELECT B.ColumnA, B.ColumnB, B.ColumnC, ROW_NUMBER() OVER (PARTITION BY B.ColumnA, B.ColumnB ORDER BY B.ColumnA, B.ColumnB) AS RowId FROM TableB B ) B WHE...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Check if parent class is instance of child class<p>I have one class defined like this:</p> <pre><code>class Car { } </code></pre> <p>And many other define...
<p>You can use <code>instanceof</code>:</p> <pre><code>Car car = cars.get(0); if (car instanceof Audi) { // It's an Audi, now you can safely cast it Audi audi = (Audi) car; // ...do whatever needs to be done with the Audi } </code></pre> <p>However, in practice you should use <code>instanceof</code> spari...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Android Crashlytics - Unable to upload symbols<p>Crashlytics has been set up for my Android app for a while and working fine for normal Java/Kotlin code. I'm...
<p>When contacting the Crashlytics helpdesk I got some steps to provide them with some logs. While going through these steps everything just worked, the stacktraces are showing up in Crashlytics as expected.</p> <p>In case someone runs into any problems. Check the crashlytics logs (Thanks for the helpdesk for providin...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to unit test collection methods with velocity/jasmine<p>I'm completely new to javascript testing and I am trying to get a grasp on how to approach testin...
<p>Unless you are manually inputting data into Mongo manually (or outside of Meteor) then you don't need to test the database.</p> <p>What you should be testing, are the execution paths in your code.</p> <p>So for the case above, <code>hasAnyPayments</code> is a unit that finds all user payments and returns true if t...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Calling simple java static method via JNI does not work, though c++ compiles and run it<p>Considering this Java class with the static method:</p> <pre><code...
<p>You should specify the returned JNI type in <code>&lt;...&gt;</code> when calling the method :</p> <pre><code>QAndroidJniObject str = QAndroidJniObject::callStaticObjectMethod&lt;jstring&gt;( "org/.../TestClass" ,"staticMethod"); QString string = str.t...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: adf test and acf plot on multiple columns<p>I am trying to apply adf.test to all columns of a dataframe. Some columns have NA values. I would like to store t...
<p>You could try</p> <pre><code>lapply(H, function(x) adf.test(x[!is.na(x)], alternative='stationary', k=0)) </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: connect a function when menu title is clicked<p>I am trying to find open ports and add them to my menu. Right now, what I succeed having an action to my menu...
<p>You have to use the <a href="https://doc.qt.io/qt-5/qmenu.html#aboutToShow" rel="nofollow noreferrer"><code>aboutToShow</code></a> signal:</p> <pre class="lang-py prettyprint-override"><code>self.ui.productMenu.aboutToShow.connect(self.findPort) </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Clean the data based on condition pandas<p>I have a data frame as shown below</p> <pre><code>ID Unit_ID Price Duration 1 A 20...
<p>Use <a href="http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.transform.html" rel="nofollow noreferrer"><code>GroupBy.transform</code></a> with <a href="http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.size.html" rel="nofollow noreferrer"><cod...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Populating matrix with for loop depending if index is even or odd<p>This is a part of a PDE problem that I'm trying to solve numerically. I know that my calc...
<p>I think you can simply pad matrix <code>A</code> with two extra rows and columns, and remove them later: </p> <p>Look at the following modified version of your code: </p> <pre><code>h = 1/10; x = 0:h:1; M = length(x); % Assemble stiffness matrix A and load vector b. %Initialize A to have two more rows and c...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: SPARQL Query with filtering over an integer<p>I am writing a very straightforward sparql query that filter an integer value.</p> <p>I figured it out through...
<p>You should write it like this: </p> <pre><code>select ?uri where {?uri &lt;http://dbpedia.org/ontology/wikiPageID&gt; ?id. FILTER (?id=856)} </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Maximum Flow and Some Condition<p>Suppose we have a Directed Graph and each edges has a positive capacity. if C is a positive constant, i say, if we add or s...
<p>The claim is true, because the maximum flow is also the <em>min cut</em>.</p> <p>Let the old capacity be <code>w:E-&gt;N</code>, and the new capacity <code>w':E-&gt;N</code> such that <code>w'(e) = C*w(e)</code></p> <p>The min cut is the sum of <code>w'(e_i)</code> for each <code>e_i</code> in the cut, but since <...