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 |
|---|---|---|---|---|---|
54,877,792 | Realtime download optimization. How to find a leak? | <p>I'm using realtime firebase. The problem is that randomly it the graphic shows a high quantity of download on some period of time. The main question is not how to fix it. The main questions are:
1) What is the system of Download from Firebase? How does it work? What are the principles? and the Second question is 2) How to find a leak?
One more interesting fact is that app was published 17 of February BUT the highest leak was on 3rd of February that means it was while testing. It is basic chat app with profiles of users. Media is only photos. But each user got only 1 photo and total amount in storage so far is only 20mb. The size of the app is less than 50kb. So I don't understand how it is possible to download such amount of data and WHAT DATA WAS DOW
DOWNLOADED to make 5GB.
Below the graphic for 30 days
<a href="https://i.stack.imgur.com/kwTMY.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kwTMY.jpg" alt="enter image description here"></a></p>
| <android><firebase><firebase-realtime-database> | 2019-02-26 02:59:11 | LQ_CLOSE |
54,879,100 | the result of my code is 0 and i don't know why, can someone help me? | Can somebody help me please. The question is to print out the smallest prime number but bigger than other not prime number. after hours of work, my code print out 0 no matter what i type in, can anyone tell me where i go wrong? sorry for bad english, i have try to translate my code into english for you. Hope it help (i post this yesterday but because of my lack of communication ability, no one seem to firgue out the problem, i have tried harder, hoping today will be different)
for example: 4 7 8 9 then the result is 9 because 9 is the smallest prime number and bigger then the biggest non-prime number ( which is 8) here is my code:
#include <iostream>
#include <cmath>
#include <complex>
using namespace std;
void TypeIn(int a[] ,int &n)
{
cout<< "\nType in n: ";
cin >> n;
for(int i=0; i<n; i++)
{
cout << "a[" << i << "]= ";
cin >> a[i];
}
}
int CheckPrimeNum(int Number)
{
int Count=0;
int Divisor =1;
while (Number >= Divisor)
{
if(Number % Divisor == 0)
{
Count++;
}
Divisor++;
}
return Count;
}
int BiggestNotPrime(int a[], int n)
{
int BiggestNotPrime =0;
for( int i=0; i<n; i++)
{
if( CheckPrimeNum(a[i]) !=2)
{
BiggestNotPrime = a[i];
break;
}
}
if(BiggestNotPrime ==0)
{
return 0;
}
else
{
for( int i=0; i<n; i++)
{
if(CheckPrimeNum(a[i])!=2 && a[i] > BiggestNotPrime)
BiggestNotPrime =a[i];
}
return BiggestNotPrime;
}
}
int main()
{
int n;
int a[100];
TypeIn(a,n);
int SmallestPrimeLocation =0;
for(int i=0; i<n; i++)
{
if(CheckPrimeNum(a[i])==2 && a[i]> BiggestNotPrime(a,n))
SmallestPrimeLocation =i;
break;
}
if(SmallestPrimeLocation ==0)
{
cout << 0;
}
else
{
for(int i=SmallestPrimeLocation; i<n; i++)
{
if(a[i]>BiggestNotPrime(a,n) && a[i] < a[SmallestPrimeLocation] && CheckPrimeNum(a[i])==2)
{
SmallestPrimeLocation=i;
}
}
cout << a[SmallestPrimeLocation];
}
return 0;
}
| <c++> | 2019-02-26 05:43:32 | LQ_EDIT |
54,879,169 | Kindly explain why in following example the output is 'undefined'? | <p>Why the value of outcome is 'undefined' in the following example? Kindly explain someone how is this calculated? </p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><script>
var foo = {
bar: function() { return this.baz; },
baz: 1
};
var a = (function(){
return typeof arguments[0]();
})(foo.bar);
console.log(a);
</script></code></pre>
</div>
</div>
</p>
<blockquote>
<p>Note: I've been through following link and it doesn't explain this
example. There is no constructor function here ...
<a href="https://stackoverflow.com/questions/20279484/how-to-access-the-correct-this-inside-a-callback">How to access the correct `this` inside a callback?</a></p>
</blockquote>
| <javascript><html><function> | 2019-02-26 05:49:31 | LQ_CLOSE |
54,879,212 | Unable to use Spring cloud to connect with AWS SES | <p>I have made a very simple maven project using Spring Boot. I am trying to connect with AWS SES using Spring cloud. While running the project, I am getting following error: </p>
<p><strong>No valid instance id defined</strong></p>
<pre><code>Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cloud.aws.core.env.ResourceIdResolver.BEAN_NAME': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stackResourceRegistryFactoryBean' defined in class path resource [org/springframework/cloud/aws/autoconfigure/context/ContextStackAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.aws.core.env.stack.config.StackResourceRegistryFactoryBean]: Factory method 'stackResourceRegistryFactoryBean' threw exception; nested exception is java.lang.IllegalArgumentException: No valid instance id defined
</code></pre>
<p>I am showing snippets of files in use:</p>
<p>pom.xml</p>
<pre><code><parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-aws</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-ses</artifactId>
<version>1.11.505</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</code></pre>
<p>SimpleMailAutoConfig.java</p>
<pre><code>@Configuration
public class SimpleMailAutoConfig {
@Bean
public AmazonSimpleEmailService amazonSimpleEmailService(AWSCredentialsProvider credentialsProvider) {
return AmazonSimpleEmailServiceClientBuilder.standard()
.withCredentials(credentialsProvider)
.withRegion(Regions.US_EAST_1).build();
}
@Bean
public MailSender mailSender(AmazonSimpleEmailService ses) {
return new SimpleEmailServiceMailSender(ses);
}
}
</code></pre>
<p>MailSendingService.java</p>
<pre><code>@Service
public class MailSendingService {
@Autowired
private MailSender mailSender;
public void sendMailMessage() {
SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
simpleMailMessage.setFrom("foo@bar.com");
simpleMailMessage.setTo("example@test.com");
simpleMailMessage.setSubject("test subject");
simpleMailMessage.setText("test content");
this.mailSender.send(simpleMailMessage);
}
}
</code></pre>
<p>Application.java</p>
<pre><code>@SpringBootApplication
@ComponentScan("com.example")
public class Application extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}
}
</code></pre>
<p>application.properties</p>
<pre><code>cloud.aws.credentials.accessKey=${MyAccessKey}
cloud.aws.credentials.secretKey=${MySecretKey}
cloud.aws.region.static=us-east-1
</code></pre>
<p>I am not trying to connect to any EC2 instance. Not able to find any proper documentation for using spring cloud for SES</p>
| <spring-boot><spring-cloud><amazon-ses> | 2019-02-26 05:54:36 | HQ |
54,880,669 | React DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node | <p>If state is true to play youtube video, and it is false I would like to delete youtube playing.
MY code is as follows.</p>
<pre><code>{this.state.isPreViewVideo && <PlayYouTube video_id="ScSn235gQx0" />}
</code></pre>
<p>sandbox URL:</p>
<p><a href="https://codesandbox.io/s/xryoz10k6o" rel="noreferrer">https://codesandbox.io/s/xryoz10k6o</a></p>
<p>Reproduction method:</p>
<p>If 4-digit characters are included in input form, "isPreViewVideo: true" by setState and if it is less than false</p>
<p>It works fine when state is true,
but when state is false, I encounter this error as follows.</p>
<pre><code>DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
</code></pre>
<p>is there a way to avoid or resolve this error?</p>
| <javascript><reactjs> | 2019-02-26 07:50:25 | HQ |
54,880,687 | how to retrive data from json response | I am trying to get data from json response,and the response format is mentioning below.I want to fetch "recipient" dictionary.Can anyone help me to get this dictionary to story in local dictionary.Thank in advance.
"chat": [
{
"id": 12,
"status": 0,
"created_at": "2019-02-22 04:57:12",
"updated_at": "2019-02-22 04:57:12",
"recipient": {
"id": 26,
"unique_id": "10024",
"name": "Kaverinew",
"avatar": "https://www.planetzoom.co.in/storage/user/avatar/1PyI4ceM3zPsG1fxbfatktWUT75sOE2Ttah8ctIp.png"
},
"conversation": {
"id": 65,
"chat_id": 12,
"user_id": 4,
"type": 1,
"message": "https://www.planetzoom.co.in/storage/chat/message/e759KWdSBegwXslAoS2xst0lohbbjNZMdpVnbxQG.png",
"status": 0,
"created_at": "2019-02-25 15:39:24"
}
},
{
"id": 6,
"status": 0,
"created_at": "2019-02-20 07:16:35",
"updated_at": "2019-02-20 07:16:35",
"recipient": {
"id": 7,
"unique_id": "10006",
"name": "Hema",
"avatar": "https://www.planetzoom.co.in/img/default_avatar_female.png"
},
"conversation": {
"id": 44,
"chat_id": 6,
"user_id": 4,
"type": 1,
"message": "https://www.planetzoom.co.in/storage/chat/message/qJjOtCRcBKBuq3UKaKVuVOEIQhaVPeJr3Bd4NoLo.png",
"status": 0,
"created_at": "2019-02-22 10:17:49"
}
}
] | <ios><json><swift> | 2019-02-26 07:52:00 | LQ_EDIT |
54,883,379 | What is Debugger PIN when I run the flask app python | <ul>
<li>Debugger is active!</li>
<li>Debugger PIN: 620-122-212</li>
</ul>
<p>I see this when I run the flask app and i'm trying to understand where it will get used?</p>
<p>Please let me know!</p>
| <python><flask> | 2019-02-26 10:29:01 | HQ |
54,884,072 | Need to move file names in a directory with path to a file using unix scipt | I tried using
cd /data/sources/;
ls $PWD/Asset_* >> /data/sources/processing/asset_files.txt;
But it works only for small number files not for higher number of files.
Please let me know how to do it effectively | <linux><bash><shell><unix> | 2019-02-26 11:04:20 | LQ_EDIT |
54,884,488 | How can I solve the error 'TS2532: Object is possibly 'undefined'? | <p>I'm trying to rebuild a web app example that uses Firebase Cloud Functions and Firestore. When deploying a function I get the following error: </p>
<pre><code>src/index.ts:45:18 - error TS2532: Object is possibly 'undefined'.
45 const data = change.after.data();
</code></pre>
<p>This is the function:</p>
<pre><code>export const archiveChat = functions.firestore
.document("chats/{chatId}")
.onUpdate(change => {
const data = change.after.data();
const maxLen = 100;
const msgLen = data.messages.length;
const charLen = JSON.stringify(data).length;
const batch = db.batch();
if (charLen >= 10000 || msgLen >= maxLen) {
// Always delete at least 1 message
const deleteCount = msgLen - maxLen <= 0 ? 1 : msgLen - maxLen
data.messages.splice(0, deleteCount);
const ref = db.collection("chats").doc(change.after.id);
batch.set(ref, data, { merge: true });
return batch.commit();
} else {
return null;
}
});
</code></pre>
<p>I'm just trying to deploy the function to test it. And already searched the web for similar problems, but couldn't find any other posts that match my problem. </p>
| <typescript><firebase><google-cloud-firestore><google-cloud-functions> | 2019-02-26 11:27:41 | HQ |
54,885,163 | Match this string with a strong RegEx? | <p>I am new to regex and I need to create a pattern for this string. This should be somewhat easy but I can't make a regex that would only include this string as a match. Thanks in advance!</p>
<p>Rule ^/sampleForExample/f/default.htm$ %{SCHEME}://www${TIER}.someadress.com/something/ [F=200]</p>
<p>Rule ^/notTheSameSample/something/default.htm$ %{SCHEME}://www${TIER}.someaddress.com/something/educators/ [F=200]</p>
| <regex> | 2019-02-26 12:03:47 | LQ_CLOSE |
54,885,241 | Are there any other options to style an html page than css? | <p>Css got pretty much features and has a fair amount of flexibility. Unlike other languages ive never heard of other options to expect the same result. Event js seams to be the only active laguage in html pages. Did i miss anything? Or are there acctually no other options?</p>
| <html><css> | 2019-02-26 12:08:25 | LQ_CLOSE |
54,885,288 | Using POST to get data instead of GET request | <p>I see in few legacy applications, POST request is used to return data to the client. Input data is provided in Form data.
Ideally to get data we should be using GET request.</p>
<p>What are the possible reasons to use POST instead of GET to get data ?</p>
<p>If its for security reasons, why we have GET in the first place ?
If input data is large, probably we may have to choose POST.</p>
<p>Please clarify.</p>
| <java><rest> | 2019-02-26 12:11:19 | LQ_CLOSE |
54,885,590 | Definition of "atomic object" | <p>In standard jargon of C and C++, the phrase "<strong>atomic object</strong>" means "<em>object</em> of <em>atomic type,</em>" does it not?</p>
<p>No standard will explicitly define every two-word phrase, so one does not fault the C and C++ standards for omitting explicit definition of this one. Nevertheless, when I read in the C++17 standard (draft <a href="http://open-std.org/JTC1/SC22/WG21/docs/papers/2017/n4659.pdf" rel="noreferrer">here</a>), sect. 4.7.1(4), that "all modifications to a particular atomic object <em>M</em> occur in some particular total order, called the <em>modification order</em> of <em>M</em>"—and when the standard repeatedly employs similar language to delimit ever more precise logic for concurrency—I would like to be sure that I am not inadvertently misunderstanding.</p>
<p>Do I assume correctly that the phrase "atomic object" means</p>
<ul>
<li><em>object</em> of <em>atomic type</em>?</li>
</ul>
<p>The only plausible alternative I can imagine would be that the phrase instead meant</p>
<ul>
<li>properly aligned <em>object</em> small enough that hardware could handle it atomically.</li>
</ul>
<p>Which is it, please?</p>
<p>(Note: I tag this question both C and C++ because, when it comes to atomics, the two standards use almost identical language. For this reason, an expert in either language can answer as far as I know. If for some reason I am mistaken, then please remove the C tag and retain the C++.)</p>
<p>Reference: see also <a href="https://stackoverflow.com/q/52606524/1275653">this question,</a> for which my question is preliminary.</p>
| <c++><c><language-lawyer><atomic><definition> | 2019-02-26 12:27:49 | HQ |
54,886,162 | I can't parce JSON by JQuery | I need to send some data to JQuery by JSON. There is my code below:
PHP:
$name = "test";
$answer = array("code" => 1, "name" => $name);
echo json_encode($answer);
Js:
console.log(data);
var response = JSON.parse(data);
Console says:
{"code":1,"name":"test"}
VM635:2 Uncaught SyntaxError: Unexpected token in JSON at position 2
at JSON.parse (<anonymous>)
at Object.onAjaxSuccess [as success] (auth.js:32)
at u (jquery.js:2)
at Object.fireWith [as resolveWith] (jquery.js:2)
at k (jquery.js:2)
at XMLHttpRequest.<anonymous> (jquery.js:2)
Help me :O | <javascript><php><jquery> | 2019-02-26 13:02:24 | LQ_EDIT |
54,886,961 | difficulty in choosing algorithm for similarity checker software | I am planning to build a project for final year that is similar to similarity checker.
In the project, I am planning to check the similarity percentage among the submitted assignments i.e offline.
For example:
1) When first student submits assignment, it is not checked with any other assignments.
2) When second student submits assignment, it is checked with the first assignment.
3) When third student submit assignment, it is checked with first and second submitted assignments.
4) Similarly if there are 35 students than the 36th submitted assignment is checked with rest 35 submitted assignments.
Now, here comes the question that how to compare two assignments.
In this case comparison is similarity between the texts in the documents.
I want the result similar to this:
[![Similarity checking between the documents][1]][1]
[1]: https://i.stack.imgur.com/jmQ9W.jpg
I just want to show percentage of similar sentences and what they are?
What I did:
I studied different algorithms like td-idf, cosine similarity algorithm but I am unable to correctly interpolate the results of algorithm.
so, I want to know which algorithm is best in this situation and I want know how this is done. Is there any references to any sites, blogs that would help me??
| <algorithm><project><cosine-similarity><sentence-similarity> | 2019-02-26 13:47:08 | LQ_EDIT |
54,887,852 | Could not find cordova integration in the default project | <p>following the <a href="https://ionicframework.com/docs/building/running" rel="noreferrer">official getting started tutorial</a> I get the following error when I try to deploy the application in my phone using this command: <code>ionic serve --devapp</code> (it works on browser):</p>
<pre><code>[ERROR] Could not find cordova integration in the default project.
</code></pre>
<p>I get this error both on Windows and MacOS.
I'm using <strong>Node 6.4.1</strong> and <strong>Ionic CLI 4.10.3</strong></p>
<p>Does the official tutorial missing something?</p>
| <ionic-framework><ionic4> | 2019-02-26 14:33:37 | HQ |
54,888,478 | Javascript change the value of a key | <p>I have some data that looks like this:</p>
<pre><code>obj = {
pref: {
language: 'English',
}
};
</code></pre>
<p>I want to change the value of <code>language to 'Spanish'</code></p>
| <javascript><typescript> | 2019-02-26 15:05:04 | LQ_CLOSE |
54,888,709 | Android - Which Button was pressed first? | I need a way to know which of my buttons was pressed first. The app layout is more or less like this.:
Button1 Button2
Button3 Button4
Button5 Button6
Button7 Button8
Button9 Button10
Button11 Button12
And if one of the buttons of it's "line" is pressed, the other disappears. The thing is, I have no idea how to know which one of all these 12 buttons was pressed first, then pressed second, then pressed third and so on...
The code I have for hiding buttons works well, but that's pretty much the easy part.
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
button1.setVisibility(View.GONE);
button2.setVisibility(View.GONE);
}
});
I searched but maybe I don't know what exactly to search for, and I didn't find a good answer.
Thanks in advance! | <android> | 2019-02-26 15:17:35 | LQ_EDIT |
54,889,458 | Kubernetes check serviceaccount permissions | <p>When deploying a service via a Helm Chart, the installation failed because the <code>tiller</code> serviceaccount was not allowed to create a <code>ServiceMonitor</code> resource.</p>
<p>Note:</p>
<ul>
<li><code>ServiceMonitor</code> is a CRD defined by the Prometheus Operator to automagically get metrics of running containers in Pods.</li>
<li>Helm Tiller is installed in a single namespace and the RBAC has been setup using Role and RoleBinding.</li>
</ul>
<p>I wanted to verify the permissions of the <code>tiller</code> serviceaccount.<br>
<code>kubectl</code> has the <code>auth can-i</code> command, queries like these (see below) always return <code>no</code>.</p>
<ul>
<li><code>kubectl auth can-i list deployment --as=tiller</code></li>
<li><code>kubectl auth can-i list deployment --as=staging:tiller</code></li>
</ul>
<p>What is the proper way to check permissions for a serviceaccount?<br>
How to enable the <code>tiller</code> account to create a ServiceMonitor resource?</p>
| <kubernetes><kubectl> | 2019-02-26 15:55:54 | HQ |
54,889,489 | Timespan function to convert minutes into 8 hour working days | <p>Need to count in C# app, minutes in SLA to show in format : </p>
<pre><code>N working days, N working hours, N working minutes
</code></pre>
<p>current code show up only hours:minutes format:</p>
<pre><code>TimeSpan spWorkMin = TimeSpan.FromMinutes(12534);
string workHours = string.Format("{0}:{1:00}", (int)spWorkMin.TotalHours, spWorkMin.Minutes);
Console.WriteLine(workHours);
</code></pre>
| <c#><.net><timespan> | 2019-02-26 15:57:34 | LQ_CLOSE |
54,889,720 | Handle "Loading chunk failed" errors with Lazy-loading/Code-splitting | <p>We are developing a Vue.js application based on Vue CLI 3 with Vue Router and Webpack. The <a href="https://router.vuejs.org/guide/advanced/lazy-loading.html" rel="noreferrer">routes are lazy-loaded</a> and the <a href="https://webpack.js.org/guides/caching/" rel="noreferrer">chunk file names contain a hash</a> for cache busting. In general, everything is working fine.</p>
<p>However, there is a problem during the deployment. Steps to reproduce are the following.</p>
<ul>
<li>User opens the application (let's assume route "/"), thus the main chunk file is loaded.</li>
<li>We change something in the application and deploy a new version.
<ul>
<li>Old chunk files are removed</li>
<li>New chunk files are being added (i.e. hashes in the chunk file names change)</li>
</ul></li>
<li>User clicks a link to another route (e.g. "/foo")
<ul>
<li>An error occurs as the application tries to load a chunk file that has been renamed: <code>Error: "Loading CSS chunk foo failed.
(/assets/css/foo.abc123.css)"</code> (this might be CSS or JavaScript)</li>
</ul></li>
</ul>
<p><strong>What is the best way to avoid errors like this?</strong></p>
<ul>
<li><p>One approach that should work is just to retain old chunk files and delete them at a later time. That, however, complicates the deployment of new versions as you need to keep track of old versions and always also deploy the old chunk files with the new version.</p></li>
<li><p>Another (naive) approach is to just reload as soon as such an error is detected (e.g. <a href="https://blog.francium.tech/vue-lazy-routes-loading-chunk-failed-9ee407bbd58" rel="noreferrer">Vue Lazy Routes & loading chunk failed</a>). It somewhat works, but it reloads the <em>old</em> route, not the <em>new</em> one. But at least it ensure that consecutive route changes work again.</p></li>
</ul>
<p>Any other ideas? Maybe there is something in webpack that could fix this?</p>
| <javascript><vue.js><webpack><lazy-loading><code-splitting> | 2019-02-26 16:10:39 | HQ |
54,890,218 | Different routes for different subdomains in Nuxt.js | <p>Suppose there're two subdomains working for one nuxt instance. They should have different pages structure. For example it can be:</p>
<pre><code>pages/
index.vue // technical entry point that has some logic for determining what routes subtree should be used
subdomain1/
index.vue // entry point for subdomain1.mysite.com/
page1.vue // entry point for subdomain1.mysite.com/page1
subdomain2/
index.vue // entry point for subdomain2.mysite.com/
page1.vue // entry point for subdomain2.mysite.com/page1
page2.vue // entry point for subdomain2.mysite.com/page2
</code></pre>
<p>The folder structure can be different. The goal is to be able to load different pages for different subdomains. <code>subdomain1.mysite.com/page1</code> has to load one file (e.g. <code>pages/subdomain1/page1.vue</code>) while <code>subdomain2.mysite.com/page1</code> has to load the other file (e.g. <code>pages/subdomain2/page2.vue</code>).</p>
<p>We can use <code>nuxtServerInit</code> action for determining the subdomain, so there's some <code>this.$store.state.ux.subdomain</code> variable that is eiter subdomain1 or subdomain2. But the rest is not clear for me. </p>
<p>Is it possible to achieve in nuxt.js? If it is, I suppose we should use named views <code><nuxt-child :name="subdomain"/></code> and <code>extendRoutes</code> in nuxt.config.js somehow, but I was not able to achieve it so far. Any help would be appreciated.</p>
| <routes><vue-router><nuxt.js> | 2019-02-26 16:40:08 | HQ |
54,891,110 | Router getCurrentNavigation always returns null | <p>In the latest version of Angular 7.2.6, I'm trying to pass data in router itself</p>
<pre><code>this.router.navigate(['other'], {state: {someData: 'qwert'}}
</code></pre>
<p>In the <code>OtherComponent</code> file, <code>this.router.getCurrentNavigation()</code> always return null</p>
<p><a href="https://stackblitz.com/edit/angular-uapqsj" rel="noreferrer">Stackblitz Link</a></p>
<p><a href="https://angular.io/api/router/Router#getcurrentnavigation" rel="noreferrer">Angular Docs - getCurrentNavigation</a></p>
<p><a href="https://angular.io/api/router/NavigationExtras#state" rel="noreferrer">Angular Docs - state</a></p>
| <angular> | 2019-02-26 17:32:23 | HQ |
54,891,175 | i am try to get my current location in android but this shows wrong. And also try to get my location following code but it's not working |
> **i am usjing this code but it is not working.**
>
>
>
> locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
> if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER))
> {
> if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) !=
> PackageManager.PERMISSION_GRANTED &&
> ActivityCompat.checkSelfPermission(this,
> Manifest.permission.ACCESS_COARSE_LOCATION) !=
> PackageManager.PERMISSION_GRANTED) {
> // TODO: Consider calling
> // ActivityCompat#requestPermissions
> // here to request the missing permissions, and then overriding
> // public void onRequestPermissionsResult(int requestCode, String[] permissions,
> // int[] grantResults)
> // to handle the case where the user grants the permission. See the documentation
> // for ActivityCompat#requestPermissions for more details.
> return;
> }
> locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
> 0, 0, new LocationListener() {
> @Override
> public void onLocationChanged(Location location) {
> //get latitude
> double latitude = location.getLatitude();
> //get Longtitude
> double longitude = location.getLongitude();
>
>
> LatLng latLng = new LatLng(latitude, longitude);
>
> // Toast.makeText(getApplicationContext(), latitude+" "+longitude,
> Toast.LENGTH_LONG).show();
>
> Geocoder geocoder = new Geocoder(getApplicationContext());
> try {
> List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);
> String str = addresses.get(0).getLocality() + ",";
> str += addresses.get(0).getCountryName();
> mMap.addMarker(new MarkerOptions().position(latLng).title(str));
> mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 18));
> } catch (IOException e) {
> e.printStackTrace();
> }
> }
>
> @Override
> public void onStatusChanged(String provider, int status, Bundle extras) {
>
> }
>
> @Override
> public void onProviderEnabled(String provider) {
>
> }
>
> @Override
> public void onProviderDisabled(String provider) {
>
> }
> });
> }
> else if(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
> {
> locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
> 0, 0, new LocationListener() {
> @Override
> public void onLocationChanged(Location location) {
> //get latitude
> double latitude = location.getLatitude();
> //get Longtitude
> double longitude = location.getLongitude();
>
> LatLng latLng = new LatLng(latitude, longitude);
>
>
> Geocoder geocoder = new Geocoder(getApplicationContext());
> try {
> List<Address> addresses = geocoder.getFromLocation(latitude,longitude,1);
> String str = addresses.get(0).getLocality()+",";
> str +=addresses.get(0).getCountryName();
> mMap.addMarker(new MarkerOptions().position(latLng).title(str));
> mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 18));
> } catch (IOException e) {
> e.printStackTrace();
> }
> }
>
> @Override
> public void onStatusChanged(String provider, int status, Bundle extras) {
>
> }
>
> @Override
> public void onProviderEnabled(String provider) {
>
> }
>
> @Override
> public void onProviderDisabled(String provider) {
>
> }
> });
>
>
> **how to solve this problem** | <android><location> | 2019-02-26 17:35:56 | LQ_EDIT |
54,894,418 | How to pass parameter to PythonOperator in Airflow | <p>I just started using <strong>Airflow</strong>, can anyone enlighten me how to pass a parameter into <strong>PythonOperator</strong> like below:</p>
<pre><code>t5_send_notification = PythonOperator(
task_id='t5_send_notification',
provide_context=True,
python_callable=SendEmail,
op_kwargs=None,
#op_kwargs=(key1='value1', key2='value2'),
dag=dag,
)
def SendEmail(**kwargs):
msg = MIMEText("The pipeline for client1 is completed, please check.")
msg['Subject'] = "xxxx"
msg['From'] = "xxxx"
......
s = smtplib.SMTP('localhost')
s.send_message(msg)
s.quit()
</code></pre>
<p>I would like to be able to pass some parameters into the <code>t5_send_notification</code>'s callable which is <code>SendEmail</code>, ideally I want to attach the full log and/or part of the log (which is essentially from the kwargs) to the email to be sent out, guessing the <code>t5_send_notification</code> is the place to gather those information.</p>
<p>Thank you very much.</p>
| <python><airflow> | 2019-02-26 21:29:42 | HQ |
54,895,801 | React hook equivalent to callback function after setting state | <p>In react (before hooks) when we set state we could call a function after state had been set as such:</p>
<pre><code>this.setState({}, () => {//Callback})
</code></pre>
<p>What is the equivalent of this with hooks?</p>
<p>I tried doing this </p>
<pre><code>const [currentRange, setCurrentRange] = useState("24h");
setCurrentRange(someRange, () => console.log('hi'))
</code></pre>
<p>But this did not work</p>
<p>Anyone know a solution for this?</p>
| <javascript><reactjs> | 2019-02-26 23:28:15 | HQ |
54,895,883 | Reset to Initial State with React Hooks | <p>I'm currently working on a signup form and the following is a snippet of my code:</p>
<pre><code>const Signup = () => {
const [username, setUsername] = useState('')
const [email, setEmail] = useState('')
const [password, setPassword] = useState('')
const [passwordConfirmation, setPasswordConfirmation] = useState('')
const clearState = () => {
setUsername('')
setEmail('')
setPassword('')
setPasswordConfirmation('')
}
const handleSubmit = signupUser => e => {
e.preventDefault()
signupUser().then(data => {
console.log(data)
clearState() // <-----------
})
}
return <JSX />
}
export default Signup
</code></pre>
<p>Each piece of state is used for a controlled input for the form.</p>
<p>Essentially what I want to do is after the user has successfully signed up, I want the state to go back to the initial state with the fields cleared.</p>
<p>It's quite imperative to manually set each piece of state back to empty strings in<code>clearState</code> I was wondering if there is a method or function that comes with React that resets the state back to its initial values?</p>
| <reactjs><react-hooks> | 2019-02-26 23:39:09 | HQ |
54,897,358 | Program to find duplicates in array and place them after the unique one in python? | <p>I have tried many times to solve this problem but not getting proper answer.</p>
| <python><duplicates> | 2019-02-27 03:01:45 | LQ_CLOSE |
54,897,876 | Python functions in general | <p><a href="https://i.stack.imgur.com/WGYfR.png" rel="nofollow noreferrer">How do I fix this error?! I'm not sure what to change about it. I tried to remove using float but its not working? </a></p>
| <python><function><typeerror> | 2019-02-27 04:04:02 | LQ_CLOSE |
54,898,013 | Difference between tsconfig.json and tsconfig.app.json files in Angular | <p>I'm a newbie in Angular. I used <code>angular-cli</code> to learn about angular and I found the files <code>tsconfig.json</code> and <code>tsconfig.app.json</code>. Both of these are typescript related and I found <a href="https://stackoverflow.com/questions/48798431/use-of-tsconfig-app-json">this link</a> useful.</p>
<p>But why two such files has been used? Why can't the configurations in these two files be combined in one file? Please help me figure this out.</p>
| <html><angular><typescript><angular-cli><package.json> | 2019-02-27 04:22:11 | HQ |
54,898,413 | Regarding Palindrome algorithm. Finding the shortest possible string | Hello guys,
The task is the following: "Write a JavaScript program to find the shortest possible string which can create a string to make it a palindrome by adding characters to the end of it."
This is a code:
"function build_Palindrome(new_str) {
var flag;
for (var i = new_str.length;; i++) {
flag = true;
for (var j = 0; j < i - j - 1; j++) {
if (i - j - 1 < new_str.length && new_str[j] != new_str[i - j - 1]) {
flag = false;
break;
}
}
if (flag) {
for (var j = new_str.length; j < i; j++) {
new_str += new_str[i - j - 1];
}
return new_str;
}
}
}"
Test:
console.log(build_Palindrome("abcddc"))
Output:
abcddcba
My question: At first it starts with j=0. If in the for loop, flag=false, then how it proceeds? Is i=7 (i++?) and is j=0 or j=1?
| <javascript><palindrome> | 2019-02-27 05:10:36 | LQ_EDIT |
54,898,732 | Hi! Kindly refer to the image attached | I am unable to run this javascript code in terminal even though the code is correct! I am using visual studio. and it runs perfectly when i click on run code but doesn't run in terminal
[error][1]
[1]: https://i.stack.imgur.com/VSPPG.jpg | <javascript><syntax> | 2019-02-27 05:39:57 | LQ_EDIT |
54,899,320 | What is the meaning of bind = True keyword in celery? | <p>What is the meaning of <code>bind=True</code> in below <strong>celery</strong> code? When to use it and when not?</p>
<pre><code>@app.task(bind=True)
def send_twitter_status(self, oauth, tweet):
try:
twitter = Twitter(oauth)
twitter.update_status(tweet)
except (Twitter.FailWhaleError, Twitter.LoginError) as exc:
raise self.retry(exc=exc)
</code></pre>
| <python><django><celery> | 2019-02-27 06:27:21 | HQ |
54,901,077 | Bundle install could not find compatible versions for gem "bundler" | <p>When I type bundle install I got this error. I tried to find solution but nothing solve my case. Please help me.</p>
<pre><code> Bundler could not find compatible versions for gem "bundler":
In Gemfile:
rails (= 4.1.8) was resolved to 4.1.8, which depends on
bundler (< 2.0, >= 1.3.0)
Current Bundler version:
bundler (2.0.1)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
Could not find gem 'bundler (< 2.0, >= 1.3.0)', which is required by gem 'rails
(= 4.1.8)', in any of the sources.
Bundler could not find compatible versions for gem "rails":
In Gemfile:
rails (= 4.1.8)
animate-rails was resolved to 1.0.10, which depends on
rails
</code></pre>
| <ruby-on-rails><bundle> | 2019-02-27 08:31:47 | HQ |
54,901,511 | summing list using java 8 streams | I have
List<Pocket> pockets;
and
public class Pocket {
String name;
Double amount;
}
pockets list contains:
[
{"pocket1", 280},
{"pocket2", 320},
{"pocket3", 100},
{"pocket4", 125},
{"pocket5", 150},
{"pocket6", 175}
]
I need to get 650 from first pockets,
What I want to receive in the end is:
[
{"pocket1", 280},
{"pocket2", 320},
{"pocket3", 50}
]
How to implement it with Java Streams/Lamda?
Thanks in advance. | <java><lambda><collections><java-8><java-stream> | 2019-02-27 08:57:52 | LQ_EDIT |
54,902,356 | Cannot send json to express server from the browser | <p>I established 2 servers: the first one is for frontend (localhost:7200), the second one is for backend (localhost:7300). And there is a test request made by frontend to backend, correspondingly, on a route '/test'.</p>
<p>The problem is when I send a json object (when 'btn' button is clicked) it rejects with the following message:</p>
<blockquote>
<p>Access to XMLHttpRequest at '<a href="http://localhost:7300/test" rel="nofollow noreferrer">http://localhost:7300/test</a>' from origin '<a href="http://localhost:7200" rel="nofollow noreferrer">http://localhost:7200</a>' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.</p>
</blockquote>
<p>Of course, I set 'Access-Control-Allow-Origin' header on backend (see below).</p>
<p>This happens if I set 'Content-Type' header as 'application/json'. But it works fine if there is no header set at all or the header is 'application/x-www-form-urlencoded' (and, therefore, the message sent is not JSON-like).</p>
<p>The code on frontend</p>
<pre><code>btn.addEventListener('click', () => {
const xhr = new XMLHttpRequest();
xhr.open('POST', 'http://localhost:7300/test', true);
xhr.setRequestHeader('Accept', 'application/json');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.addEventListener('load', (e) => {
console.log(e.target.responseText);
});
xhr.send(JSON.stringify({name: 'kek'}))
});
</code></pre>
<p>The code on backend:</p>
<pre><code>const express = require('express');
const app = express();
const bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({extended: true}))
app.use(bodyParser.json());
app.post('/test', (req, res) => {
res.set('Access-Control-Allow-Origin', '*');
res.set('Access-Control-Allow-Headers', 'Content-Type')
// res.set('Content-Type', 'application/json');
res.header("Content-Type",'application/json');
console.log(req.body)
res.json({success: true});
});
</code></pre>
| <javascript><node.js><json><express> | 2019-02-27 09:43:54 | LQ_CLOSE |
54,902,408 | How to convert characters of a string "One" into an Integer "1" in swift | <p>I have implemented an quiz application in swift 4.0. Here, user can enter his choice from ("one" or "1") to ("four" or "4") .</p>
<p>If the user can provide his choice as an integer(Eg 1,2,3, or 4)then there is no issue.
but if he provide his choice as an alphabet characters (Eg "one","two", ..), then i am facing the issues while validating correct answer.</p>
<p>Kindly, could anyone help me, How to convert word characters "one" into integer 1 etc..</p>
<p>thanks a lot in advance.</p>
| <ios><swift> | 2019-02-27 09:45:47 | LQ_CLOSE |
54,903,818 | Optional({ message = Hello; success = true; user = { fullname = "xyz"; id = 0; }; }) | I Want To Access "fullname" In User Array In UserDefaults By This Statement
if currentUser?[""] != nil {
// do something
}
| <swift> | 2019-02-27 10:54:28 | LQ_EDIT |
54,904,563 | I want my horizontal scroll bar enable all the time | <p>I want my horizontal scroll bar enable all the time. Actually when I scroll horizontally it comes up and when I move my pointer anywhere else then it gets hidden all the time, so I don't want it to be disabled. Please help...</p>
| <html><css> | 2019-02-27 11:35:06 | LQ_CLOSE |
54,906,244 | How to allocate/genrate new ip address in ec2 instance in same subnet range? |
I know i can get new IP address by going to Elastic IPs --> Allocate new address but by doing this i always get IPs in different subnet range.
I want to IPs with same subnet.
| <amazon-web-services><networking><amazon-ec2><subnet> | 2019-02-27 13:07:35 | LQ_EDIT |
54,907,893 | what's wrong with deleteAll method for single linked list? I want to delete all nodes in the list. Can't figure out what's wrong with this |
public void deleteAll() {
if(head==null) {
System.out.println("list already empty");
}
else {
Node temp=head; Node del;
while(temp.next!=null) {
del=temp.next;
temp=null;
temp=del;
}
System.out.println("all nodes deleted");
}
}
this is the method to delete all nodes in linked list without taking parameters. | <java><singly-linked-list> | 2019-02-27 14:37:56 | LQ_EDIT |
54,908,059 | MVC C# Searc Filter | I'm trying to filter records from my database. Checkbox value post controller when checkbox checked,
I choose "a" and I show which record contains "a", I choose "a,b" and I'm showing "a - b - a,b " but I want to show just "a,b"
My controller;
public ActionResult GetProducts(List<string> filter)
{
List<Product> proc = new List<Product>();
foreach (var item in filter )
{
var model = db.Product.Where(x => x.tMal.Contains(item)).ToList();
proc.AddRange(model);
}
return View(proc);
How Can I do? | <c#><asp.net-mvc> | 2019-02-27 14:47:19 | LQ_EDIT |
54,908,671 | Vue Cli unit test with jest how to run single test | <p>I have vue application using the vue cli 3.
During the setup process i chose jest as the testing framework.
To run my unit tests i have a script in the package.json:</p>
<pre><code>test:unit": "vue-cli-service test:unit",
</code></pre>
<p>and to run this i write in the vs code terminal:</p>
<pre><code>npm run test:unit
</code></pre>
<p>This runs all my tests that meet the specifications set up in the jest config section of the package.json file.</p>
<p>My question is how to run just a single test. Is there a specific command i need to run? or is there an vscode extension that will work with this setup. </p>
| <vuejs2><jestjs><vue-cli-3> | 2019-02-27 15:15:01 | HQ |
54,908,679 | i want text after 3 '_' s means '110_DT_H55_VXELQ318_10Q' this is the text i want 'VXELQ318_10Q' | this is my quary:-
DECLARE @x varchar(100)
SET @x = '110_DT_H55_VXELQ318_10Q'
SELECT left(@x, CHARINDEX('_', REVERSE(@x)) )
| <sql><sql-server><tsql> | 2019-02-27 15:15:37 | LQ_EDIT |
54,911,667 | How to load YouTube live video streaming in unity? | <p>I need some doubt about youtube live video streaming. how to load that youtube live video stream inside of unity any possible. because unity default video player does not support youtube URL that only any other player for youtube URL supporting are not plz replay soon.</p>
| <unity3d><youtube><video-streaming> | 2019-02-27 17:54:39 | LQ_CLOSE |
54,913,079 | what are some good scenarios in which to use reduce()? | <p>What are some good scenarios in which to use reduce()? I've used map() and filter() quite a bit but I don't use reduce(), mainly b/c I'm not exactly sure what the niche/benefits of the reduce() function are.</p>
| <javascript> | 2019-02-27 19:27:22 | LQ_CLOSE |
54,913,541 | Arrays being re-assigned (Python) | <p>I'm recreating Conway's game of life in pygame, and I've been having an issue implementing the preset feature. When I'm assigning the preset array to the default array, and then assigning it back to the default array again, the preset is changed. I'm only editing the array "Initial_frame" but it is somehow changing the preset array.</p>
<p>Code:
<a href="https://paste.pythondiscord.com/uvetekikot.py" rel="nofollow noreferrer">https://paste.pythondiscord.com/uvetekikot.py</a></p>
| <python><pygame> | 2019-02-27 19:58:01 | LQ_CLOSE |
54,913,898 | Creating a list from a range of numbers in Python | <p>I am trying to create a list of size 9 (but that can change) which is populated with numbers from the range of [-pi/2,pi/2] where basically the range is split into 9 numbers and those 9 numbers are what the list is populated with.</p>
| <python><python-3.x><numpy> | 2019-02-27 20:24:23 | LQ_CLOSE |
54,914,345 | I need to replace specific words in a string with the words defined as values in my hash | [My Attempt][1]
[1]: https://i.stack.imgur.com/NnKvI.png
I've been stuck on this exercise for some time now, i need some help on getting the desired output. The aim is to replace specific words in a string by the values defined in the dictionary. I would really appreciate the help and also could you explain it in laymans terms. I am a bit new to Ruby and coding in general. Hopefully, I'll get the hang of it!, You can see my code on the picture attached. | <ruby> | 2019-02-27 20:56:38 | LQ_EDIT |
54,916,343 | How to set the maximum and minimum limit for a variable in C? | <ol>
<li><p>If I want to set a int variable which is "larger or equal to 100" and "smaller or equal to 200", how do I do that?</p></li>
<li><p>I heard it is like "char a[1024]" if I want to set maximum string length to 1024 but how to set minimum string length?</p></li>
</ol>
| <c> | 2019-02-27 23:54:24 | LQ_CLOSE |
54,917,658 | How to learn golang quickly and efficiently? | <p>How to learn golang quickly and efficiently?
I have learned C/C++/Java, any documentation about the syntax diff
among these languages?
Any classic and popular books high recommended?</p>
| <go> | 2019-02-28 02:48:49 | LQ_CLOSE |
54,918,577 | Visual studio community problem in unity 3d, asking to upgrade even i am using free version, what to do ? Please help me someone, Thank you | [enter image description here][1]
I am using visual studio community 2017 with unity 3d, but after few days i got this issue, what to do ?
[1]: https://i.stack.imgur.com/M9Kxh.jpg | <visual-studio><unity3d> | 2019-02-28 04:47:44 | LQ_EDIT |
54,918,615 | How to insert/update information in SqlServer using C# | Hello I am trying to insert new information into my already created table where id = 2019;
I get the error incorrect syntax near WHERE
private void button6_Click(object sender, EventArgs e)
{
xcon.Open();
SqlDataAdapter xadapter = new SqlDataAdapter();
xadapter.InsertCommand = new SqlCommand("INSERT into dbo.SysX VALUES (@fpp, @sdd, @sff) WHERE id = 2019", xcon);
xadapter.InsertCommand.Parameters.Add("@fpp", SqlDbType.Int).Value = Convert.ToInt32(textBox1.Text);
xadapter.InsertCommand.Parameters.Add("@sdd", SqlDbType.Int).Value = Convert.ToInt32(textBox2.Text);
xadapter.InsertCommand.Parameters.Add("@sff", SqlDbType.Int).Value = Convert.ToInt32(textBox3.Text);
xadapter.InsertCommand.ExecuteNonQuery();
xcon.Close();
}
How can I insert new information on click of button where ID = 2019
thanks | <c#><sql-server> | 2019-02-28 04:51:11 | LQ_EDIT |
54,918,883 | Invalid date is populated when we use yyyy-MM-dd'T'HH:mm:ssXXX format in java | <p>When we convert the date from yyyy-MM-dd'T'HH:mm:ssXXX to YYMMDD date is invalid.</p>
<p>Say..
If the date is 2019-02-27T12:52:58.249Z
then the converted date is generated as "190258"</p>
| <java><date><simpledateformat> | 2019-02-28 05:21:45 | LQ_CLOSE |
54,919,006 | Finding an object in a nested object array | I have an object array that looks like the image below depicts. I need to iterate through that object array and return the object where the text property is equals to a string variable that comes as a param. e.g: an object where the text property is "Book an Internal Interview", the object could be in any level of the hierarchy.
i was trying something like this, but it just allow me to look in a specific level:
var txt = "Book an Internal Interview";
var obj = items[0].items[0].items.find(o => o.text === txt);
I need something more recursive
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/4wlhp.png | <javascript><arrays><ecmascript-6> | 2019-02-28 05:33:49 | LQ_EDIT |
54,919,297 | Google Map API : Geometry Library is free? | I am using Google-maps Geometry Library,
google.maps.geometry.spherical.computeDistanceBetween
It is not available in pricing table anywhere. How google is charging money for the same.
Is it coming under other library like places or distance-matrix?
As far as I searched Geometry library is the individual one. Please help me out with the same.
Thanks in advance. | <google-maps-api-3> | 2019-02-28 05:58:49 | LQ_EDIT |
54,919,759 | Can't create handler inside thread Thread[Thread-5,5,main] that has not called Looper.prepare() | <p>What does the following exception mean; how can I fix it?
<strong>This is the code:</strong></p>
<pre><code> if (response.isSuccessful()) {
String message = response.body().string();
JSONObject jsonObject = new JSONObject(message);
new AlertDialog.Builder(mcontext)
.setTitle("title:")
.setMessage(TmpPwd)
.setPositiveButton("close", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
})
.show();
}
</code></pre>
<p><strong>This is the exception:</strong></p>
<pre><code> W/System.err: java.lang.RuntimeException: Can't create handler inside thread Thread[Thread-5,5,main] that has not called Looper.prepare()
at android.os.Handler.<init>(Handler.java:205)
</code></pre>
| <java><android> | 2019-02-28 06:34:38 | LQ_CLOSE |
54,920,263 | Using PERL extract data between two symbols (: and ;) line by line from a log file | I have to extract data between two symbols (: and ;) line by line from a log file. My data is:
INFO @3035155 mti_lane1_bw_mon: total bytes = 0, at time = 3035155; T=3035155
I'm using this code to extract data after colon(:)
use strict;
use warnings;
my $filename = 'log1';
my @fields;
open(FILE, $filename) or die "Could not read from $filename, program halting.";
while(<FILE>)
{
chomp;
@fields = split(':', $_);
print "$fields[1]\n";
}
close FILE;
Current Output :
total bytes = 0, at time = 3035155; T=3035155
Required Output
total bytes = 0, at time = 3035155
| <perl> | 2019-02-28 07:12:12 | LQ_EDIT |
54,920,682 | Program based on issuing a book in library | <p>The library at the Hogwarts School of Witchcraft and Wizardry has computerized its book issuing process. The relevant information is provided as text from standard input in three parts: information about books, information about borrowers and information about checkouts. Each part has a specific line format, described below.</p>
<p>Information about books
Line format: Accession Number~Title</p>
<p>Information about borrowers
Line format: Username~Full Name</p>
<p>Information about checkouts
Line format: Username~Accession Number~Due Date
Note: Due Date is in YYYY-MM-DD format.</p>
<p>You may assume that the data is internally consistent. For every checkout, there is a corresponding username and accession number in the input data, and no book is simultaneously checked out by two people.
Each section of the input starts with a line containing a single keyword. The first section begins with a line containing Books. The second section begins with a line containing Borrowers. The third section begins with a line containing Checkouts. The end of the input is marked by a line containing EndOfInput.
Write a Python program to read the data as described above and print out details about books that have been checked out. Each line should describe to one currently issued book in the following format:
Due Date~Full Name~Accession Number~Title
Your output should be sorted in increasing order of due date. For books due on the same date, sort in increasing order of full name.
Here is a sample input and its corresponding output.
Sample Input
Books APM-001~Advanced Potion-Making GWG-001~Gadding With Ghouls APM-002~Advanced Potion-Making DMT-001~Defensive Magical Theory DMT-003~Defensive Magical Theory GWG-002~Gadding With Ghouls DMT-002~Defensive Magical Theory Borrowers SLY2301~Hannah Abbott SLY2302~Euan Abercrombie SLY2303~Stewart Ackerley SLY2304~Bertram Aubrey SLY2305~Avery SLY2306~Malcolm Baddock SLY2307~Marcus Belby SLY2308~Katie Bell SLY2309~Sirius Orion Black Checkouts SLY2304~DMT-002~2019-03-27 SLY2301~GWG-001~2019-03-27 SLY2308~APM-002~2019-03-14 SLY2303~DMT-001~2019-04-03 SLY2301~GWG-002~2019-04-03 EndOfInput
Sample Output
2019-03-14~Katie Bell~APM-002~Advanced Potion-Making 2019-03-27~Bertram Aubrey~DMT-002~Defensive Magical Theory 2019-03-27~Hannah Abbott~GWG-001~Gadding With Ghouls 2019-04-03~Hannah Abbott~GWG-002~Gadding With Ghouls 2019-04-03~Stewart Ackerley~DMT-001~Defensive Magical Theory</p>
| <python> | 2019-02-28 07:41:55 | LQ_CLOSE |
54,921,435 | Array size and elements by user input | <p>I want a program that asks first for the size of an array and next asks for the element. The size of the array is int and the stored values are double. Like this:</p>
<pre><code>How many numbers? 5 // 5 is user input
Please type the numbers:
1,111
4
11,45
21
3
The numbers in reverse order are:
3.0 21.0 11.45 4.0 1.111
</code></pre>
<p>My problem is, how to ask for the size and for the elements? Thanks in advance!</p>
| <java><arrays> | 2019-02-28 08:36:54 | LQ_CLOSE |
54,921,815 | Why use json format when read mode and write mode are available? | Why do we use `json files` when we can as easily store and load data with two other functions, namely `read()` and `write()`?
Since I am a beginner in Python I don't know what else `json` can be used for except to store and load data from different files. Is `json` used for something else too? | <python><json><python-3.x> | 2019-02-28 09:01:10 | LQ_EDIT |
54,922,817 | Run function in input if it is empty? | <p>Is there anyway I can check if an input is empty using javascript and then run a function? I'd like it to be in the input itself if possible. </p>
<p>There is <code>onChange</code> so is there an <code>ifEmpty</code> lol?</p>
| <javascript> | 2019-02-28 09:55:23 | LQ_CLOSE |
54,924,961 | Why images are not showing up in iframe? | <p>I am using iframe to show data from our media manager site. But iframe is not showing up images.</p>
<pre><code><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>MM Test IFrame</title>
</head>
<body>
<iframe width="100%" height="400" src="http://mediamanager.b-
yy.com/filemanager/newmediamanager/filemanager/dialog.php"
frameborder="0" style="overflow: scroll; overflow-x: hidden; overflow-
y: scroll; "></iframe>
</body>
</html>
</code></pre>
<p>But if we directly try url then all is fine.
url: <a href="http://mediamanager.b-" rel="nofollow noreferrer">http://mediamanager.b-</a>
yy.com/filemanager/newmediamanager/filemanager/dialog.php</p>
| <php><html><iframe><server> | 2019-02-28 11:44:00 | LQ_CLOSE |
54,925,425 | how to Convert HTML characters to Text in c# | Tell me how to convert these characters to plain text
â„¢ , ® , â„¢ , ® and —
this problem occurs when I convert HTML text to string in c#.
| <c#> | 2019-02-28 12:09:44 | LQ_EDIT |
54,925,631 | Set current time to yyyy-MM-dd using swift | the code I've used is working but I have a problem. For example, when the minute is 02, it says 2. I want it to be 02. He writes without 0. Do you help me share the code?
@objc func tick() {
var calendar = Calendar(identifier: .iso8601)
calendar.timeZone = NSTimeZone.local
let currentDay = calendar.component(.day, from: Date())
let currentMonth = calendar.component(.month, from: Date())
let currentYear = calendar.component(.year, from: Date())
let currentHour = calendar.component(.hour, from: Date())
let currentHour1 = calendar.component(.minute, from: Date())
labelTimer.text = String (currentDay) + ("/") + String (currentMonth) + ("/") + String (currentYear) + ("/") + String (currentHour) + (":") + String (currentHour1)
} | <swift><time> | 2019-02-28 12:20:57 | LQ_EDIT |
54,926,851 | MERGING PDF IN CORE NON-COMMERCIAL LICENCE | i found this [link](https://github.com/GowenGit/docnet) but can i anyone show how to use it for merge several pdf into one? i would like to use MIT licence | <c#><linq> | 2019-02-28 13:26:54 | LQ_EDIT |
54,927,028 | Generate numbers by algorithm (interesting) | Maybe anyone know how to generate numbers in this way.
I have function, for example, `generate (current, count, limit)`
current – central number in array
count – max numbers count
limit - for example, 2 means two numbers before and after current number.
This function might return array like that:
[ current - n, current - 1, current, current + 1, current + n ] (n < limit)
For example:
generate(5, 10, 2)
Returns:
[3, 4, 5, 6, 7]
But `generate(1, 5, 2)` must return `[4, 5, 1, 2, 3 ]`
Numbers before current take from reverse array of max numbers count.
| <javascript><python><arrays><algorithm><math> | 2019-02-28 13:36:11 | LQ_EDIT |
54,927,762 | Can someone explain Fetch APIs in detail? | <p>Whats the use of Fetch API and what are promises and responses? I heard it is just used for fetching or extracting the data from the server.</p>
| <javascript> | 2019-02-28 14:19:01 | LQ_CLOSE |
54,929,148 | Download File from SFTP server without using JSch | <p>Due to some policy constraint at our company, we cannot use any external Library. I couldn't find any way to do that in Java.</p>
| <java> | 2019-02-28 15:31:19 | LQ_CLOSE |
54,931,009 | strips out all characters except: a-z, A-Z, 0-9, underscore and the forward slash from a String using Python | <p>Using regular expression strips out all characters except a-z, A-Z, 0-9, underscore and the forward slash from a String and All other characters are to get removed and replaced by an underscore. In the replaced version, no consecutive multiple underscores should exist. </p>
<p>For example, </p>
<p>input :- "Ab 4/5 (t) "
output:- "Ab_4/5_t_"</p>
<p>input :- "AB___cd@# E"
output:- "AB_cd_E"</p>
| <python><regex> | 2019-02-28 17:17:29 | LQ_CLOSE |
54,931,480 | How would I create a python function that outputs all combinations of a defined set of variables? | <p>Here is what I am trying to do but not exactly sure how to make this work. I have 3 sets of variables and I want to output all combinations of those 3 sets and output in a format that maintains the order of the variables like this:</p>
<pre><code>list_of_vars = [var1, var2, var3]
</code></pre>
<p>The variables would look something like this:</p>
<pre><code>var1 = [1, 2, 3]
var2 = ["foo", "bar", "foo2"]
var3 = ["a", "b", "c"]
</code></pre>
<p>The final output should look like this.</p>
<pre><code>final_list_of_vars = [[1, "foo", a], [1, "bar", a], .......]
</code></pre>
| <python> | 2019-02-28 17:49:18 | LQ_CLOSE |
54,933,030 | How do I print a single string into multiple lines in C#? | I am using C#, ASP. I have a single string that looks like the following:
"["Fruit:Apple","Animal:Dog", Food:Pizza"]"
How do I format it so I can get it to print like the following:
Fruit:Apple
Animal:Dog
Food:Pizza
| <c#><asp.net><string> | 2019-02-28 19:36:47 | LQ_EDIT |
54,933,630 | Java Big Decimal Half Even Bug? | <p>I'm trying to specifically use this value</p>
<p><code>new BigDecimal("23.025").setScale(2, RoundingMode.HALF_EVEN);</code></p>
<p>The output is 23.02, but should be 23.03. Is it a bug?</p>
<p>Just for curiosity <code>DecimalFormat("#####0,00");</code> also does not work</p>
<p>Any other suggestion?</p>
| <java><rounding><bigdecimal> | 2019-02-28 20:20:26 | LQ_CLOSE |
54,934,176 | Flatmapping in Java | Given the following two dimensional array
int[][] arr = {{1, 2}, {3, 4}, {5, 6}};
What is the most elegant way in java to flatmap this to the following form
int[] arr = {1, 3, 5, 2, 4, 6};
It can be assumed that all the nested arrays are of same length. | <java><java-stream> | 2019-02-28 21:00:06 | LQ_EDIT |
54,937,764 | How can i add 10000 users in for loop just take time less than 1 minute? | I have java assignment. The tagert is just only build a java app using eclipse IDE to `add.userAccount(String id, String name, String email)` in to a file. Note that i'm done this assignment because it's no difficult. But i have curious about optimization. Put that code into a loops(such as `for(int times = 0, time < 10000;time++) add.userAccount(String id, String name, String email);`) but i takes alot of time( 5 minutes). I use FileIntputStream and FileOutputStream. Is anyone here suggest me the way to optimize me problem??? | <java> | 2019-03-01 04:00:41 | LQ_EDIT |
54,940,811 | if in the directory, files size is less than 2.1kb move the files to another directory | <p>I need to move file to another directory, if the files size is less than 2.1kb.
There are multiple files in the directory.
Please let me know how to resolve this.
I can not use mv command as there are large number of files in the directory, it has to be using find command.</p>
| <bash><shell><unix> | 2019-03-01 08:38:15 | LQ_CLOSE |
54,941,374 | Why to put img inside div? | <p>Hey guys I am beginner at html and css and confused with why to put img inside div, I mean, are there any benefits. Secondly, if I put img inside div then will it suffice to define height of the img without specifying width of the img.</p>
| <html><css> | 2019-03-01 09:15:06 | LQ_CLOSE |
54,941,645 | How to connect mysqli Databse in php | Her Is MyCode
`$conn=mysqli_connect("localhost","root","");
$db=mysqli_select_db("root");`
Now It Showing Me Some Error
| <php><mysql><mysqli> | 2019-03-01 09:30:29 | LQ_EDIT |
54,941,782 | Erro na busca sql, preciso de ajuda para fazer a busca | Ola, estou tendo dificuldade para fazer uma consulta seletiva usando duas tabelas, provavelmente estou errando a sintaxe da busca, agradeço caso alguem possa me passar a forma correta de fazer a busca.
ara testes criei 4 perguntas,apos responder as 4 deveria direcionar para uma pagina dizendo que nao ha mais perguntas.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<?php
$sqluser = "SELECT a.aquestion_id, a.user_id, b.pergunta, b.question_id FROM respostas a INNER JOIN questions b ON a.aquestion_id != b.question_id WHERE a.user_id = '$logado' ORDER BY RAND() LIMIT 1";
$executarquest=mysqli_query($conuser, $sqluser);
while ($exibir = mysqli_fetch_array($executarquest)){
if ($exibir['question_id'] > 0)
{
$guarda = ($exibir['question_id']);
echo '<b>Quesion ID: </b>';
echo $exibir['question_id'];
echo '<br>';
echo $exibir['pergunta'];
echo $exibir['user_id'];
}
else{
header('location:/quiz/acabou.php');
}
}
?>
<!-- end snippet -->
Estou tentando criar uma serie de perguntas para ajudar meu filho na escola, uma especie de licao de casa mas nao estou conseguindo...
Agradeco qualquer ajuda.
| <php><mysql><sql><mysqli> | 2019-03-01 09:36:59 | LQ_EDIT |
54,942,319 | Navigableset vs Navigablemap | <p>I am new to JAVA and i am really confused about the difference between the two data structures navigableset and navigablemap in terms of both structure and implementation.
Where should we use each of them?</p>
| <java><collections> | 2019-03-01 10:07:48 | LQ_CLOSE |
54,942,812 | how to create rounded corner hexagon in android | i want create a hexagon with rounded corners in android XML. i don't want java code.i want to set hexagon as a background of text view. please help me. thank you in advance.this vector image currently using
<vector android:height="24dp" android:viewportHeight="628.0"
android:viewportWidth="726.0"
android:width="27dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#00ffffff"
android:pathData="m723,314c-60,103.9 -120,207.8 -180,311.8 -120,0 -240,0 -360,0C123,521.8 63,417.9 3,314 63,210.1 123,106.2 183,2.2c120,0 240,0 360,0C603,106.2 663,210.1 723,314Z"
android:strokeColor="#008000" android:strokeWidth="25"
/>
</vector>
| <android><android-layout><svg> | 2019-03-01 10:35:41 | LQ_EDIT |
54,945,967 | Why DateTime diff wrong result | I have the following code that is returning the wrong answer. Please let me know what's wrong.
$start_date = new DateTime('31-03-2019');
$end_date = new DateTime('01-05-2019');
$d = $start_date->diff($end_date);
echo "day: " . $d->d . " month: " . $d->m . "\n";
It is returning the wrong answer.
day: 0 month: 1
I expect the answer to be
day: 1 month: 1
| <php><datetime><datediff> | 2019-03-01 13:47:38 | LQ_EDIT |
54,949,936 | How do Dinamic binding in PHP? | I'm trying to develop a little MVC Site in PHP to work with passwords. (Without any framework like Laravel or similar, for learning purposes).
In order to do so I've write at least 4 classes and an index file:
Controller -> A base class to be extended contaning all the basic logic for controllers;
Index -> A controller class to handle with normal user's login;
Admin -> A controller class to handle with admin users's login;
Bootstrap -> A class to interpret the url passedand use as a router;
The classes are shown as follow:
libs/Controller.php
```
<?php
class Controller {
protected $view;
protected $security_level;
function __construct() {
$this->security_level = 0;
}
public function model($model) {
$path = 'models/' . ucfirst($model). '.php';
if (file_exists($path)) {
require_once ($path);
return new $model();
}
}
public function getSecurityLevel(){
return $this->securiy_level;
}
public function view($view, $data = []){
require_once('views/commom/header.php');
require_once('views/' . $view . '.php');
require_once('views/commom/footer.php');
}
}
```
controllers/Index.php
```
<?php
class Index extends Controller {
public function __construct() {
parent::__construct();
$this->model('UserModel');
//$this->securiy_level = 0;
}
public function index($error = 0) {
$this->view('index/index', ['error' => $error]);
}
public function admin($error = 0) {
$this->view('index/index_adm', ['error' => $error]);
}
public function login(){
$auth = new Authentication();
$permission = $auth->authenticate("user");
if($permission){
header("location: /account/index");
}
else{
$this->index(1);
}
}
public function login_adm(){
$auth = new Authentication();
$permission = $auth->authenticate("admin");
if($permission){
header("location: /admin/index");
}
else{
$this->admin(1);
}
}
public function signin(){
echo "method sign in invoked <br />";
}
public function logout(){
$this->view('index/logout');
}
public function lostMyPassword(){
echo "method lost invoked <br />";
}
public function details() {
$this->view->view('index/index');
}
}
```
controllers/Admin
```
<?php
//I Think that this is VERY wrong, but okay
@session_start();
class Admin extends Controller {
private $encrypt_unit;
public function __construct() {
parent::__construct();
$this->model('UserModel');
$this->encrypt_unit = new Encrypter();
$this->securiy_level = 1;
}
public function index($msg = "", $err = false){
$users = $this->recover();
$this->view('admin/index', ["msg" => $msg, "err" => $err, "users" => $users]);
}
public function create(){
$user_var = new UserModel();
$user_var->setLogin($_POST["login"]);
$user_var->setEmail($_POST["email"]);
$user_var->setPassword($this->encrypt_unit->encrypt($_POST["password"]));
$user_var->setIsAdmin($_POST["isAdmin"]);
$user_dao = new UserDAO();
$flag = $user_dao->insertUser($user_var);
if($flag)
$this->index("User created successfully", false);
else
$this->index("Can't created user, please try again", true);
}
public function recover(){
$user_dao = new UserDAO();
$all_users = $user_dao->getUsers();
$users = array();
foreach ($all_users as $value) {
array_push($users, [
"id" => $value->getId(),
"login" => $value->getLogin(),
"email" => $value->getEmail(),
"password" => $this->encrypt_unit->decrypt($value->getPassword()),
"isAdmin" => $value->getIsAdmin()
]);
}
return $users;
}
public function update(){
$user_var = new UserModel();
$user_var->setId($_POST["id"]);
$user_var->setLogin($_POST["login"]);
$user_var->setEmail($_POST["email"]);
$user_var->setPassword($this->encrypt_unit->encrypt($_POST["password"]));
$user_dao = new UserDAO();
$flag = $user_dao->updateUser($user_var);
if($flag)
$this->index("User updated successfully", false);
else
$this->index("Can't updated user, please try again", true);
}
public function update_credential($credential_level){
$user_var = new UserModel();
$user_var->setId($_POST["id"]);
$user_var->setIsAdmin($credential_level);
$user_dao = new UserDAO();
$flag = $user_dao->updateUserCredential($user_var);
if($flag)
$this->index("User updated successfully", false);
else
$this->index("Can't updated user, please try again", true);
}
public function delete(){
$user_var = new UserModel();
$user_var->setId($_POST["id"]);
$user_dao = new UserDAO();
$flag = $user_dao->deleteUser($user_var);
if($flag)
$this->index("User deleted successfully", false);
else
$this->index("Can't deleted user, please try again", true);
}
public function search(){
echo "method search invoked <br />";
}
}
```
libs/Bootstrap:
```
<?php
class Bootstrap {
// protected $controller;
// protected $method;
// protected $params;
function __construct() {
//$this->method = 'index';
$this->redirect();
}
public function parseUrl(){
return isset($_GET['url']) ? explode('/',filter_var(rtrim($_GET['url'], '/'), FILTER_SANITIZE_URL)) : null;
}
function redirect(){
$controller;
$method;
$params;
$url = $this->parseUrl();
if(empty($url[0])){
$controller_name = 'Index';
}
else{
$controller_name = ucfirst($url[0]);
}
$filename_controller = 'controllers/' . $controller_name . '.php';
if (file_exists($filename_controller)) {
require_once($filename_controller);
// Do this to use the rest of array to select method, and than parameters
unset($url[0]);
}
else{
$this->error("Controller $controller_name not founded");
return false;
}
$controller = new $controller_name;
//default method
$method = 'index';
if(isset($url[1])){
if (method_exists($controller, $url[1])) {
$method = $url[1];
// Do this to use the rest of array to select parameters
unset($url[1]);
}
else{
$this->error("The controller $controller_name doesn't have any public method called $url[1]");
}
}
//This 'array_values($url)' command is possible because we have unseted the first and second position of this aray before
$params = $url ? array_values($url) : [];
// Securiy comparassion?
var_dump($controller);
var_dump(get_class_methods($controller));
var_dump($controller->getSecurityLevel());
var_dump($controller->{"getSecurityLevel"}());
// if(property_exists($controller, "securiy_level")){
// $authEntity = new Authentication();
// $authEntity->auth($controller->getSecurityLevel());
// }
//(new $url[0])->{$url[1]}($url[2]);
call_user_func_array([$controller, $method], $params);
}
function error($msg="") {
//echo "error invoked: <br /> $msg <br />";
require_once('controllers/Error.php');
$errorHandler = new ErrorController();
$errorHandler->index();
return false;
}
}
```
/index.php:
```
<?php
// Use an autoloader!
require_once('libs/Bootstrap.php');
require_once('libs/Controller.php');
require_once('libs/Model.php');
require_once('libs/View.php');
// Library
require_once('libs/Database.php');
require_once('libs/ConnectionDB.php');
require_once('libs/Session.php');
require_once('libs/Authentication.php');
require_once('libs/Encrypter.php');
require_once('config/paths.php');
require_once('config/database.php');
require_once('config/passwords.php');
// DAOS
require_once('daos/UserDAO.php');
require_once('daos/AccountDAO.php');
$app = new Bootstrap();
```
My main problem is on the Bootstrap class, specifically when I try to run:
```
var_dump($controller->getSecurityLevel()); //or
var_dump($controller->{"getSecurityLevel"}());
```
This is my actual exit:
object(Index)#2 (2) { ["view":protected]=> NULL ["security_level":protected]=> int(0) }
array(12) { [0]=> string(11) "__construct" [1]=> string(5) "index" [2]=> string(5) "admin" [3]=> string(5) "login" [4]=> string(9) "login_adm" [5]=> string(6) "signin" [6]=> string(6) "logout" [7]=> string(14) "lostMyPassword" [8]=> string(7) "details" [9]=> string(5) "model" [10]=> string(16) "getSecurityLevel" [11]=> string(4) "view" }
Notice: Undefined property: Index::$securiy_level in /var/www/html/libs/Controller.php on line 21
NULL
Notice: Undefined property: Index::$securiy_level in /var/www/html/libs/Controller.php on line 21
NULL
What I cannot understand is how PHP shows me that the ```$controller``` variable has the property that I want to access, I have the method to do the access, but I cannot access. And what does means the "static" bind that PHP is trying to do when he shows: " Index::$securiy_level "
My configuration is: PHP 7, Ubuntu 16, apache2;
Any help I will thank in advanced.
If my question is not clear, please comment it too to clarify anything. | <php><model-view-controller> | 2019-03-01 17:54:31 | LQ_EDIT |
54,950,757 | Find case insensitive word or sentence in a body of text - PHP | <p>I am a complete newbie in PHP and programming generally. I am looking for an example or function of searching a sentence or a word in a body of text.</p>
<p>Thanks,</p>
<p>Matt</p>
| <php> | 2019-03-01 19:01:09 | LQ_CLOSE |
54,951,058 | creating array that compare arrays and state if they are true or false | how i can i improve this array so they compare in the same order. I'm comparing two arrays
enter code here
static bool CompareArray(int[] a, int[] b)
{
bool areLenghtsEqual = a.Length == b.Length;
if (!areLenghtsEqual)
{
return false;
}
return true;
} | <c#><visual-studio> | 2019-03-01 19:22:13 | LQ_EDIT |
54,951,111 | How to delete an undesirable row from pandas dataframe | <p>I have pandas dataframe for exemple like :</p>
<pre><code>id column1 column2
1 aaa mmm
2 bbb nnn
3 ccc ooo
4 ddd ppp
5 eee qqq
</code></pre>
<p>I have a list that contain some values from column1 :</p>
<pre><code>[bbb],[ddd],[eee]
</code></pre>
<p>I need python code in order to delete from the pandas all elements existing in the list </p>
<p>Ps: my pandas contains 280 000 samples so I need a fast code</p>
<p>Thanks </p>
| <python><pandas> | 2019-03-01 19:26:00 | LQ_CLOSE |
54,951,145 | Buttons in HTML/Javascript | <p>My button creates text in one line. So if I click it multiple times it will just display the text in one long line. I have come to ask if there is a way to replace the text created by the click when you press the button again. so that every time you press the button, it doesn't just add it to one long line, but instead displays only the text from that click.</p>
| <javascript><html> | 2019-03-01 19:29:01 | LQ_CLOSE |
54,952,112 | order in stl queue container | <p>I'm trying to make a queue of a class that uses a template, but when I try to use the functions front or back I get an error saying that the operator "<<" doesn't match the function. But if I use the function size, for example, it works fine. So, I was wondering that maybe it is because of the order in objects in the queue? I already tried to overload the << operator but didn't work. Thanks for any help.
Here's my code:</p>
<pre><code>//STL queue container
queue<stackType<int>> stack5;
stack5.push(5);
stack5.push(8);
stack5.push(6);
cout << "The front element of stack5 is: " << stack5.front() << endl;
</code></pre>
| <c++><queue> | 2019-03-01 20:50:44 | LQ_CLOSE |
54,952,660 | How to preserve data around a column index in each row of pandas data frame? | If I have an array with column indices for each row like this:
array = [NaN, 3, 4, 3, NaN]
And a pandas data frame like this:
1 2 3 4 5 6
1 1 NaN NaN NaN NaN 1
2 1 1 1 NaN NaN 1
3 NaN 1 1 1 1 1
4 NaN 1 1 1 NaN 1
5 1 NaN 1 NaN NaN 1
How do I keep values that overlap with my column index for each row such that I get a data frame like this:
1 2 3 4 5 6
1 NaN NaN NaN NaN NaN NaN
2 1 1 1 NaN NaN NaN
3 NaN 1 1 1 1 1
4 NaN 1 1 1 NaN NaN
5 NaN NaN NaN NaN NaN NaN
Where data associated with my rows column index is preserved?
| <python><pandas> | 2019-03-01 21:37:14 | LQ_EDIT |
54,955,354 | How to sort object of array values based on property values length | expected result should have keys & values of object ,but when sort with sortBy function, the result will be only values of object. Any help would be appreciated.
------------------------------------------------------------------------
[1]: https://jsfiddle.net/eswar786/k46a7vjq/3/
| <javascript><arrays><sorting><javascript-objects> | 2019-03-02 04:52:19 | LQ_EDIT |
54,955,761 | what does the statement means in Java? | <p>I find a strange statement while reading the openjdk resources.
<a href="https://i.stack.imgur.com/ElYbv.png" rel="nofollow noreferrer">enter image description here</a></p>
<p>what does the "found:{}" means?</p>
| <java> | 2019-03-02 06:15:34 | LQ_CLOSE |
54,955,947 | ionic app getting compailed and on building getting error | hi i am new to ionic and i had build an app using ionic it had running while i am compling on my pc and when i am trying to run the app using ionic cordova run android it was showing error and i found that all the variables i am using as the errors and i am unable to build the app too. so plz anyone help me with this issue
thank q in advance
This is the error i am getting
[12:00:54] typescript: src/pages/find-genie4/find-genie4.ts, line: 31
Argument of type '{ headers: { 'Authorization': string; }; }' is not assignable to parameter of type
'RequestOptionsArgs'. Types of property 'headers' are incompatible. Type '{ 'Authorization': string; }' is
not assignable to type 'Headers'. Object literal may only specify known properties, and ''Authorization''
does not exist in type 'Headers'.
L30: const token = JSON.parse(localStorage.getItem("userData"));
L31: this.http.get('https://api.findgenie.org/v1/my-requests/',{headers: {'Authorization': 'Token '+token.token}}
L32: this.posts = data.json().data.user_requests;
[12:00:54] typescript: src/pages/find-genie4/find-genie4.ts, line: 32
Property 'posts' does not exist on type 'FindGenie4Page'.
L31: this.http.get('https://api.findgenie.org/v1/my-requests/',{headers: {'Authorization': 'Token '+token.token}}).subscribe(data => {
L32: this.posts = data.json().data.user_requests;
L33: this.rating = data.json().data.user_details.rating;
[12:00:54] typescript: src/pages/find-genie4/find-genie4.ts, line: 33
Property 'rating' does not exist on type 'FindGenie4Page'.
L32: this.posts = data.json().data.user_requests;
L33: this.rating = data.json().data.user_details.rating;
L34: console.log("this.posts",this.posts)
[12:00:54] typescript: src/pages/find-genie4/find-genie4.ts, line: 34
Property 'posts' does not exist on type 'FindGenie4Page'.
L33: this.rating = data.json().data.user_details.rating;
L34: console.log("this.posts",this.posts)
L35: });
| <angular><ionic-framework><django-rest-framework><ionic3> | 2019-03-02 06:45:03 | LQ_EDIT |
54,957,193 | why Linux VmSize VmData is lager than estimation from code? | I want to know how many memory will take when the code is running.
I sum all memory used in my code and use gcc to convert to an executable bin file.
When I the bin file, and use cat /proc/$PID/status, the VmSize VmData is much larger than expected. Even if remove all code but only sleep, the result still is the same.
VmPeak: 12816 kB
VmSize: 12816 kB
VmLck: 0 kB
VmPin: 0 kB
VmHWM: 964 kB
VmRSS: 964 kB
VmData: 204 kB
VmStk: 136 kB
VmExe: 56 kB
VmLib: 2100 kB
VmPTE: 48 kB
VmPMD: 12 kB
VmSwap: 0 kB
- Why the memory is so large even if no data is in my code?
- Why VmData is the same no matter I removed variables in code or not? Why not change smaller?
- how to get memory my code is using exactly? | <c><linux><gcc><memory> | 2019-03-02 09:47:13 | LQ_EDIT |
54,958,545 | how can i code this function?? C# gridview | so i want to get daily incomings(from gridview) by push a button
private void button1_Click(object sender, EventArgs e)
{
int sum = 0;
if (DateTime.Today == SalesGridView)
{
for (int i = 0; i < SalesGridView.Rows.Count; ++i)
{
sum += Convert.ToInt32(SalesGridView.Rows[i].Cells[3].Value);
}
label1.Text = sum.ToString();
}
..................................................................................... | <c#><winforms><gridview> | 2019-03-02 12:30:19 | LQ_EDIT |
54,961,026 | how to add days using Date without using Calender | so i made a class called XDate which extends java.util.Date but do things little different, for example getMonth return a value from 1-12 and not 0-11,
now , i want to make a function called addDays(int a), wich bassicly uses the current date (the date can be edited in the constructor) and add the number a to the days section, using Date.getTime() and the Date constructor that gets miliseconds . | <java><date> | 2019-03-02 17:18:23 | LQ_EDIT |
54,964,665 | If you allow, you can help solve this problem | Gradle 'My Application' project refresh failed
Error:Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at https://docs.gradle.org/4.1/userguide/gradle_daemon.html
Please read the following process output to find out more:
-----------------------
-Xmx1536m: illegal argument
usage: java [-options] class
where options include:
-help print out this message
-version print out the build version
-v -verbose turn on verbose mode
-debug enable remote JAVA debugging
-noasyncgc don't allow asynchronous garbage collection
-verbosegc print a message when garbage collection occurs
-noclassgc disable class garbage collection
-ss<number> set the maximum native stack size for any thread
-oss<number> set the maximum Java stack size for any thread
-ms<number> set the initial Java heap size
-mx<number> set the maximum Java heap size
-classpath <directories separated by semicolons>
list directories in which to look for classes
-prof[:<file>] output profiling data to .\java.prof or .\<file>
-verify verify all classes when read in
-verifyremote verify classes read in over the network [default]
-noverify do not verify any class
-nojit disable JIT compiler
Consult IDE log for more details (Help | Show Log) | <android><gradle><android-gradle-plugin> | 2019-03-03 01:12:09 | LQ_EDIT |
54,964,945 | How to Find a String Among Thousands of Code Pages? | <p>Lets say you downloaded a free PHP script from GitHub and it has thousands of PHP files, language files, etc.</p>
<p>Now if you need to customize a specific line of code and you don't know where it is located, you have to go through each file to find where it belongs to and after spending a huge amount of time, you may be lucky to find it.</p>
<p>Is there any way to find the code faster (offline or in cPanel)?</p>
| <php><linux><cpanel> | 2019-03-03 02:05:47 | LQ_CLOSE |
54,965,037 | Spliting a number like 15 into these(0, 1, 2, 4, 8) Python | <p>I need to split a number like 15 into these(0, 1, 2, 4, 8) different numbers that one is used only once.</p>
<p>For example, 15 would output (8, 4, 2, 1).</p>
<p>I am a beginner programmer so I apologize for my lack of understanding in advance.</p>
<p>Thank you.</p>
| <python><python-3.x><numbers> | 2019-03-03 02:28:43 | LQ_CLOSE |
54,965,670 | How to undo a commit in freshly initialized repository (not pushed) | <p>I intialized a repo but now want to <a href="https://stackoverflow.com/questions/2845731/how-to-uncommit-my-last-commit-in-git">undo</a> the <strong>first</strong> (and only) commit. </p>
<p>These <a href="https://stackoverflow.com/a/2846154/5783745">three solutions</a> for undoing a commit all error because the <a href="https://stackoverflow.com/questions/12267912/git-fatal-ambiguous-argument-head-unknown-revision-or-path-not-in-the-workin">freshly created repo points to a ref that doesn't exist yet</a></p>
<p>So my question is how do I undo a commit in a repo that hasn't been pushed and hence hasn't got a ref yet? </p>
<p>Note: I have also tried <code>git commit -amend</code> without success</p>
| <git> | 2019-03-03 04:51:58 | LQ_CLOSE |
54,966,222 | Interact with object values in JavaScript | <pre><code>a = [{name: James, Location: London},
{name: Martin, Location: Seattle},...
{name: George, Location: New York}];
</code></pre>
<p>How can I find the count of number of items present?
How can I replace George with Suarez?
How can I display only <em>"Martin from Seattle"</em> on the screen?
How can I add a new object in between first and second?</p>
| <javascript><arrays> | 2019-03-03 06:35:31 | LQ_CLOSE |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.