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 |
|---|---|---|---|---|---|
55,931,234 | Unknown column 'email_input' (PHP MySQLi Prepared Statement) | <p>I'm using MySQLiIn the <code>WHERE</code> clause of my statement I am adding parameters on RHS:</p>
<p>Prepared statement:</p>
<p><code>$sql = 'select * from emailstobeverified where email=email_input and verification_code=code_input;';</code></p>
<p>And then I use <code>$stmt->prepare($sql);</code></p>
<p>And I get a PHP error saying:</p>
<p><code>Sql Error: Unknown column 'email_input' in 'where clause'</code></p>
<p>(I thought that the LHS of the boolean expression counts as the column? )</p>
<p>the below query will work:</p>
<p><code>$sql = 'insert into emailstobeverified (email) values (:email);';</code></p>
<p>Here, I can use <code>:email</code> as a parameter, so I tried making <code>email_input</code> have a colon before it: <code>:email_input</code> and used that as the param. However I got a syntax error:</p>
<pre><code>Sql Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ':email_input and verification_code=:code_input' at line 1
</code></pre>
<p>What's the correct syntax for comparing the table column value to some param?</p>
| <php><mysqli> | 2019-05-01 03:22:24 | LQ_CLOSE |
55,931,244 | I got an error about something having 'already been defined in game.obj'. What do I do? | <p>While I was working with SDL2 in Visual Studio 2019, I came across a few errors:</p>
<pre><code> 1>Source.obj : error LNK2005: "struct SDL_Window * game::gWindow" (?gWindow@game@@3PAUSDL_Window@@A) already defined in game.obj
1>Source.obj : error LNK2005: "struct SDL_Surface * game::gScreenSurface" (?gScreenSurface@game@@3PAUSDL_Surface@@A) already defined in game.obj
1>Source.obj : error LNK2005: "struct SDL_Surface * game::gImage" (?gImage@game@@3PAUSDL_Surface@@A) already defined in game.obj
</code></pre>
<p>I looked up how to fix it to no avail. I tried using externs, changing my game.h file but nothing worked. Just as some background info, I am trying to make a game engine type thing using SDL2 to help me in the future with game development. I would like to keep as much code as possible, not removing too much.</p>
<p>Here is my code:
Source.cpp</p>
<pre><code> #include <SDL.h>
#include "game.h"
#include <stdio.h>
int main(int argc, char* args[]) {
if (!game::init()) { // SDL failed it initialize
printf("error");
}
else { // SDL was able to initialize
if (!game::loadMedia()) { // Could not load media
printf("error");
}
else { // Could load media
SDL_BlitSurface(game::gImage, NULL, game::gScreenSurface, NULL);
}
}
return 0;
}
</code></pre>
<p>game.cpp</p>
<pre><code>#include <SDL.h>
#include "game.h"
#include <stdio.h>
namespace game { //functions
bool init() {
bool success = true;
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
printf("SDL failed to initialize.\n");
success = false;
}
else {
gWindow = SDL_CreateWindow(
"SDL Window (;", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN
);
if (gWindow == NULL)
{
printf("Window could not be created! SDL_Error: %s\n", SDL_GetError());
success = false;
}
else
{
//Get window surface
gScreenSurface = SDL_GetWindowSurface(gWindow);
}
}
return success;
}
bool loadMedia() {
// Loading success flag
bool success = true;
// File name of image
const char* fileName = "mario.bmp";
// Load splash image
gImage = SDL_LoadBMP(fileName);
if (gImage == NULL)
{
printf("Unable to load image '%s'! SDL Error: %s\n", fileName, SDL_GetError());
success = false;
}
return success;
}
}
</code></pre>
<p>and game.h</p>
<pre><code>#ifndef _GAME_H
namespace game {
SDL_Window* gWindow;
SDL_Surface* gScreenSurface;
SDL_Surface* gImage;
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
bool init();
bool loadMedia();
}
#endif
</code></pre>
<p>Thanks in advance!</p>
| <c++><compiler-errors><sdl><sdl-2> | 2019-05-01 03:25:50 | LQ_CLOSE |
55,933,119 | make navigation transparent when on home page otherwise default | <p>I am creating a navigation in which I try to put two backgrounds
1. Transparent (Only show when a user at homepage)
2. Default Color(When a user visit other pages)</p>
<p>I try to solve this using javascript by checking up the address bar URL but then I realize that I am unable to catch the Home page URL.</p>
<p>Does anyone know how to solve this problem?</p>
| <javascript><html><css><bootstrap-4> | 2019-05-01 07:49:42 | LQ_CLOSE |
55,933,124 | How can I use i in loop to make variance? | <p>How can I change this code</p>
<pre><code>train_0.append(0)
train_1.append(1)
train_2.append(2)
train_3.append(3)
</code></pre>
<p>using loop like under?</p>
<pre><code>for i in range(4):
train_i.append(i)
</code></pre>
<p>My code occurs this error.</p>
<pre><code>NameError: name 'train_i' is not defined
</code></pre>
<p>Thank you.</p>
| <python> | 2019-05-01 07:50:20 | LQ_CLOSE |
55,933,354 | Java Linkedlist recursion methods | so i couldnt understand the linkedlist Data structur and how the recursion works in it , it doesnt make sense to me at all , i mean i understand normal recursion but with linkedLists not at all
i've seen many things on the net but they just don't explain how it exactly works so i would really apperciate if anyone could help me , the code is below is about a linkedList class with A elements it has a head as A element and the rest of the list(tail) as another linkedList
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
public class LL<A> {
private final A hd;
private final LL<A> tl;
public boolean isEmpty(){
return hd==null&&tl==null;
}
public LL(A hd, LL<A> tl) {
this.hd = hd;
this.tl = tl;
}
public LL() {
this(null,null);
}
public int size() {
if (isEmpty())
return 0;
return 1 + tl.size();
}
public A get(int i) {
return i==0?hd:tl.get(i-1);
}
LL<A> drop(int i){
if(i==0) return this;
if(i<0) return new LL<>();
if(isEmpty()) return new LL<A>();
return this.tl.drop(i-1);
}
}
so for example this drop method creates a new LinkedList with the elements other than the first i Elements and i actually don't get how it works
lets say if i make drop(1) on a linkedList what will it step by step do .
Thanks in advance :) sorry to bother | <java><recursion> | 2019-05-01 08:15:52 | LQ_EDIT |
55,934,008 | please assist me to add google ads on my websitei tried they arent showing | i wish to get a guide on how to add google ads on html of my website i tried they are not showing
<!DOCTYPE html>
<html>
<head>
<title>WEB DEVELOPMENT TUTORIAL</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<header>
<div class="main">
<div class="logo">
<img src="logo.jpg">
</div>
<ul>
<li class="active"><a href="#">Home</a></li>
<li><a href="dailyposted.php">DAILY BETTING TIPS</a></li>
<li><a href="megaposted.php">MEGAJACKPOT PREDICTIONS</a></li>
<li><a href="midweekposted.php">MIDWEEKJACKPOT PREDICTIONS</a></li>
<li><a href="https://www.goal.com">TRANSFER NEWS</a></li>
</ul>
</div>
<div class="title">
<h1>SURE DAILY BETTING TIPS</h1>
</div>
<div class="button">
<a href="#" class="btn">WATCH VIDEO</a>
<a href="#" class="btn">LEARN MORE</a>
</div>
i tried to add google auto ads here. The website shows nothing even after 4 hours.please help.is there any test ads for website please aslso
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-2870870041610409",
enable_page_level_ads: true
});
</script>
</header>
</body>
</html> | <html><google-adwords> | 2019-05-01 09:15:19 | LQ_EDIT |
55,934,083 | How to group array of objects by value | <p>I'm making a data set for one of my components,
current data is</p>
<pre><code> [
{name : "John" , id : "123"} ,
{name : "Josh" , id : "1234"},
{name : "Charlie" , id : "1234253"},
{name : "Charles" , id : "123345"}
]
</code></pre>
<p>want it to groupby like</p>
<pre><code> {
C : [{name:"Charlie",id:"1234253"},{name:"Charles",id:"123345"}],
J : [{name:"John",id:"123"},{name:"Josh",id:"1234"}]
}
</code></pre>
| <javascript><arrays><group-by> | 2019-05-01 09:21:28 | LQ_CLOSE |
55,934,490 | Why are await and async valid variable names? | <p>I was experimenting with how <code>/</code> is interpreted when around different keywords and operators, and found that the following syntax is perfectly legal:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>// awaiting something that isn't a Promise is fine, it's just strange to do:
const foo = await /barbaz/
myFn()</code></pre>
</div>
</div>
</p>
<p>Error:</p>
<blockquote>
<p>Uncaught ReferenceError: await is not defined</p>
</blockquote>
<p>It looks like it tries to parse the <code>await</code> as a <em>variable name</em>..? I was expecting</p>
<blockquote>
<p>await is only valid in async function</p>
</blockquote>
<p>or maybe something like</p>
<blockquote>
<p>Unexpected token await</p>
</blockquote>
<p>To my horror, you can even assign things to it:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const await = 'Wait, this actually works?';
console.log(await);</code></pre>
</div>
</div>
</p>
<p>Shouldn't something so obviously wrong cause a syntax error, as it does with <code>let</code>, <code>finally</code>, <code>break</code>, etc? Why is this allowed, and what the heck is going on in the first snippet?</p>
| <javascript><async-await><specifications><language-design><es2017> | 2019-05-01 09:56:54 | HQ |
55,934,733 | documentation for Kaggle API *within* python? | <p>I want to write a <code>python</code> script that downloads a public dataset from Kaggle.com. </p>
<p>The Kaggle API is written in python, but almost all of the documentation and resources that I can find are on how to use the API in command line, and very little on how to use the <code>kaggle</code> library within <code>python</code>. </p>
<p>Some users seem to know how to do this, see for example <a href="https://stackoverflow.com/questions/52681196/kaggle-datasets-into-jupyter-notebook/52909923#52909923">several answers to this question</a>, but the hints are not enough to resolve my specific issue. </p>
<p>Namely, I have a script that looks like this: </p>
<pre><code>from kaggle.api.kaggle_api_extended import KaggleApi
api = KaggleApi('content of my json metadata file')
file = api.datasets_download_file(
owner_slug='the-owner-slug',
dataset_slug='the-dataset-slug',
file_name='the-file-name.csv',
)
</code></pre>
<p>I have come up with this by looking at the method's signature:<br>
<code>api.datasets_download_file(owner_slug, dataset_slug, file_name, **kwargs)</code></p>
<p>I get the following error: </p>
<p><code>UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa1 in position 12: invalid start byte</code> </p>
<p>Beyond the solution to this specific problem, I would be really happy to know how to go about troubleshooting errors with the Kaggle library, other than going through the code itself. In fact, perhaps the issue has nothing to do with utf-encoding, but I don't know how to figure this out. What if it is just that the filename is wrong, or something as silly as this? </p>
<p>The <code>csv</code> file is nothing special: three columns, first is timestamp, the other two are integers.</p>
| <python><kaggle> | 2019-05-01 10:19:31 | HQ |
55,935,148 | Need to parse the data from Json file using python script | I created the json from a python script, and here is the code what I wrote to get the json data:
import requests
import json
import ConfigParser
url = "xxx"
payload = "items.find({ \"repo\": {\"$match\" : \"nswps-*\"}}).include(\"name\",\"repo\",\"path\")\r\n"
headers = {
'Content-Type': "text/plain",
'Authorization': "Basic xxxxxxxxx",
'Accept': "*/*",
'Cache-Control': "no-cache",
'Host': "xxxxxx.com",
'accept-encoding': "gzip, deflate",
'content-length': "77",
'Connection': "keep-alive",
'cache-control': "no-cache"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
the above code gives me the json file which is a huge file of multiple objects. Due to some limitation in artifactory I am unable to get the repos starting with nswps but rather the result is all the repository names. The json file has data like this:
"repo" : "npm-remote-cache",
"path" : "zrender/-",
"name" : "zrender-4.0.7.tgz"
},{
"repo" : "npm-remote-cache",
"path" : "ztree/-",
"name" : "ztree-3.5.24.tgz"
},{
"repo" : "nswps-docker-inprogress-local",
"path" : "ace/core/latest",
"name" : "manifest.json"
},{
"repo" : "nswps-docker-inprogress-local",
"path" : "ace/core/latest",
"name" : "sha256__0a381222a179dbaef7d1f50914549a84e922162a772ca5346b5f6147d0e5aab4"
},{
.........
Now I need to create a python script which fetches out the objects in which only the object that has value of nswps , lets say from the above json I need data like this:
{
"repo" : "nswps-docker-inprogress-local",
"path" : "ace/core/latest",
"name" : "manifest.json"
},{
"repo" : "nswps-docker-inprogress-local",
"path" : "ace/core/latest",
"name" : "sha256__0a381222a179dbaef7d1f50914549a84e922162a772ca5346b5f6147d0e5aab4"
}
Please suggest! | <python><json> | 2019-05-01 10:57:31 | LQ_EDIT |
55,937,371 | Execute certain code in function (Calling function in function)? Python | <p>I want to execute a certain lines of codes in a function and not other ones.</p>
<p>Example:</p>
<pre><code>def function1():
print("execute function 1")
def function2():
print("execute funciton 2")
def function3():
print("execute function 3")
function1()
</code></pre>
<p>This gives an output of: <code>execute function 1</code> </p>
<p>How can i get an output of
<code>execute function 1</code>
<code>execute function 2</code> </p>
<p>Or <code>execute function 1</code> <code>execute function 3</code> </p>
| <python><function> | 2019-05-01 13:53:58 | LQ_CLOSE |
55,937,702 | How to read data from SAE j1939 bus is there any tutorial for iOS | Here we are trying to read data from J1939 SAE bus devices but seems it not read with iOS we are working with `Core bluetooth` connectivity we have done in android and in android work fine but same device not read with iOS can any one please help me on that. if suggest any tutorial it will great. | <ios><swift><bluetooth-lowenergy><j1939> | 2019-05-01 14:17:53 | LQ_EDIT |
55,937,858 | Is it possible to overload operator of class A in a friend class B? | <p>I'm trying to solve the following problem from the lab where it says:</p>
<blockquote>
<p>Define a class called Repository that has 2 integer private variables. The >class contains an empty constructor and another one with 2 parameters. An >accesor method that displays the variables values is also included in the >class. Write another class called Mathematics which is friend to the first >one. This class contains the implementation of the elementary arithmetical >operations (+, -, *, /) applied to the values stored in the first class. Each >arithmetical method receives as parameter an object instantiated from the >first class.</p>
</blockquote>
<p>I have been searching all over the internet for a couple of hours already but I haven't found anything about overloading operators of a class in another one. I understand the overloading mechanism, I solved the problem using friend functions but I'm still asking myself if it is possible to do as above mentioned and if yes, I wish to know how to do it. Thanks in advance !</p>
<p>I have tried the solution mentioned <a href="https://stackoverflow.com/questions/3981911/operators-overloading-in-other-classes">here</a></p>
<pre><code>//friend Repository operator + (Repository &, Repository &);
friend Mathematics;
};
/*
Repository operator + (Repository &rep1, Repository &rep2)
{
Repository obToRet;
obToRet.val1 = rep1.val1 + rep2.val1;
obToRet.val2 = rep1.val2 + rep2.val2;
return obToRet;
}*/
class Mathematics
{
public:
friend Repository;
public static Repository operator+(Repository &rep1, Repository &rep2)
{
Repository objtoret;
objtoret.val1 = rep1.val1 + rep2.val1;
objtoret.val2 = rep1.val2 + rep2.val2;
return objtoret;
}
};
</code></pre>
| <c++> | 2019-05-01 14:29:59 | LQ_CLOSE |
55,938,207 | How to generate OpenApi 3.0 spec from existing Spring Boot App? | <p>I have a project (Spring Boot App + Kotlin) that I would like to have an Open API 3.0 spec for (preferably in YAML). The Springfox libraries are nice but they generate Swagger 2.0 JSON. What is the best way to generate an Open Api 3.0 spec from the annotations in my controllers? Is writing it from scratch the only way?</p>
| <spring-boot><kotlin><swagger><openapi> | 2019-05-01 14:55:02 | HQ |
55,938,560 | C struct local copy inside a function | <p>I have a struct named "point", and an array of "points", named "A[N]".
I also have a function, where I want to have a local copy of "A".
How should I do in order to optain a local copy of "A", inside the function?</p>
<pre><code>struct point A[N];
int function(struct point *A)
{
struct point *ALocal;
...
}
</code></pre>
| <c><struct><copy> | 2019-05-01 15:19:52 | LQ_CLOSE |
55,939,084 | How to test styled Material-UI components wrapped in withStyles using react-testing-library? | <p>I am trying to create a test with a styled Material-UI component using react-testing-library in typescript. I'm finding it difficult to access the internal functions of the component to mock and assert. </p>
<p>Form.tsx</p>
<pre><code>export const styles = ({ palette, spacing }: Theme) => createStyles({
root: {
flexGrow: 1,
},
paper: {
padding: spacing.unit * 2,
margin: spacing.unit * 2,
textAlign: 'center',
color: palette.text.secondary,
},
button: {
margin: spacing.unit * 2,
}
});
interface Props extends WithStyles<typeof styles> { };
export class ExampleForm extends Component<Props, State> {
async handleSubmit(event: React.FormEvent<HTMLFormElement>) {
// Handle form Submit
...
if (errors) {
window.alert('Some Error occurred');
return;
}
}
// render the form
}
export default withStyles(styles)(ExampleForm);
</code></pre>
<p>Test.tsx</p>
<pre><code>import FormWithStyles from './Form';
it('alerts on submit click', async () => {
jest.spyOn(window,'alert').mockImplementation(()=>{});
const spy = jest.spyOn(ActivityCreateStyles,'handleSubmit');
const { getByText, getByTestId } = render(<FormWithStyles />)
fireEvent.click(getByText('Submit'));
expect(spy).toHaveBeenCalledTimes(1);
expect(window.alert).toHaveBeenCalledTimes(1);
})
</code></pre>
<p><code>jest.spyOn</code> throws the following error <code>Argument of type '"handleSubmit"' is not assignable to parameter of type 'never'.ts(2345)</code> probably because ExampleForm in wrapped in withStyles. </p>
<p>I also tried directly importing the <code>ExampleForm</code> component and manually assigning the styles, was couldn't do so:</p>
<pre><code>import {ExampleForm, styles} from './Form';
it('alerts on submit click', async () => {
...
const { getByText, getByTestId } = render(<ActivityCreateForm classes={styles({palette,spacing})} />)
...
}
</code></pre>
<p>Got the following error: <code>Type '{ palette: any; spacing: any; }' is missing the following properties from type 'Theme': shape, breakpoints, direction, mixins, and 4 more.ts(2345)</code></p>
<p>I'm finding it difficult to write basic tests in Typescript for <code>Material-UI</code> components with <code>react-testing-library</code> & <code>Jest</code> due to strong typings and wrapped components. Please Guide.</p>
| <reactjs><typescript><jestjs><material-ui><react-testing-library> | 2019-05-01 15:59:22 | HQ |
55,939,204 | CircleCI: Error unmarshaling return header; nested exception is: | <p>We keep getting the following exception on CircleCI while building out project. Everything runs well when running the job from the CircleCI CLI. Has anyone found a fix / resolution for this?</p>
<pre><code>Compilation with Kotlin compile daemon was not successful
java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
java.io.EOFException
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:236)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:161)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:227)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:179)
at com.sun.proxy.$Proxy104.compile(Unknown Source)
at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.incrementalCompilationWithDaemon(GradleKotlinCompilerWork.kt:284)
at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.compileWithDaemon(GradleKotlinCompilerWork.kt:198)
at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.compileWithDaemonOrFallbackImpl(GradleKotlinCompilerWork.kt:141)
at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.run(GradleKotlinCompilerWork.kt:118)
at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runCompilerAsync(GradleKotlinCompilerRunner.kt:158)
at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runCompilerAsync(GradleKotlinCompilerRunner.kt:153)
at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runJvmCompilerAsync(GradleKotlinCompilerRunner.kt:92)
at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompilerAsync$kotlin_gradle_plugin(Tasks.kt:447)
at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompilerAsync$kotlin_gradle_plugin(Tasks.kt:355)
at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.executeImpl(Tasks.kt:312)
at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute(Tasks.kt:284)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:103)
at org.gradle.api.internal.project.taskfactory.IncrementalTaskInputsTaskAction.doExecute(IncrementalTaskInputsTaskAction.java:46)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:41)
at org.gradle.api.internal.project.taskfactory.AbstractIncrementalTaskAction.execute(AbstractIncrementalTaskAction.java:25)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:28)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$5.run(ExecuteActionsTaskExecuter.java:404)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:394)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:92)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:393)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:376)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$200(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:213)
at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$0(ExecuteStep.java:32)
at java.util.Optional.map(Optional.java:215)
at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:32)
at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:58)
at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:35)
at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:48)
at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:33)
at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:39)
at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:73)
at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:54)
at org.gradle.internal.execution.steps.CatchExceptionStep.execute(CatchExceptionStep.java:35)
at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:51)
at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:45)
at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:31)
at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:201)
at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:70)
at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:45)
at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:49)
at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:43)
at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:32)
at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:38)
at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:24)
at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:96)
at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:89)
at java.util.Optional.map(Optional.java:215)
at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:54)
at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:38)
at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:77)
at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:37)
at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:90)
at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:48)
at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:33)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:120)
at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionStateTaskExecuter.execute(ResolveBeforeExecutionStateTaskExecuter.java:75)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:108)
at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionOutputsTaskExecuter.execute(ResolveBeforeExecutionOutputsTaskExecuter.java:67)
at org.gradle.api.internal.tasks.execution.ResolveAfterPreviousExecutionStateTaskExecuter.execute(ResolveAfterPreviousExecutionStateTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:94)
at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:95)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:73)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:49)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:49)
at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:355)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:134)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:129)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:202)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:267)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:222)
... 110 more
Unable to clear jar cache after compilation, maybe daemon is already down: java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
java.net.ConnectException: Connection refused (Connection refused)
Could not connect to kotlin daemon. Using fallback strategy.
</code></pre>
| <circleci> | 2019-05-01 16:10:23 | HQ |
55,939,539 | Enter Key To Download Product | <p>I'm a game developer who is creating a website for his project. I want players to enter a key before downloading my game from this website. I am trying to use HTML and JavaScript to make this possible. I haven't done something like this before and would like some help writing the code for it. Could someone please help me out? If so, that'd be a big help. Thanks in advance!</p>
| <javascript><html><key><product> | 2019-05-01 16:40:10 | LQ_CLOSE |
55,940,243 | How to fix 'Uncaught ReferenceError: $ is not defined' | <p>This is for a navigation header and it works, but I still get an error on line 2. VM4582 header.js:2 Uncaught ReferenceError: $ is not defined
I don't understand why it says $(window) is not defined.</p>
<pre><code>// Sticky Header
$(window).scroll(function() {
if ($(window).scrollTop() > 100) {
$('.main_h').addClass('sticky');
} else {
$('.main_h').removeClass('sticky');
}
});
// Mobile Navigation
$('.mobile-toggle').click(function() {
if ($('.main_h').hasClass('open-nav')) {
$('.main_h').removeClass('open-nav');
} else {
$('.main_h').addClass('open-nav');
}
});
$('.main_h li a').click(function() {
if ($('.main_h').hasClass('open-nav')) {
$('.navigation').removeClass('open-nav');
$('.main_h').removeClass('open-nav');
}
});
// navigation scroll lijepo radi materem
$('nav a').click(function(event) {
var id = $(this).attr("href");
var offset = 70;
var target = $(id).offset().top - offset;
$('html, body').animate({
scrollTop: target
}, 500);
event.preventDefault();
});
</code></pre>
| <javascript> | 2019-05-01 17:35:37 | LQ_CLOSE |
55,940,895 | Store First & Second Character value in two different veritable | <p>I wish to store First & Second character of value in two different variable <code>id</code> with <code>ccMain</code>.Using jquery or Javascript.</p>
<p>Here is the html code I have to set up the environment:</p>
<pre><code><span id="ccMain">GM</span>
</code></pre>
| <javascript><jquery> | 2019-05-01 18:29:08 | LQ_CLOSE |
55,940,984 | API to allow user with a (+) signed in their username to log in | <p>Currently right now, user with an email such as test+test@email.com are not getting through are API because of the (+) sign. When making a database call with such a user ID, it brings results. However, when making an api call such as this.</p>
<pre><code>api.hq.org/user?token=1234567&username=test+test@email.com
</code></pre>
<p>it does not bring any results. I am trying to find a way to allow such users to return results. I know its an URL encoding but I am wondering if anyone has encounter this at one point?</p>
| <php><rest><api><symfony><urlencode> | 2019-05-01 18:36:04 | LQ_CLOSE |
55,941,242 | Comparing numerical input in python list | <p>Trying to create a list. </p>
<pre><code>n = 0
while n = 0:
number = int(input ("What number of groceries do you wish to purchase?"))
</code></pre>
<p>is there some way I can write a code that asks the user what groceries they want based on what number the user inputs. </p>
<p>Something like</p>
<pre><code>while number = int(1,20):
print ("What grocery would you like to purchase?")
</code></pre>
<p>only that wouldn't print it that many times...</p>
| <python><list><numbers><numeric><shopping> | 2019-05-01 18:58:14 | LQ_CLOSE |
55,943,743 | Why would a C# regex credit card validation function validate with invalid values? | <p>I am creating a payment processor WinForms app which of course pushes the results to the gateway API. I am simply trying to validate the credit card number before sending it out. I just need a working 'prototype' so I can finish designing the UI before I dive into learning the Luhn and Base 10 Algorithms so I found the ValidateCreditCard() method in a forum and I just need to get it to be functional.</p>
<pre><code>using System;
using System.Text;
using System.Windows.Forms;
namespace PaymentPlanCalculator
{
public partial class paymentPlanCalculator : Form
{
public paymentPlanCalculator()
{
InitializeComponent();
}
public void Form1_Load(object sender, EventArgs e)
{
/****************************************** //
/* DEFINE VARIABLES //
/****************************************** */
//I have a bunch of variables defined here, nothing relevant to the question
}
public void Button1_Click(object sender, EventArgs e)
{
string creditCardNumber = txtCreditCardNumber.Text;
if (ValidateCreditCard(creditCardNumber))
{
lblCardValid.Text = "VALID!";
}
else
{
lblCardValid.Text = "INVALID!";
}
}
public bool ValidateCreditCard(string creditCardNumber)
{
//Strip any non-numeric values
creditCardNumber = Regex.Replace(creditCardNumber, @"[^\d]", "");
//Build your Regular Expression
Regex expression = new Regex(@"^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$");
//Return if it was a match or not
return expression.IsMatch(creditCardNumber);
}
}
}
</code></pre>
<p>It appears to work but I have a STRONG feeling that it is validating invalid card numbers as long as they're 16 digits and begin with a 4 or 5.</p>
<p>I have never used regex before and I'm a relatively green C# programmer so I'm assuming that there is something wrong with my implementation as opposed to the function I found online.</p>
| <c#><regex><validation> | 2019-05-01 22:59:24 | LQ_CLOSE |
55,947,129 | How to build a comma separated array in python | <p>I have a list of user id's in a list in python
<code>['user1', 'user2' , 'user3',...]</code>
and i am trying to build an array from these list of user id's and then trying to pass this new array into a shell command in python. I am able to do all the other steps but i am stuck with this building an array thing. </p>
<p>I have tried this so far, </p>
<pre><code>my_list = ['user1', 'user2' , 'user3'
string = "user_id="
var = [string + x for x in my_list]
</code></pre>
<p>But what i actually need is something like this</p>
<pre><code>var = "(|(user_id=user1)(user_id=user2)(user_id=user3))"
</code></pre>
<p>and this list goes for many other values.
I am stuck here how to build this value <code>(user_id=user1)(user_id=user2)(user_id=user3)</code> in python.</p>
<p>Can anyone suggest some ideas?</p>
| <python> | 2019-05-02 06:56:34 | LQ_CLOSE |
55,953,052 | Kotlin - Void vs. Unit vs. Nothing | <p>Kotlin has three types that are very similar in nature:</p>
<ul>
<li><code>Void</code></li>
<li><code>Unit</code></li>
<li><code>Nothing</code></li>
</ul>
<p>It almost seems like they're making the JavaScript mistake:</p>
<ul>
<li><code>null</code></li>
<li><code>undefined</code></li>
<li><code>void(0)</code></li>
</ul>
<p>Assuming that they <em>haven't</em> fallen into the same mistake, what are they all for, and how do they differ?</p>
| <kotlin> | 2019-05-02 12:59:17 | HQ |
55,953,884 | Is i=++i; undefined behavior? | <p>This is undefined behavior, right? Double assignment in the same sequence point?</p>
<pre><code>int i = 0;
i = ++i;
</code></pre>
| <c++> | 2019-05-02 13:46:16 | LQ_CLOSE |
55,954,399 | How to install the latest openjdk 12 on Ubuntu 18.04 | <p>I've installed the default jdk by issuing the command:</p>
<pre><code>apt-get install default-jdk
</code></pre>
<p>This will install openjdk 11 and apt-get seems to install the files all over the place. Examples:</p>
<pre><code>/etc/java-11-openjdk/management
/usr/lib/jvm/java-11-openjdk-amd64/lib
/usr/share/doc/openjdk-11-jre-headless/JAVA_HOME
/var/lib/dpkg/info/openjdk-11-jre:amd64.postinst
</code></pre>
<p>As you can see by the example locations above, there are files scattered everywhere.</p>
<p>I've just installed a web app that's giving a warning that it only supports jdk 12 (I think it's the latest openjdk version). How can I install version 12 so that it replaces version 11? What is the best way to upgrade the openjdk version on Ubuntu 18.04 so that it doesn't mingle with the previous version?</p>
| <java><ubuntu><apt-get> | 2019-05-02 14:14:37 | HQ |
55,954,595 | How to escap "..." | <p>I R imports columns with no colname as ...1 I need to replace this ... with something else</p>
<p>Trying:</p>
<pre><code>str_replace("hi_...","/././.","&")
</code></pre>
| <r><regex> | 2019-05-02 14:26:35 | LQ_CLOSE |
55,954,738 | Why a variable affects on another variable in this Python example? | <p>What is the reason for this output?</p>
<p>Here is an example:</p>
<pre><code>list_ = [{'status': True}]
print(list_)
for dict_ in list_:
dict_['status'] = False
print(dict_)
print(list_)
</code></pre>
<p>Out:</p>
<pre><code>[{'status': True}]
{'status': False}
[{'status': False}] # Why list_ changed? I changed only the dict_!
</code></pre>
<p>Why <code>list_</code> changed? I changed only the <code>dict_</code></p>
| <python><python-3.x><list><dictionary> | 2019-05-02 14:35:47 | LQ_CLOSE |
55,955,232 | Inferring parameter type for a lambda (again!) | <p>I am wondering why does this not work (missing parameter type)? </p>
<pre><code> Seq(1,2,3).toSet.map(_ + 1)
</code></pre>
<p>but this does: </p>
<pre><code> val foo = Seq(1,2,3).toSet
foo.map(_ + 1)
</code></pre>
<p>as well as this: (3)</p>
<pre><code> Seq(1,2,3).toSet[Int].map(_ + 1)
</code></pre>
<p>or this: </p>
<pre><code> Seq(1,2,3).toList.map(_ + 1)
</code></pre>
<p>What is special about <code>toSet</code> that makes it loose the type in the first case, but not in the second?</p>
| <scala><lambda> | 2019-05-02 15:01:13 | HQ |
55,955,722 | Creating One Unique Array from 2 Arrays | I have 2 arrays(Arr1, Arr2). I am trying to create a single array that has as many objects in it as Arr.1.length where the format is:
[{name:Arr1[0], Arr2[0],Arr2[1]...etc}, {name:Arr1[1], Arr2[0],Arr2[1]...etc}..... etc]
Working with proprietary information so I cannot show the actual code. For the sake of Simplicity we will examine the two arrays:
Arr1[1,2,3,4,5] and
Arr2[6,7,8,9].
The resulting array should be:
[{1,6,7,8,9}{2,6,7,8,9}{3,6,7,8,9}{4,6,7,8,9}{5,6,7,8,9}]. I have used two for loops to manipulate two arrays. Did not know if there was a method to call that would make this easier. | <javascript><arrays><javascript-objects> | 2019-05-02 15:27:50 | LQ_EDIT |
55,955,850 | My code keeps printing a certain part of the code, instead of continuing with the rest of the program | <p>After I type in any username and password (doesn't matter whether it's correct or not), it keeps printing another part of the code.</p>
<p>The login part works fine but it doesn't show the correct output afterwards. It continuously shows:
"Incorrect login details entered
Have you made an account?
Yes or No"</p>
<p>This has stumped both my teacher and I. I have looked at different websites with examples of login/registration systems. I have also tried re-arranging the code differently. </p>
<p>This is the code:</p>
<pre><code>username = input("Please enter your username: ")
password = input("Please enter your password: ")
file = open("Usernames.txt","r")
found = False
for line in file:
user = line.split(",")
if user[0] == username and user[1] == password:
found = True
print("Username: " + user[0])
print("~~~~~")
print("Welcome to the game, " + user[0])
else:
found == False
print("Incorrect login details entered")
print("Have you made an account?")
ans = input("Yes or No ")
while ans not in ("Yes", "No"):
if ans == "Yes":
print ("Please sign in again")
username = input("Please enter your correct username: ")
password = input("Please enter your correct password: ")
elif ans == "No":
print("Would you like to make an account? ")
else:
ans = input("Please enter Yes or No ")
</code></pre>
<p>The expected result when the username and password is correct:</p>
<pre><code>Username: Smartic
~~~~~
Welcome to the game, Smartic
</code></pre>
<p>The expected result when the username and password is incorrect:</p>
<pre><code>Incorrect login details entered
Have you made an account?
Yes or No
</code></pre>
<p>The expected result when the user enters <code>Yes</code>:</p>
<pre><code>Please sign in again
Please enter your correct username:
Please enter your correct password:
</code></pre>
<p>The expected result when the user enters <code>No</code>:</p>
<pre><code>Would you like to make an account?
</code></pre>
<p>The expected result when the user enters something other than <code>Yes</code> or <code>No</code>:</p>
<pre><code>Please enter Yes or No
</code></pre>
| <python> | 2019-05-02 15:35:31 | LQ_CLOSE |
55,956,645 | docker-compose.yml for elasticsearch 7.0.1 and kibana 7.0.1 | <p>I am using Docker Desktop with linux containers on Windows 10 and would like to launch the latest versions of the elasticsearch and kibana containers over a docker compose file.</p>
<p>Everything works fine when using some older version like 6.2.4.</p>
<p>This is the working docker-compose.yml file for 6.2.4.</p>
<pre><code>version: '3.1'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.2.4
container_name: elasticsearch
ports:
- "9200:9200"
volumes:
- elasticsearch-data:/usr/share/elasticsearch/data
networks:
- docker-network
kibana:
image: docker.elastic.co/kibana/kibana:6.2.4
container_name: kibana
ports:
- "5601:5601"
depends_on:
- elasticsearch
networks:
- docker-network
networks:
docker-network:
driver: bridge
volumes:
elasticsearch-data:
</code></pre>
<p>I deleted all installed docker containers and adapted the docker-compose.yml file by changing 6.2.4 to 7.0.1.
By starting the new compose file everything looks fine, both the elasticsearch and kibana containers are started. But after a couple of seconds the elasticsearch container exits (the kibana container is running further). I restarted everything, attached a terminal to the elasticsearch container and saw the following error message:</p>
<pre><code>...
ERROR: [1] bootstrap checks failed
[1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
...
</code></pre>
<p>What must be changed in the docker-compose.yml file to get elasticsearch 7.0.1 working?</p>
| <docker><elasticsearch><docker-compose><kibana> | 2019-05-02 16:27:31 | HQ |
55,956,792 | Is there a general way to remove substring which starts with a number and ends with a Capital Letter in R | <p>Hard to describe, but basically, I'm trying to find a <strong><em>general</em></strong> method which would make this: </p>
<pre class="lang-r prettyprint-override"><code> [1]" On The Grill(1)95 E Kennedy BlvdLakewood, NJ 08701(732) 942-6555Restaurants I had a business dinner at this restaurant with 5 other people. Everyone was pleased with their appetizers and main courses. We’ll be back for sure…"
[2]" Sushi Now231 3rd StLakewood, NJ 08701(732) 719-2275RestaurantsSushi BarsWebsiteMenuOrder Online"
</code></pre>
<p>into this: </p>
<pre class="lang-r prettyprint-override"><code> [1] "95 E Kennedy Blvd"
[2] "231 3rd St"
</code></pre>
<p>Using R. I know it involves regular expressions, but I am not as fluent as I would like to be. </p>
<p>Thanks!</p>
| <r><regex><gsub> | 2019-05-02 16:37:20 | LQ_CLOSE |
55,957,347 | How to write a cosine theorem on Java? | How to write this theorem correctly as is written in the formula?
package com.company;
public class Exercise8 {
public static void main(String[] args) {
double AB = 6;
double AC = 16;
double Angle = 60;
double CosOfAngle = 0.5;
// Почему-то значение косинуса 60 градусов вместо 0.5, пишет
-0.9524129804151563??? (Do not pay attention)
// Formula is BC^2 = AB^2 + AC^2 - 2AB*AC * cos A
double bc = (2*(Math.pow(AB,2) + Math.pow(AC,2) -
((AB * AC)))*CosOfAngle);
double BC = Math.sqrt(bc);
double P = AB + BC + AC;
double p = 0.5 * P; // Где p - полупериметр
double S0 = (p*((p-AB)*(p-BC)*(p-AC)));
double S1 = Math.sqrt(S0);
double S = Math.round(S1);
System.out.println("Perimeter of triangle is : " + P + " cm ");
System.out.println("Area of triangle is : " + S + " cm^2 ");
}
} | <java><math> | 2019-05-02 17:17:40 | LQ_EDIT |
55,957,572 | Can't display a string from an array of strings | When i press button VK_LEFT / VK_RIGHT nothing happens, why??? I would like it to print the next string in the array but it won't do it for some reason!!! what am i doing wrong here? thanks for anyone helping me out here!
```
int TotalItems = 0, IntForItem = 0;
struct Item
{
int * Index;
std::string* stringArray = new std::string[3];
};
Item item[120];
int AddNewItem(int i, int * Index, std::string stringarray[])
{
item[i].Index = Index;
item[i].stringArray = stringarray;
return (i + 1);
}
void GetItems()
{
int i = 0;
std::string * test = new std::string[3]{ "hi", "and", "bye" };
i = AddNewItem(i, &IntForItem, test);
TotalItems = i;
}
int main()
{
GetItems();
while (true)
{
system("CLS");
std::cout << item[0].stringArray[*item[0].Index].c_str() << std::endl;
while (true)
{
if (GetAsyncKeyState(VK_LEFT))
*item[0].Index -= 1;
else if (GetAsyncKeyState(VK_RIGHT))
*item[0].Index += 1;
}
}
Sleep(1);
return 0;
}
``` | <c++><winapi> | 2019-05-02 17:35:45 | LQ_EDIT |
55,957,685 | Replace Single Quotes and Comma in Nested List | <p>Have a list of list that looks like this:</p>
<pre><code>mylist = [['A'],['A', 'B'], ['A', 'B', 'C']]
</code></pre>
<p>Need to remove and replace all ', ' instances with a comma only (no spaces). Output should look like this:</p>
<pre><code>mynewlist = [['A'],['A,B'], ['A,B,C']]
</code></pre>
<p>Tried the following:</p>
<pre><code>mynewlist = [[x.replace("', ''",",") for x in i] for i in mylist]
</code></pre>
<p>This works on other characters within the nested lists (e.g. replacing 'A' with 'D', but does not function for the purpose described above (something to do with with the commas not being literal strings?).</p>
| <python><list> | 2019-05-02 17:44:22 | LQ_CLOSE |
55,959,602 | Which solution is better, faster and readable? | <p>ok, problem: "An isogram is a word that has no repeating letters, consecutive or non-consecutive. Implement a function that determines whether a string that contains only letters is an isogram. Assume the empty string is an isogram. Ignore letter case."
and I write 2 solutions </p>
<p>First solution:</p>
<pre class="lang-java prettyprint-override"><code>Scanner scanner = new Scanner(System.in);
String string = scanner.next();
long start = System.currentTimeMillis();
char words[] = string.toCharArray();
boolean isIsogram=true;
for (int i=(words.length-1); i>=0; i--){
for(int j=0; j<(i-1);j++){
if(words[i]==words[j]){
isIsogram=false;
}
}
}
long finish = System.currentTimeMillis();
System.out.println(isIsogram + " time:"+ (finish-start) );
</code></pre>
<p>Second solution:</p>
<pre class="lang-java prettyprint-override"><code> Scanner scanner = new Scanner(System.in);
String string = scanner.next();
long start = System.currentTimeMillis();
boolean isIsogram = (string.length() == string.toLowerCase().chars().distinct().count());
long finish = System.currentTimeMillis();
System.out.println(isIsogram + " time:"+ (finish-start) );
</code></pre>
<p>I have tested both solutions and there is results:
input: "asd" <br>
1) true time 0 <br>
2) true time 113 </p>
<p>and I want to know your ideas and opinion which solution is better?
My teacher told me 2 solution is better, but 1 solution takes
less time, and I am not sure which is better.....</p>
| <java><algorithm><time> | 2019-05-02 20:12:16 | LQ_CLOSE |
55,959,661 | scala - convert tuplen of long datatype to Array[Long] | <p>I get the counts of dataframe columns from spark to scala variable as below</p>
<pre><code>scala> col_counts
res38: (Long, Long, Long) = (3,3,0)
scala>
</code></pre>
<p>Now, I want to convert this to Array(3,3,0). I'm doing a roundabout way like</p>
<pre><code>scala> col_counts.toString.replaceAll("""\)|\(""","").split(",")
res47: Array[String] = Array(3, 3, 0)
scala>
</code></pre>
<p>But it looks ugly. Is there an elegant way of getting it? I'm looking for a generic solution to convert any n - Long tuple to Array. </p>
| <scala> | 2019-05-02 20:17:23 | LQ_CLOSE |
55,959,923 | Make an array of arrays with 10 items each | <p>I have an array that has X number of values.</p>
<p>I'm trying to make an array of arrays with 10 items each of X. How do I go on about in doing something like this?</p>
<p>I've tried using a count while iterating it and let's just say I didn't get anywhere with that. </p>
<p>I want something like </p>
<pre class="lang-py prettyprint-override"><code># Random list of 20 items
random_array = [1,...20]
# Do cool things here
# Output after doing cool thing
fancy_array = [[1,...10],[11,..20]]
</code></pre>
| <python><python-3.x> | 2019-05-02 20:39:06 | LQ_CLOSE |
55,960,817 | Java can't use public static final int = 283 in switch | i had a weird problem with java, while working with Sockets i created a new public static final int LOGOUT = 283 to decleare a Service of the server to handle ( in simple terms client send different int to specify a service request to server), but here were a weird thing start to happen, in my switch LOGOUT statement was unreachable for no reason ( intelliJ told me that this statement was unreachable). SO i tried to System.out.println(ServiceId) and it was always a different number ( not a random one) from 283, it was really weird, i solved this problem by change the number. Obviously the number 283 wasn't in no other variable.
Could it be Java that use a final static int with value 283 for something else?
P.S : could it be that switch has maximum number of statement where this number is less than 283?
switch(ServiceID){
case A:
// TODO
break;
................
case LOGOUT: // here it told me that this state was unreachable, no break or return problem, but when i changed the number from 283 to another number it was ok
//NOT IMPORTANT CODE
} | <java><int><switch-statement> | 2019-05-02 22:02:01 | LQ_EDIT |
55,961,284 | Set state and then reading the state shows the previous value | <p>I have the following code that maintains the value when the textbox value is changed. However, whilst debugging the valueHasChangedEvent the variable x line shown below holds the previous value strangely. Is there something I'm doing wrong? The example shown is when I enter 'test123' into the textbox. </p>
<p>Thanks</p>
<p><strong>onChange event</strong></p>
<pre><code><Input onChange={this.valueHasChangedEvent}
type="text"
name="test"
id="test" />
</code></pre>
<p><strong>Method</strong></p>
<pre><code>valueHasChangedEvent = (event) => {
var self = this;
const { name, value } = event.target;
self.setState({test: value}); // value = 'test123'
var x = self.state.test; // x = 'test12'
}
</code></pre>
| <javascript><reactjs> | 2019-05-02 23:01:37 | LQ_CLOSE |
55,962,324 | How to transfer working html, css, javascript code from codepen to Visual Studio Code and browser | My code works on codepen but not outside of there using Visual Studio Code to create my files (which are: Quote.html, Quote.css, Quote.js all in the same folder). When I open my html file in a browser I get a green screen, so the css file links correctly but the js file does not.
According to what I have read on stackoverflow I am putting in the js file in the script correctly as I understand it, but something I am doing is wrong. I
//html file code:
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" integrity="sha384-XdYbMnZ/QjLh6iI4ogqCTaIjrFk87ip+ekIjefZch0Y+PvJ8CDYtEs1ipDmPorQ+" crossorigin="anonymous">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="Quote.css">
</head>
<body>
<div id="app"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.8.6/umd/react.production.min.js" crossorigin></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.8.6/umd/react-dom.production.min.js" crossorigin></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css"></script>
<script src="Quote.js" type="text/javascript"></script>
</body>
</html>
//css file code:
body {background-color: green; color: white;}
#quote-box {
margin-top: 80px;
}
// js file code:
const quotes = [
{
quote: "Don't cry because it's over, smile because it happened.",
author: "Dr. Seuss"
},
{
quote: "You only live once, but if you do it right, once is enough.",
author: "Mae West"
},
{
quote: "Be yourself; everyone else is already taken.",
author: "Oscar Wilde"
},
{
quote:
"Two things are infinite: the universe and human stupidity; and I'm not sure about the universe.",
author: "Albert Einstein"
},
{ quote: "So many books, so little time.", author: "Frank Zappa" },
{
quote: "A room without books is like a body without a soul.",
author: "Marcus Tullius Cicero"
},
{
quote:
"If you want to know what a man's like, take a good look at how he treats his inferiors, not his equals.",
author: "J.K. Rowling"
}
];
class Presentational extends React.Component {
constructor(props) {
super(props);
this.state = {
quote: "If you want to know what a man's like, take a good look at how he treats his inferiors, not his equals.", author: "J.K. Rowling"
}
this.newQuote = this.newQuote.bind(this);
this.sendTweet = this.sendTweet.bind(this);
}
newQuote() {
const randNumber = Math.floor(Math.random() * quotes.length);
this.setState({quote: quotes[randNumber].quote, author: quotes[randNumber].author})
}
sendTweet = () => {
const url = "twitter.com";
const text = this.state.quote.concat(" - ").concat(this.state.author);
window.open('http://twitter.com/share?url='+encodeURIComponent(url)+'&text='+encodeURIComponent(text), '', 'left=0,top=0,width=550,height=450,personalbar=0,toolbar=0,scrollbars=0,resizable=0');
}
render() {
return (
<div id="quote-box" class="container">
<div class="row">
<h1 class="col-md-3"></h1>
<h1 class="text-center col-md-6">Random Quotes:</h1>
<h1 class="col-md-3"></h1>
</div>
<div class="row">
<p class="col-md-3"></p>
<blockquote class="col-md-6">
<p id="text"><i class="fa fa-quote-left"></i> {this.state.quote} <i class="fa fa-quote-right"></i></p>
<cite id="author">-- {this.state.author}</cite>
</blockquote>
<p class="col-md-3"></p>
</div>
<div class="row">
<p class="col-md-3"></p>
<button id="new-quote" class="btn btn-default col-md-1" onClick={this.newQuote}>New Quote</button>
<p class="col-md-3"></p>
<a id="tweet-quote" onClick={this.sendTweet} class="text-right"><button class="btn btn-default col-md-2">Tweet Quote <i class="fa fa-twitter"></i></button></a>
<p class="col-md-3"></p>
</div>
</div>
);
}
};
ReactDOM.render(<Presentational />, document.getElementById("app"));
This is the codepen link to what should be displayed: https://codepen.io/EOJA/pen/MRNoBq | <javascript><html><css><reactjs><twitter-bootstrap> | 2019-05-03 01:53:16 | LQ_EDIT |
55,964,485 | how do i handle nested json objects in android | I have a nested jsonobjects with jsonarray which I have to post it a volley request. how should i do it. sample json below.
{
"type":"invoice",
"customer":{
"name": "Deepak",
"email":"test@test.com",
"contact":"912345678",
"billing_address":{
"line1":"Bangalore",
"city":"Bangalore",
"state":"Karnataka",
"zipcode":"000000",
"country":"India"
}
},
"line_items":[
{
"name":"News Paper",
"description":"Times of India",
"amount":10000,
"currency":"INR",
"quantity":1
},
{
"name":"News Paper",
"description":"Bangalore Mirror",
"amount":10000,
"currency":"INR",
"quantity":1
}
],
"currency":"INR",
"sms_notify": "1",
"email_notify": "1"
}
The above is the jsonobject structure i want to send to volley request.
This is what i have done but not getting the right jsonobject.
try {
objMainList = new JSONObject();
objMainList.put("type","invoice");
headobj = new JSONObject();
detobj = new JSONObject();
addrobj = new JSONObject();
footobj = new JSONObject();
headobj.put("name", custname);
headobj.put("email", custemail);
headobj.put("contact", "1234567");
addrobj.put("line1",custaddr);
addrobj.put("city",custcity);
addrobj.put("state",custstate);
addrobj.put("zipcode",pincode);
addrobj.put("country",country);
objMainList.put("customer",headobj);
objMainList.put("billing_address",headobj);
JSONArray prodarray = new JSONArray();
for (int i = 0; i < pvt_list_prodlist.size(); i++) {
JSONObject detobj = new JSONObject();
detobj.put("name", pvt_list_prodlist.get(i).getProductcatg());
detobj.put("description", pvt_list_prodlist.get(i).getProductname());
Float total = Float.parseFloat(pvt_list_prodlist.get(i).getProductprice());
Integer gtotal = (int)Math.ceil(total);
gtotal = gtotal * 100;
detobj.put("amount",gtotal );
detobj.put("currency", "INR");
detobj.put("quantity", 1);
prodarray.put(detobj);
}
objMainList.put("line_items",prodarray);
objMainList.put("currency","INR");
objMainList.put("sms_notify",1);
objMainList.put("email_notify",1);
} catch (JSONException e) {
// JSON error
e.printStackTrace();
Toast.makeText(getApplicationContext(), "Json error: " + e.getMessage(), Toast.LENGTH_LONG).show();
}
This is what I am getting from the above code...
{"type":"invoice","customer":{"name":"Deepak","email":"test_test.com","contact":"1234567"},"billing_address":{"line1":"Bangalore","city":"Bangalore","state":"Karnataka","zipcode":"000001","country":"India"},"line_items":[{"name":"NEWS","description":"Times of India","amount":500,"currency":"INR","quantity":1}],"currency":"INR","sms_notify":1,"email_notify":1}
before billing_address it is getting closed. I want it in the above mentioned format.
{
"type":"invoice",
"customer":{
"name": "Deepak",
"email":"test@test.com",
"contact":"912345678",
"billing_address":{
"line1":"Bangalore",
"city":"Bangalore",
"state":"Karnataka",
"zipcode":"000000",
"country":"India"
}
},
"line_items":[
{
"name":"News Paper",
"description":"Times of India",
"amount":10000,
"currency":"INR",
"quantity":1
},
{
"name":"News Paper",
"description":"Bangalore Mirror",
"amount":10000,
"currency":"INR",
"quantity":1
}
],
"currency":"INR",
"sms_notify": "1",
"email_notify": "1"
}
The above is the jsonobject structure i want to send to volley request.
This is what i have done but not getting the right jsonobject.
try {
objMainList = new JSONObject();
objMainList.put("type","invoice");
headobj = new JSONObject();
detobj = new JSONObject();
addrobj = new JSONObject();
footobj = new JSONObject();
headobj.put("name", custname);
headobj.put("email", custemail);
headobj.put("contact", "1234567");
addrobj.put("line1",custaddr);
addrobj.put("city",custcity);
addrobj.put("state",custstate);
addrobj.put("zipcode",pincode);
addrobj.put("country",country);
objMainList.put("customer",headobj);
objMainList.put("billing_address",headobj);
JSONArray prodarray = new JSONArray();
for (int i = 0; i < pvt_list_prodlist.size(); i++) {
JSONObject detobj = new JSONObject();
detobj.put("name", pvt_list_prodlist.get(i).getProductcatg());
detobj.put("description", pvt_list_prodlist.get(i).getProductname());
Float total = Float.parseFloat(pvt_list_prodlist.get(i).getProductprice());
Integer gtotal = (int)Math.ceil(total);
gtotal = gtotal * 100;
detobj.put("amount",gtotal );
detobj.put("currency", "INR");
detobj.put("quantity", 1);
prodarray.put(detobj);
}
objMainList.put("line_items",prodarray);
objMainList.put("currency","INR");
objMainList.put("sms_notify",1);
objMainList.put("email_notify",1);
} catch (JSONException e) {
// JSON error
e.printStackTrace();
Toast.makeText(getApplicationContext(), "Json error: " + e.getMessage(), Toast.LENGTH_LONG).show();
}
This is what I am getting from the above code...
{"type":"invoice","customer":{"name":"Deepak","email":"test_test.com","contact":"1234567"},"billing_address":{"line1":"Bangalore","city":"Bangalore","state":"Karnataka","zipcode":"000001","country":"India"},"line_items":[{"name":"NEWS","description":"Times of India","amount":500,"currency":"INR","quantity":1}],"currency":"INR","sms_notify":1,"email_notify":1}
before billing_address it is getting closed. I want it in the above mentioned format.
this is the output i should get as jsonobject .
{
"type":"invoice",
"customer":{
"name": "Deepak",
"email":"test@test.com",
"contact":"912345678",
"billing_address":{
"line1":"Bangalore",
"city":"Bangalore",
"state":"Karnataka",
"zipcode":"000000",
"country":"India"
}
},
"line_items":[
{
"name":"News Paper",
"description":"Times of India",
"amount":10000,
"currency":"INR",
"quantity":1
},
{
"name":"News Paper",
"description":"Bangalore Mirror",
"amount":10000,
"currency":"INR",
"quantity":1
}
],
"currency":"INR",
"sms_notify": "1",
"email_notify": "1"
} | <android><json><android-volley> | 2019-05-03 06:39:03 | LQ_EDIT |
55,966,332 | Android sqlite get largest value of a row among multiple entries | My question is similar to the following post:
https://stackoverflow.com/questions/35565309/find-largest-value-among-repeated-entries-in-an-sql-table
but it is for mysql and and I cannot understand how it translates in sqlite.
I want to get the max value of `pages` from my table `metadata` with multiple `file_ids` and multiple entries
My table with the two columns I am interested in.
`file_id pages
1 2
1 5
2 10
3 20
4 12
4 1
5 4
6 5
6 14
7 12`
What I am looking for is
`file_id pages
1 5
2 10
3 20
4 12
5 4
6 14
7 12`
I am trying to make a query but don't know how
String[]cols = {"file_id","pages"};
String groupBy = {"pages"};
all others params are null
that's as far as I can think.
What will be the query like. Please help. | <java><android><sqlite> | 2019-05-03 08:51:10 | LQ_EDIT |
55,966,515 | department wise Sum of salary of employee with each employee details | <p>I Have following table which contains details of Employee</p>
<pre><code>EmpId EmpName Mgr Salary Dept
1 Deepak 2 20000 1
2 Annu NULL 22000 1
3 Jai 2 19500 1
4 Jitendra 1 18000 2
5 Vaishali 1 18000 2
6 Philip 4 15000 3
</code></pre>
<p>I wants to show salary of each dept with each employee details,if it repeats no issues as shown below</p>
<pre><code>EmpId EmpName Mgr Salary Dept DeptSal
1 Deepak 2 20000 1 61500
2 Annu NULL 22000 1 61500
3 Jai 2 19500 1 61500
4 Jitendra 1 18000 2 36000
5 Vaishali 1 18000 2 36000
6 Philip 4 15000 3 15000
</code></pre>
| <sql><sql-server> | 2019-05-03 09:02:20 | LQ_CLOSE |
55,966,664 | Symfony 4.2 and API Platform: how to use custom operations before return a response | <p>I'm trying to create a custom operation when calling /api/employees.</p>
<p>I have done a method in EmployeesController.php called jiraSync, this method must be called before returning the response in JSON to obtain a synchronized response.</p>
<p>I have also thought about creating a service, but I do not know if it will be a good idea, what do you recommend?</p>
<p>This is my Employees <strong>entity</strong>:</p>
<pre><code><?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Controller\EmployeeController;
use Doctrine\ORM\Mapping as ORM;
/**
* Employees
*
* @ApiResource()
* @ORM\Table(name="employees", uniqueConstraints={@ORM\UniqueConstraint(name="email_UNIQUE", columns={"email"})}, indexes={@ORM\Index(name="fk_employees_departments_idx", columns={"department_id"})})
* @ORM\Entity
*/
class Employees
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="email", type="string", length=255, nullable=false)
*/
private $email;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=50, nullable=false)
*/
private $name;
/**
* @var string|null
*
* @ORM\Column(name="surname", type="string", length=100, nullable=true)
*/
private $surname;
/**
* @var string|null
*
* @ORM\Column(name="image", type="string", length=255, nullable=true)
*/
private $image;
/**
* @var \Departments
*
* @ORM\ManyToOne(targetEntity="Departments")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="department_id", referencedColumnName="id")
* })
*/
private $department;
/**
* @var bool
*
* @ORM\Column(name="is_enabled", type="boolean", nullable=false)
*/
private $isEnabled = '0';
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getSurname(): ?string
{
return $this->surname;
}
public function setSurname(?string $surname): self
{
$this->surname = $surname;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function getDepartment(): ?Departments
{
return $this->department;
}
public function setDepartment(?Departments $department): self
{
$this->department = $department;
return $this;
}
public function getIsEnabled(): ?bool
{
return $this->isEnabled;
}
public function setIsEnabled($isEnabled): self
{
$this->isEnabled = $isEnabled;
return $this;
}
}
</code></pre>
<p>And this is my <strong>controller</strong>:</p>
<pre><code><?php
namespace App\Controller;
use App\Entity\Employees;
use JiraRestApi\JiraException;
use JiraRestApi\User\UserService;
use Symfony\Bridge\Doctrine\Tests\Fixtures\Employee;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
class EmployeeController extends AbstractController
{
public function jiraSync()
{
// ...
}
}
</code></pre>
| <php><symfony><doctrine><api-platform.com> | 2019-05-03 09:10:28 | LQ_CLOSE |
55,966,749 | Indent text does not work with line brakes | <p>I have here a simple problem but I searched a lot and still didn't find a quick fix to it, I do not want to add a lot of styling because I was looking on a website and I saw that he put line brakes. I will show you 2 images to understand more clearly what I want to say.<a href="https://i.stack.imgur.com/eFdJ7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eFdJ7.jpg" alt="["></a>]<a href="https://i.stack.imgur.com/GoUDX.jpg" rel="nofollow noreferrer">2</a>]<a href="https://i.stack.imgur.com/GoUDX.jpg" rel="nofollow noreferrer">2</a></p>
| <html><css><drop-down-menu><text-indent> | 2019-05-03 09:17:16 | LQ_CLOSE |
55,966,890 | Why I can't found the loader element from parent element? | here is the full code: https://codepen.io/dotku/pen/gyVZqj?editors=1011
```html
<div id="carousel">
<span class="loader">Loading...</span>
</div>
```
```js
if (!containerElement) {
console.log('Carousel element is required.')
return;
} else {
console.log(
'Carousel element is found',
document.querySelector(`#${containerID}`)
);
}
```
I have a checking statement, but the document.querySelector won't return the loader, why?
| <javascript><html> | 2019-05-03 09:25:50 | LQ_EDIT |
55,967,160 | Deleting last element in a std::vector of std::shared_ptr while iterating over it causes segmentation fault | <p>please try to compile and run the following code.
When iterating over a vector of shared pointers, I have to delete last element, this will result in a segmentation fault, but I can't understand why the <code>for</code> iteration doesn't break when <code>el_it</code> reaches <code>v.end()</code>, and I have to do it manually (commented code).</p>
<pre><code>#include <vector>
using std::vector;
#include <memory>
using std::shared_ptr;
#include <algorithm>
using std::remove;
class A {
public:
A(int age) { age_ = age; }
int age_ = 0;
int alive_ = 1;
};
int main() {
shared_ptr<A> a0(new A(0));
shared_ptr<A> a1(new A(1));
shared_ptr<A> a2(new A(2));
vector< shared_ptr <A> > v;
v.push_back(a0);
v.insert(v.end(), a1);
v.insert(v.end(), a2);
for (auto el_it = v.begin(); el_it != v.end(); ++ el_it) {
auto el = *el_it;
if (el->age_ == 2) {
v.erase(el_it);
}
/*
if (el_it == v.end()) // Why is this required ??
break;
*/
}
return 0;
}
</code></pre>
| <c++><vector><shared-ptr> | 2019-05-03 09:41:51 | LQ_CLOSE |
55,967,970 | How to know if Firebase Auth is currently trying to retrieve user? | ##Background
I am using `GoogleAuthProvider`, with the default `LOCAL` persistence.
When I navigate to the page, I do:
```js
firebase.initializeApp(firebaseConfig)
firebase.auth().currentUser // this is always null
firebase.auth().onAuthStateChanged(user => {
console.log("authStateChanged", user)
})
```
If the user is logged in, the callback is called once, with the user.
If the user is *not* logged in, the callback is also called once, *with* the user.
This suggests I *could* wait until the first callback after navigating to the page to get the real login state before deciding what view to display, for instance. (I originally thought that it would not get called with `null`, and so I could wait indefinitely)
## Question
Is this idiomatic usage? Does it seem like it will be robust against updates to firebase? Where can I find this discussed in the official documentation? | <firebase><firebase-authentication> | 2019-05-03 10:29:06 | LQ_EDIT |
55,970,137 | Bypass Android's hidden API restrictions | <p>Starting with Android Pie, <a href="https://developer.android.com/distribute/best-practices/develop/restrictions-non-sdk-interfaces" rel="noreferrer">access to certain hidden classes, methods and fields was restricted</a>. Before Pie, it was pretty easy to use these hidden non-SDK components by simply using reflection. </p>
<p>Now, however, apps targeting API 28 (Pie) or later will be met with ClassNotFoundException, NoSuchMethodError or NoSuchFieldException when trying to access components such as <code>Activity#createDialog()</code>. For most people this is fine, but as someone who likes to hack around the API, it can make things difficult.</p>
<p>How can I work around these restrictions?</p>
| <android> | 2019-05-03 12:47:09 | HQ |
55,970,686 | Tensorboard not found as magic function in jupyter | <p>I want to run tensorboard in jupyter using the latest tensorflow 2.0.0a0.
With the tensorboard version 1.13.1, and python 3.6. </p>
<p>using </p>
<p><code>...
%tensorboard --logdir {logs_base_dir}</code></p>
<p>I get the error :</p>
<p><code>UsageError: Line magic function %tensorboard not found</code></p>
<p>Do you have an idea what the problem could be? It seems that all versions are up to date and the command seems correct too. </p>
<p>Thanks</p>
| <python><tensorflow><tensorboard> | 2019-05-03 13:20:14 | HQ |
55,972,329 | How to split string by repeated characters? | <p>I'm doing a codewars kate where I need to implement code highlighting. I need to split the string of code into strings of repeated characters, add proper highlighting tags to them and finally connect it all and return. You can train this kata on your own (<a href="https://www.codewars.com/kata/roboscript-number-1-implement-syntax-highlighting" rel="nofollow noreferrer">https://www.codewars.com/kata/roboscript-number-1-implement-syntax-highlighting</a>). The first step I thought of is to split the code by repeated characters. But i found it hard to come up with working algorithm. So, I need your help.</p>
<p>Input: <code>"FFFR345F2LL"</code></p>
<p>Output: <code>"FFF", "R", "345", "F", "2", "LL"</code></p>
| <c#><string> | 2019-05-03 14:53:57 | LQ_CLOSE |
55,974,331 | Unity Export Android 64-bit | <p>I've been trying to upload .abb to the google play console. When I upload it, it gives me this error:</p>
<p>This release is not compliant with the Google Play 64-bit requirement</p>
<p>The following APKs or App Bundles are available to 64-bit devices, but they only have 32-bit native code: 2.</p>
<p>From 1. August 2019 all releases must be compliant with the Google Play 64-bit requirement.</p>
<p>Include 64-bit and 32-bit native code in your app. Use the Android App Bundle publishing format to automatically ensure that each device architecture receives only the native code it needs. This avoids increasing the overall size of your app.</p>
<p>I tried to export an 64-bit version but I couldnt do it.</p>
| <android><unity3d><google-play-console> | 2019-05-03 17:06:46 | HQ |
55,975,728 | Lists in Python - Each array in different row | <p>how can I create a new list with the following format.</p>
<p>The 3 arrays inside each row should be in different rows.</p>
<pre><code>a= [['111,0.0,1', '111,1.27,2', '111,3.47,3'],
['222,0.0,1', '222,1.27,2', '222,3.47,3'],
['33,0.0,1', '33,1.27,2', '33,3.47,3'],
['44,0.0,1', '44,1.27,2', '4,3.47,3'],
['55,0.0,1', '55,1.27,2', '55,3.47,3']]
</code></pre>
<p>Final desired ouput:</p>
<pre><code> b=[['111,0.0,1',
'111,1.27,2',
'111,3.47,3',
'222,0.0,1',
'222,1.27,2',
'222,3.47,3',
'33,0.0,1',
'33,1.27,2',
'33,3.47,3',
'44,0.0,1',
'44,1.27,2',
'44,3.47,3',
'55,0.0,1',
'55,1.27,2',
'55,3.47,3']]
</code></pre>
| <python><list> | 2019-05-03 19:00:15 | LQ_CLOSE |
55,975,872 | How can i make my own command to my first console application in VB.NET? | <p>I'm doing my first VB.NET console application. I have some experience making VB.NET "non-console" applications.</p>
<p>My guestion is, how can i make my own commands to my console application. For example if user types to console "Hello World" and then the application would answer back to the user. I dont want it to be like "Press any key to continue..." nothing like that. I just want to make my own commands. </p>
<p>I've already tried to find some help from YouTube or Google but i couldn't find anything that would help even little. So i'm asking from you guys.</p>
<p>I also would like an answer soon as possible.</p>
| <vb.net><console><console-application> | 2019-05-03 19:13:02 | LQ_CLOSE |
55,975,907 | Share a URL that is sharable on Facebook on LinkedIN | I've worked on sharing dynamic content to be sharable on Facebok populating OpenGraph tags, I know LinkedIn uses OpenGraph tags.
To my surprise when I've tried sharing the same url on LinkedIn nothing shows up.
did anyone have such expericne?
I;ve used https://www.linkedin.com/post-inspector/
But no luck, I get '503 Failure' exception.
Is this the new way to share something on LinkedIn? (Below url)
https://docs.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/share-on-linkedin
I've tried inspecting the url with https://www.linkedin.com/post-inspector/
also
https://developers.facebook.com/tools/debug/
Here in facebook I got response for all the og:tags | <facebook><linkedin><sharing> | 2019-05-03 19:16:06 | LQ_EDIT |
55,977,991 | How to do flow type annotations for React hooks (useState, etc.)? | <p>How should we be using Flow type annotations with react hooks, such as <code>useState</code>? I've tried searching for some examples of how they should be implemented, but can't find anything. </p>
<p>I tried this:</p>
<pre class="lang-js prettyprint-override"><code>const [allResultsVisible, setAllResultsVisible]: [ boolean, (boolean) => void, ] = useState(false);
</code></pre>
<p>Which doesn't throw any flow related errors, but I'm not sure if this is correct or the best way to annotate the hook. If my attempt isn't correct or the best way, what should I do instead?</p>
| <reactjs><flowtype> | 2019-05-03 22:57:01 | HQ |
55,978,926 | Convert Number in Java | <p>I need help
How to round number in java
I have value 0.655308 then I wan to show to 65.53%
I have value 1.0583104 then I wan to show 105.83
in power builder compute expression I use </p>
<pre><code> act_qty *work_hour /
if (on_hour < work_hour ) /
sec_setm_gole_qty ,4)
</code></pre>
<p>and How to run in java
Thanks for advanced</p>
| <java><powerbuilder> | 2019-05-04 02:16:23 | LQ_CLOSE |
55,979,377 | How to convert String to Float Array? | I have a String like this String volt;
and it has values like [1.2, 3.1, 5.3...]
How can I convert the String to a float array ? | <java><arrays><string><type-conversion> | 2019-05-04 04:13:56 | LQ_EDIT |
55,979,815 | Why it's illegal to have static block inside interface JAVA? | <p>It is legal to have static block inside a class but illegal to have inside an interface.
Please explain the reason.</p>
| <java><class><interface><static> | 2019-05-04 05:39:37 | LQ_CLOSE |
55,979,962 | How show specific data on click of ListView from sqlite database? | Hello friend i am new in android i have one table in sqlite database which have two field one is b and another is "n" "b" represent book number and "n" represent book names i am successfully fetch all "n" field in my list view now i want when any user click particular listitem show book b number which in my databas for example i have book n=Genesis when any any one click on genesis it show book number like b=1;
here my code an database structure
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
}
});
return view;
}
private void setData() {
stringArrayList = new ArrayList<>();
mDBHelper = new DatabaseHelper(getContext());
mDb = mDBHelper.getReadableDatabase();
Cursor cursor = mDb.rawQuery("SELECT b, n FROM key_english;", new String[]{});
if (cursor.getCount() == 0) {
Toast.makeText(getContext(), "NO DATA FOUND", Toast.LENGTH_SHORT).show();
} else {
while (cursor.moveToNext()) {
stringArrayList.add(cursor.getString(1));
}
}
[Here my database my database structre][1]
[1]: https://i.stack.imgur.com/7aXut.png | <java><android><android-sqlite> | 2019-05-04 06:05:04 | LQ_EDIT |
55,981,316 | Showing step by step solving of sudoku | <p>Is there any way to show the steps of solving a sudoku? My code just solve it within 0.5 second and I wish to modify it to show the changes on the sudoku grid step by step on processing. (I am using python)</p>
| <python><processing><sudoku> | 2019-05-04 09:49:00 | LQ_CLOSE |
55,981,488 | installed laravel but unable to view the project | <p>I have just installed and downloaded laravel and installed via composer the laravel folder is located in my htdocs/laravel now when I type in localhost/laravell it is showing me list of files how can i access the project I am new to laravel lsearched alot but non of them help me out can anyone help me out with my query please</p>
| <php><laravel> | 2019-05-04 10:11:04 | LQ_CLOSE |
55,981,622 | re-numbering list members in python | <p>How can re-numbering list members respectively from zero to n in Python ?</p>
<p>for example :</p>
<pre><code>In : [4, 10, 12, 40, 4, 12, 20, 21]
Out : [0, 1, 2, 3, 0, 2, 4, 5]
</code></pre>
| <python><python-3.x><list><numpy> | 2019-05-04 10:29:23 | LQ_CLOSE |
55,982,750 | How to disable textbox focusing C# | <p>i have a application where</p>
<p><strong>Scenario :</strong>
when i click on that textbox the cursor should not point the textbox it should be disabled</p>
<p>how do i achieve this disabling the textbox</p>
<pre><code>textbox1.focus()=false;
textbox1.focused()=false;
</code></pre>
| <c#> | 2019-05-04 12:56:48 | LQ_CLOSE |
55,983,002 | in for loop no adding elements in list please see my sorce and help me please with this problem | no adding elements in list
and please help me whit this I am beginner
list1 =[]
print("How much numbers")
x =int(input())
print("input numbers:")
for n in range(x):
int(input())
y =list1.append(n)
print(list1)
"""
output:
[0,1,2,3]
"""
lkfl;dklf; k;kjk;lfj;kj;edjf;ejf;ejf;ejirfj | <python><list><for-loop> | 2019-05-04 13:27:59 | LQ_EDIT |
55,983,985 | Implement an interface | I'm studying implement an interface and abstract class and here it comes to this question that I'm struggling with. I hope you guys can help me out with this question and I'm looking for an explanation in order to understand the code. Any advice is welcome and truly appreciate.
I have been trying to run the code to get the output but it does not work.I think C is an answer but I'm not sure.
Here is the question: Which of the following will order an array of Student objects by last name, then by credits (if two students have the same last name) if you were to pass the array of Students to the Arrays.sort() method?
```java
Student[] list;
// The array is created and filled with Student objects...
Arrays.sort(list);
A. public class Student implements Comparable {
private String lastName;
private int credits;
public int compareTo(Student s) {
int result = lastName.compareTo( s.getLastName() );
if (result != 0)
return result;
else
return credits - s.getCredits();
}
}
B. public class Student implements Comparable {
private String lastName;
private int credits;
public int compareTo(Object o) {
int result = credits - ( ((Student) o).getCredits() );
if (result != 0)
return result;
else
return lastName.compareTo( ((Student) o).getLastName() );
}
}
C. public class Student {
private String lastName;
private int credits;
public int compareTo(Object o) {
result = lastName.compareTo( ((Student) o).getLastName() );
if (result != 0)
return result;
else
return credits - ( ((Student) o).getCredits() );
}
}
D. public class Student implements Comparable {
private String lastName;
private int credits;
public int compareTo(Object o) {
int result = lastName.compareTo( ((Student) o).getLastName() );
if (result != 0)
return result;
else
return credits - ( ((Student) o).getCredits() );
}
}
``` | <java> | 2019-05-04 15:22:07 | LQ_EDIT |
55,984,279 | Why is my result varying if I am performing division with a Global constant vs local variable? | I have been working on a C code. I have declared few constants using #define. However I have observed that while I am performing division of a local variable with a constant(defined using #define) I am numerically getting a wrong answer.
I have tried changing the constant defined(using #define) to a local variable and then performing division. Now I am getting correct answer.
The problem is I have many constants, whose values are to be used throughout various functions. I want to know how I van solve this problem.
These are the results I am getting when used #define
"0.106883 is q2, 28.348689 is D2 ,1.508116 is q2/D2"
These are the results I am getting when used as a local variable.
"0.106883 is q2, 28.348689 is D2 ,0.003770 is q2/D2"
Any help is appreciated.I am using GCC 8.3.0_2. | <c><gcc> | 2019-05-04 15:55:39 | LQ_EDIT |
55,984,621 | SDL2 libSDL2_image.so: undefined reference to ... [gcc, c, SDL2] | I'm using Kubuntu 18.04
So i recently tried to use SDL2, i wanted to create a simple window showing a few pictures following a tutorial but i was unable to compile the example code.
When i try to compile the code i get:
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libSDL2_image.so: undefined reference to `SDL_ceilf'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libSDL2_image.so: undefined reference to `SDL_acosf'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libSDL2_image.so: undefined reference to `SDL_floorf'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libSDL2_image.so: undefined reference to `SDL_fabsf'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libSDL2_image.so: undefined reference to `SDL_LoadFile_RW'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libSDL2_image.so: undefined reference to `SDL_fmodf'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libSDL2_image.so: undefined reference to `SDL_atan2f'
collect2: error: ld returned 1 exit status
Command used:
gcc SDLProject.c -o SDLProject `sdl2-config --cflags --libs` -lSDL2_gfx -lSDL2_image
Command used to install SDL2 libs:
sudo apt install libsdl2-dev libsdl2-gfx-dev libsdl2-image-dev libsdl2-ttf-dev libsdl2-mixer-dev
Installed packages:
sudo apt list --installed | grep "sdl"
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
libsdl2-2.0-0/bionic-updates,now 2.0.8+dfsg1-1ubuntu1.18.04.3 amd64 [installed]
libsdl2-dev/bionic-updates,now 2.0.8+dfsg1-1ubuntu1.18.04.3 amd64 [installed]
libsdl2-gfx-1.0-0/bionic,now 1.0.4+dfsg-1 amd64 [installed,automatic]
libsdl2-gfx-dev/bionic,now 1.0.4+dfsg-1 amd64 [installed]
libsdl2-image-2.0-0/bionic,now 2.0.3+dfsg1-1 amd64 [installed,automatic]
libsdl2-image-dev/bionic,now 2.0.3+dfsg1-1 amd64 [installed]
libsdl2-mixer-2.0-0/bionic,now 2.0.2+dfsg1-2 amd64 [installed,automatic]
libsdl2-mixer-dev/bionic,now 2.0.2+dfsg1-2 amd64 [installed]
libsdl2-ttf-2.0-0/bionic,now 2.0.14+dfsg1-2 amd64 [installed,automatic]
libsdl2-ttf-dev/bionic,now 2.0.14+dfsg1-2 amd64 [installed]
I already tried deleting everything that is related to SDL / SDL2 and only reinstalling the ones the project uses (SDL2, gfx and image) and **i found out that this error only happens when i try to inlude the SDL_image.h and I'm able to run other exmaple codes that does not use it.**
I do not think that the error is related to the code itself but:
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL2_gfxPrimitives.h>
#include <stdlib.h>
typedef enum Babu {
VKiraly, VVezer, VBastya, VFuto, VHuszar, VGyalog,
SKiraly, SVezer, SSastya, SFuto, SHuszar, SGyalog
} Babu;
enum { MERET = 52 };
void babu_rajzol(SDL_Renderer *renderer, SDL_Texture *babuk, Babu melyik, int x, int y) {
SDL_Rect src = { (melyik % 6) * 62 + 10, (melyik / 6) * 60 + 10, MERET, MERET };
SDL_Rect dest = { x, y, MERET, MERET };
SDL_RenderCopy(renderer, babuk, &src, &dest);
}
void sdl_init(int szeles, int magas, SDL_Window **pwindow, SDL_Renderer **prenderer) {
if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
SDL_Log("Nem indithato az SDL: %s", SDL_GetError());
exit(1);
}
SDL_Window *window = SDL_CreateWindow("SDL peldaprogram", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, szeles, magas, 0);
if (window == NULL) {
SDL_Log("Nem hozhato letre az ablak: %s", SDL_GetError());
exit(1);
}
SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
if (renderer == NULL) {
SDL_Log("Nem hozhato letre a megjelenito: %s", SDL_GetError());
exit(1);
}
SDL_RenderClear(renderer);
*pwindow = window;
*prenderer = renderer;
}
int main(int argc, char *argv[]) {
SDL_Window *window;
SDL_Renderer *renderer;
sdl_init(320, 200, &window, &renderer);
SDL_Texture *babuk = IMG_LoadTexture(renderer, "pieces.png");
if (babuk == NULL) {
SDL_Log("Nem nyithato meg a kepfajl: %s", IMG_GetError());
exit(1);
}
boxRGBA(renderer, 0, 0, 319, 199, 0x90, 0xE0, 0x90, 0xFF);
babu_rajzol(renderer, babuk, VKiraly, 82, 74);
babu_rajzol(renderer, babuk, SGyalog, 82+MERET, 74);
babu_rajzol(renderer, babuk, VHuszar, 82+2*MERET, 74);
SDL_RenderPresent(renderer);
SDL_DestroyTexture(babuk);
SDL_Event event;
while (SDL_WaitEvent(&event) && event.type != SDL_QUIT) {
}
SDL_Quit();
return 0;
}
| <c><linux><gcc><sdl><ubuntu-18.04> | 2019-05-04 16:20:44 | LQ_EDIT |
55,987,140 | SQL Query result to Java Array | <p>I want to read the query result in to array and want to check the array in if condition.
Query in returns </p>
<pre><code>SELECT COLUMN
FROM Table;
OUT PUT:
A
B
C
D
F
</code></pre>
<p>Want to store the above result in array in java and use in the if condition.</p>
| <java> | 2019-05-04 21:57:51 | LQ_CLOSE |
55,988,045 | What is the difference between UseStaticFiles, UseSpaStaticFiles, and UseSpa in ASP.NET Core 2.1? | <p>ASP.NET Core 2.1.1 offers several seemingly related extension methods for appBuilder:</p>
<ul>
<li><code>UseStaticFiles</code> from <code>Microsoft.AspNetCore.StaticFiles</code></li>
<li><code>UseSpaStaticFiles</code> from <code>Microsoft.AspNetCore.SpaServices.Extensions</code></li>
<li><code>UseSpa</code> from <code>Microsoft.AspNetCore.SpaServices.Extensions</code></li>
</ul>
<p><strong>Please help me make sense of their purpose and relation to each other?</strong></p>
<p>Also, is there any difference from the server execution standpoint if I run these methods in a different order (e.g. <code>app.UseStaticFiles() -> app.UseSpaStaticFiles() -> app.UseSpa()</code> vs <code>app.UseSpa() -> app.UseSpaStaticFiles() -> app.UseStaticFiles()</code>)?</p>
| <c#><asp.net-core><asp.net-core-2.0><asp.net-core-2.1> | 2019-05-05 01:03:11 | HQ |
55,988,490 | How do I run a URL whithout opening the browser in Visual Studio? | <p>I am using the <code>System.Diagnostics.Process.Start()</code> to run a URL, but every time I execute the function, it opens a new browser tab. How can I just access the link without open the browser?</p>
| <c#><visual-studio> | 2019-05-05 03:04:01 | LQ_CLOSE |
55,989,804 | Convert list of list into single list | <p>Currently I have a list of lists</p>
<p><code>l=[['asd'],['fgd']].</code></p>
<p>I want to turn it into a list </p>
<p><code>goal_list=['asd','fgd']</code></p>
<p>but I do not know how to turn a list into the value inside it - does anyone have an idea how to this efficiently?</p>
| <python><list> | 2019-05-05 07:36:21 | LQ_CLOSE |
55,991,641 | npm test -- --coverage never exits | <p>I am using <strong>create-react-app</strong> to create a react application. When I executes <strong>npm test -- --coverage</strong> the test never exists. npm test actually runs <strong>react-scripts test</strong>. Any Idea?</p>
<p><a href="https://i.stack.imgur.com/ooy7Y.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ooy7Y.png" alt="enter image description here"></a></p>
| <node.js><reactjs><unit-testing><continuous-integration><frontend> | 2019-05-05 11:54:45 | HQ |
55,991,901 | How to change cursor color in flutter | <p>Dears,
I have 2 qestions in flutter If you don't mind. </p>
<p><strong>1- How to change the color of the cursor as it default blue and I don't like it</strong></p>
<p><strong>2- how can I make the text at the bottom of the screen whatever the screen size. ??</strong></p>
<p>Thank you in advance. </p>
<p><a href="https://i.stack.imgur.com/1wj8G.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/1wj8G.jpg" alt="enter image description here"></a></p>
| <flutter><flutter-layout> | 2019-05-05 12:25:19 | HQ |
55,992,343 | How to perform multiplication for integers larger than 64 bits in C? | I want to multiply 57bit integer with 11bit integer. The result can be up to 68bits so I'm planning to split my result in to 2 different integers. I cannot use any library and It should be as simple as possible because the code will be translated to VHDL.
There is some ways to that online but all of them are not meet my criteria. I want to split the result as 60bits lower part and 8 bits higher part.
C-Code
---
int main(){
unsigned long long int log2 = 0b101100010111001000010111111101111101000111001111011110011;
unsigned short int absE;
unsigned in result_M;
unsigned long long int result_L;
result_L = absE * log2;
result_M = 0;
}
VHDL
---
signal absE : std_logic_vector(10 downto 0);
signal log2 : std_logic_vector(57 downto 0) := "101100010111001000010111111101111101000111001111011110011";
signal result: std_logic_vector(67 downto 0);
result <= absE * log2;
| <c++><vhdl> | 2019-05-05 13:17:02 | LQ_EDIT |
55,993,104 | If Loop Not working Correctly Won't Pass If Statement | I'm making a magic 8 ball within the cmd. I want to ask the user if they would like to do. I want the program to keep asking questions until the user selects the letter E. If they try to shake before they ask a question then they will get an error.
The issue that I'm having is that when you enter A, you will enter a question. Then when I enter S right after, I get the error message searching RAM and it doesn't call my shake method.
public static string userAnswer = "";
static void Main(string[] args)
{
Console.WriteLine("Main program!");
Console.WriteLine("Welcome to the Magic 8 Ball");
Console.WriteLine("What would you like to do?");
Console.WriteLine("(S)hake the Ball");
Console.WriteLine("(A)sk a Question");
Console.WriteLine("(G)et the Answer");
Console.WriteLine("(E)xit the Game");
Magic8Ball_Logic.Magic8Ball ball = new Magic8Ball_Logic.Magic8Ball();
string input = Console.ReadLine().ToUpper();
do {
if (input == "S")
{
if (userAnswer != null)
{
Console.WriteLine("Searching the Mystic Realms(RAM) for the answer");
Console.WriteLine("(S)hake the Ball");
Console.WriteLine("(A)sk a Question");
Console.WriteLine("(G)et the Answer");
Console.WriteLine("(E)xit the Game");
input = Console.ReadLine();
}
else
{
//Call Method Shake()
ball.Shake();
Console.WriteLine("(S)hake the Ball");
Console.WriteLine("(A)sk a Question");
Console.WriteLine("(G)et the Answer");
Console.WriteLine("(E)xit the Game");
input = Console.ReadLine();
}
}
else if (input == "A")
{
userAnswer = Console.ReadLine();
Console.WriteLine("(S)hake the Ball");
Console.WriteLine("(A)sk a Question");
Console.WriteLine("(G)et the Answer");
Console.WriteLine("(E)xit the Game");
input = Console.ReadLine();
}
else if (input == "G")
{
if (userAnswer != null)
{
Console.WriteLine("Please Enter A Question Before Asking For An Answer.");
Console.WriteLine("(S)hake the Ball");
Console.WriteLine("(A)sk a Question");
Console.WriteLine("(G)et the Answer");
Console.WriteLine("(E)xit the Game");
input = Console.ReadLine();
}
else
{
//Call Method GetAnswer()
ball.GetAnswer();
Console.WriteLine("(S)hake the Ball");
Console.WriteLine("(A)sk a Question");
Console.WriteLine("(G)et the Answer");
Console.WriteLine("(E)xit the Game");
input = Console.ReadLine();
}
}
}while (input != "E");
}
}
}
| <c#><if-statement> | 2019-05-05 14:39:44 | LQ_EDIT |
55,993,422 | Expected ')' to match this '(' when adding & to function prototype | I'm writing a recursive bst insert function and I recognized that I was modifying a copy of the struct.
So I changed the prototype of the function from this: ```void BSTRecursiveInsert(BSTNode* tree, DataObject* elem)``` to this: ```void BSTRecursiveInsert(BSTNode*& tree, DataObject* elem)``` but I get the compiler error I wrote as question title. What am I missing? | <c><gcc><struct><binary-search-tree> | 2019-05-05 15:11:00 | LQ_EDIT |
55,993,718 | Python program to find all video titles of a playilist | <p>I want to quickly find titles of all videos of a playlist on youtube. Please tell me how to do it using python.</p>
| <python><youtube> | 2019-05-05 15:44:55 | LQ_CLOSE |
55,994,059 | why need to change url when we are working with ajax | <p>why it's need to change URL when we are working with AJAX ? as example when google translate start translate phrase or word change URL? whereas all information are sending and receiving using AJAX.</p>
| <ajax> | 2019-05-05 16:27:19 | LQ_CLOSE |
55,995,647 | SQL query group and filter by filed value | for example have this table:
```
ID ProdId Status
1 111 None
2 111 Success
3 222 Process
4 222 Fail
5 333 Process
6 333 Process
7 444 None
```
I need to group by field ```ProdId``` and exclude all rows that contain ```Status``` - "Success" or "Fail"
So, result of this sql query must be :
```
6 333 Process
7 444 None
```
Is it possible?
I use sqlalchemy and postgres. | <sql><postgresql> | 2019-05-05 19:32:48 | LQ_EDIT |
55,995,760 | How to add "refs" dynamically with react hooks? | <p>So I have an array of data in and I am generating a list of components with that data. I'd like to have a ref on each generated element to calculate the height.
I know how to do it with a Class component, but I would like to do it with React Hooks.</p>
<p>Here is an example explaining what I want to do:</p>
<pre><code>import React, {useState, useCallback} from 'react'
const data = [
{
text: 'test1'
},
{
text: 'test2'
}
]
const Component = () => {
const [height, setHeight] = useState(0);
const measuredRef = useCallback(node => {
if (node !== null) {
setHeight(node.getBoundingClientRect().height);
}
}, []);
return (
<div>
{
data.map((item, index) =>
<div ref={measuredRef} key={index}>
{item.text}
</div>
)
}
</div>
)
}
</code></pre>
| <javascript><reactjs><react-hooks> | 2019-05-05 19:45:21 | HQ |
55,996,872 | What is the difference between new pointer and simple pointer? | What is the difference between those two declarations?
```
int *p = new int;
int *q;
``` | <c++><pointers><dynamic-memory-allocation> | 2019-05-05 22:12:49 | LQ_EDIT |
55,998,124 | Why does my algorithm to convert between index and x,y with bitmap buffers result in the image being flipped vertically? | <p>When working with bitmap buffers like:</p>
<pre><code>[50, 50, 50, 255, 50, 50, 50, 255, ...]
[r, g, b, a, r, g, b, a, ...]
</code></pre>
<p>I often use math like this:</p>
<pre><code>let bufferWidth = width * 4;
buffer.forEach((channel, index) => {
let y = Math.floor(index / bufferWidth);
let x = Math.floor((index % bufferWidth) / 4);
let remainder = index % 4;
</code></pre>
<p>in order to calculate x, y, or vice versa to work with flat buffers of bitmap data. Almost always I end up with flipped results and some way or another end up flipping them back, but clearly there's something wrong with my thinking on this.</p>
<p>What's wrong with this math that would cause the bitmap to be flipped?</p>
<p>Full code, a function to crop a bitmap:</p>
<pre><code>function crop(
buffer,
width,
height,
leftLimit,
rightLimit,
lowerLimit,
upperLimit
) {
let croppedWidth = rightLimit - leftLimit;
let croppedHeight = upperLimit - lowerLimit;
let length = croppedHeight * croppedWidth * 4;
let bufferWidth = width * 4;
let croppedBuffer = new Uint8Array(length);
buffer.forEach((channel, index) => {
let y = Math.floor(index / bufferWidth);
let x = Math.floor((index % bufferWidth) / 4);
let remainder = index % 4;
let yCropped = y - lowerLimit;
let xCropped = x - leftLimit;
let indexCropped = yCropped * croppedWidth * 4 + xCropped * 4 + remainder;
if (
xCropped >= 0 &&
xCropped <= croppedWidth &&
yCropped >= 0 &&
yCropped <= croppedHeight
) {
croppedBuffer[indexCropped] = buffer[index];
}
});
return croppedBuffer;
}
</code></pre>
| <javascript><algorithm><bitmap> | 2019-05-06 02:32:06 | HQ |
55,998,273 | MySQL - SELECT COUNT(*) AND IGNORE SAME ID | <p>As per the title, I want to count rows in a table but if multiple rows got same ID, should count them as ONE ROW.</p>
<p>For example, I have a table named <code>my_table</code>.</p>
<p>And below is the data:</p>
<p><a href="https://i.stack.imgur.com/cpC3n.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cpC3n.png" alt="enter image description here"></a></p>
<p>Ok, let's say if I run this query: <code>SELECT COUNT(*) AS cnt FROM my_table;</code></p>
<p>the result will be
<code>cnt = 6</code> ..</p>
<p>But I don't want that.</p>
<p>What I want to achieve is the <code>cnt</code> should be <code>4</code> because multiple rows with SAME ID should be counted as ONE..</p>
<p>p/s: Sorry for my bad english language..</p>
| <mysql><count><id> | 2019-05-06 02:58:24 | LQ_CLOSE |
55,999,686 | Regex - Extract string between square bracket tag | <p>I've tags in string like <code>[note]some text[/note]</code> where I want to extract the inside text between the tags.</p>
<p>Sample Text:</p>
<pre><code>Want to extract data [note]This is the text I want to extract[/note]
but this is not only tag [note]Another text I want to [text:sample]
extract[/note]. Can you do it?
</code></pre>
<p>From the given text, extract following:</p>
<p><code>This is the text I want to extract</code></p>
<p><code>Another text I want to [text:sample] extract</code></p>
| <javascript><php><regex> | 2019-05-06 06:15:17 | LQ_CLOSE |
55,999,977 | Allow Underscores at the start and end of Usernames | <p>Looking to see how I can edit the Username creation process to allow underscores and hyphens at the beginning and end of usernames.</p>
<p>Currently, if you end your username with a _, it drops it from the creation process.</p>
<pre><code>$regex = '/^[A-Za-z0-9]+[A-Za-z0-9_.]*[A-Za-z0-9]+$/';
if(!preg_match($regex, $_POST['username'])) {
$_SESSION['error'][] = $language->register->error_message->username_characters;
}
</code></pre>
| <php><sql><regex> | 2019-05-06 06:40:09 | LQ_CLOSE |
56,002,528 | Python not standart list sorting | <p>Let's say I have a list like this: <code>[2, 3, 3, 2, 1, 1]</code> and I want to sort it to get <code>[1, 1, 3, 3, 2, 2]</code>. How I can do it in good pythonic way? I've tried like this:</p>
<pre><code>import random
alist = [1, 1, 2, 2, 3, 3]
random.shuffle(alist)
print(alist)
ones = []
twos = []
threes = []
for item in alist:
if item == 1:
ones.append(item)
elif item == 2:
twos.append(item)
else:
threes.append(item)
ordered_list = []
ordered_list.extend(ones)
ordered_list.extend(threes)
ordered_list.extend(twos)
print(ordered_list)
</code></pre>
<p>But I guess it's not the best way to do it. Maybe there is a better way?</p>
| <python> | 2019-05-06 09:37:43 | LQ_CLOSE |
56,003,101 | How can I get this text with the ID? | <p>Hello I have this code in HTML :</p>
<pre><code><td id="t_startdate">2019-04-29 00:00</td>
</code></pre>
<p>And I would like to get <code>2019-04-29 00:00</code> using jquery I tried this :</p>
<pre><code>var start = $('#t_startdate');
</code></pre>
<p>But when I try to show the variable start with :</p>
<pre><code>alert(start);
</code></pre>
<p>I get <code>undefined</code></p>
<p>Could you help me please ?</p>
<p>Thank you !</p>
| <javascript><jquery><html> | 2019-05-06 10:13:50 | LQ_CLOSE |
56,003,683 | Sorting array of diffrent customers type? The main shoul have this | -Printing number of NormalCustomers
-Printing number of MemberCustomers
-Printing number of StudentCustomers
-Creat Mylibrary objecr from library class with valus enterd from keybord
-Creat number of subscribers (the number is enterd by the keyboard)and add them to the Mylibrary matrix
-Craeat number of ordinary customers(the number is enterd by keyboard) and add them to the my library matrix and same thing for the other to types
-Printing information after passing id
-Print info for all custimers
-Sort customers according to the bill value
-Sortcustimer according to their type
Note: i have created every thing i need in the classes exept the sortig according to type i just cant seem to get all of this together so i need help please | <c#> | 2019-05-06 10:50:08 | LQ_EDIT |
56,004,483 | What is a multi-headed model? And what exactly is a 'head' in a model? | <p>What is a multi-headed model in deep learning?</p>
<p>The only explanation I found so far is this: <em>Every model might be thought of as a backbone plus a head, and if you pre-train backbone and put a random head, you can fine tune it and it is a good idea</em><br>
Can someone please provide a more detailed explanation.</p>
| <machine-learning><neural-network><deep-learning> | 2019-05-06 11:39:47 | HQ |
56,004,808 | Where can I download the Remote Debugger for Visual Studio 2017 | <p>About six weeks ago I set up remote debugging on a couple of our servers to enable us to remotely debug applications that were created in Visual Studio 2017. However, I want to install remote debugging onto a different server but can't now seem to find a source from which to download the remote debugging software - it looks as if the source has been removed by Microsoft since the release of Visual Studio 2019.</p>
<p>Can someone point me to a reliable source for the software? I stupidly didn't keep a copy of the download when I pulled it down before. Alternatively, is the remote debugging software available as part of the actual installation software for VS2017?</p>
| <visual-studio-2017><remote-debugging> | 2019-05-06 12:02:03 | HQ |
56,006,111 | Is it possible to define a non empty array type in Typescript? | <p>I have a list of numbers that I know is never empty. Is it possible to define an array in Typescript that is never empty?</p>
<p>I know that it is possible with tuples like <code>[ number, number ]</code> but this will not work as my array can be any size.</p>
<p>I guess what I am looking for is a <code>NonEmptyArray<number></code> type.</p>
<p>Does it exist? :)</p>
| <typescript> | 2019-05-06 13:20:09 | HQ |
56,007,244 | Warning message when leaving your website to another | <p>How do you set up a warning message for any external links letting the user know that they are leaving your site and going to another?</p>
<pre><code><div class="row">
<div class="col-lg-12">
<div class="form-group">
*For a list of all other forms not listed above that may be applicable - <a href="" target="_blank"><span class="noprint">(click here to print)</span></a>
</div>
</div>
</div>
</code></pre>
| <javascript><jquery><html> | 2019-05-06 14:30:09 | LQ_CLOSE |
56,008,835 | ERROR: (gcloud.app.deploy) INVALID_ARGUMENT: unable to resolve source | <p>I am trying to deploy a <code>go 1.11</code> runtime that used to work, but recently I've been getting: <code>ERROR: (gcloud.app.deploy) INVALID_ARGUMENT: unable to resolve source</code> errors. </p>
<p>Nothing in my <code>app.yaml</code> has changed, and the error message isn't helpful to understand what the issue could be. I ran it with the <code>--verbosity=debug flag</code> and get:</p>
<pre><code>Building and pushing image for service [apiv1]
DEBUG: Could not call git with args ('config', '--get-regexp', 'remote\\.(.*)\\.url'): Command '['git', 'config', '--get-regexp', 'remote\\.(.*)\\.url']' returned non-zero exit status 1
INFO: Could not generate [source-context.json]: Could not list remote URLs from source directory: /var/folders/18/k3w6w7f169xg4mypdwj7p4_c0000gn/T/tmp6IkZKx/tmphibUAo
Stackdriver Debugger may not be configured or enabled on this application. See https://cloud.google.com/debugger/ for more information.
INFO: Uploading [/var/folders/18/k3w6w7f169xg4mypdwj7p4_c0000gn/T/tmpVHKXol/src.tgz] to [staging.wildfire-app-backend.appspot.com/asia.gcr.io/wildfire-app-backend/appengine/apiv1.20190506t090359:latest]
DEBUG: Using runtime builder root [gs://runtime-builders/]
DEBUG: Loading runtimes manifest from [gs://runtime-builders/runtimes.yaml]
INFO: Reading [<googlecloudsdk.api_lib.storage.storage_util.ObjectReference object at 0x105ca9b10>]
DEBUG: Resolved runtime [go1.11] as build configuration [gs://runtime-builders/go-1.11-builder-20181217154124.yaml]
INFO: Using runtime builder [gs://runtime-builders/go-1.11-builder-20181217154124.yaml]
INFO: Reading [<googlecloudsdk.api_lib.storage.storage_util.ObjectReference object at 0x105b03b50>]
DEBUG: (gcloud.app.deploy) INVALID_ARGUMENT: unable to resolve source
Traceback (most recent call last):
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 985, in Execute
resources = calliope_command.Run(cli=self, args=args)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 795, in Run
resources = command_instance.Run(args)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/surface/app/deploy.py", line 90, in Run
parallel_build=False)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deploy_util.py", line 636, in RunDeploy
flex_image_build_option=flex_image_build_option)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deploy_util.py", line 411, in Deploy
image, code_bucket_ref, gcr_domain, flex_image_build_option)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deploy_util.py", line 287, in _PossiblyBuildAndPush
self.deploy_options.parallel_build)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/deploy_command_util.py", line 450, in BuildAndPushDockerImage
return _SubmitBuild(build, image, project, parallel_build)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/deploy_command_util.py", line 483, in _SubmitBuild
build, project=project)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/api_lib/cloudbuild/build.py", line 149, in ExecuteCloudBuild
build_op = self.ExecuteCloudBuildAsync(build, project)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/api_lib/cloudbuild/build.py", line 133, in ExecuteCloudBuildAsync
build=build,))
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/cloudbuild/v1/cloudbuild_v1_client.py", line 205, in Create
config, request, global_params=global_params)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/third_party/apitools/base/py/base_api.py", line 731, in _RunMethod
return self.ProcessHttpResponse(method_config, http_response, request)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/third_party/apitools/base/py/base_api.py", line 737, in ProcessHttpResponse
self.__ProcessHttpResponse(method_config, http_response, request))
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/third_party/apitools/base/py/base_api.py", line 604, in __ProcessHttpResponse
http_response, method_config=method_config, request=request)
HttpBadRequestError: HttpError accessing <https://cloudbuild.googleapis.com/v1/projects/wildfire-app-backend/builds?alt=json>: response: <{'status': '400', 'content-length': '114', 'x-xss-protection': '0'
, 'x-content-type-options': 'nosniff', 'transfer-encoding': 'chunked', 'vary': 'Origin, X-Origin, Referer', 'server': 'ESF', '-content-encoding': 'gzip', 'cache-control': 'private', 'date': 'Mon, 06 May 2
019 16:04:41 GMT', 'x-frame-options': 'SAMEORIGIN', 'alt-svc': 'quic=":443"; ma=2592000; v="46,44,43,39"', 'content-type': 'application/json; charset=UTF-8'}>, content <{
"error": {
"code": 400,
"message": "unable to resolve source",
"status": "INVALID_ARGUMENT"
}
}
>
ERROR: (gcloud.app.deploy) INVALID_ARGUMENT: unable to resolve
</code></pre>
<p>Any advice would be useful, I also tried it with <code>gcloud beta</code>, I rotated my credentials and was of no use. My user has <code>Owner</code> role, but I added individually all the roles that might be necessary </p>
<pre><code>App Engine Admin
App Engine Code Viewer
App Engine Deployer
App Engine Service Admin
Project Billing Manager
Cloud Build Service Account
Cloud Build Editor
Cloud Build Viewer
Owner
Storage Admin
</code></pre>
| <google-app-engine><go><google-cloud-platform><app-engine-flexible> | 2019-05-06 16:09:36 | HQ |
56,009,145 | How do I fix having an endless loop for my output? | I am trying to read data from a text file and display it on screen. Later I will be attempting to re-order the lines by symbol and percent gain, but first I wanted to make the code simply read and display what is contained.
The actual question I am trying to answer is:
(Stock Market) Write a program to help a local stock trading company automate its systems. The company invests only in the stock market. At the end of each trading day, the company would like to generate and post the listing of its stocks so that investors can see how their holdings performed that day. We assume that the company invests in, say, 10 different stocks. The desired output is to produce two listings, one sorted by stock symbol and another sorted by percent gain from highest to lowest. The input data is provided in a file in the following format: symbol openingPrice closingPrice todayHigh todayLow prevClose volume For example, the sample data is:
Develop this programming exercise in two steps. In the first step (part a), design and implement a stock object. In the second step (part b), design and implement an object to maintain a list of stocks.
a. (Stock Object) Design and implement the stock object. Call the class that captures the various characteristics of a stock object stockType. The main components of a stock are the stock symbol, stock price, and number of shares. Moreover, we need to output the opening price, closing price, high price, low price, previous price, and the percent gain/loss for the day. These are also all the characteristics of a stock. Therefore, the stock object should store all this information. Perform the following operations on each stock object: i. Set the stock information. ii. Print the stock information. iii. Show the different prices. iv. Calculate and print the percent gain/loss. v. Show the number of shares. a.1. The natural ordering of the stock list is by stock symbol. Overload the relational operators to compare two stock objects by their symbols. a.2. Overload the insertion operator, <<, for easy output. a.3. Because the data is stored in a file, overload the stream extraction operator, >>, for easy input. For example, suppose infile is an ifstream object and the input file was opened using the object infile. Further suppose that myStock is a stock object. Then, the statement: infile >> myStock; reads the data from the input file and stores it in the object myStock.
b. Now that you have designed and implemented the class stockType to implement a stock object in a program, it is time to create a list of stock objects. Let us call the class to implement a list of stock objects stockListType. The class stockListType must be derived from the class listType, which you designed and implemented in the previous exercise. However, the class stockListType is a very specific class, designed to create a list of stock objects. Therefore, the class stockListType is no longer a template. Add and/or overwrite the operations of the class listType to implement the necessary operations on a stock list. The following statement derives the class stockListType from the class listType. class stockListType: public listType { member list }; The member variables to hold the list elements, the length of the list, and the max listSize were declared as protected in the class listType. Therefore, these members can be directly accessed in the class stockListType. Because the company also requires you to produce the list ordered by the percent gain/loss, you need to sort the stock list by this component. However, you are not to physically sort the list by the component percent gain/loss. Instead, you will provide a logical ordering with respect to this component. To do so, add a member variable, an array, to hold the indices of the stock list ordered by the component percent gain/loss. Call this array sortIndicesGainLoss. When printing the list ordered by the component percent gain/loss, use the array sortIndicesGainLoss to print the list. The elements of the array sortIndicesGainLoss will tell which component of the stock list to print next.
c. Write a program that uses these two classes to automate the company’s analysis of stock data.
This may be my end goal but I am not attempting to do some of what it describes yet.
The part I believe is causing the issue is somewhere in here:
void printScreen(ifstream &infile)
{
stockType in;
stockType out;
int count = 0;
string line;
cout << "********* First Investor's Heaven *********" << endl;
cout << "********* Financial Report *********" << endl;
cout << "Stock Today Previous Percent" << endl;
cout << "Symbol Open Close High Low Close Gain Volume" << endl;
cout << "----- ----- ----- ----- ------ ------- -----" << endl;
while (getline(infile, line))
{
count++;
}
for (int i = 0; i < count; i++)
{
infile >> in;
cout << out;
}
cout << "-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*";
}
My main function is:
int main()
{
char repeat = ' ';
string userSelection;
int selection;
ifstream infile;
cout << "Please enter a filename of type .txt: ";
cin >> userSelection;
infile.open(userSelection);
if (!infile)
{
cout << userSelection << " is not found. The program will now exect. Please ensure the filename is correct and the file is in the porper directory." << endl;
exit(0);
}
do
{
selection = Menu();
switch (selection)
{
case 1:
printScreen(infile);
break;
case 2:
exit(0);
break;
default:
cout << "An error has occured, the program will now exit." << endl;
exit(0);
}
cout << "If you would like to enter another file enter y. Otherwise the system will conclude: ";
cin >> repeat;
} while (repeat = 'y');
infile.close();
return 0;
}
and I am attempting to utilize this:
ostream& operator << (ostream& out, stockType& temp)
{
char tab = '\t';
out.imbue(locale(""));
out << setprecision(2) << fixed;
out << temp.getStockSymbol() << tab << setw(6) << temp.getOpeningPrice() << tab << setw(6) << temp.getClosingPrice() << tab << setw(7) << temp.getHighPrice() << tab << setw(8) << temp.getLowPrice() << setw(9) << temp.getPreviousPrice() << setw(10) << temp.getPercentGainLoss() << "%" << tab << setw(11) << temp.getStockShares() << endl;
return out;
}
istream& operator>>(istream& in, stockType& obj)
{
string temp;
double val;
int x;
in >> temp;
obj.setStockSymbol(temp);
in >> val;
obj.setOpeningPrice(val);
in >> val;
obj.setClosingPrice(val);
in >> val;
obj.setHighPrice(val);
in >> val;
obj.setLowPrice(val);
in >> val;
obj.setPreviousPrice(val);
in >> x;
obj.setStockShares(x);
return in;
}
My output should be ordered the same way as it is being read yet I am getting no output of the symbol and I am getting an endless loop that doesn't seem to be reading everything.
| <c++> | 2019-05-06 16:31:51 | LQ_EDIT |
56,011,529 | Why are interfaces subtypes of Object in Java? | <p>Why are interfaces with no super interface subtypes of Object in Java?
What I am asking about here is why was this design choice taken by the language creators i.e. what is the practical purpose of this subtyping?</p>
| <java><interface><subtyping> | 2019-05-06 19:52:05 | LQ_CLOSE |
56,011,589 | Why is adding methods to a type different than adding a sub or an operator in perl6? | <p>Making subs/procedures available for reuse is one core function of modules, and I would argue that it is the fundamental way how a language can be composable and therefore efficient with programmer time: </p>
<p>if you create a type in your module, I can create my own module that adds a sub that operates on your type. I do not have to extend your module to do that.</p>
<pre><code># your module
class Foo {
has $.id;
has $.name;
}
# my module
sub foo-str(Foo:D $f) is export {
return "[{$f.id}-{$f.name}]"
}
# someone else using yours and mine together for profit
my $f = Foo.new(:id(1234), :name("brclge"));
say foo-str($f);
</code></pre>
<p>As seen in <a href="https://stackoverflow.com/questions/55814075/overloading-operators-for-a-class">Overloading operators for a class</a> this composability of modules works equally well for operators, which to me makes sense since operators are just some kinda syntactic sugar for subs anyway (in my head at least). Note that the definition of such an operator does not cause any surprising change of behavior of existing code, you need to import it into your code explicitly to get access to it, just like the sub above.</p>
<p>Given this, I find it very odd that we do not have a similar mechanism for methods, see e.g. the discussion at <a href="https://stackoverflow.com/questions/34504849/how-do-you-add-a-method-to-an-existing-class-in-perl-6">How do you add a method to an existing class in Perl 6?</a>, especially since perl6 is such a method-happy language. If I want to extend the usage of an existing type, I would want to do that in the same style as the original module was written in. If there is a .is-prime on Int, it must be possible for me to add a .is-semi-prime as well, right?</p>
<p>I read the discussion at the link above, but don't quite buy the "action at a distance" argument: how is that different from me exporting another multi sub from a module? for example the rust way of making this a lexical change (Trait + impl ... for) seems quite hygienic to me, and would be very much in line with the operator approach above.</p>
<p>More interesting (to me at least) than the technicalities is the question if language design: isn't the ability to provide new verbs (subs, operators, methods) for existing nouns (types) a core design goal for a language like perl6? If it is, why would it treat methods differently? And if it does treat them differently for a good reason, does that not mean we are using way to many non-composable methods as nouns where we should be using subs instead?</p>
| <raku> | 2019-05-06 19:55:57 | HQ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.