Id int64 34.6M 60.5M | Title stringlengths 15 150 | Body stringlengths 33 36.7k | Tags stringlengths 3 112 | CreationDate stringdate 2016-01-01 00:21:59 2020-02-29 17:55:56 | Y stringclasses 3 values |
|---|---|---|---|---|---|
56,086,286 | terraform.tfvars vs variables.tf difference | <p>I've been researching this but can't find the distinction. A variables.tf file can store variable defaults/values, like a terraform.tfvars file.</p>
<p>What's the difference between these two and the need for one over the other? My understanding is if you pass in the var file as an argument in terraform via the command line.</p>
<p>There is a thread about this already and the only benefit seems to be passing in the tfvars file as an argument, as you can "potentially" do assignment of variables in a variable.tf file.</p>
<p>Is this the correct thinking?</p>
| <terraform> | 2019-05-11 00:34:49 | HQ |
56,086,599 | Two dimmensional array feeding | need to do an arr[n,n] which will do a result as [0,0] = 0 [0,1] = 1 [0,2] = 3 [0,3] = 6 [1,1] = 0 [1,2] = 2 [1,3] = 5 [2,2] = 0 [2,3] = 3 [3,3] = 0
It is night right now and I feel so flustrated(read sleepy) as I can't solve the problem. Trying to feed that arr with two for cycles, that's I think is good way to go. Anyway, can't figure out how to set conditions to generate it as I want it.
Any hint is welcome, trying to programme solution for optional task in school.
Pasting code which I ended, totaly mishmash. I guess when I wake up in the morning I will try to do it once again all. Thanks for any hint/advice.
I tried to feed an array with two fors, where I tried to sum values. So many errors occur when I start typing code.
```int[,] array_prava = new int[n,
for (int i = 0; i < n; i++) // array_prava
{
for (int j = 0; j < n; j++)
{
if (j == i || j == 0)
{
array_prava[i, j] = Math.Abs(j - i);
}
else if (i >= 1)
{
array_prava[i, j] = Math.Abs(j + 1 - i) + array_prava[i, j - 1];
}
else if (i > j) {
array_prava[i, j] = 0;
}else
{
array_prava[i, j] = Math.Abs(j - i) + array_prava[i, j - 1];
}
any hint is welcome | <c#><arrays><feed> | 2019-05-11 01:56:37 | LQ_EDIT |
56,086,634 | How to remove the first dot from every line but only if it exists | <p>I have a list of subdomains and I want to remove any dot at the beginning of a line, if there is no dot at the beginning of the line, then it leaves that line untouched.</p>
<p>Like this example:</p>
<pre><code>x8.ext.indeed.com
yk1.ext.indeed.com
za.indeed.com
zera.ext.indeed.com
.envoy.eastus2.qa.notjet.net
.envoy.westus.qa.notjet.net
.nomad.eastus2.qa.notjet.net
.nomad.westus.qa.notjet.net
.notjet.net
.torbit.notjet.net
artifacts.notjet.net
bamf.notjet.net
bamfdb.notjet.net
</code></pre>
| <regex><sublimetext3> | 2019-05-11 02:09:58 | LQ_CLOSE |
56,087,500 | How to fix MySQL State [2002] Database "Connection Refused " C panel | i am setting a new live server for my Laravel application its work perfectly on localhost but not on live server. Now its showing SQL State [2002] connection refused. i also try with mysqli_connect and PDO but error remains same.
<?php
$servername = "examrunner.com";
$database = "XXXXXXXX";
$username = "XXXXXXX";
$password = "XXXXXXXXXX";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?> | <php><mysql><mysqli><cpanel> | 2019-05-11 05:31:27 | LQ_EDIT |
56,087,713 | guys i have below test code. How can I made this condition to be True | guys i have below test code. How can I made this condition to be True. I know a.split is method in Str() but when I put it on a variable it sees it as a list.
a="1.1.1.1/29"
aa=a.split('/')
>>aa == "29"
>>False | <python><python-3.x> | 2019-05-11 06:10:09 | LQ_EDIT |
56,088,464 | Is there a way to expose folder outside Spring to be accessed over the Internet? | <p>I am building Spring application that has to expose images over the web.
I tried to store them at Maven's structure's resource directory in static folder,however,whenever an image is uploaded, in order for me to access it over the web I had to restart spring server. I assume this is because spring server is packed as one jar file. My question is, is it possible for me to expose such a folder outside spring so that whenever I upload an image, it would be visible without need to restart spring server?</p>
| <java><spring><image><spring-boot><model-view-controller> | 2019-05-11 08:12:06 | LQ_CLOSE |
56,090,633 | My script works the first time and does anymore not after reload on this online IDE | <p>I have a slight problem with this online code editor. When I launch my snippet, it only works one time. If I try to bring any modification to the code, it crashes for unknown reasons.</p>
<p><a href="https://playcode.io/313059?tabs=console&script.js&output" rel="nofollow noreferrer">https://playcode.io/313059?tabs=console&script.js&output</a></p>
<p>Any clue of what is going on here?</p>
| <javascript> | 2019-05-11 13:08:24 | LQ_CLOSE |
56,091,062 | For the erase-remove idiom, why is the second parameter necessary which points to the end of the container? | <p>Consider the following code (taken from <a href="https://en.cppreference.com/w/cpp/algorithm/remove" rel="noreferrer">cppreference.com</a>, slightly adapted):</p>
<pre><code>#include <algorithm>
#include <string>
#include <iostream>
#include <cctype>
int main()
{
std::string str1 = " Text with some spaces";
str1.erase(std::remove(str1.begin(), str1.end(), ' '), str1.end());
std::cout << str1 << '\n';
return 0;
}
</code></pre>
<p>Why is the second parameter to <code>erase</code> neccessary? (I.e. <code>str1.end()</code> in this case.)</p>
<p>Why can't I just supply the iterators which are returned by <code>remove</code> to <code>erase</code>? Why do I have to tell it also about the last element of the container from which to erase?</p>
<p>The pitfall here is that you can also call <code>erase</code> without the second parameter but that produces the wrong result, obviously. </p>
<p>Are there use cases where I would not want to pass the end of the container as a second parameter to <code>erase</code>?</p>
<p>Is omitting the second parameter of <code>erase</code> for the erase-remove idiom always an error or could that be a valid thing to do?</p>
| <c++><stl><erase-remove-idiom> | 2019-05-11 14:05:10 | HQ |
56,092,083 | async/await in Angular `ngOnInit` | <p>I’m currently evaluating the pros ‘n’ cons of replacing Angular’s resp. RxJS’ <code>Observable</code> with plain <code>Promise</code> so that I can use <code>async</code> and <code>await</code> and get a more intuitive code style.</p>
<p>One of our typical scenarios: Load some data within <code>ngOnInit</code>. Using <code>Observables</code>, we do:</p>
<pre><code>ngOnInit () {
this.service.getData().subscribe(data => {
this.data = this.modifyMyData(data);
});
}
</code></pre>
<p>When I return a <code>Promise</code> from <code>getData()</code> instead, and use <code>async</code> and <code>await</code>, it becomes:</p>
<pre><code>async ngOnInit () {
const data = await this.service.getData();
this.data = this.modifyMyData(data);
}
</code></pre>
<p>Now, obviously, Angular will not “know”, that <code>ngOnInit</code> has become <code>async</code>. I feel that this is not a problem: My app still works as before. But when I look at the <code>OnInit</code> interface, the function is obviously not declared in such a way which would suggest that it can be declared <code>async</code>:</p>
<pre><code>ngOnInit(): void;
</code></pre>
<p>So -- bottom line: Is it reasonable what I’m doing here? Or will I run into any unforseen problems?</p>
| <angular><typescript><asynchronous><promise><observable> | 2019-05-11 16:10:07 | HQ |
56,093,426 | Python battleship game index out of range error (BEGINNER) | I just started coding about a week ago. I'm trying to code a very simple battleship game. Its doing what I want it to do, but I get an index out of range error about 1 in 10 times when I test it. Any suggestions?
Thanks :)
from random import randint, choice
x_cor = [0,1,2,3,4,5]
y_cor = [0,1,2,3,4]
def create_board():
row = [["O" for i in x_cor] for x in y_cor]
return row
board = create_board()
def create_ship(board):
board[choice(x_cor)][choice(y_cor)] = "*"
return board
world = create_ship(board)
for i in world:
print(" ".join(i)) | <python> | 2019-05-11 19:03:28 | LQ_EDIT |
56,094,495 | Microsoft SQL Server Management Studio starts then suddenly fails to lunch | I have installed sql server 2014 express then I have installed microsoft sql server management studio 2018. Every thing worked fine and I created a database. SUDDENLY I tried to open microsoft sql server management studio 2018, and the start popup appears and then disappear without luncing the application and without error message. Any help? | <sql-server><ssms> | 2019-05-11 21:44:48 | LQ_EDIT |
56,095,142 | Python Pandas Expand a Column of List of Lists to Two New Column | <p>I have a DF which looks like this.</p>
<pre><code>name id apps
john 1 [[app1, v1], [app2, v2], [app3,v3]]
smith 2 [[app1, v1], [app4, v4]]
</code></pre>
<p>I want to expand the apps column such that it looks like this.</p>
<pre><code>name id app_name app_version
john 1 app1 v1
john 1 app2 v2
john 1 app3 v3
smith 2 app1 v1
smith 2 app4 v4
</code></pre>
<p>Any help is appreciated</p>
| <python><pandas><list> | 2019-05-11 23:52:51 | HQ |
56,095,668 | how to render window xaml in c# without visual studio? | I want to run and display xaml gui from the command prompt.
the steps I follow is write the cs code and compile it through the command line but i end up with errors dealing with InitializeComponent or really anything to do with the gui components. The code below is just many of codes i copy and paste that just error out. I don't have visual studio. I didn't need it to compile my cs code i just needed to find the file that contain the csc.exe command to compile my code. No additional tools unless window 10 or any window don't provide this out the box. No other questions come close to my questions. Please don't point out download visual studio. I will down vote.
```
using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.Text = "Change Prperties Through Coding";
this.BackColor = Color.Brown;
this.Size = new Size(350, 125);
this.Location = new Point(300, 300);
this.MaximizeBox = false;
}
}
}
``` | <c#><xaml> | 2019-05-12 02:03:04 | LQ_EDIT |
56,095,884 | local variable not defined from function A to function B | I am working with python functions to make a simple text based word guessing in python. But i am facing problems with local variables defined within a function and i don't know which is right way to get data of that particular local variable or perform action from another function to that local variable which is defined within another function, whether use of ```global``` keyword.
i can use ```global``` but some experienced geeks advise to avoid. what is the right way to do the same. It sows ```ask``` is not defined. please suggest me some best practice to do the same.
```
import random
def get_random():
random_word = random.choice(open('sowpods.txt', 'r').read().split())
return(random_word)
def board():
hidden_word = get_random()
print("Welcome to Hangman!")
place = ["_" for i in list(hidden_word)]
print(" ".join(place))
ask = input("Guess the letter. ").upper()
return(ask)
def assing_letters(ask):
return(ask)
get_random()
board()
assing_letters(ask)
```
P.S. I am a beginner and i have problem with OOP and functions. | <python> | 2019-05-12 03:01:48 | LQ_EDIT |
56,096,273 | How to count the longest number of sequence that does not contain 3 in x=[1,2,3,4,5,6,5,4,3,3,4,5,2,3,7] with loop | I am answering possible questions related to python data structure and algorithm. | <python><python-3.x><algorithm> | 2019-05-12 04:38:34 | LQ_EDIT |
56,096,584 | How to transform next text using regex in phpstrom's search and replace dialog | I need to transform text using regex
TPI +2573<br>
NM$ +719<br>
Молоко +801<br>
Прод. жизнь +6.5<br>
Оплод-сть +3.6<br>
Л. отела 6.3/3.9<br>
Вымя +1.48<br>
Ноги +1.61<br>
to this one
<strong>TPI</strong> +2573<br>
<strong>NM$</strong> +719<br>
<strong>Молоко</strong> +801<br>
<strong>Прод. жизнь</strong> +6.5<br>
<strong>Оплод-сть</strong> +3.6<br>
<strong>Л. отела</strong> 6.3/3.9<br>
<strong>Вымя</strong> +1.48<br>
<strong>Ноги</strong> +1.61<br>
Is it possible with regex in phpstorm's search and replace dialog? | <regex><phpstorm><regex-lookarounds><regex-group><regex-greedy> | 2019-05-12 05:57:55 | LQ_EDIT |
56,097,475 | Dart 2.3 for, if and spread support warning message regarding versions | <p>I am getting the warning message '<strong>The for, if and spread elements were not supported until version 2.2.2, but this code is required to be able to run on earlier versions</strong>' but the code </p>
<pre><code>Column( crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
if (document['propertyid'] == '1') Text('jjj'),
GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
PropertyDetails(document['propertyid'])));
},
child: Text(document['propertyname'],
style: TextStyle(
color: Colors.blue,
fontStyle: FontStyle.italic,
fontWeight: FontWeight
.w500) //Theme.of(context).textTheme.title,
),
),
],
),
</code></pre>
<p>works as expected. The minSDKVersion etc is 28. Why does it think I want to be able to run this code on any earlier version? What do I need to change to a later version?</p>
| <dart><flutter> | 2019-05-12 08:33:28 | HQ |
56,097,929 | Tax Rate in new Stripe Checkout | <p><br>
I've implemented the new <code>Stripe Checkout</code> on my <code>NodeJS server</code>, but I cannot specify the <strong>Tax Rate</strong> for Invoicing.</p>
<p>As per my understanding <strong>Tax Rates</strong> should be specified in the <a href="https://stripe.com/docs/api/payment_intents/object#payment_intent_object-invoice" rel="noreferrer">Payment Intent API</a>. Fact is that the new <code>Checkout</code> automatically creates a <code>Payment Intent</code> via its <a href="https://stripe.com/docs/api/checkout/sessions/create" rel="noreferrer">CreateSession</a> (see <code>payment_intent_data</code>), but I'm not able to insert a <strong>Tax Rate</strong> upon its creation.</p>
<p>How can this be done? What I want to achieve is to have the user know the Tax % both in the <code>Checkout UI</code> and in the final <code>email invoice</code>.</p>
<p>This is my code:</p>
<pre><code>return stripe.checkout.sessions.create({
payment_method_types: [paymentMethod],
line_items: [{
name: name,
description: description,
images: [imageUrl],
amount: amount,
currency: currency,
quantity: 1
}],
success_url: successUrl,
cancel_url: cancelUrl,
customer: stripeId,
payment_intent_data: {
receipt_email: email,
metadata: {
userId: userId,
amount: amount,
currency: currency,
ref: ref,
stripeId: stripeId,
details: details
}
}
}).then(session => {
return res.send(session)
</code></pre>
| <stripe-payments><checkout> | 2019-05-12 09:38:17 | HQ |
56,098,017 | Block Block background on all page bootstrap | Hello i want this background on my project [like this][1]
[1]: https://i.stack.imgur.com/3XwIz.png | <html><css> | 2019-05-12 09:48:38 | LQ_EDIT |
56,100,369 | Dividing Long with Double in Java producing wrong results | <p>I am trying to divide a <code>Long</code> in Java with a percentage like <code>0.99</code> and it keeps giving me crazy results.</p>
<pre><code>long totalBytes = 5877062
long final = (long) (totalBytes / 0.99) // IT PRODUCES 5936426 > totalBytes
</code></pre>
<p><a href="https://i.stack.imgur.com/ImfS9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ImfS9.png" alt="enter image description here"></a></p>
<p>what am i doing wrong ? For <code>1.00</code> it works well , if i give <code>0.95 ++</code> it always produces something bigger than the <code>totalBytes</code>.</p>
<p>Why am i loosing precision ?</p>
<p><code>Java Version 10.0.2</code></p>
| <java><long-integer> | 2019-05-12 14:49:16 | LQ_CLOSE |
56,100,379 | Neural network periodically cost value change | I am creating neural network with sigmoid activation function with back propagation, adaptive learning rate and momentum. I am using wine data set.
My main problem is that algorithm is oscillating around 0.88 cost value or change periodically from 0.88 to 12. I am unable to brake 0.88 value
Also I normalize all data.
There is link to my repo with it: https://github.com/mikart143/trainbpx-wine-core | <c#><neural-network> | 2019-05-12 14:50:04 | LQ_EDIT |
56,100,396 | could std::list<char> be converted to std::list<int> in c++ | <p>I have this Question in my Uni Home work.could std:list-char be converted to std:list-int in c++.I hope to get right Answers from you as soon as possible.</p>
| <c++> | 2019-05-12 14:52:31 | LQ_CLOSE |
56,101,657 | Is it lecit to define final an immutable parameter, bind the parameter to another local variable and mutate the local variable? | Note well: The same question applies for other immutable types, like String and Boolean.
---
I have a method like this (this is a simple example):
###Example 1
public BigDecimal addTwo(BigDecimal bigDecimal) {
bigDecimal = bigDecimal.add(new BigDecimal(2));
return bigDecimal;
}
I know, I could simply return `bigDecimal.add(new BigDecimal(2))`. But it's only an example.
The problem with this code is that I can't add `final` to the method parameter. So I would write:
###Example 2
public BigDecimal addTwo(final BigDecimal bigDecimal) {
BigDecimal bigDecimalLocal = bigDecimal;
bigDecimalLocal = bigDecimalLocal.add(new BigDecimal(2));
return bigDecimalLocal;
}
I know, I can do directly `BigDecimal bigDecimalLocal = bigDecimal.add(new BigDecimal(2))`. But I repeat, this is only an example.
The question is: when I do:
BigDecimal bigDecimalLocal = bigDecimal;
I'm ***not*** creating a new `BigDecimal`. I'm assigning the same object to a different variable. I [found on SO](https://stackoverflow.com/questions/33381260/is-new-a-bigdecimal-from-another-bigdecimal-tostring-always-equals) that a simple way to clone `BigDecimal` is:
###Example 3
BigDecimal bigDecimalLocal = new BigDecimal(bigDecimal.toString());
The question is: since `BigDecimal` is immutable, is this really necessary? Can't I simple do as in example #2? I think the `final` keyword could not be invalidated. | <java><clone><immutability><final> | 2019-05-12 17:19:33 | LQ_EDIT |
56,101,755 | Can't call datepicker in my laravel framework | I try to use jquery in my laravel framework but i can't call date picker in
label cus_birthday. What i miss ?
[Mycode][1]
[1]: https://i.stack.imgur.com/6UfcG.png | <php><jquery> | 2019-05-12 17:30:59 | LQ_EDIT |
56,102,653 | Cannot implicitly convert System.xml.linq.xdocument to string[] | i have an x m l file which pretty much looks like this:
" <?x m l version="1.0" en co n ding ="u t f-8"?>
<Hangman><string>سال</string><string>کل</string><string>منٹ</string><string>بجے</string></Hangman> "
i want to store it's contents to an Array of string
string[] words = X Document. Load(Hangman Urdu. Properties. Resources.Hangman Urdu) "
it's showing me an error :( i' v e added libraries like using system. x ml and x ml . l i n q | <c#><xml> | 2019-05-12 19:17:24 | LQ_EDIT |
56,102,929 | Need to expand an inventory journal (log) pandas dataframe to include all dates per product id | <p>I have an inventory journal that contains products and their relative inventory qty (resulting_qty) as well as the loss/gain every time inventory is added or subtracted (delta_qty). </p>
<p>The issue is that inventory records do not get updated daily, rather they are only updated when a change in inventory occurs. For this reason, it is difficult to extract the total inventory qty for all items on a given day, because some items are not recorded on certain days, despite the fact that they do have available inventory given their last entry resulting_qty was greater than 0. Logically, this would mean that an item went without a change in qty for a certain amount of days equal to the number of days between the max date and the last recorded date.</p>
<p>my data looks something like this, except in reality there are thousands of product ids</p>
<pre><code>| date | timestamp | pid | delta_qty | resulting_qty |
|------------|---------------------|-----|-----------|---------------|
| 2017-03-06 | 2017-03-06 12:24:22 | A | 0 | 0.0 |
| 2017-03-31 | 2017-03-31 02:43:11 | A | 3 | 3.0 |
| 2017-04-08 | 2017-04-08 22:04:35 | A | -1 | 2.0 |
| 2017-04-12 | 2017-04-12 18:26:39 | A | -1 | 1.0 |
| 2017-04-19 | 2017-04-19 09:15:38 | A | -1 | 0.0 |
| 2019-01-16 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-01-19 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-04-05 | 2019-04-05 16:40:32 | B | 2 | 2.0 |
| 2019-04-22 | 2019-04-22 11:06:33 | B | -1 | 1.0 |
| 2019-04-23 | 2019-04-23 13:23:17 | B | -1 | 0.0 |
| 2019-05-09 | 2019-05-09 16:25:41 | C | 2 | 2.0 |
</code></pre>
<p>Essentially, I need to make the data look something more like this so that I can simply pull a date and get the sum of total inventory for a given day when grouping by date (e.g. df.groupby(date).resulting_qty.sum()):</p>
<p><strong><em>Note</strong> I removed the PID= A rows due to character limitations, but I hope you get the idea:</em></p>
<pre><code>| date | timestamp | pid | delta_qty | resulting_qty |
|------------|---------------------|-----|-----------|---------------|
| 2019-01-16 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-01-17 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-01-18 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-01-19 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-01-20 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-01-21 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-01-22 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-01-23 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-01-24 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-01-25 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-01-26 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-01-27 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-01-28 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-01-29 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-01-30 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-01-31 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-01 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-02 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-03 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-04 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-05 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-06 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-07 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-08 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-09 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-10 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-11 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-12 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-13 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-14 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-15 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-16 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-17 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-18 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-19 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-20 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-21 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-22 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-23 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-24 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-25 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-26 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-27 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-02-28 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-01 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-02 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-03 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-04 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-05 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-06 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-07 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-08 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-09 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-10 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-11 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-12 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-13 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-14 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-15 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-16 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-17 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-18 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-19 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-20 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-21 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-22 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-23 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-24 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-25 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-26 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-27 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-28 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-29 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-30 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-03-31 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-04-01 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-04-02 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-04-03 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-04-04 | 2019-01-16 23:37:17 | B | 0 | 0.0 |
| 2019-04-05 | 2019-04-05 16:40:32 | B | 2 | 2.0 |
| 2019-04-06 | 2019-04-05 16:40:32 | B | 2 | 2.0 |
| 2019-04-07 | 2019-04-05 16:40:32 | B | 2 | 2.0 |
| 2019-04-08 | 2019-04-05 16:40:32 | B | 2 | 2.0 |
| 2019-04-09 | 2019-04-05 16:40:32 | B | 2 | 2.0 |
| 2019-04-10 | 2019-04-05 16:40:32 | B | 2 | 2.0 |
| 2019-04-11 | 2019-04-05 16:40:32 | B | 2 | 2.0 |
| 2019-04-12 | 2019-04-05 16:40:32 | B | 2 | 2.0 |
| 2019-04-13 | 2019-04-05 16:40:32 | B | 2 | 2.0 |
| 2019-04-14 | 2019-04-05 16:40:32 | B | 2 | 2.0 |
| 2019-04-15 | 2019-04-05 16:40:32 | B | 2 | 2.0 |
| 2019-04-16 | 2019-04-05 16:40:32 | B | 2 | 2.0 |
| 2019-04-17 | 2019-04-05 16:40:32 | B | 2 | 2.0 |
| 2019-04-18 | 2019-04-05 16:40:32 | B | 2 | 2.0 |
| 2019-04-19 | 2019-04-05 16:40:32 | B | 2 | 2.0 |
| 2019-04-20 | 2019-04-05 16:40:32 | B | 2 | 2.0 |
| 2019-04-21 | 2019-04-05 16:40:32 | B | 2 | 2.0 |
| 2019-04-22 | 2019-04-22 11:06:33 | B | -1 | 1.0 |
| 2019-04-23 | 2019-04-23 13:23:17 | B | -1 | 0.0 |
| 2019-04-24 | 2019-04-23 13:23:17 | B | -1 | 0.0 |
| 2019-04-25 | 2019-04-23 13:23:17 | B | -1 | 0.0 |
| 2019-04-26 | 2019-04-23 13:23:17 | B | -1 | 0.0 |
| 2019-04-27 | 2019-04-23 13:23:17 | B | -1 | 0.0 |
| 2019-04-28 | 2019-04-23 13:23:17 | B | -1 | 0.0 |
| 2019-04-29 | 2019-04-23 13:23:17 | B | -1 | 0.0 |
| 2019-04-30 | 2019-04-23 13:23:17 | B | -1 | 0.0 |
| 2019-05-01 | 2019-04-23 13:23:17 | B | -1 | 0.0 |
| 2019-05-02 | 2019-04-23 13:23:17 | B | -1 | 0.0 |
| 2019-05-03 | 2019-04-23 13:23:17 | B | -1 | 0.0 |
| 2019-05-04 | 2019-04-23 13:23:17 | B | -1 | 0.0 |
| 2019-05-05 | 2019-04-23 13:23:17 | B | -1 | 0.0 |
| 2019-05-06 | 2019-04-23 13:23:17 | B | -1 | 0.0 |
| 2019-05-07 | 2019-04-23 13:23:17 | B | -1 | 0.0 |
| 2019-05-08 | 2019-04-23 13:23:17 | B | -1 | 0.0 |
| 2019-05-09 | 2019-04-23 13:23:17 | B | -1 | 0.0 |
| 2019-05-10 | 2019-04-23 13:23:17 | B | -1 | 0.0 |
| 2019-01-19 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-01-20 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-01-21 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-01-22 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-01-23 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-01-24 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-01-25 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-01-26 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-01-27 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-01-28 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-01-29 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-01-30 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-01-31 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-01 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-02 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-03 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-04 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-05 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-06 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-07 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-08 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-09 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-10 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-11 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-12 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-13 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-14 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-15 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-16 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-17 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-18 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-19 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-20 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-21 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-22 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-23 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-24 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-25 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-26 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-27 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-02-28 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-01 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-02 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-03 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-04 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-05 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-06 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-07 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-08 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-09 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-10 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-11 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-12 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-13 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-14 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-15 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-16 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-17 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-18 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-19 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-20 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-21 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-22 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-23 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-24 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-25 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-26 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-27 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-28 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-29 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-30 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-03-31 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-04-01 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-04-02 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-04-03 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-04-04 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-04-05 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-04-06 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-04-07 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-04-08 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-04-09 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-04-10 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-04-11 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-04-12 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-04-13 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-04-14 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-04-15 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-04-16 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
| 2019-04-17 | 2019-01-19 09:40:38 | C | 0 | 0.0 |
</code></pre>
<p>So far what I've done was created a series of loops that generates a date range between the min date of the product lifecycle and the max date of all products. I then append the last recorded row values as a new row with a new date if there is no information for said new date. I append these to lists, and then generate a new dataframe with the updated lists. The code is terribly slow and takes 2+ hours to complete on the total dataset:</p>
<pre><code>date_list = []
pid_list= []
time_stamp_list = []
delta_qty_list = []
resulting_qty_list = []
timer = len(test.product_id.unique().tolist())
counter = 0
for product in test.product_id.unique().tolist():
counter+=1
print((counter/timer)*100)
temp_df = test.query(f'product_id=={product}', engine='python')
for idx,date in enumerate(pd.date_range(temp_df.index.min(),test.index.max()).tolist()):
min_date= temp_df.index.min()
if date.date() == min_date:
date2=min_date
pid = temp_df.loc[date2]['product_id']
timestamp = temp_df.loc[date2]['timestamp']
delta_qty = temp_df.loc[date2]['delta_qty']
resulting_qty = temp_df.loc[date2]['resulting_qty']
date_list.append(date2)
pid_list.append(pid)
delta_qty_list.append(delta_qty)
time_stamp_list.append(timestamp)
resulting_qty_list.append(resulting_qty)
else:
if date.date() in temp_df.index:
date2= date.date()
pid = temp_df.loc[date2]['product_id']
timestamp = temp_df.loc[date2]['timestamp']
delta_qty = temp_df.loc[date2]['delta_qty']
resulting_qty = temp_df.loc[date2]['resulting_qty']
date_list.append(date2)
pid_list.append(pid)
delta_qty_list.append(delta_qty)
time_stamp_list.append(timestamp)
resulting_qty_list.append(resulting_qty)
elif date.date() > date2:
date_list.append(date.date())
pid_list.append(pid)
time_stamp_list.append(timestamp)
delta_qty_list.append(delta_qty)
resulting_qty_list.append(resulting_qty)
else:
pass
</code></pre>
<p>Can someone please help me to understand what is the right way I should approach this as I'm 100% sure this is not the best approach.</p>
<p>Thank you</p>
| <python><pandas><performance><inventory-management> | 2019-05-12 19:53:12 | HQ |
56,103,313 | How can I resolve this problem with "while" | <p>I want to make a timer using while, and when I lunch the code in Chrome, the Chrome don't load.</p>
<p>I am making this:</p>
<pre><code>var time = 0;
while (time < 5) {
setTimeout(function(){
tempo[0].innerHTML = time;
time++;
}, 1000);
}
</code></pre>
<p>I expect when time it gets to 5, javascript will exit the loop and execute the next action</p>
| <javascript> | 2019-05-12 20:43:14 | LQ_CLOSE |
56,103,529 | ArrayList add() function overwrites all the elements (processing/java) | <p>So I am trying to shuffle the same ArrayList (knots) 50 times in a for-loop and adding the shuffled list to another ArrayList (gen0). But every time I add a new ArrayList it overwrites all existing ArrayList-elements to the same ArrayList I just added, can someone tell me why?</p>
<pre class="lang-java prettyprint-override"><code>ArrayList<ArrayList> seed(ArrayList<PVector> knots) {
ArrayList<ArrayList> gen0 = new ArrayList<ArrayList>();
for(int i=1; i<=50; i++) {
Collections.shuffle(knots);
gen0.add(knots);
}
return gen0;
}```
</code></pre>
| <java><arraylist><processing><shuffle> | 2019-05-12 21:10:11 | LQ_CLOSE |
56,104,372 | Maze won't backtrack [Python] | There are a couple of maze questions similar to this one but none of them ever really go into the why it won't work.
This is for an assignment for my summer class. I don't need precise answers. I just need to know why this particular thing doesn't work.
This is the bit of my class Maze that I need help with.
ysize in my example is 10
xsize is 10
xend is 20 (changing it to 19 messes with the results and doesn't draw anything)
yend is 10 (changing it to 9 does this too)
'''
def solve(self, x, y):
if y > (self.ysize) or x > (self.xsize):
print("1")
return False
if self.maze[y][x] == self.maze[self.yend][self.xend]:
print("2")
return True
if self.maze[y][x] != " ":
print("3")
return False
self.maze[y][x] = "o" # MARKING WITH o for path already taken.
if self.solve(x+1,y) == True:
return True
elif self.solve(x,y+1) == True:
return True
elif self.solve(x-1,y) == True:
return True
elif self.solve(x,y-1) == True:
return True
self.maze[y][x] = " " # ELSE I want it to be replaced with space
return False
'''
The expected result is the solved maze with a trailing path of "o" from 1 1 to 9 19 as per the current file.
However what I get is a path from 1 1 to 13 4 (x)(y) format.
There is a dead end around 13 4 and it won't backtrack to go up and left. Sorry if it doesn't make that much sense but copy pasting the drawing doesn't turn out well. | <python-3.x> | 2019-05-12 23:48:05 | LQ_EDIT |
56,105,789 | How can I build a binary image with random sequence of 80% 1s and 20% 0s? | <p>I want to implement an algorithm for generating a binary image having random sequence of 80% 1s and 20% 0s in it with python-opencv.</p>
| <python><image><opencv><image-processing> | 2019-05-13 04:32:43 | LQ_CLOSE |
56,107,603 | Setter for class within a class | i have a Sheet class which contains two attributes and each is a class
1. summary (class)
2. data (class)
summary and data has 1 attribute,df, which is a dataframe
my question is, am i right to say that since summary and data are classes:
1. I shouldn't store summary and data directly as dataframes in Sheet class's attribute.
2. I should store summary and data as objects and when main class wish to set summary/ data, i use Sheet's setter which uses summary/ data's setter to set the actual dataframe
Create sheet object in Main Class :
```
import Sheet
sheet = Sheet.Sheet() # create empty sheet
sheet.set_summary(new_df) # set summary
sheet.set_data(new_df) # set data
```
In Sheet Class :
```
import Summary
import Data
class Sheet:
def __init__(self):
self.name = None
self._summary = Summary.Summary()
self._data = Data.Data()
def get_SheetSummary(self):
return self._summary.get_summary()
def set_SheetSummary(self,new_df):
self._summary.set_summary(new_df)
def get_SheetData(self):
return self._data.get_data()
def set_SheetData(self, new_df):
self._data.set_data(new_df)
``` | <python><dataframe> | 2019-05-13 07:30:53 | LQ_EDIT |
56,108,004 | Any idea how I could structure my project? | <p>I've been teaching python courses for a while and I've started doing my own project to practice with the knowledge I learned. The problem is when it comes to structuring that I'm a little lost since I've always programmed on the web.</p>
<p>My project is about a virtual assistant, the one who listens and from that command makes an action.</p>
<p>I have it structured in this way:</p>
<pre><code>main.py
vs
• mediator.py
• commands.py
• skills.py
</code></pre>
<p>in skills.py I have connections like listening, speaking, etc.</p>
<p>in commands.py a dictionary, where the value is the command and the key the function that you have to execute, making use of the skills.</p>
<p>in the mediator.py, I'm calling commands functions.</p>
<p>in the main.py I call the mediator.</p>
<p>I'm not using an object because I do not know in what way I can implement the. Any idea or opinion is good, thank you.</p>
| <python><python-3.x><python-2.7> | 2019-05-13 08:00:06 | LQ_CLOSE |
56,108,110 | confused with babel preset configs between @babel/env and @babel/preset-env | <p>I try to config a environment to develop javascript with babel and webpack.</p>
<p>But I don't understand babel configuration about <code>presets</code>.</p>
<p>In <a href="https://babeljs.io/docs/en/usage" rel="noreferrer">Usage Guide</a>, we can see that presets with <code>"@babel/env"</code>.</p>
<p>But other places in document, I cannot see such a configuration more, instead of <code>"@babel/preset-env"</code>. for example here <a href="https://babeljs.io/docs/en/babel-preset-env" rel="noreferrer">https://babeljs.io/docs/en/babel-preset-env</a></p>
<p>I can not find out the difference between <code>"@babel/env"</code> and <code>"@babel/preset-env"</code> everywhere with my poor English, I do really read document again and again, without luck.</p>
<p>Maybe they are same?</p>
<p>Btw, targets sets seems not work, remove targets also can run normally in ie9+(or what's it default targets), if I wish my es6 script can be transformed to compatibility ie8, thus it not most important.</p>
<p>here is my project <a href="https://github.com/whidy/sdk-dev-env/tree/for-es6-without-babel/polyfill" rel="noreferrer">sdk-dev-env</a></p>
<pre><code>// https://babeljs.io/docs/en/configuration
const presets = [
[
'@babel/env',
{
// https://babeljs.io/docs/en/babel-preset-env#targets
// TODO: how to compatibilite with ie 8
targets: {
ie: '8',
edge: '17',
firefox: '60',
chrome: '67',
safari: '11.1'
/**
* you can also set browsers in package.json
* "browserslist": ["last 3 versions"]
* relative links:
* https://github.com/browserslist/browserslist
*/
},
corejs: '3',
// corejs: { version: 3, proposals: true },
/**
* https://babeljs.io/docs/en/usage#polyfill
* https://github.com/zloirock/core-js#babelpreset-env
* "usage" will practically apply the last optimization mentioned above where you only include the polyfills you need
*/
useBuiltIns: 'usage'
}
]
]
const plugins = []
if (process.env['ENV'] === 'prod') {
// plugins.push(...);
}
module.exports = { presets, plugins }
</code></pre>
<p>I hope to know they are same or not, if not, what different.</p>
<p>And the best way to use babeljs 7.4 with core-js 3</p>
| <javascript><babeljs> | 2019-05-13 08:06:57 | HQ |
56,109,587 | How to write Sqlite database in Fragment Android |
while i am creating a database on android sqlite database with fragment if i i write inside the onViewCreated method couldn't write the database name and Listview findviewbyid get error i don't know.what i tried so i wrote below.
cannot resolve the method openOrCreateDatabase
SQLiteDatabase db = openOrCreateDatabase("course", Context.MODE_PRIVATE, null);
lst1 = findViewById(R.id.lst1);
cannot resolve the method findViewById
cannot resolve the constructor ArrayAdapter
**arrayAdapter = new ArrayAdapter(this, `R.layout.support_simple_spinner_dropdown_item, titles);**`
lst1 = findViewById(R.id.lst1);
ListView lst1;
ArrayList<String> titles = new ArrayList<String>();
ArrayAdapter arrayAdapter;
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
SQLiteDatabase db = openOrCreateDatabase("course", Context.MODE_PRIVATE, null);
lst1 = findViewById(R.id.lst1);
final Cursor c = db.rawQuery("select * from category", null);
int id = c.getColumnIndex("id");
int title = c.getColumnIndex("title");
int description = c.getColumnIndex("description");
titles.clear();
arrayAdapter = new ArrayAdapter(this, R.layout.support_simple_spinner_dropdown_item, titles);
lst1.setAdapter(arrayAdapter);
final ArrayList<cate> cat = new ArrayList<cate>();
if (c.moveToFirst()) {
do {
cate stu = new cate();
stu.id = c.getString(id);
stu.course = c.getString(title);
stu.description = c.getString(description);
cat.add(stu);
titles.add(c.getString(id) + " \t " + c.getString(title) );
} while (c.moveToNext());
arrayAdapter.notifyDataSetChanged();
lst1.invalidateViews();
}
lst1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String aa = titles.get(position).toString();
cate stu = cat.get(position);
Intent i = new Intent(getApplicationContext(), editcategory.class);
i.putExtra("id", stu.id);
i.putExtra("category", stu.course);
i.putExtra("description", stu.description);
startActivity(i);
}
});
}
| <android> | 2019-05-13 09:35:47 | LQ_EDIT |
56,110,430 | Is there a way to enable auditing in all entities via sql sever in dynamic crm? | In Dynamics Crm I need to enable all auditing in all entities without over each entity one by one. | <sql-server><dynamics-crm> | 2019-05-13 10:25:46 | LQ_EDIT |
56,110,623 | MYSQL Check if username already exists in database | <p>My code was working but after I inserted a query to check if the first name in MYSQL database already exists, it does not work anymore. Here you can see my code, if you have any tip on how to make this work, I will appreciate it. Thank you very much!</p>
<p>I have tried to work with mysql_num_rows command, but it seems like I didn't use it correctly. </p>
<pre><code><?php
require_once __DIR__.'/connect.php';
$sName = $_POST['txtName'];
$query = mysql_query("SELECT * FROM users WHERE firstName = '$sName' ");
if (mysql_num_rows ($query) > 0){
echo 'User with this name already exists';
}else{
try {
$stmt = $db->prepare('INSERT INTO users
VALUES (null, :sName, :sLastName, :sEmail, :sCountry )');
$stmt->bindValue(':sName', $sName);
$stmt->execute();
echo 'New user was successfully inserted';
} catch (PDOEXception $ex) {
echo $ex;
}
}
</code></pre>
| <php><mysql><database> | 2019-05-13 10:38:09 | LQ_CLOSE |
56,111,992 | How to get all tweets in twitter through code? | <p>What is the best way to retrieve all tweets by all users in twitter? Ideally using python code and API calls. I understand that Twitter don't make tweets older than a time frame available for us to download. I don't care about them. But all tweets that are available to us for download.</p>
| <python><twitter> | 2019-05-13 12:05:58 | LQ_CLOSE |
56,113,045 | How can I check the content of a list with step 3 by 3? | I need to write a function that given a list of integers `L` and integer `n`, it returns `True` if the list contains a consecutive sequence of ones of length `n`, and `False` otherwhise.
Let's say my list is : `L = [1,2,3,4,1,1,1,2,3,4]` and `n` = 3.
The function should return `True` because there are 3 ones at the 5th position.
I tried with:
def consecutive (L,n):
for i in range(len(L)):
if [1]*n in L:
return True
return False
L = [1,2,3,4,1,1,1,2,3,4]
n = 3
consecutive (L,n)
But this is not working of course, because `[1]*3` generate `[1,1,1]` and there are not sublist inside `L`.
Is there any way using list comprehension? Something like:
L = [1,2,3,4,1,1,1,2,3,4]
result = all(x==(1,1,1) for x in range(0,len(L)+1,3))
result
Again, I know is not working because each element `x` can't be equal to `(1,1,1)`. I wrote it down just to give an idea of what was in my mind. | <python><arrays><python-3.x><list> | 2019-05-13 13:08:31 | LQ_EDIT |
56,114,131 | I need an example power-shell script for deploying the MS virtual assistant template | im new to the framework and powershell. Im trying to deploy the virtual assistant via powershell but I cant auto create an AD app. I cant work out what the powershell script should look like in order to add an app id and secret in manually. can any one help with an example | <powershell><deployment><botframework><bots> | 2019-05-13 14:08:55 | LQ_EDIT |
56,115,239 | How to unit test components with react hooks? | <p>Currently trying to unit test components with hooks (useState and useEffects).
As I have read, lifecycles can only be tested with a mount and not a shallow render.</p>
<p>Implementation code:</p>
<pre><code>export function MainPageRouter({issuerDeals, match, dbLoadIssuerDeals}) {
console.log("MainPageRouter")
const [isLoading, setIsLoading] = useState(true);
const selectedIssuerId = match.params.id;
const issuerDeal = filterIssuerDealByIssuerId(issuerDeals,
selectedIssuerId);
useEffect(() => {
dbLoadIssuerDeals(selectedIssuerId)
.then(() => {
setIsLoading(false);
})
.catch(function (error) {
setIsLoading(false);
});
}, [selectedIssuerId]);
if (isLoading) {
return <MainPageLoading />
} else if(issuerDeal.length > 0) {
return <MappedDeal match={match}/>
} else {
return <MapDeal match={match}/>
}
}
const mapStateToProps = state => {
return {
deals: state.deals,
issuerDeals: state.issuerDeals
}
};
const mapDispatchToProps = {
dbLoadIssuerDeals
}
export default connect(mapStateToProps, mapDispatchToProps)(MainPageRouter);
</code></pre>
<p>However doing so results in this error: </p>
<pre><code>Warning: An update to MainPageRouter inside a test was not wrapped in
act(...).
When testing, code that causes React state updates should be wrapped into
act(...):
act(() => {
/* fire events that update state */
});
</code></pre>
<p>Test:</p>
<pre><code>it('Should render Mapped Deal', () => {
const dbLoadIssuerDeals = jest.fn(() => Promise.resolve({
payload:{ deals: { dealid: "1", sourceCode: "TEST" }, issuerId: "1" } }))
const props = createProps(issuerDeals, dbLoadIssuerDeals);
const mainPageRouter = mount(<MemoryRouter><MainPageRouter{...props} /></MemoryRouter>);
});
</code></pre>
<p>Is there a clean way to test that mainPageRouter would return back MappedDeal or MapDeal? I also understand that using mount is more towards integration tests.</p>
| <javascript><unit-testing><react-redux><enzyme> | 2019-05-13 15:12:23 | HQ |
56,116,628 | How to use tf.keras with bfloat16 | <p>I'm trying to get a tf.keras model to run on a TPU using mixed precision. I was wondering how to build the keras model using bfloat16 mixed precision. Is it something like this?</p>
<pre><code>with tf.contrib.tpu.bfloat16_scope():
inputs = tf.keras.layers.Input(shape=(2,), dtype=tf.bfloat16)
logits = tf.keras.layers.Dense(2)(inputs)
logits = tf.cast(logits, tf.float32)
model = tf.keras.models.Model(inputs=inputs, outputs=logits)
model.compile(optimizer=tf.keras.optimizers.Adam(.001),
loss='mean_absolute_error', metrics=[])
tpu_model = tf.contrib.tpu.keras_to_tpu_model(
model,
strategy=tf.contrib.tpu.TPUDistributionStrategy(
tf.contrib.cluster_resolver.TPUClusterResolver(tpu='my_tpu_name')
)
)
</code></pre>
| <python><tensorflow><keras><google-compute-engine><google-cloud-tpu> | 2019-05-13 16:44:18 | HQ |
56,117,488 | how can I make a triangle appear on the screen using OpenGL? | <p>I'm trying to make a triangle appear on the screen using OpenGL but when I run the code, a black screen appears</p>
<p>I am currently using a guide I found on the internet (here is the link: <a href="http://www.opengl-tutorial.org/beginners-tutorials/tutorial-2-the-first-triangle/" rel="nofollow noreferrer">http://www.opengl-tutorial.org/beginners-tutorials/tutorial-2-the-first-triangle/</a>).</p>
<p>this is the code :</p>
<pre><code>#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
int larghezza = 1024;
int altezza = 768;
int main (){
glewExperimental = true;
if (!glfwInit() )
{
fprintf (stderr, "non è stato possibile inizzializzare glfw\n");
return -1;
}
glfwWindowHint(GLFW_SAMPLES, 4);// 4x antialiasing
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR,4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);// utilizza OpenGL 4.1
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);//NON VOGLIO VECCHIE VERSIONI DI OPENGL
GLFWwindow* window; // crea una finestra
window = glfwCreateWindow(larghezza, altezza, "FINESTRA 1", NULL, NULL);
if (!window){
fprintf (stderr, "Non è stato possibile aprire la finestra!\n");
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window); //inizzializza GLEW
glewExperimental = true;
if (glewInit() != GLEW_OK){
fprintf (stderr, "non è stato possibile inizzializzare GLEW");
return -1;
}
glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
do {
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
glfwPollEvents();
}
while( glfwGetKey(window, GLFW_KEY_ESCAPE ) != GLFW_PRESS &&
glfwWindowShouldClose(window) == 0 );
GLuint VertexArrayID;
glGenVertexArrays(1, &VertexArrayID);
glBindVertexArray(VertexArrayID);
static const GLfloat g_vertex_buffer_data[] = {
-1.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
};
GLuint vertexbuffer;
// Generate 1 buffer, put the resulting identifier in vertexbuffer
glGenBuffers(1, &vertexbuffer);
// The following commands will talk about our 'vertexbuffer' buffer
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
// Give our vertices to OpenGL.
glBufferData(GL_ARRAY_BUFFER, sizeof(g_vertex_buffer_data), g_vertex_buffer_data, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(
0, // attribute 0. No particular reason for 0, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// Draw the triangle !
glDrawArrays(GL_TRIANGLES, 0, 3); // Starting from vertex 0; 3 vertices total -> 1 triangle
glDisableVertexAttribArray(0);
}
</code></pre>
<p>how can i fix it?</p>
| <c++><opengl><glfw><glew> | 2019-05-13 17:49:47 | LQ_CLOSE |
56,117,496 | Why do I keep getting this indexing erorr? | I keep getting StringIndexOutOfBoundsException. I'm trying to take a String and replace each letter with the one after it, then return the new manipulated String. For example, "Hey", is "Ifz".
I've tried changing the indexing but nothing is working.
String change = "";
char[] alpha = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
for(int i = 0; i < alpha.length; i++) {
if(str.charAt(i) == alpha[i]) {
change =+ str.charAt(i+1) + "";
}
}
return change;
}
public static void main (String[] args) {
// keep this function call here
Scanner s = new Scanner(System.in);
System.out.print(LetterChanges(s.nextLine()));
}
I've already tried to change the indexing. | <java><arrays><loops><indexing> | 2019-05-13 17:50:06 | LQ_EDIT |
56,117,834 | How can I use "Apply Changes" if I use Crashlytics? | <p>I'm using Android Studio 3.5 Beta 1. I decided to try out "Apply Changes". Instant Run was problematic, so we've had it disabled for years. I hoped that this would work better.</p>
<p>If I try the "Apply Code Changes" button, I get an error in the Run window:</p>
<pre><code>Changes were not applied.
Modifying resources requires an activity restart.
Resource 'assets/crashlytics-build.properties' was modified.
Apply changes and restart activity
</code></pre>
<p><code>crashlytics-build.properties</code> has comments that say</p>
<pre><code>#This file is automatically generated by Crashlytics to uniquely
#identify individual builds of your Android application
</code></pre>
<p>And indeed, it has a <code>build_id</code> property that presumably changes for every Gradle build. And since Gradle runs a build whenever I use the "Apply Code Changes" or "Apply Changes and Restart Activity" buttons, the Gradle build changes the file, which prevents Apply Run from completing.</p>
<p>The only information I've found online related to this was one <a href="https://www.reddit.com/r/androiddev/comments/atlzmk/android_studio_project_marble_apply_changes/eh98465/" rel="noreferrer">Reddit comment</a> saying</p>
<blockquote>
<p>I learned the hard way that crashlytics + proguard breaks instant run</p>
</blockquote>
<p>So it would seem I'm not the only person with this problem. Removing Crashlytics isn't an option. Nor would I want to disable it every time I'm going to do some debugging, then re-enable it again.</p>
<p>The "Apply Changes and Restart Activity" button does function. The Activity I'm using restarts and changes are visible. I tried comparing the timing of this to using the regular "Run" button. "Apply Changes and Restart Activity" takes just as long. The only benefit seems to be that instead of having to navigate through the app to that screen each time, I can remain on that screen and reload the changes. That is a nice benefit, I just expected more.</p>
<p>Is there anything I can do to make "Apply Changes" work more effectively for me?</p>
| <android><android-studio><android-gradle-plugin> | 2019-05-13 18:17:29 | HQ |
56,120,643 | Facebook's setReadPermissions() on Login Button deprecated - what to use instead? | <p>Im following Facebook's login tutorial for Android SDK and it seems <code>login_button.setReadPermissions()</code> is now deprecated:</p>
<p><a href="https://i.stack.imgur.com/zvmPq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/zvmPq.png" alt="enter image description here"></a></p>
<p>What do I use as a replacement?</p>
| <android><facebook><kotlin><facebook-login> | 2019-05-13 22:29:53 | HQ |
56,121,443 | How to create a section of StaticTableView with variable rows in Swift/xCode? | so basically I have a view controller with a static table view with 2 sections. the first section will have 1 row and represent a main category
I want the second section to have variable amount of rows depending on how many entries the user has for that category; so if the category is "Activities" and they have "Baseball, softball" as activities I want there to be 2 rows in that section
how do you do this? it keeps crashing when I code it | <ios><swift><uitableview> | 2019-05-14 00:25:13 | LQ_EDIT |
56,122,219 | In Material-ui when do we use Input vs. Textfield for building a form? | <p>Maybe this is just a basic question, but so far have not found any reasonable explanation. I am a beginner in react and using material-ui very recently. I am not very clear on when to use an Input vs. Textfield for building a form?</p>
<p>Looking at documentation, it feels like TextField is a superset of what Input can do, but not sure. Material-ui site uses examples for text field and input both, without stating benefits of one over the other and any use cases.</p>
<p>Please suggest.</p>
| <reactjs><input><material-ui><textfield> | 2019-05-14 02:29:50 | HQ |
56,124,580 | Refractoring to be more SOLID | Im trying to rewrite my current piece of code into (see example0. But it doesnt know the carriage animal in my CheckIfAnimalFits method. How would I fix this without moving the entire foreach into the method
Current code
```
public bool AddAnimaltoWagon(Animal animal)
{
if (CheckWagonFull(animal) == true ) { return false; }
foreach (Animal carriageAnimal in Animals)
{
if (carriageAnimal.AnimalDiet == AnimalDiet.Carnivore && animal.Size <= carriageAnimal.Size || animal.AnimalDiet == AnimalDiet.Carnivore && animal.Size > carriageAnimal.Size)
{
return false;
}
}
Animals.Add(animal);
return true;
}
```
trying to get
```
public bool AddAnimaltoWagon(Animal animal)
{
if (CheckWagonFull(animal) == true ) { return false; }
foreach (Animal carriageAnimal in Animals)
{
if (CheckIfAnimalFits == false)
{
return false;
}
}
Animals.Add(animal);
return true;
}
public bool CheckIfAnimalFits(Animal animal)
{
if (carriageAnimal.AnimalDiet == AnimalDiet.Carnivore && animal.Size <= carriageAnimal.Size || animal.AnimalDiet == AnimalDiet.Carnivore && animal.Size > carriageAnimal.Size)
{
return false;
}
else
{
return true;
}
}
```
So it doesnt know `carriageAnimal` in my new method | <c#><asp.net><methods><solid-principles> | 2019-05-14 06:55:09 | LQ_EDIT |
56,124,885 | How to fix AssertTrue error when running junit test | Setting up a Junit test but run into an test fail. Issue seems to be around my assertrue
import static org.junit.Assert.*;
import org.junit.Test;
import com.neueda.cap.spark.model.NeuFixMessage;
import quickfix.Message;
public class CalculateFillValue {
@Test
public void test() throws Exception {
CalculateFillValuesMapper test = new CalculateFillValuesMapper();
NeuFixMessage msg= new NeuFixMessage();
msg.setMsgType("8");
msg.setExecType("1");
msg.setLastPx("10.10");
msg.setLastShares("100");
msg = test.call(msg);
assertTrue("The file value should be 1010", msg.getFillValue() == 1010);
}
} | <java><junit><assert> | 2019-05-14 07:15:40 | LQ_EDIT |
56,126,062 | How to destroy Python objects and free up memory | <p>I am trying to iterate over 100,000 images and capture some image features and store the resulting dataFrame on disk as a pickle file. </p>
<p>Unfortunately due to RAM constraints, i am forced to split the images into chunks of 20,000 and perform operations on them before saving the results onto disk.</p>
<p>The code written below is supposed to save the dataframe of results for 20,000 images before starting the loop to process the next 20,000 images. </p>
<p>However - This does not seem to be solving my problem as the memory is not getting released from RAM at the end of the first for loop</p>
<p>So somewhere while processing the 50,000th record, the program crashes due to Out of Memory Error.</p>
<p>I tried deleting the objects after saving them to disk and invoking the garbage collector, however the RAM usage does not seem to be going down.</p>
<p>What am i missing? </p>
<pre><code>#file_list_1 contains 100,000 images
file_list_chunks = list(divide_chunks(file_list_1,20000))
for count,f in enumerate(file_list_chunks):
# make the Pool of workers
pool = ThreadPool(64)
results = pool.map(get_image_features,f)
# close the pool and wait for the work to finish
list_a, list_b = zip(*results)
df = pd.DataFrame({'filename':list_a,'image_features':list_b})
df.to_pickle("PATH_TO_FILE"+str(count)+".pickle")
del list_a
del list_b
del df
gc.collect()
pool.close()
pool.join()
print("pool closed")
</code></pre>
| <python><pandas><memory-management><out-of-memory> | 2019-05-14 08:28:27 | HQ |
56,126,442 | Why Button click event works in all version but not works in Android latest pie? | Recently Just know that all app works fine in android but testing in Emulator with android Pie stuck and first page not able to click and showing on email field "Unverified Post" i don't know what it means so can anybody know what updated in PIE?
Checked code but not getting where's problem ! and what is Unverified Post that shows on email Textview ?
```java
[enter image description here][1]
findViewById(R.id.submit_btn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
findViewById(R.id.submit_btn).setEnabled(false);
register();
}
});
```
[1]: https://i.stack.imgur.com/H4uIh.png | <android><android-9.0-pie> | 2019-05-14 08:54:28 | LQ_EDIT |
56,127,044 | Can you instantiate another class within the constructor? | <p>Can you instantiate another class within the constructor? If not then why?</p>
<pre><code>public class Class1() {}
public class Class2() {
public Class2() {
Class1 c1 = new Class1();
}
}
</code></pre>
| <c#><constructor><initialization> | 2019-05-14 09:26:04 | LQ_CLOSE |
56,127,105 | Extract text between slashes which contain '=' | <p>I want a regex to extract the text between slashes which contain an equals '='</p>
<p><code>data/xx/yy/zz/date=20190506/xxx.json</code></p>
<p>-> <code>date=20190506</code></p>
| <regex><scala> | 2019-05-14 09:28:32 | LQ_CLOSE |
56,128,114 | Using Rails-UJS in JS modules (Rails 6 with webpacker) | <p>i just switched to Rails 6 (6.0.0.rc1) which uses the <a href="https://github.com/rails/webpacker" rel="noreferrer">Webpacker</a> gem by default for Javascript assets together with Rails-UJS. I want to use Rails UJS in some of my modules in order to submit forms from a function with:</p>
<pre><code>const form = document.querySelector("form")
Rails.fire(form, "submit")
</code></pre>
<p>In former Rails versions with Webpacker installed, the <code>Rails</code> reference seemed to be "globally" available in my modules, but now i get this when calling <code>Rails.fire</code>…</p>
<pre><code>ReferenceError: Rails is not defined
</code></pre>
<p><strong>How can i make <code>Rails</code> from <code>@rails/ujs</code> available to a specific or to all of my modules?</strong></p>
<p>Below my setup…</p>
<p><em>app/javascript/controllers/form_controller.js</em></p>
<pre><code>import { Controller } from "stimulus"
export default class extends Controller {
// ...
submit() {
const form = this.element
Rails.fire(form, "submit")
}
// ...
}
</code></pre>
<p><em>app/javascript/controllers.js</em></p>
<pre><code>// Load all the controllers within this directory and all subdirectories.
// Controller files must be named *_controller.js.
import { Application } from "stimulus"
import { definitionsFromContext } from "stimulus/webpack-helpers"
const application = Application.start()
const context = require.context("controllers", true, /_controller\.js$/)
application.load(definitionsFromContext(context))
</code></pre>
<p><em>app/javascript/packs/application.js</em></p>
<pre><code>require("@rails/ujs").start()
import "controllers"
</code></pre>
<p>Thanks!</p>
| <ruby-on-rails><webpack><webpacker><rails-ujs> | 2019-05-14 10:17:59 | HQ |
56,129,104 | Why does my code result in a compiler error? | <p>I'm trying to understand why my code causes an compiler error. Can someone explain it to me?</p>
<pre><code>public class Employee {
private String name;
public Employee(String name) {
this.name = name;
}
}
public class Test {
public static void main(String[] JavaLatte) {
Employee e = new Employee("JavaDeveloper");
System.out.println("Emp Name : " + e.name);
}
}
</code></pre>
| <java><compiler-errors> | 2019-05-14 11:12:58 | LQ_CLOSE |
56,130,459 | How to fix Android compatibility warnings | <p>I have an app that is targeting Android 9 and I noticed in the Google Play prelaunch report a new section called Android compatibility. This new section lists warnings or errors related to the usage of unsupported APIs. The following is one of the problems and is listed as a greylisted API. Can someone explain which is the unsupported API in this case? The usage seems to be coming from the Android support library and not my code.</p>
<pre><code>StrictMode policy violation: android.os.strictmode.NonSdkApiUsedViolation: Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V
at android.os.StrictMode.lambda$static$1(StrictMode.java:428)
at android.os.-$$Lambda$StrictMode$lu9ekkHJ2HMz0jd3F8K8MnhenxQ.accept(Unknown Source:2)
at java.lang.Class.getDeclaredMethodInternal(Native Method)
at java.lang.Class.getPublicMethodRecursive(Class.java:2075)
at java.lang.Class.getMethod(Class.java:2063)
at java.lang.Class.getMethod(Class.java:1690)
at android.support.v7.widget.ViewUtils.makeOptionalFitsSystemWindows(ViewUtils.java:84)
at android.support.v7.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:685)
at android.support.v7.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:518)
at android.support.v7.app.AppCompatDelegateImpl.onPostCreate(AppCompatDelegateImpl.java:299)
at android.support.v7.app.AppCompatActivity.onPostCreate(AppCompatActivity.java:98)
at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1342)
at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3002)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:180)
at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:165)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:142)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6718)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
</code></pre>
| <android> | 2019-05-14 12:25:01 | HQ |
56,130,624 | How to get an already existing file (on my computer) in my method and convert it to InputStream? | <p>I've a generated file in D:/EXPORT_BASE/Export_report. What I need to do is use the filePath string to fetch this file from my local, and then convert this to InputStream.</p>
<p><code>String filePath = D:/EXPORT_BASE/Export_report/1557834965979_report.txt</code></p>
<p>I need to use the String to get the file and write it to InputStream.</p>
| <java> | 2019-05-14 12:34:42 | LQ_CLOSE |
56,133,546 | c++ conditional uni-directional iterator | <p>I want to achieve something like the pseudo-code below:</p>
<pre><code>string foo; // or vector<int> foo;
auto itr = bar? foo.begin() : foo.rbegin();
auto end = bar? foo.end() : foo.rend();
for ( ; itr != end; ++itr) {
// SomeAction ...
}
</code></pre>
<p>That is, I want to set <code>itr</code> to be either a forward iterator or the reverse iterator, depending on some condition <code>bar</code>, to scan in forward or reverse direction.</p>
<p>Apparently code like that won't work, since forward iterator and reverse iterator has different type.</p>
<p>Note that I don't want to split into two loops, as those code like <code>// SomeAction</code> will be duplicated.</p>
<p>How can I do that?
Answers using C++11 and/or before are preferred.</p>
<p>Also, please elaborate if string and vector have different solutions.</p>
| <c++><c++11> | 2019-05-14 15:07:05 | HQ |
56,134,182 | C# reference pointer | <pre><code>using System;
public class Class1 {
public int A {get;set;}
}
public class Class2 {
public Class1 class1 {get;set;}
}
public class Test
{
public static void Main()
{
Class1 c1 = null;
var c2 = new Class2();
c2.class1 = c1;
c1 = new Class1();
c1.A = 1;
Console.WriteLine(c2.class1.A); //Expect 1 not NULL ref err
}
}
</code></pre>
<p>I would expect that the <code>c2</code> object would get its <code>class1</code> reference updated because its passing by reference, so the reference was updated but it remained null.</p>
<p>When you set c2.class1 = c1 and c1 is currently null does it keep the the value <code>null</code> and not use a pointer to the empty memory space?</p>
| <c#> | 2019-05-14 15:43:31 | LQ_CLOSE |
56,134,630 | how find elements with data attribute and id | is possible find a element id in the same sentence?
```
<div class="test">
<input id="999" type="text" data-test="2">
</div>
Example
$('.test').find('[data-test="2"] #999)
```
I try to find a specifict input in my html code, but this input exists many time with the same id value, the only diference is the attr "data-test" (the number is incremental)
Any help for this? | <javascript><jquery><html> | 2019-05-14 16:14:42 | LQ_EDIT |
56,135,497 | Can I install python 3.7 in ubuntu 18.04 without having python 3.6 in the system? | <p>Please read the question carefully before closing as duplicate, I believe the use case to be unique.</p>
<p>I'm trying to create a docker image that <strong>only has python 3.7 installed</strong>, the problem is that if I try to install pip, the command also installs python 3.6 which <strong>I do not want</strong>.</p>
<p>The relevant part of the ideal docker file I'm tinkering is as follows</p>
<pre><code>FROM ubuntu:18.04
# Upgrade installed packages
RUN apt-get update && apt-get upgrade -y && apt-get clean
# (...)
# Python package management and basic dependencies
RUN apt-get install -y python3.7 python3.7-dev python3.7-pip
# Register the version in alternatives
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1
# Set python 3 as the default python
RUN update-alternatives --set python /usr/bin/python3.7
# Upgrade pip to latest version
RUN python -m ensurepip --upgrade
# (...)
</code></pre>
<p>This would fail as <em>python3.7-pip</em> doesn't seem to exist; only <em>python3-pip</em> does, which is what installs python 3.6 for some reason.</p>
<p>I tried not installing pip at all and doing it manually, like so</p>
<pre><code># (...)
RUN apt-get install -y python3.7 python3.7-dev
# (...)
RUN curl 'https://bootstrap.pypa.io/get-pip.py' > get-pip.py
RUN python get-pip.py pip --no-setuptools --no-wheel
</code></pre>
<p>Which fails with this error:</p>
<pre><code>Traceback (most recent call last):
File "get-pip.py", line 21492, in <module>
main()
File "get-pip.py", line 197, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 82, in bootstrap
import pip._internal
File "/tmp/tmpbez2vju9/pip.zip/pip/_internal/__init__.py", line 40, in <module>
File "/tmp/tmpbez2vju9/pip.zip/pip/_internal/cli/autocompletion.py", line 8, in <module>
File "/tmp/tmpbez2vju9/pip.zip/pip/_internal/cli/main_parser.py", line 8, in <module>
File "/tmp/tmpbez2vju9/pip.zip/pip/_internal/cli/cmdoptions.py", line 14, in <module>
ModuleNotFoundError: No module named 'distutils.util'
</code></pre>
<p>Again, installing python3-distutils results in python 3.6 appearing in the system</p>
<p>So, is there a way to install ONLY a fully functional python 3.7 in ubuntu 18.04, WITHOUT having to install python 3.6?</p>
| <python-3.x><docker><ubuntu><pip> | 2019-05-14 17:17:10 | HQ |
56,135,613 | How to use JaveScript to imitate the cutsom filter/selector in this example? | I saw this custom filter on this site (which is based on mediawiki): **https://fgo.wiki/w/%E8%8B%B1%E7%81%B5%E5%9B%BE%E9%89%B4** , and want to imitate its function on the fandom I've on for the self-learning purpose.
I did figure out how to get the certain innerTEXT from the table as the identifier for each option, and set a div to place all the option image. But I don't know what to do next, use addEventListener() or playing around with <select> tag?
The table's code I'm playing with is too long, so just put the codes here: https://a-normal-playground.fandom.com/wiki/Filter_searching_test?action=edit
The "identifier" I get from the table is:
```
var type = document.querySelectorAll("tr td:nth-last-child(1)").innerTEXT;
```
What I want to do is if the identifier of that column is not matching the "value" of the button, the column will not be showed in the result. Not sure do I need the knowledge of jquery or something else. | <javascript><mediawiki> | 2019-05-14 17:25:47 | LQ_EDIT |
56,136,005 | Programmatically capture Chrome Async Javascript stack trace | <p>I've been working on trying to add some better error logging to a web application that is only run on Chrome. In essence, I want to be able to capture and store stack traces. For synchronous code, this works fine, but for async code, I've run into something a tad strange. Essentially, Chrome appears to log additional information as part of its async stack trace feature, but I haven't been able to figure out how to capture it.</p>
<p>Code, to run in Chrome browser console:</p>
<pre><code>let e;
let a = () => Promise.resolve(null)
.then(() => (null).foo)
.catch(err => {
console.info(err);
console.error(err);
e = err;
})
let b = () => a();
let c = () => b();
c();
</code></pre>
<p>Output:</p>
<pre><code>(info)
TypeError: Cannot read property 'foo' of null
at <anonymous>:3:20
(error, after expanding)
TypeError: Cannot read property 'foo' of null
at <anonymous>:3:20
(anonymous) @ VM1963:6
Promise.catch (async)
a @ VM1963:4
b @ VM1963:9
c @ VM1963:10
(anonymous) @ VM1963:11
</code></pre>
<p>So <code>console.error</code> gives me a stack trace threaded all the way through the callstack, presumably through some form of Chrome engine magick. <code>console.info</code> gives me the actual stack trace that's stored on <code>err</code>. If after this is all done I attempt to read the value of <code>e</code>, its stack is the two lines I get from the <code>console.info</code> statement, not the <code>console.error</code> statement.</p>
<p>What I'm asking is, is there any way to capture and store the async stack trace that Chrome is generating and using when I call <code>console.error</code>?</p>
| <javascript><asynchronous><google-chrome-devtools> | 2019-05-14 17:52:43 | HQ |
56,139,234 | what should be filled up so the code can run successfully? | <pre><code>import java.util.*;
public class Main
{
public static void main(String[] args)
{
List student = new ArrayList();
student.add("123");
student.add("ABC");
student.add("70.8");
Iterator itr = listItr.iterator();
while(itr.hasNext())
{
System.out.println(itr.next());
}
}
</code></pre>
<p>}
What should i write here Iterator itr = _________; in order to get an
output? </p>
| <java> | 2019-05-14 22:03:56 | LQ_CLOSE |
56,139,505 | How to make HTTP request to In Flutter Web | <p>I was trying my hands on flutter web. I tried to connect a simple flutter web app I created to mysql database and localhost using the http package. However I dont get any data returned from the request method. When I tried to print out <code>snaphot.error</code> I got this: <code>XMLHttpRequest error</code>. I have this method in a <code>FutureBuilder()</code></p>
<pre><code>getMethod()async{
String theUrl = 'https://localhost/fetchData.php';
var res = await http.get(Uri.encodeFull(theUrl),headers: {"Accept":"application/json"});
var responsBody = json.decode(res.body);
print(responsBody);
return responsBody;
}
</code></pre>
| <dart><flutter><flutter-web> | 2019-05-14 22:36:11 | HQ |
56,141,260 | Trying to write a code in Python-where am I going wrong? | The question i attempted to answer is as follows: Write a Python function that computes the number of days, hours, and minutes in a given number of minutes
ie: def daysHoursMinutes(m): which ends as return (d, h, M)
I wrote the following code:
def daysHoursMinutes(m):
import math
d=m/1440 #integer
h=m/60 #integer
M=m #integer
return(d,h,M)
and when I input in daysHoursMinutes(241) what im expecting to get is (0,4,1), but I get ((0.1673611111111111, 4.016666666666667, 241)Im confused as to what I'm doing wrong?? | <python><python-3.x> | 2019-05-15 03:12:07 | LQ_EDIT |
56,145,220 | SDKApplicationDelegate Use of unresolved identifier | <p>I have two pods installed for facebook login</p>
<pre><code>pod 'FacebookCore'
pod 'FacebookLogin'
</code></pre>
<p>than imported FacebookCore in appdelegate. still it shows use of unresolved identifier error.</p>
<p><a href="https://i.stack.imgur.com/eCxmf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/eCxmf.png" alt="unresolved identifier error"></a></p>
<p>I have also implemented tags in info.plist</p>
<pre><code><array>
<string>fb---------</string>
</array>
<key>FacebookAppID</key>
<string>-----------</string>
<key>FacebookDisplayName</key>
<string>-----------</string>
</code></pre>
<p>Still not able to get SDKApplicationDelegate.</p>
<pre><code>func application(_ app: UIApplication, open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool {
if SDKApplicationDelegate.shared.application(app, open: url, options: options) {
return true
}
return false
}
</code></pre>
| <swift><fbsdk><fbsdkloginkit> | 2019-05-15 08:52:13 | HQ |
56,145,896 | how to fix "<variable> not defined" | so i am making a alert system where if someone deletes a channel it sends a message with the name of the channel that was deleted and the Deleter, so i tried making it by coding *this* :
```
client.on('channelDelete', channel => {
var channelDeleteAuthor = channelDelete.action.author
const lChannel = message.channels.find(ch => ch.name === 'bot-logs')
if (!channel) return; channel.send(`Channel Deleted by ${channelDeleteAuthor}`)
.then(message => console.log(`Channel Deleted by ${channelDeleteAuthor}`))
.catch(console.error)
})
```
and it didn't work, how do i achieve that action? | <javascript><node.js><discord><discord.js> | 2019-05-15 09:26:25 | LQ_EDIT |
56,147,289 | How to compare to different table coloms and matched coloms fetch all rows from table one? | i am compairing two tables single coloms and matched coloms fetch all rows
select * from t_registered_std_info
where t_registered_std_info.t_ds_name == attendance.std_name | <sql><sql-server><sqlite> | 2019-05-15 10:36:05 | LQ_EDIT |
56,148,511 | Missing Script when I run npm start to create React app | <p>I'm trying to run the React server by running <code>npm start</code></p>
<p>When I do this I get a missing script error:</p>
<pre><code>λ npm start
npm ERR! missing script: start
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Aristophanes\AppData\Roaming\npm-cache\_logs\2019-05-15T11_34_47_404Z-debug.log
</code></pre>
<p>Full error log:</p>
<pre><code>0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'start' ]
2 info using npm@6.4.1
3 info using node@v11.1.0
4 verbose stack Error: missing script: start
4 verbose stack at run (C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:155:19)
4 verbose stack at C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:63:5
4 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:115:5
4 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:418:5
4 verbose stack at checkBinReferences_ (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:373:45)
4 verbose stack at final (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:416:3)
4 verbose stack at then (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:160:5)
4 verbose stack at ReadFileContext.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:332:20)
4 verbose stack at ReadFileContext.callback (C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:78:16)
4 verbose stack at FSReqCallback.readFileAfterOpen [as oncomplete] (fs.js:242:13)
5 verbose cwd C:\Users\Aristophanes\eth-todo-list-react
6 verbose Windows_NT 10.0.17134
7 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
8 verbose node v11.1.0
9 verbose npm v6.4.1
10 error missing script: start
</code></pre>
| <node.js><reactjs><npm><create-react-app><npm-start> | 2019-05-15 11:40:41 | HQ |
56,148,952 | define a diagonal matrix from a matrix | I need a help plz
I want to construct a diagonal matrix D from a matrix A
the first element of the diagonal matrix D must be the product of all elements in the subdiagonal of the matrix A, the second element in the diagonal matrix D must be the product of all elements in the subdiagonal of the matrix A except the first one , the third element in the diagonal matrix D must be the product of all elements in the subdiagonal of the matrix A expect the first and the second one,.... , and the last element of the diagonal matrix D must be 1 | <python><numpy> | 2019-05-15 12:04:02 | LQ_EDIT |
56,149,368 | Publishing a release build with debuggable true | I would like to publish a a library with debuggable true on release build types. This would help me debug that library. What are the potential problems if this library goes into production? Is it secure ? What difference does it make when released with debuggable as false?
```
buildTypes {
release {
minifyEnabled true
debuggable true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
``` | <android><debugging><android-gradle-plugin><android-build-type> | 2019-05-15 12:28:08 | LQ_EDIT |
56,149,620 | How can I get Java date in another Language | <p>I am living in Austria and if I print the date in Java I get in the german format. But I want to have it in the english format.</p>
<p>I already tried it with the following code.</p>
<pre><code>import java.util.Date;
import java.text.*;
public class Calendar extends JFrame {
public static void main(String[] args) {
Date currentDate = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, d MMM yyyy", Locale.UK);
System.out.println(dateFormat.format(currentDate));
</code></pre>
| <java> | 2019-05-15 12:42:18 | LQ_CLOSE |
56,150,370 | Did not get value as per My ID get all database data | Hii I want Edit my form so i want data as per passed id which i selected but i did Not get data as per my requirement.
==>JSON Eroor Screen Shot **https://imgur.com/a/vD2fKpK**
==> Ajax Code
var url = document.URL;
var id = url.substring(url.lastIndexOf('=') + 1);
$.ajax({
method:"post",
data:id,
url: 'get.php',
success: function (data) {
console.log(data);
data = $.parseJSON(data);
}
});
$(function () {
$('#datetimepicker1').datetimepicker();
});
});
==> get.php
if(isset($_POST['data'])) {
$getUsers = $connect->prepare("SELECT * FROM registration WHERE
id='".$_POST['data']."'");
$getUsers->execute();
$users = $getUsers->fetchAll(PDO::FETCH_ASSOC);
echo json_encode($users);
} | <php><jquery><ajax> | 2019-05-15 13:17:35 | LQ_EDIT |
56,150,898 | Get clomuns with value 0 on group by sum | I'm using this query to get the sum of rows grupued by cmp2 field but I need to get a colum for every cmp2 even if its sum resul is 0, but I can't get it this way
SELECT CMP2,COALESCE(count(*), 0) as count
FROM datos_con851_0,datos_con851_1
WHERE datos_con851_0.REGISTRO = datos_con851_1.REGISTRO
AND SPEEDER = 1
GROUP BY CMP2;
| <mysql><sql> | 2019-05-15 13:43:48 | LQ_EDIT |
56,151,099 | Unexpected end of JSON input in MongoDB Compass | <p>I want to import data of type json in MongoDB compass,
the import function gives this error
" unexpected end of json input "</p>
<p><a href="https://i.stack.imgur.com/kTBmO.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kTBmO.png" alt="enter image description here"></a></p>
<p>there is a some of my json file </p>
<pre><code>[
{
'id' :4,
'user' : 'test@example.com',
'date1' :'2019-03-01',
'date2' : '2019-04-01',
'statut' : 'Good',
'guest_number' : 4
}
]
</code></pre>
| <json><mongodb> | 2019-05-15 13:55:09 | HQ |
56,153,943 | How to read value pointed by a reference | I have a pointer to an u64 value and I can't read it. I am getting this error:
error[E0507]: cannot move out of borrowed content
--> /home/niko/sub/substrate/srml/system/src/lib.rs:533:32
|
533 | let mut aid: T::AccountId = *copy_who;
| ^^^^^^^^^
| |
| cannot move out of borrowed content
| help: consider removing the `*`: `copy_who`
How does one get around "borrowed content" error ? And what is the point of having a pointer to a variable if you can't read anything that it points to ???
// getter for AccountId
pub fn get_account_id(who: &T::AccountId) -> T::AccountId {
let mut copy_who: &T::AccountId=who;
{
let mut aid: T::AccountId = *copy_who;
return aid;
}
}
AccountId is defined like this:
type AccountId = u64;
| <rust> | 2019-05-15 16:33:59 | LQ_EDIT |
56,154,120 | Compteur de clic c# | I would like to make a clicks counter with a button, that's my code.
I want to make a click counter, with the help of a button, which at each click, would display in a text box a number (1 then 2 ...) Can you help me?
private vous btn_click(object sender, EventArgs e)
{
do
{
int i = 0;
label1.Text = i.ToString();
break;
}
while(i < 10);
{
i++;
} | <c#><winforms> | 2019-05-15 16:46:22 | LQ_EDIT |
56,154,266 | Why does change from Spring boot version 2.1.4 to 2.1.5 gives unknown configuration Maven error? | <p>I had installed Eclipse (actually Spring Tool Suite). It came with Maven. I had created Spring boot starter projects. Maven was downloading all the dependencies and things were working fine.</p>
<p>Recently, I created a new project. This time, I noticed an error in pom.xml
and the problem window (in STS) showing the following:</p>
<pre><code>Description Resource Path Location Type
Unknown pom.xml /TestSessionAttribute line 1 Maven Configuration Problem
</code></pre>
<p>I noticed that the spring boot version was at 2.1.5 (it was 2.1.4 before). </p>
<pre><code><parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
</code></pre>
<p>I went ahead and did an update of the project (Maven > Update project) with the 'Force Update of Snapshots/Releases' checked. This did not resolve the problem.
I do see the </p>
<pre><code>spring-boot-2.1.5.RELEASE.jar
</code></pre>
<p>in the m2 repository.</p>
<p>I went back and changed the version to 2.1.4 and then a Maven > Update Project and the errors went away.</p>
<p>Why am I getting the Maven error when version is 2.1.5?</p>
| <java><spring><eclipse><maven><spring-boot> | 2019-05-15 16:56:17 | HQ |
56,154,843 | How can I write Fibonacci with for...of? | <p>** How can I write a program that produce Fibonacci with for...of in javascript**</p>
<p>I've tried this, and it works well</p>
<pre><code>function createFibonacci(number) {
var i;
var fib = []; // Initialize array!
fib[0] = 0;
fib[1] = 1;
for (i = 2; i <= number; i++) {
// Next fibonacci number = previous + one before previous
// Translated to JavaScript:
fib[i] = fib[i - 2] + fib[i - 1];
console.log(fib[i]);
}
}
createFibonacci(8);
</code></pre>
<p>But I'm wondering if it is possible to write it with <strong>for..of</strong>, is there any way to do this?</p>
| <javascript> | 2019-05-15 17:35:02 | LQ_CLOSE |
56,155,668 | how to finding out a remaining value in a query | I currently have a databases exam and one of the questions is asking me to find out how many tickets are remaining at a event. There are 5 events i think and a NumOfAdultsTickets field and a NumOfChildTickets field so i would need to add both them values together and then take away that value from 80 which is the total amount of tickets for that event location. In a query I've tried grouping the num of adults and the num of childs and then having a calculation field that adds them two values and then subtracts that value from 80 but that gives me a value of something like -1000. Please Help would be greatlly appreciated | <sql><ms-access><ms-access-2010> | 2019-05-15 18:32:41 | LQ_EDIT |
56,156,809 | OpenTracing doesn't send logs with Serilog | <p>I'm trying to use <a href="https://github.com/opentracing-contrib/csharp-netcore" rel="noreferrer">OpenTracing.Contrib.NetCore</a> with Serilog. I need to send to Jaeger my custom logs. Now, it works only when I use default logger factory <code>Microsoft.Extensions.Logging.ILoggerFactory</code></p>
<p>My Startup:</p>
<pre><code>public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.AddSingleton<ITracer>(sp =>
{
var loggerFactory = sp.GetRequiredService<ILoggerFactory>();
string serviceName = sp.GetRequiredService<IHostingEnvironment>().ApplicationName;
var samplerConfiguration = new Configuration.SamplerConfiguration(loggerFactory)
.WithType(ConstSampler.Type)
.WithParam(1);
var senderConfiguration = new Configuration.SenderConfiguration(loggerFactory)
.WithAgentHost("localhost")
.WithAgentPort(6831);
var reporterConfiguration = new Configuration.ReporterConfiguration(loggerFactory)
.WithLogSpans(true)
.WithSender(senderConfiguration);
var tracer = (Tracer)new Configuration(serviceName, loggerFactory)
.WithSampler(samplerConfiguration)
.WithReporter(reporterConfiguration)
.GetTracer();
//GlobalTracer.Register(tracer);
return tracer;
});
services.AddOpenTracing();
}
</code></pre>
<p>and somewhere in controller:</p>
<pre><code>[Route("api/[controller]")]
public class ValuesController : ControllerBase
{
private readonly ILogger<ValuesController> _logger;
public ValuesController(ILogger<ValuesController> logger)
{
_logger = logger;
}
[HttpGet("{id}")]
public ActionResult<string> Get(int id)
{
_logger.LogWarning("Get values by id: {valueId}", id);
return "value";
}
}
</code></pre>
<p>in a result I will able to see that log in Jaeger UI
<a href="https://i.stack.imgur.com/5at1L.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5at1L.png" alt="enter image description here"></a></p>
<p>But when I use Serilog, there are no any custom logs. I've added <code>UseSerilog()</code> to <code>WebHostBuilder</code>, and all custom logs I can see in console but not in Jaeger.
There is open issue in <a href="https://github.com/jaegertracing/jaeger-client-csharp/issues/146" rel="noreferrer">github</a>. Could you please suggest how I can use Serilog with OpenTracing?</p>
| <c#><asp.net-core><serilog><opentracing><jaeger> | 2019-05-15 20:02:43 | HQ |
56,162,926 | What is mean by return 1, -1 and 0 ? What values does this method returns? | <p>/*
What values are return when I mention return 1, -1 and 0 in the method</p>
<p>I was writing thing this code to sort String based on there size
*/</p>
<pre><code>public int compare(String s1, String s2)
{
int len1 = s1.length();
int len2 = s2.length();
if(len1 > len2)
{
return 1;
}
else if (len1 < len2)
{
return -1;
}
return 0;
}
</code></pre>
| <java><methods><return> | 2019-05-16 07:21:53 | LQ_CLOSE |
56,164,267 | Need help in json parsing | I am getting data from api and i need to filter the array of dictionary based upon "total_price" tag, now the condition is i want only those flights whose price is between "35.0" to "55.0"
{
airline = 9W;
"available_seats" = "<null>";
bags = (
);
currency = USD;
destination = 38551;
origin = 39232;
"price_details" = {
};
"rate_plan_code" = WIP;
routes = (
);
taxes = "17.51";
"total_price" = "31.7";
}
As the total_price tag is coming as string i am not sure how to filter it using predicate etc. I need to filter the json response itself, no models were created for this api response. Please help | <json><swift> | 2019-05-16 08:36:04 | LQ_EDIT |
56,166,267 | How do I get Java FX running with OpenJDK 8 on Ubuntu 18.04.2 LTS? | <p>When trying to compile an JavaFX application in the environment:</p>
<pre><code>java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-8u212-b03-0ubuntu1.18.04.1-b03)
OpenJDK 64-Bit Server VM (build 25.212-b03, mixed mode)
cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.2 LTS"
</code></pre>
<p>I get the error-message:</p>
<pre><code>cannot access javafx.event.EventHandler
[ERROR] class file for javafx.event.EventHandler not found
</code></pre>
<p>I tried to find a solution by following these links:</p>
<ul>
<li><a href="https://stackoverflow.com/questions/50510033/how-to-add-javafx-dependencies-in-maven-with-java-10/50511752">how to add javafx dependencies in maven with java 10</a></li>
<li><a href="https://mvnrepository.com/artifact/org.openjfx/javafx/11" rel="noreferrer">https://mvnrepository.com/artifact/org.openjfx/javafx/11</a></li>
<li><a href="https://stackoverflow.com/questions/15278215/maven-project-with-javafx-with-jar-file-in-lib">Maven project with JavaFX (with jar file in `lib`)</a></li>
<li><a href="https://github.com/javafx-maven-plugin/javafx-maven-plugin" rel="noreferrer">https://github.com/javafx-maven-plugin/javafx-maven-plugin</a></li>
<li><a href="https://askubuntu.com/questions/1091157/javafx-missing-ubuntu-18-04">https://askubuntu.com/questions/1091157/javafx-missing-ubuntu-18-04</a></li>
<li><a href="https://unix.stackexchange.com/questions/505628/add-openjfx-class-path-in-debian-for-java11">https://unix.stackexchange.com/questions/505628/add-openjfx-class-path-in-debian-for-java11</a></li>
<li><a href="https://askubuntu.com/questions/609951/javafx-is-not-on-the-default-classpath-even-with-oracle-jdk-1-8">https://askubuntu.com/questions/609951/javafx-is-not-on-the-default-classpath-even-with-oracle-jdk-1-8</a></li>
<li><a href="https://stackoverflow.com/questions/34243982/why-is-javafx-is-not-included-in-openjdk-8-on-ubuntu-wily-15-10/34244308#34244308">Why is JavaFX is not included in OpenJDK 8 on Ubuntu Wily (15.10)?</a></li>
<li><a href="http://can4eve.bitplan.com/index.php/JavaFX" rel="noreferrer">http://can4eve.bitplan.com/index.php/JavaFX</a></li>
</ul>
<p>The most promising actions where to </p>
<ol>
<li>install openjfx with apt install openjfx</li>
<li>set the JAVA_HOME environment variable to /usr/lib/jvm/java-8-openjdk-amd64</li>
</ol>
<p>But the error persists.</p>
<p><strong>What needs to be done to get OpenJDK 8 and JavaFX working on Ubuntu 18.04.2 LTS?</strong></p>
| <java><ubuntu><javafx><openjfx> | 2019-05-16 10:19:55 | HQ |
56,167,280 | convert time into range in sql | I have a datetime field which displays as eg: 2019-05-13 13:01:39.
I want this to come as 1-2pm or 13-14pmin sql.
Like wise,2019-05-03 19:31:31 should be displayed as 7-8 or 19-20.
Is this possible in SQL using query? | <mysql><sql><datetimerangefield> | 2019-05-16 11:16:10 | LQ_EDIT |
56,167,412 | Can we create sql DB server backup on different database(free database)? | <p>I have SQL database with huge amount of data. I want to create backup DB server using free databsase (e.g.Mysql) which will be back up server of SQL database. How can I do this ?</p>
| <mysql><sql-server> | 2019-05-16 11:22:03 | LQ_CLOSE |
56,168,771 | How to limit for 10 results the array.filter? | <p>I have big array, I want to make an autocomplete search, but I want to display only 10 results, so stop iterating through the array by the time there were found 10 results. I have made this:</p>
<pre><code>let items = array.filter(r => r.indexOf(term)!=-1);
console.log(items.length) // lots of items, need to be limited to 10
</code></pre>
<p>It works but I don't know how to stop the <code>array.filter</code> by the time it reaches the desired limit.</p>
| <javascript> | 2019-05-16 12:38:35 | HQ |
56,169,074 | Recursion stops after some executions | <p>I am trying to find the largest prime factor of a number. The code stops working (at least I think like that) after some executions. <code>printf</code> parts are for debugging.
The number is 600851475143.</p>
<pre><code>long recursed(long i, long j){
if (j == 1){
return i;
}
else if (i%j != 0){
printf("Else if i : %ld %ld\n", i, j);
return recursed(i, j-1);
}
else{
i /= j;
printf("Else i : %ld\n", i);
return recursed(i, i-1);
}
}
</code></pre>
| <c> | 2019-05-16 12:53:28 | LQ_CLOSE |
56,170,438 | How can I add up all the Values of a List<Integer> if its a value in a map? | <p>So, basically I have a map that looks like :</p>
<p><code>Map<String, List<Integer>> map = new HashMap<>();</code></p>
<p>I also have a method that needs to add up all those values for a certain key:</p>
<p><code>public Integer getTotalPointsForStudent(String student) {
}</code></p>
<p>How can I add up all the Values of the List assigned to a certain "student"?</p>
<p>Thanks in advance.</p>
| <java><list><sum><key><key-value> | 2019-05-16 14:03:44 | LQ_CLOSE |
56,170,528 | Change of Activity with Intent on Android Studio that doesn't work and don't know why | Studying and learning Android with a Youtube tutorial, i went to change between activities, followed it step by step and it just doesn't work.
Tried the only way i find, with the Intent, some codes may vary but at the end uses Intent.
This is what i have.
-The Button at activity_main.xml:
<Button
android:id="@+id/btnNext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/lvFood"
android:text="@string/btnNext" />
-The Button at MainActivity.java:
Button btnNext;
btnNext = findViewById(R.id.btnNext);
-The Listener of the Button:
btnNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent toSecond = new Intent(MainActivity.this, SecondActivity.class);
startActivity(toSecond);
}
});
Also tried this, but the same result.
Intent toSecond = new Intent (v.getContext(), SecondActivity.class);
startActivityForResult(toSecond, 0);
My manifest file:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/hello"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".SecondActivity"></activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
-The Run Log:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.helloworld, PID: 11503
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.helloworld/com.example.helloworld.SecondActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at com.example.helloworld.SecondActivity.onCreate(SecondActivity.java:19)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
It should take me to the activity SecondActivity, wich only have two buttons, one for back to the MainActivity and one for close the app.
BUT...the app just stop and close...
And just don't know why at this point... | <java><android><android-activity> | 2019-05-16 14:08:06 | LQ_EDIT |
56,171,620 | PHP: Aggregating arrays | <p>Assuming I have the following 3 PHP arrays:</p>
<pre><code>$arr1 = [1,2,3,4]
$arr2 = [5,2,4,1]
$arr3 = [2,1,2,2]
</code></pre>
<p>What's the most efficient built-in way that PHP has to add these arrays to elements in the same index of each array. Meaning, the final output would be the following:</p>
<pre><code>$final = [8,5,9,7]
</code></pre>
<p>There should be an easier way than doing <code>final = [$arr1[0]+$arr2[0]+$arr3[0]..]</code> etc. Also, I need to assume there's a variable amount of arrays, so hard coding the math like above isn't correct.</p>
| <php> | 2019-05-16 15:07:28 | LQ_CLOSE |
56,172,103 | fetch returns promise when I expect an array | I am doing a simple api get request, but I cant seem to isolate the array on its own. its always inside of a promise and I'm not sure how to remove it or how to access the values stored in the array.
```javascript
function getLocation(name) {
let output = fetch(`http://dataservice.accuweather.com/locations/v1/cities/search?apikey=oqAor7Al7Fkcj7AudulUkk5WGoySmEu7&q=london`).then(data => data.json());
return output
}
function App() {
var output = getLocation(`london`);
console.log (output)
...
```
```Promise {<pending>}
__proto__: Promise
[[PromiseStatus]]: "resolved"
[[PromiseValue]]: Array(3)```
is what is displayed in the console.log I require just the Array(3) | <javascript><reactjs> | 2019-05-16 15:35:27 | LQ_EDIT |
56,172,351 | How can I make all html tags close in the same line with php | <p>For example, if I have</p>
<pre><code><b>Line 1
Line 2</b>
</code></pre>
<p>I want to make it become </p>
<pre><code><b>Line 1</b>
<b>Line 2</b>
</code></pre>
<p>thanks.</p>
| <php><regex><dom><preg-replace><htmlpurifier> | 2019-05-16 15:49:39 | LQ_CLOSE |
56,172,373 | Mean Programm in python | I'm trying to implement the median in Python language, but when I run the script, it doesn't work properly. But just stop, nothing else happen. Could someone help me, pls.
**Median Programm**
data = []
value = input("Enter a value (blank line to quit): ")
while value != " ":
value = float(value)
data.append(value)
value = input("Enter a value (blank line to quit): ")
data.sort()
if len(data) == 0:
print("No values were entered: ")
elif len(data) % 2 == 1:
median = data[len(data) // 2]
print("The median of those values is", median)
else:
median = (data[len(data) // 2] + data[len(data) // 2 - 1]) / 2
print("The median of those values is", median) | <python> | 2019-05-16 15:51:01 | LQ_EDIT |
56,173,322 | Bubble sort problems | I want to create a program which sorts the array using bubble sort technique. but only the first iteration happens, can you help why
a=[10,4,5,2,0,6]
def srt(element):
element1=element[:]
element2=element[:]
idx=1
for x in element:
for y in element2[idx:]:
if x>y:
element1[idx]=x
element1[idx-1]=y
print(element1)
idx+=1
else:
pass
want to show all steps of the sort | <python><bubble-sort> | 2019-05-16 16:57:28 | LQ_EDIT |
56,174,918 | How can I ensure that an overloaded method calls another method at the end in Java? | I have an abstract class `Foo` with two methods `bar()` and `qux()` as the following:
```java
abstract class Foo {
abstract void bar();
private void qux() {
// Do something...
}
}
```
How can I force that the overloaded method `bar()` in subclasses of `Foo` calls `qux()` as the last statement? | <java><class><methods><abstract-class> | 2019-05-16 18:52:40 | LQ_EDIT |
56,175,031 | Get data from JSON by using a variable JavaScript/jQuery | <p>I'm trying to get data out of a JSON using a value.</p>
<p>I have an array of objects:</p>
<pre><code>"fruits": [
{
"Name": "Orange",
"Quantity": "5"
},
{
"Name": "Apple",
"Quantity": "2"
}
]
</code></pre>
<p>And I also have the name "Apple". How can I get the quantity of Apples?</p>
<p>I'm stuck on this..</p>
<p>Thanks!</p>
| <javascript><jquery><json> | 2019-05-16 19:01:13 | LQ_CLOSE |
56,175,308 | Internal compiler error: Classcast exception | <p>I am getting below error at the start of java file right at letter 'p' of package</p>
<p>Internal compiler error: java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.lookup.MethodBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.FieldBinding at org.eclipse.jdt.internal.compiler.ast.ASTNode.resolveAnnotations(ASTNode.java:817)</p>
<p>Project compiles fine from command prompt. but eclipse is showing this error.I am using jdk 8.
any help is highly appreciated</p>
<p>I tried restarting eclipse, cleaning project, installing different versions of eclipse etc.</p>
| <java><eclipse><gradle><javabuilders> | 2019-05-16 19:21:26 | HQ |
56,176,671 | Copying data and pasting it to specific range | <p>I am not being able to paste my data into specific cells in sheet2. </p>
<p>Like I have some data on sheet1 on the range of D:F and I want to paste it to the range of A:C on the last row. I need the code to adjust the range.</p>
| <google-apps-script><copy-paste> | 2019-05-16 21:10:49 | LQ_CLOSE |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.