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:
Why are the addresses of argc and argv 12 bytes apart?<p>I ran the following program on my computer (64-bit Intel running Linux).</p>
<pre class="lang-c pre... | <p>On your system, the first few integer or pointer arguments are passed in registers and have no addresses. When you take their addresses with <code>&argc</code> or <code>&argv</code>, the compiler has to fabricate addresses by writing the register contents to stack locations and giving you the addresses of th... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Unable to get the closest span text<p>I am trying to fetch the clicked attribute text </p>
<p>This is my code </p>
<pre><code><div class="swiper-wrapper... | <p>Closest is a method so needs to have <code>()</code> at the end of the call, however you don't need to use it here as <code>closest()</code> looks <em>up</em> the DOM tree, whereas you want to look <em>down</em> to find the child <code>span</code>:</p>
<pre><code>$(document).on("click", ".swiper-slide", function ()... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Python PrettyTable - enter a value into column once and update count of its occurrences<p>I have created a pretty table as below:</p>
<pre><code>from pretty... | <p>i was able to solve this myself :-) </p>
<pre><code>from collections import Counter
from prettytable import PrettyTable
# objects
my_table = PrettyTable()
my_table.field_names = ["Permit_Type", "Count"]
def get_list_of_permissions():
requests = []
for permission in permit_type_list:
requests_in_lis... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How can I use textbox to write the user key input? (WPF, C#)<p>Basically, I'm trying to write in a TextBox the key corresponding to the user input. The probl... | <p>You get such behaviour since both <code>PreviewKeyDown</code> and <code>KeyDown</code> are called. You just need to tell that you dont need to process it further by setting <code>e.Handled = true</code></p>
<pre><code>private void OnTextBoxOneKeyDown(object sender, KeyEventArgs e)
{
TextBox1.Text = e.Key.ToStri... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Cannot get just the second list on a page with PHP Simple DOM<p>I have this code to try and extract a list on a page:</p>
<pre><code>$websiteURL = "https://... | <p>To answer your question "I suppose my bottom line question is how do I access all the <code><li></code>'s from the second on a web page?" using an API that is relatively modern, well-supported, and built into PHP:</p>
<pre><code><?php
$url = "https://waset.org/conferences-in-january-2022-in-tokyo";
libxm... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to get current date time format in SQlite?<p>I am using sqlite for local database in mobile and in my database. i want to know that</p>
<p>How to get cu... | <p>To get the current date you can use:</p>
<pre><code>SELECT date('now');
</code></pre>
<p>Note: This is NOT a server date, it's the same time you get if you query the date and time directly from your application because SQLITE runs in-process.</p>
<p>It's mostly useful for putting a current time into a table or for s... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Secure way to update a remote database using a java client<p><strong>Language : JAVA
Target-OS : Cross Platform</strong></p>
<p>I have a database on my serv... | <p>Here I found the answer, Seems it is the second option. Awake SQL (mentioned by Pavan Kumar ) also seems to be connecting to a server side web service layer. Read this.
<a href="https://softwareengineering.stackexchange.com/a/150529">How do you handle database security from a desktop application?</a></p> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Full width floatingactionbutton in flutter?<p>How can I implement a full width floatingactionbutton without using padding in bottom of the screen in flutter<... | <p>You can use a different approach. You can implement the same using stack. </p>
<pre><code>Stack(
children: <Widget>[
Align(
alignment: Alignment.bottomCenter,
child: Container(
width: MediaQuery.of(context).size.width,
height: 55,
child: FloatingActionButton.extende... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Regex remove everything after 2nd dash<p>I have a large amount of data that I need to filter using Regex. The data consists of strings that look like this:</... | <p>You can use a simple regex like this:</p>
<pre><code>(.*?-.*?)-.*
</code></pre>
<p><strong><a href="https://regex101.com/r/iO7hD2/2" rel="nofollow noreferrer">Working demo</a></strong></p>
<p><img src="https://i.stack.imgur.com/Pim6d.png" alt="enter image description here"></p>
<p>You can check on <strong>Code g... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to stop or break free from a Twig loop?<p>In PHP you've got the possibility to break from a loop or continue to the next iteration. I was wondering if yo... | <p>You could do something like this, in order to simulate the pattern:</p>
<pre><code>{% set breakLoop = false %}
{% for value in array if breakLoop == false %}
{% if value == 'somethingElse' %}
{% breakLoop = true %}
{% endif %}
{% if value != 'something' and breakLoop == false %}
{{ v... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to dynamically set number of swipeable tabs in Action Bar with Fragments at runtime<p>I am referring this <a href="http://www.androidhive.info/2013/10/an... | <p><strong>STEP 1:</strong></p>
<p>Define your <code>TabsPagerAdapter</code> as follows:</p>
<pre><code>public class TabsPagerAdapter extends FragmentPagerAdapter {
private ArrayList<Fragment> list;
public TabsPagerAdapter(FragmentManager fm, ArrayList<Fragment> list) {
super(fm);
... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Generic type assignment says incompatible type for more restrictive assignment<p>I have a variable of following type</p>
<pre><code>Pair<String, Class<... | <p><code>Tiger</code> is subtype of <code>Animal</code>, but <code>Class<Tiger></code> is <em>not</em> a subtype of <code>Class<Animal></code>. The parent of both <code>Class<Tiger></code> and <code>Class<Animal></code> is <code>Class<?></code>.</p>
<p>Similarly, <code>Pair<String, Cla... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Fill Multiple Tables in Single Typed Dataset?<p>Background</p>
<p>I am new to working with Datasets. I am finding examples, reading how-tos, watching tutori... | <p>Sure - just use the same dataset reference in each <code>Fill</code>:</p>
<pre><code>GPDataSetTableAdapters.VPF_WORKTableAdapter adapt_VPF_WORK = new GPDataSetTableAdapters.VPF_WORKTableAdapter();
GPDataSetTableAdapters.VPF_Exhibitor_MSTRTableAdapter adapt_VPF_Exhibitor = new GPDataSetTableAdapters.VPF_Exhibitor_MS... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Is any method overloading be a compile time polymorphism?<p>I refer to some java tutorials and found java having two types of polymorphism.</p>
<blockquote>... | <p>In Java, the choice, which of the overloads to invoke, is always made at compile-time. This applies to <code>static</code> methods, instance methods, and also constructors.</p>
<p>Note that the two statements are not contradicting. The first says, “If you overload a static method…”, which names a correct example, b... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Singleton thread-safe programs<p>I'm trying to write a simple app with singleton design in Qt. Below is the header file:</p>
<pre><code>#ifndef MAINWINDOW_H... | <p>Based on previous answers and also <a href="http://doc.qt.io/qt-5/qglobalstatic.html#Q_GLOBAL_STATIC" rel="nofollow">http://doc.qt.io/qt-5/qglobalstatic.html#Q_GLOBAL_STATIC</a>, the answer is like below:</p>
<pre><code>#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class M... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
laravel function permissions<p>I have a working function in my controller but I want to add a permissions gate in order to use the function.</p>
<p>Basicall... | <p>I am not sure how you defined your gate, but the code below works for me.</p>
<p><code>controller</code></p>
<pre class="lang-php prettyprint-override"><code>Route::get('/test', function () {
Gate::allows('can-fix') ?: dd('you do not have the access');
dd('yes you can reach here');
});
</code></pre>
<p><... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Can not connect to kafka with conduktor?<p>I installed Kafka on a VM Ubuntu 18.0.4 with following compose file</p>
<pre><code>version: '2'
networks:
kafk... | <p>You should change <code>KAFKA_CFG_ADVERTISED_LISTENERS</code> if your conductor is not installed in the same machine as Kafka cluster installed.</p>
<p>It should be like this for kafka-server1:</p>
<pre><code>KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://192.168.179.33:9092
</code></pre>
<p>and kafka-server2:</p>
<... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
SQL query to LINQ expression - Entity Core Framework 3 + SQL Server<pre><code>DECLARE @thirtyDaysAgo DATETIME = getdate()-30
SELECT
sum(case when CreatedWh... | <p>You need to use the singleton <code>GroupBy</code> trick:</p>
<pre><code>var ans = ThisAwesomeTable.GroupBy(r => 1)
.Select(rg => new {
lessThan30 = rg.Sum(r => r.CreatedWhen >= thirtyDaysAgo ? 1 : 0),
GreaterThan30 = ... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Is this possible to create 2-axis 4 color gradient in css (bilinear gradient)?<p>My exmaple in JavaScript and <code><canvas></code>. <a href="https://c... | <p><code>mask</code> combined with <code>linear-gradient</code> can do it:</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-css lang-css prettyprint-override"><code>.box {
height: 200px;
width: 300px;
backgroun... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to get a Dynamic Content Control to refresh onChange?<p>I have used the Dynamic Content Control with a Dynamic Page formula a fair bit but it has always ... | <p>You can load different custom controls dynamically if you <code>redirect</code> to the same page instead of a full or partial refresh and write the desired custom control name into a session scope variable before.</p>
<p>Your test XPage could look like this then:</p>
<pre class="lang-xml prettyprint-override"><c... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Python, process a large text file in parallel<p>Samples records in the data file (SAM file):</p>
<pre><code>M01383 0 chr4 66439384 255 31M * 0 0 AA... | <p>The simplest approach would probably be to do all 30 files at once with your existing code -- would still take all day, but you'd have all the files done at once. (ie, "9 babies in 9 months" is easy, "1 baby in 1 month" is hard)</p>
<p>If you really want to get a single file done faster, it will depend on how your ... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Better packages structure in my Android library<p>I'm writing (for the first time) an Android library (with its own Activities) that will be imported in othe... | <p>A common convention is to use a package named <code>internal</code> for private implementation/internal classes .</p>
<pre><code>com.mycompany.myplugin // all public stuff here and in its subpackages
com.mycompany.myplugin.internal // all non public stuff
</code></pre>
<p>Also, follow <a href="https://stackoverflo... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Problem importing a function within another function<p>I have two files, blah.py containing</p>
<pre><code>def blah():
print("External blah")
return... | <p>I think this link <a href="https://stackoverflow.com/questions/42451827/python-local-variable-compile-principle">Python local variable compile principle</a> should help you to understand what happens (all three answers and comments are helpful).</p>
<p>To summarize, the names are added to a scope during compilation... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to extend an ember-cli addon?<p>In my ember-cli app i have installed an addon called <code>'ember-cli-selectize'</code>. Looking at the directory structu... | <p>You were close with: </p>
<pre><code>import EmberSelectize from 'components/ember-selectize';
</code></pre>
<p>Addons namespace themselves - in this case, ember-cli-selectize. So, just add the namespace to your import: </p>
<pre><code>import EmberSelectizeComponent from 'ember-cli-selectize/components/ember-selec... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
custom formatting of parameters in xdebug error messages<p>I know with Xdebug you can change your <code>xdebug.collect_params</code> settings, so that the er... | <p>As pointed out in the comment above:</p>
<p>PHP 5.6 supports <a href="http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.debuginfo" rel="nofollow noreferrer">__debugInfo()</a>. A <a href="https://github.com/xdebug/xdebug/commit/14159486d8d77732b5ae193ca9431bae80c94074" rel="nofollow noreferrer">pa... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How specialized are the Stream implementations returned by the standard collections?<p><a href="http://docs.oracle.com/javase/8/docs/api/java/util/stream/Str... | <blockquote>
<p>Does it run in constant or linear time?</p>
</blockquote>
<p>The current implementation runs in linear time:</p>
<pre><code>public final long count() {
return mapToLong(e -> 1L).sum();
}
</code></pre>
<p>But, this could be improved (there's an RFE for this somewhere) to run in constant time ... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
If statement from different sheet base on two cell<p>I have a 2 sheets,Summary & Remarks and I'm trying to create a REMARKS ERROR base on summary sheet d... | <p>try like this:</p>
<pre><code>=IF(TRIM(C9)=LEFT(D8, 4), IFNA(VLOOKUP(F8, I:J, 2, 0), ))
</code></pre>
<p>or arrayformula:</p>
<pre><code>=ARRAYFORMULA(IF(TRIM(C9)=LEFT(D8:D, 4), IFNA(VLOOKUP(F8:F, I:J, 2, 0), ), ))
</code></pre>
<p><a href="https://i.stack.imgur.com/rrDs4.png" rel="nofollow noreferrer"><img src=... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
React/Redux - Update state in parent component from child component<p>I've 2 components: Header and Child in an already developed <code>react</code> applicat... | <p>mapStateToProps = putting redux store state into the props</p>
<p>mapDispatchToProps = putting redux actions into the props</p>
<p>So on the child, you want to call an action that will update the store via mapDispatchToProps</p>
<p>Then on the parent you want to use mapStateToProps to read this updated value </p>... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
return type for event in TinyOS<p>I'm implementing a module using <code>nesC</code> for <code>TinyOS</code>. My modules uses interface Timer<> so I have t... | <p>The return type of the <code>Timer.fired</code> event is defined as <code>void</code> and this cannot be changed. Even if the type was non-void, the returned value would be delivered to the component that signals the event, which is some system component implementing the <code>Timer</code> interface.</p>
<p>In orde... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How can I use a 3d array as a datasource for a UICollectionView in Swift?<p>I have a datasource that is a three dimensional array.</p>
<p>I am using the fir... | <p>This is how I solved this problem:</p>
<ol>
<li>Partially flatten the 3d array to become a 2d array useable as a datasource for the collection view.</li>
<li>Find what the index of the twoDimensionalArray[indexPath.section][indexPath.row] would be if that array were also flattened. (<a href="https://stackoverflow.c... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
What does joinPoint.proceed() do?<p>It is my first approaching to AOP. I've a spring-boot application with one Aspect, a Logger. Searching i reach to the con... | <p>As you said, when you're using <code>@Around</code> it's just like you can do whatever you want <strong>before</strong> the method, then <strong>invoke</strong> the method, then you can do whatever you want after the method called.</p>
<pre><code>//Read file, Log , .... (Before method calling)
//Invoke the method (j... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
DELETE operation in GET rest service<p>I got a query while developing rest service.</p>
<p>As per the REST design, GET is to read , PUT or POST are to creat... | <blockquote>
<p>so my question is the DELETE or CREATE technically not possible in GET service or is it a rule to adhere to REST principles.</p>
</blockquote>
<p>The latter. It is only a convention to use the DELETE HTTP method for delete operations. However using the GET HTTP method for delete operations is a bad i... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Exception error while installing NLTK in Ubuntu 14.4 and Python 2.7<p>I got following error while installing NLTK when i run this command</p>
<p><code>sudo ... | <p>Most likely, you've cut and pasted this line from some web page (or PDF). The web page probably changed the <a href="http://www.theasciicode.com.ar/ascii-printable-characters/minus-sign-hyphen-ascii-code-45.html" rel="nofollow">ASCII hyphen (minus sign)</a> into a <a href="http://www.fileformat.info/info/unicode/cha... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Is it possible to use both L and E letters to initializing 'Long' numeric literal?<p>If I declare a <code>long</code> variable as:</p>
<pre><code>long n = 1... | <p>No, this is not possible. The use of <code>e</code> or <code>E</code> in a numeric literal (i.e. <a href="https://en.wikipedia.org/wiki/Scientific_notation#E_notation" rel="nofollow noreferrer">scientific notation</a>) is not allowed by the Java Language Specification for <a href="https://docs.oracle.com/javase/spec... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to retrieve the json_encode values to user side<p>My table name is tinfo and columnname is classconducted. column conducted class contains like this.</p... | <p>There is a PHP function called <code>json_decode()</code> <a href="http://php.net/manual/en/function.json-decode.php" rel="nofollow">see manual</a></p>
<p>Basically if you run the json string through this function it will convert it to a PHP variable i.e. if the json string is an object you get a PHP object and if ... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
strange behaviour in StorageFolder.CreateFolderAsync<p>I'm doing something for a windows store app, it's an Universal App project and I'm debugging on a Wind... | <p>This:</p>
<pre><code>CacheManager.InitializeOfflineFiles().Wait();
</code></pre>
<p>Is causing your app to <strong>deadlock</strong>. This is why you're seeing the "hanging" behavior. It is peculiar that you seem to be seeing folder 1 & 2 being created, as i assume this should deadlock when the first <code>awa... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How do I distinguish between an ID and a display value in a WPF ItemSource?<p>I have a data collection that I'd like to display in a WPF DataGrid (in C#). Se... | <p>You can use <a href="https://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter.aspx" rel="nofollow">IValueConverter</a> to convert 'Box type' integer to string like this:</p>
<pre><code>class BoxTypeConverter : IValueConverter
{
private static readonly List<string> idNames = new List<... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
PayPal Smart Payments: changing the currency code<p>I'm trying to set up PayPal Smart Payments on a webpage. I'm using the example they give on here: <a href... | <p>I found the answer here: <a href="https://developer.paypal.com/docs/checkout/reference/customize-sdk/" rel="noreferrer">https://developer.paypal.com/docs/checkout/reference/customize-sdk/</a></p>
<p>You have to add the currency code to the script URL instead, and remove it from the JS.</p>
<pre><code><script
... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
xslt apply-templates removes everything but values passed<p>I am using <code>XSLT</code> templates to generate emails that will go out to call center. Issue ... | <p>If I am guessing correctly, you need to change:</p>
<pre><code><xsl:template name="Products">
</code></pre>
<p>to:</p>
<pre><code><xsl:template match="ProductsItem">
</code></pre>
<p><em>(note the change from <code>name</code> to <code>match</code>!)</em> </p>
<p>and:</p>
<pre><code><xsl:templ... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Is there a way to separately use the same animation on all the items generated by ngFor in Angular?<p>So I have a div element which I loop over with ngFor an... | <p>If you want to add a delay before next element is animated, you can use the <a href="https://angular.io/api/animations/stagger" rel="nofollow noreferrer">stagger method</a></p>
<p>Your code become :</p>
<p>HTML</p>
<pre class="lang-html prettyprint-override"><code><div [@fadeIn]="products.length">
<div... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Floating view (like in the Apple stock mail app)?<p>I would like to implement a floating view into my iOS app. Something like the one in Apple´s stock mail a... | <p>The Mail compose UI on iPad is an example of a view controller being shown as a <a href="https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/Alerts.html#//apple_ref/doc/uid/TP40006556-CH14-SW3" rel="nofollow">modal view</a>. You can get this style by <a href="https://developer.a... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to call shell scripts to manage LaunchAgents from a sandboxed macOS application?<p>I have a non-sandboxed macOS application that happily calls on shell s... | <p>I found an answer on Apple Support forums posted by an Apple staff member:</p>
<blockquote>
<p>Is is possible to have applications in the Mac App Store that work
with LaunchAgents?</p>
<p>No.</p>
<p>Why not:</p>
<ol>
<li>XPC Services included within an app are only available to that app.</li>
... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
zookeeper.log file not created inside logs directory<p>I'm unable to create zookeeper.log under the directory i had specified in the log4j.properties. I'm no... | <p>For Chef :
1) Create zookeeper-env.sh.erb template file and set the classpath.</p>
<pre><code>NAME=zookeeper
ZOODIR="path/to/zookeeper/directory"
ZOOCFGDIR="$ZOODIR/conf"
CLASSPATH="$ZOOCFGDIR:$ZOODIR/build/classes:$ZOODIR/bin/build/lib/*.jar:$ZOODIR/lib/slf4j-api-1.7.5.jar:$ZOODIR/lib/netty-3.2.2.Final.jar:$ZOODI... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Writing a promise to work with a callback that passes two arguments<p>In a recent cordova app at work, we used the WebSQL api, as it gave us the device suppo... | <p>In your <code>executeSql</code> method you pass <code>resolve</code> to the <code>transaction.executeSQL</code> method. </p>
<p>Promises are like normal values - you can't return multiple values from a function - just like you can't resolve a promise with multiple values. Your options are either to resolve it with ... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
php excel export - text is broken up into a new line<p>I am fetching mysql data and writing it to xls file, that data contains First Name,Last Name, Email, A... | <p>You should be using the fputcsv function to write as CSV. That will take care of the encoding and also escaping weird characters that break the layout. More details on the PHP documentation <a href="http://php.net/manual/en/function.fputcsv.php" rel="nofollow">here</a>.</p>
<p><strong>EDIT:</strong>
OP wanted a XL... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How can I remove a piece of javascript text with tritium?<p>I have this piece of tritium text that I was to use in order to remove a piece of javascript code... | <p>Hi there please verify that the mixer stdlib is present on your Mixer.loc file and then try using the following replace:
<a href="http://www.tritium.io/current#Text.replace(Regexp%20%25search,%20Text%20%25with)" rel="nofollow">http://www.tritium.io/current#Text.replace(Regexp%20%25search,%20Text%20%25with)</a></p>
... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to display greek letters in the body of a table in R Markdown?<p>I wish to display greek letter alpha in the table generated by the following code in R M... | <p>Use <code>$</code> notation in strings to insert LaTeX symbols, including Greek letters. Like this: </p>
<pre><code>DF = cbind(c("$\\alpha$",as.character(rows)), DF)
</code></pre>
<p>If you knit <code>kable(DF)</code>, you'll see alpha appear in the first column header. Note that the symbol will not appear in t... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Unique user having unique values in two php arrays<p>I'll move to the query straight away. I have an html form having two fields(Email and a numeric id) aski... | <p>Based on the information you have provided I think this solution is sufficient:</p>
<pre><code>// ok - this is a reproduction of the two arrays you've got
$BX_EMAIL = array("1@domain.com", "2@domain.com", "3@domain.com", "2@domain.com");
$BX_NUM = array(1,2,3,2);
// merge the two arrays into two-dimensional array
... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Citrus-Framework: Conditional validation depending on status code<p>I'm evaluating citrus-framework for blackbox testing of a rest service.</p>
<p>is there ... | <p>What you need here is to store the received Http response into the local message store for later validation. Instead of extracting the payload to a variable you can add a name for the received message:</p>
<pre><code>http(httpActionBuilder -> httpActionBuilder
.client(sutClient)
.... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
PHP fetch_assoc return values, looping<p>I have the following code that returns two associative arrays (both of which are SQL query results). It should, iter... | <p><a href="http://php.net/manual/en/function.array-diff-assoc.php" rel="nofollow"><code>array_diff_assoc()</code> might do what you need</a>. It should return all keys > values that are present in both arrays.</p> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Using mod_filter instead mod_deflate, the .htaccess way<p>I've a Wordpress site running in a VPS but it's extremely slow, take a look <a href="http://elclari... | <p><strong>First check if you have mod_deflate installed by using phpinfo(), then try <a href="http://www.ipmango.com/http/deflate" rel="nofollow">http://www.ipmango.com/http/deflate</a> to check for relavant headers.</strong> </p>
<p>Besides deflate there are are couple of reasons for your site to be slow. All these ... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Is there a Framework that allows you write "real" classes using Javascript?<p>Is there a Framework that allows you to define classes like this?
If not a Fram... | <p>TypeScript has a syntax which is very similar to what you have asked.</p>
<p>From the blog post of John Papa (<a href="http://bit.ly/1E8qC6E" rel="nofollow">http://bit.ly/1E8qC6E</a>), here is a sample class in TypeScript - </p>
<pre><code>class Car {
engine: string;
constructor (engine: string) {
thi... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
how to write validation in ajax php my sql<p>this is my code run but how to write validation code in this js
and i am using ajax php</p>
<pre><code><scri... | <p>You can do this like</p>
<pre><code><script>
$(document).ready(function(){
$('#myForm').on('submit',function(e) {
if(OPRID==null || OPRID=="")
{
alert("Operator Id must be filled out");
return false;
}
else
{
$.ajax({
... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How do you send many documents to a Scout Server in Python using the Python Scout Client?<p>Im trying to index PDF text to a python lib called <a href="https... | <p>So i find a lib called scout and...got it to work!</p>
<pre><code>from scout_client import Scout
# import libraries to help read and create PDF
import PyPDF2
from fpdf import FPDF
import base64
import os
from flask import Flask, jsonify, request, render_template, json
client = Scout('http://localhost:8000')
for ... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Gson throws "BEGIN_OBJECT expected but BEGIN_ARRAY found" - how to use TypeToken<p>Trying out Gson for the first time instead of looping through the JSON obj... | <p>The problem is in your <code>AccountsResponse</code> class. It should be an object <code>PagingData</code> not an <code>ArrayList</code>, because from the json response in your question, "paging" is a JSON object not a JSON array. So, you should declare <code>paging</code> as a <code>PagingData</code> object not as ... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
C program not functioning as expected when trying to iterate over multidimensional array to fill the rest of the array with calculated table values<p>In the ... | <p>Arrays in c are indexed from <code>0</code> to <code>N - 1</code>, this for instance</p>
<pre><code>for (int i = 1 ; i <= rowNum ; i++)
</code></pre>
<p>should be</p>
<pre><code>for (int i = 0 ; i < rowNum ; i++)
</code></pre>
<p>so when you reach <code>i == rowNum</code> your program invokes undefined beh... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How can New Relic keep my Java site up?<p>Is it possible to use New Relic on my Java site? I built it with JHipster Yeoman generator and deployed the WAR fil... | <p>From looking at the Jhipster site, it says it creates a Spring boot backend: <a href="https://jhipster.github.io/" rel="nofollow">https://jhipster.github.io/</a></p>
<p>Providing the version of spring used is v3 or v4 it should work. (I was unable to verify what version boot actually uses)
<a href="https://docs.ne... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
LESS nesting multuple psuedo elements/classes not working<p>I'm trying to get the output:</p>
<pre><code>#parent a:hover,
#parent a:link,
#parent a:visited ... | <p>You need to use the <a href="http://lesscss.org/features/#parent-selectors-feature" rel="nofollow">LESS parent selector <code>&</code></a>:</p>
<pre><code>#parent a {
&:link, &:hover, &:visited {
color: #000;
}
}
</code></pre> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
OpenCV - Extracting arrows from chart<p>I'm trying to perform OpenCV on a flow chart to extract the structure (image 1). All images are computer generated. I... | <p>Since the image has no noise, using Hough transform is not optimal.</p>
<p>I would binarize the image so that I get all non-white pixels from the image.
Then, using a matched filter, I would find vertical and horizontal line segments.
Arrows in any of the four directions can be found in a similar fashion.</p>
<p>F... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
PHP Simple XML Parser, blank response<p><strong><em>PHP Simple XML Parser, blank response.</em></strong></p>
<p>The main problem with the code below is that... | <p>Is it probably because you are not passing <code>$hin</code> to <code>hibbuy.php</code>?</p>
<p>Try:</p>
<pre><code>$hin = $_GET["hin"];
$connection = curl_init();
curl_setopt($connection, CURLOPT_URL, "http://192.168.0.12/hinbuy.php?hin=" . $hin);
</code></pre> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Create a matrix by sliding down a given vector by one step for every column<p>Given this vector</p>
<pre><code>a = [1 2 3 4]
</code></pre>
<p>I want to cre... | <p>One way to do it:</p>
<pre><code>a = [1 2 3 4]
n = numel(a);
%// create circulant matrix from input vector
b = gallery('circul',[a zeros(1,n-1)]).' %'
%// crop the result
c = b(:,1:n)
</code></pre>
<hr>
<p>Another way:</p>
<pre><code>b = union( tril(toeplitz(a)), triu(toeplitz(fliplr(a))),'rows','stable')
</co... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Checking if a node has fully connected neighbours<p>I have a graph and I want to check whether a node has fully connected neighbours. For a node to have full... | <p>Is it because each node is not a neighbour of itself?</p>
<p>For example...</p>
<pre><code>for(Node neighbour : neighbours)
{
for(Node n2 : neighbours) {
if(neighbour == n2) continue;
if(! neighbour.neighbours().contains(n2)) return false;
}
}
</code></pre>
<p>...or something</p> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
yii2 gridview update from activeDropDownList<p>Is it possible to have a activeDropDownList, which will update the contents of the Gridview widget? I would li... | <p>Use javascript to redirect to gridview page with GET value as your dropdown value:</p>
<p><strong>Sample js to redirect:</strong></p>
<pre><code> $this->registerJs(
'$(document).ready(function(){
$("#sectorid").change(function(){
var e = document.getElementById("sectorid");
var strSel = e.options[e.sele... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
error: dereferencing pointer to incomplete type in main file<p>Can you explain why the struct Test is incomplete and how to remove the error? Is the error re... | <p>If you don't define the structure in the header file it will not be <em>visible</em> from your <code>main.c</code>.</p>
<p>You need to do the following</p>
<p>Point 1. Put the structure definition in the <code>test.h</code> header file. use <em>include guard</em> also.</p>
<pre><code>#ifndef __MY_HDR_H_
#define _... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to click on a flash object<p>I need to click on a flash object. This is my javascript code below, currently, which is not working. I am not too familiar ... | <p>You need to use <code>querySelector()</code> not <code>querySelectorAll()</code>. <code>querySelectorAll()</code> is plural and hence it returns all <code>elements</code> matching the <code>cssSelector</code>. You also have to be careful about the selector and make sure it returns ONLY the intended element.</p>
<pr... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Blazor wasm unable to resolve AuthorizationOptions while attempting to activate DefaultAuthorizationPolicyProvider<p>I'm working on a Blazor wasm application... | <h2>The Solution</h2>
<p>When I first added the AddOptions() to the Services in the Program.cs, the problem was solved:</p>
<pre><code>builder.Services.AddOptions();
builder.Services.AddAuthorizationCore();
</code></pre> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
The string field is required. even thou there is no Required attribute in Asp.Net Core?<p>I am building a simple Asp.Net Core app in linux(pop os). I am usin... | <p>After @devNull's suggestion I found out that somehow while I was playing around with Rider IDE it seems it switched that feature on!</p>
<p>There is an option in rider that allows to change that configuration on project level:</p>
<p>If somebody has the same problem: right click on the project level, go to propert... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to use COLLATE Latin1_General_CI_AI with Full text search column<p>How to use 'COLLATE Latin1_General_CI_AI' with Full text search column in SQL Server 2... | <p>You need to turn off accent sensitivity. Unfortunately that is what takes precedence in full-text searches. Collation is not used as you would expect.</p> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Tkinter frame expand is only displaying half my window<p>I'm trying to create a phone in tkinter and i'm using frames but the image is being cut in half. Doe... | <p>I believe you have added the picture into a frame which only takes up up to half of the screen.
You could either:</p>
<ul>
<li><p>change the dimensions of the frame</p></li>
<li><p>add the picture to root like this:</p></li>
</ul>
<pre><code>canvas = tk.Canvas(root, width = width, height = height, bg = "black")
ca... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to find a difference between consecutive rows of a same group?<p>This question was asked in Facebook interview:</p>
<p>(1) There are Two tables</p>
<ul... | <p>You could join the tables, do conditional aggregation, then sort and limit:</p>
<pre><code>select
s.grade_level
sum(a.attendance * case when a.date = date('now') then 1 else -1 end) attendance_drop
from attendances a
inner join students s on s.student_id = a.student_id
where a.date in (date('now'), date('no... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Add days to datetime object<p>My data set contains multiple columns of sales-related data. I have <code>ORDEREDDATE</code> and <code>SHIPPINGDAYS</code> in t... | <p>Here's a way to do:</p>
<pre><code># make sure types are correct format
df['ORDEREDDATE'] = pd.to_datetime(df['ORDEREDDATE'])
df['SHIPPINGDAYS'] = df['SHIPPINGDAYS'].astype(int)
df['DELIVEREDDATE'] = (df
.apply(lambda x: x['ORDEREDDATE'] + pd.Timedelta(days= x['SHIPPINGDAYS']),
... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Faster XML Jackson: Remove double quotes<p>I have the following json:</p>
<pre><code>{"test":"example"}
</code></pre>
<p>I use the following code from Fast... | <p>Well, what you obtain when you <code>.get("test")</code> is a <code>JsonNode</code> and it happens to be a <code>TextNode</code>; when you <code>.toString()</code> it, it will return the string representation of that <code>TextNode</code>, which is why you obtain that result.</p>
<p>What you want is to:</p>
<pre><... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Is it undefined behavior to take the address of an uninitialized pointer?<p>N1570 states that this is undefined behavior:</p>
<blockquote>
<p>§J.2/1 The v... | <p>In this expression:</p>
<p><code>&ptr</code></p>
<p>the address of the <code>&</code> operand, i. e., the address of the <code>ptr</code> object is yielded but the <code>ptr</code> object is never evaluated.</p>
<p>(C11, 6.3.2.1p2) "Except when it is the operand of the sizeof operator, the unary & ope... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Create model instance using data from related object<p>I have two following models (with OneToOne relation):</p>
<pre><code>class Company(BaseModel):
na... | <pre class="lang-py prettyprint-override"><code>@receiver(post_save, sender=Company)
def create_invoicing_data(sender, instance, created, **kwargs):
if created:
invdata = InvoicingData(company=instance)
# set any other fields on invdata if desired
invdata.save()
</code></pre> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
TestNG:Cannot find class in classpath, testng.xml<p>This is my testng.xml file, i named it differently, but it should still work:</p>
<pre><code> <?xml ... | <p>You need to give the fully qualified class name of the class you want to test in <code>class</code> tag, something like this</p>
<pre><code><suite thread-count="5" name="Ant suite" junit="false" annotations="JDK">
<test name="Ant test">
<classes>
<class name="com.sample.test.MyU... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Mongodb Aggregation : Project an array without the first element<pre><code>{
"_id" : ObjectId("5e3179e83708dc0dcfefaf"),
"CaseNumber" : "T978045628"... | <p>Just try with this one </p>
<pre><code>db.getCollection('cases').aggregate([
{ $project: { ServiceReferences: 1, SerRef: { $slice: [ "$ServiceReferences", 1, {$subtract: [ {$size:"$ServiceReferences"}, 1 ]} ] }} }
])
</code></pre> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Why Sum and Product aren't Functors<p><a href="http://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Monoid.html#t:Sum"><code>Sum</code></a> defined in b... | <p>I believe the main reason these are not <code>Functor</code> instances is that you have not yet submitted a code review to make them so. You can file a ticket on <a href="https://ghc.haskell.org/trac/ghc">Trac</a>, then submit a code review on <a href="https://phabricator.haskell.org/">Phabricator</a>. The preferred... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
can't use type 'object' for Type-GraphQL field types<p>I would like to create a GraphQL layer for my NestJs API. So based on this interface holding a key/val... | <p>Sounds like you should be using a custom JSON scalar. Like <a href="https://github.com/taion/graphql-type-json" rel="noreferrer">this one</a>.</p>
<pre><code>import { GraphQLJSONObject } from 'graphql-type-json'
</code></pre>
<p>This can then either be used directly in the field decorator:</p>
<pre><code>@Field((... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
onTouchEvent hold down, continuous execution<p>In my onTouchEvent() method, I want to perform an action that continues to repeat itself until I lift my finge... | <p>Have you considered using a <code>Thread</code> to accomplish this?</p>
<p>It's late here (and I've been working for 13 hours), but this should give you the gist:</p>
<pre><code>WorkerThread workerThread;
public void onTouchEvent(MotionEvent event){
int action = event.getAction();
switch(action){
... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Java - GAE Datastore persisting Date with specific format<p>I have a Google app engine JDO datastore entity with a date field and it looks like the following... | <p>Datastore will always store dates as UTC along with the time and tzinfo=None included. There is no method to override this on Java neither on Pyhton as explained here [1]. </p>
<p>The exception is that in Python there is a class that will retrieve the "raw" date from Datastore and display the date part of it. This ... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to properly dispatch app wide data from a simple class?<p>Ideally I need a plain JavaScript class I can write to dispatch data using Redux to the rest of... | <p>The React-Redux <code>connect</code> function <em>only</em> works on React components.</p>
<p>If you need to interact with the Redux store in plain JS code, you need to either import the store directly into that file, or you need to call that code from a React component and pass through data you got from <code>conn... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Open a video at a particular time<p>In my program it is possible to make certain files open externally in whichever program is their file type default. I do ... | <p>If you have to use Windows Media Player the answer is no, there is no such command line parameter, you can find full WMP parameters list <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd562624(v=vs.85).aspx" rel="nofollow">here</a>. </p>
<p>If you can use VLC it has a <a href="https://wiki.videol... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Per-node default partition in SLURM<p>I'm configuring a small cluster, controlled by SLURM.</p>
<p>This cluster has one master node and two partitions.
User... | <p>This can be solved using <code>SLURM_PARTITION</code> and <code>SBATCH_PARTITION</code> environment variables, put in the <code>/etc/environment</code> file.</p>
<p>Details on environment variables are in manual pages for <code>sbatch</code> and <code>srun</code></p> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to make an increment followed by a decrement continuously?<p>I am trying to obtain an increment that goes up from 0 to n, then decreases from n-1 to 0, a... | <p>Try -</p>
<pre><code> int change = 1;
void draw(){
background(i);
i = i + change;
if(i==256){change = -1;}
if(i==0){change = 1;}
}
</code></pre> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Equals method for PlayingCard Class, how to get working?<p>I have been working on a PlayingCard class, and I am having difficulty writing an equals() method ... | <p>This is not doing quite what you may think:</p>
<pre><code>if (getClass() != otherObject.getClass())
</code></pre>
<p>You are comparing <code>Class</code> object references here. Even if the Classes are of the same type, they may have different <code>Class</code> object references returned by their respective <cod... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to Convert PSD into PNG, using Python Wand / ImageMagick?<p>I tried converting PSD to PNG, but as I save the PNG, Wand (wand-0.4.0-py2.7) spits out all l... | <p>This would work just well and <em>fast</em> for both read and write:</p>
<pre><code># Convert a large PSD to small PNG thumbnail
myImage = Image(filename="test.psd[0]")
myImage.format = "png"
myImage.sample(100, 100)
myImage.save(filename="test.png")
</code></pre>
<p>Because Wand is only reading 1 layer instead of... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How can I modify self in a closure called from a member function?<p>I am trying to calculate legal chess moves and am having problems satisfying the borrow c... | <p>The simplest change you can make is to pass the reference to the closure:</p>
<pre><code>struct Tester {
x: i8,
}
impl Tester {
fn traverse<F>(&mut self, mut f: F)
where
F: FnMut(&mut Tester),
{
f(self);
}
}
fn main() {
let mut tester = Tester { x: 8 };
te... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
OpenCL: Better to use more registers, or to pack values using bit-shift operators?<p>In OpenCL, on GPUs, register pressure will reduce occupation rates, so w... | <p>This will probably not answer your question the way you want it.</p>
<blockquote>
<p>In OpenCL, on GPUs, register pressure will reduce occupation rates, so we want to reduce the number of registers used.</p>
</blockquote>
<p>Register pressure will indeed reduce occupancy, but that does not imply it will reduce p... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Adding hints to a JQuery hangman game<p>I am trying to create Hangman game for my country. I have a list of random words to appear, and it's working correctl... | <p>You would more than likely want to incorporate them into your <code>wordList</code> and <code>engWord</code> data objects. Perhaps convert them into actual objects in case you need to add any other data to them (difficulty, etc)</p>
<pre><code>var wordList [
{ word: "book", hint: "this is my book hint" },
{ wor... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Thread Communication when Debug mode and Release Mode<p>Threads does not communicate each other while release mode but they do communicate while debug mode. ... | <p>They gave you the correct answer in the comments.</p>
<p>Using a plain <code>bool</code> to communicate between threads creates a <a href="https://en.cppreference.com/w/cpp/language/memory_model" rel="nofollow noreferrer">data race</a>:</p>
<blockquote>
<p>When an evaluation of an expression writes to a memory locat... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Manually set 'forked from' to GitHub project<p>My project A (hosted on GitHub) somehow (not sure how) forgot that it was originally forked from another open-... | <p>No, there is no way to turn an existing repo into a fork. You can permanently switch to <code>A'</code> and abandon <code>A</code>, it's a one-time procedure. And there is no need to merge <code>A</code> into <code>A'</code>; you can simply push the whole <code>A</code> into <code>A'</code> instead.</p> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Undefined offset: 4<p>I'm new in Yii programming and i found this notice when i try to make a quiz modul. !</p>
<pre><code>Undefined offset: 4
it indicates... | <p>In PHP you get an "undefined offset" error when you try to read an array element with a key which doesn't exist.</p>
<p>For example:</p>
<pre><code>$arr1 = array('a','b','c');
echo $arr1[50]; // gives undefined offset error
</code></pre>
<p>This can be solved by using isset() first. For example:</p>
<pre><code>i... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Table layout with textviews<p>I have a table layout with 3 columns, and I have 3 string arrays. I want that every column have a textview per cell from the st... | <p>Well, finally I managed to make it:</p>
<pre><code>TableLayout prices = (TableLayout)findViewById(R.id.table);
String[] column1 = getResources().getStringArray(R.array.column1);
String[] column2 = getResources().getStringArray(R.array.column2);
String[] column3 = getResources().getStringArray(R.array.co... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How can I have static dispatch for a linked list containing different types all implementing a trait?<p>I have this working code:</p>
<pre><code>struct Laye... | <p><strong>TL;DR</strong>: It is impossible (at least w/o <a href="https://github.com/rust-lang/rfcs/issues/376" rel="nofollow noreferrer">variadic generics</a>*)</p>
<ul>
<li><p>Right now <code>Layer</code> structure requires <code>2</code> generic parameters: <code>R</code> and <code>'a</code>.</p></li>
<li><p>Let's... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Vim calling command on save<p>I am trying to call <a href="https://github.com/Chiel92/vim-autoformat" rel="nofollow">this</a> autoformatting plugin on save</... | <p>You've already found the solution - here's the explanation:</p>
<p>The <code><CR></code> is for <em>mappings</em>, which work like a recorded sequence of typed keys, so you need to start command-line mode with <code>:</code> and conclude with <code><CR></code>. An autocmd takes an <em>Ex command</em>, s... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Input fields get (readonly) after hit submit button<p>I have a script which is coded in PHP and smarty and I want to make some changes in this script like in... | <pre><code><input type="text" name="country" value="Norway" readonly>
</code></pre>
<p><a href="http://www.w3schools.com/tags/att_input_readonly.asp" rel="nofollow">http://www.w3schools.com/tags/att_input_readonly.asp</a></p>
<p>Then simply do a check if the POST/GET is set for the field you want to have readon... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to Collect first element of each row of type int[][] using Java 8 Streams<p>How do I collect <code>List<Integer></code> containing the first elemen... | <p>use <code>map(Function<? super T, ? extends R> mapper);</code></p>
<pre><code>List<Integer> output = Arrays.stream(input)
.map(r->r[0])
.collect(Collectors.toList());
</code></pre>
<p>if you want to use just <code>collect</code> -> <code><R> R collect(Supplier<R>... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Editing CSS through JavaScript produces left-hand assignment error<p>I'm trying to create a list that when an item is clicked, the item is strike-throughed (... | <p>Generally in JavaScript functions and properties are written in camelCase. So when you write</p>
<pre><code>document.getElementById(id).style.text-decoration = "line-through"
</code></pre>
<p>JavaScript sees the minus symbol (<code>-</code>) as a weird subtraction and assignment on the left hand side and gets a li... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Getting the number of different values in a PHP array<p>I need to know the number of <em>different</em> values in an array. For example if it contains (5, 5,... | <p><code>echo count(array_unique($arr));</code></p>
<p>you can use <code>array_unique</code> which returns unique elements of array (result is also array type) and then <code>count</code> on result</p> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to run function if html form is invalid?<p>I am making a form. I need to <strong>give feedback if form is invalid by changing button style and text</stro... | <p>If invalid, on button click <strong>give feedback if form is invalid by changing button style and text.</strong> If valid, and button is clicked, .submit functions run.</p>
<pre><code>$("#btn-copy").click(function(e){
if(document.getElementById('form-pesan').checkValidity()){
console.log('form valid and butt... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.