问:
Half of Matrix Size Missing
I wanted to ask why is it that some of my matrices in Python are missing a size value? The matrices/arrays that re defined show the numbers in them, but the size is missing and it is throwing me other errors because of it. Why is the variable explorer missing this info or why is it that Python can't identify the size?

Example of what happens

Code:

```<code>import numpy as np
import pylab
from scipy.integrate import odeint
import matplotlib.pyplot as plt
#import random
import mpl_toolkits.mplot3d.axes3d as p3
import random as rand

ParticleCount = 100 ## of particles to generate energies for energy generation
binsize = 15 #Determines bin size for historgram of electron energies
S1 = 0.0200001 #Specify minimum radius particles may be generated
S2 = 0.0200002 #Specify maximum radius particles may be generated
phi1 = -90
phi2 = 90
phi1rad = phi1*(np.pi/180)
phi2rad = phi2*(np.pi/180)

#Generate random positions for each particle between s1 and s2
#ICPositions = np.array([])
ICPositions = np.empty([3,ParticleCount],dtype = float)
SphPositions = np.empty([3,ParticleCount],dtype = float)
for i in range(0,ParticleCount):
    #In Spherical: Generates random position with boundaries of: S1<r<S2
    rrand = (S2 - S1)*rand.uniform(0,1) + S1 #Random # generation for component x between s1 and s2
    thetarand = (2*np.pi)*rand.uniform(0,1) #Random # generation for component y between s1 and s2
    phirand = np.arcsin((np.sin(phi2rad) - np.sin(phi1rad))*rand.uniform(0,1) + np.sin(phi1rad))
    xrand = RStart*np.sin(phirand)*np.cos(thetarand)
    yrand = RStart*np.sin(phirand)*np.sin(thetarand)
    zrand = RStart*np.cos(phirand)
    sphArray = np.array([RStart,thetarand,phirand])
    randArray = np.array([xrand,yrand,zrand])
    randArray = np.array(randArray,dtype = float)
    if ICPositions.size == 0:
        ICPositions = np.array([randArray])
    else:
        ICPositions = np.append(ICPositions,[randArray],axis = 0)

print(ICPositions)
</code>```

答:
Cleaned up your code a little...

```<code>import numpy as np
import random as rand

ParticleCount = 100 # of particles to generate energies for energy generation
S1 = 0.0200001 #Specify minimum radius particles may be generated
S2 = 0.0200002 #Specify maximum radius particles may be generated
phi1 = -20
phi2 = 20
phi1rad = phi1*(np.pi/180)
phi2rad = phi2*(np.pi/180)

#Generate random positions for each particle between s1 and s2
sphArray = np.zeros([3,ParticleCount])
randArray = np.empty([3,ParticleCount])
for i in range(0,ParticleCount):
    #In Spherical: Generates random position with boundaries of: S1<r<S2
    RStart = (S2 - S1)*rand.uniform(0,1) + S1 #Random # generation for component x between s1 and s2
    thetarand = (2*np.pi)*rand.uniform(0,1) #Random # generation for component y between s1 and s2
    phirand = np.arcsin((np.sin(phi2rad) - np.sin(phi1rad))*rand.uniform(0,1) + np.sin(phi1rad))
    xrand = RStart*np.cos(phirand)*np.cos(thetarand)
    yrand = RStart*np.cos(phirand)*np.sin(thetarand)
    zrand = RStart*np.sin(phirand)
    sphArray[:,i] = [RStart,thetarand,phirand]
    randArray[:,i] = [xrand,yrand,zrand]
</code>```

Some hints:

Stackoverflow is not meant to post messy code hoping that somebody will clean it up for you.

If you define phi from -90 to 90 you need to adapt the conversion from spherical to Cartesian coordinates accordingly.

No need to define and append arrays over and over. You know its size beforehand. Better create it and fill it while looping.

There is no information missing. You have defined SphPositions and randArray/SphArray differently. The former is a 2D array, the latter are 1D.

Title: Half of Matrix Size Missing

Body:
I wanted to ask why is it that some of my matrices in Python are missing a size value? The matrices/arrays that re defined show the numbers in them, but the size is missing and it is throwing me other errors because of it. Why is the variable explorer missing this info or why is it that Python can't identify the size?

Example of what happens

Code:

import numpy as np
import pylab
from scipy.integrate import odeint
import matplotlib.pyplot as plt
#import random
import mpl_toolkits.mplot3d.axes3d as p3
import random as rand

ParticleCount = 100 ## of particles to generate energies for energy generation
binsize = 15 #Determines bin size for historgram of electron energies
S1 = 0.0200001 #Specify minimum radius particles may be generated
S2 = 0.0200002 #Specify maximum radius particles may be generated
phi1 = -90
phi2 = 90
phi1rad = phi1*(np.pi/180)
phi2rad = phi2*(np.pi/180)

#Generate random positions for each particle between s1 and s2
#ICPositions = np.array([])
ICPositions = np.empty([3,ParticleCount],dtype = float)
SphPositions = np.empty([3,ParticleCount],dtype = float)
for i in range(0,ParticleCount):
    #In Spherical: Generates random position with boundaries of: S1<r<S2
    rrand = (S2 - S1)*rand.uniform(0,1) + S1 #Random # generation for component x between s1 and s2
    thetarand = (2*np.pi)*rand.uniform(0,1) #Random # generation for component y between s1 and s2
    phirand = np.arcsin((np.sin(phi2rad) - np.sin(phi1rad))*rand.uniform(0,1) + np.sin(phi1rad))
    xrand = RStart*np.sin(phirand)*np.cos(thetarand)
    yrand = RStart*np.sin(phirand)*np.sin(thetarand)
    zrand = RStart*np.cos(phirand)
    sphArray = np.array([RStart,thetarand,phirand])
    randArray = np.array([xrand,yrand,zrand])
    randArray = np.array(randArray,dtype = float)
    if ICPositions.size == 0:
        ICPositions = np.array([randArray])
    else:
        ICPositions = np.append(ICPositions,[randArray],axis = 0)

print(ICPositions)

Body:
Cleaned up your code a little...

import numpy as np
import random as rand

ParticleCount = 100 # of particles to generate energies for energy generation
S1 = 0.0200001 #Specify minimum radius particles may be generated
S2 = 0.0200002 #Specify maximum radius particles may be generated
phi1 = -20
phi2 = 20
phi1rad = phi1*(np.pi/180)
phi2rad = phi2*(np.pi/180)

#Generate random positions for each particle between s1 and s2
sphArray = np.zeros([3,ParticleCount])
randArray = np.empty([3,ParticleCount])
for i in range(0,ParticleCount):
    #In Spherical: Generates random position with boundaries of: S1<r<S2
    RStart = (S2 - S1)*rand.uniform(0,1) + S1 #Random # generation for component x between s1 and s2
    thetarand = (2*np.pi)*rand.uniform(0,1) #Random # generation for component y between s1 and s2
    phirand = np.arcsin((np.sin(phi2rad) - np.sin(phi1rad))*rand.uniform(0,1) + np.sin(phi1rad))
    xrand = RStart*np.cos(phirand)*np.cos(thetarand)
    yrand = RStart*np.cos(phirand)*np.sin(thetarand)
    zrand = RStart*np.sin(phirand)
    sphArray[:,i] = [RStart,thetarand,phirand]
    randArray[:,i] = [xrand,yrand,zrand]

Some hints:

Stackoverflow is not meant to post messy code hoping that somebody will clean it up for you.

If you define phi from -90 to 90 you need to adapt the conversion from spherical to Cartesian coordinates accordingly.

No need to define and append arrays over and over. You know its size beforehand. Better create it and fill it while looping.

There is no information missing. You have defined SphPositions and randArray/SphArray differently. The former is a 2D array, the latter are 1D.


来源: stackexchange

问:
Which Class is missing in the following program?
```<code>class Test
{
int unique_element(int arr[],int n)
{
    int result=0;
    for(int i=0;i<n;i++)
    {
        int sum=0;
        x=(1<<i);
        for(int j=0;j<n;j++)
        {
            if(arr[j]&x)
                sum++;
        }
        if(sum%3)
        {
            result |= x;
            System.out.println(x);
        }
    }
    return(result);
}
public static void main(String[] args){
    int arr[]={3,1,1,9,3,1,3,9,9,5};
    N=arr.length;
    System.out.println(unique_element(arr[],N));
    }
}
</code>```

Program for every element appears 3 times in a given arr except 1 element. Logic is correct but I'm getting error in print statement like .class is expected.

Test.java:28:error: '.class' expected

System.out.println(unique_element(arr[],N));

and i'm getting error in if statement --> if(arr[j] & x){ sum++;}

Test.java:298: error: incompatible types: int cannot be converted to boolean

```<code>      if(arr[j]&x)
</code>```

答:
You are calling the method "unique_element" from static method.

To solve the problem either declare the method "unique_element" to be static or call it     under the context of object

```<code>Test t = new Test();
int arr[]={3,1,1,9,3,1,3,9,9,5};
int N = arr.length;
t.unique_element(arr,N);
</code>```

Please notice, To pass array, You should call "unique_element" with "arr" as argument rather than "arr[]".

ContentLicense: CC BY-SA 4.0

Body:
class Test
{
int unique_element(int arr[],int n)
{
    int result=0;
    for(int i=0;i<n;i++)
    {
        int sum=0;
        x=(1<<i);
        for(int j=0;j<n;j++)
        {
            if(arr[j]&x)
                sum++;
        }
        if(sum%3)
        {
            result |= x;
            System.out.println(x);
        }
    }
    return(result);
}
public static void main(String[] args){
    int arr[]={3,1,1,9,3,1,3,9,9,5};
    N=arr.length;
    System.out.println(unique_element(arr[],N));
    }
}

Program for every element appears 3 times in a given arr except 1 element. Logic is correct but I'm getting error in print statement like .class is expected.

Test.java:28:error: '.class' expected

System.out.println(unique_element(arr[],N));

and i'm getting error in if statement --> if(arr[j] & x){ sum++;}

Test.java:298: error: incompatible types: int cannot be converted to boolean

      if(arr[j]&x)

Body:
You are calling the method "unique_element" from static method.

To solve the problem either declare the method "unique_element" to be static or call it     under the context of object

Test t = new Test();
int arr[]={3,1,1,9,3,1,3,9,9,5};
int N = arr.length;
t.unique_element(arr,N);

Please notice, To pass array, You should call "unique_element" with "arr" as argument rather than "arr[]".


问:
Can I change the appearance of an html image during hover without a second image?
Is there a way to change the appearance of an icon (ie. contrast / luminosity) when I hover the cursor, without requiring a second image file (or without requiring a hidden portion of the image)?</p>

答: The way I usually see things done with smaller images such as buttons it that only a certain portion of the image is shown. Then many states of the picture will make up a larger picture which gets shifted around behind the visible port. I'll delete this when someone has code.</p>

OwnerDisplayName: Brent Nesbitt

ContentLicense: CC BY-SA 2.5

LastEditorDisplayName: Brent Nesbitt

OwnerDisplayName: Flame


问:
Using the g++ C++ compiler from cygwin
I am trying to execute my first "Hello World!" in C++. I am using Windows XP, and I have installed cygwin, in which the g++ C++ compiler is installed. I have written a small hello-world program, and saved it in hello.cpp. From the command prompt I write:

g++ hello.cpp

But I get:

'g++' is not recognized as an internal or external command, operable program or batch file.

I have installed cygwin in my D:\programs\cygwin. I have made another directory with my hello-world file in D:\cpp. Something with my installation or my paths seems to be not Ok, but I cannot figure what. I have run the exe file of cygwin, and in the installation directory I have got all necessary files, I think: bin folder, lib, Cygwin.bat, etc.

I have read that in case of such error message I should check whether the cygwin1.dll file is copied into the main folder of Windows. Is this the C:\WINDOWS directory? I have looked there, and I don't have such a file there. I have cygwin1.dll in the bin folder of cygwin: D:\programs\cygwin\bin.
Also, how do I check whether the bin folder (D:\programs\cygwin\bin) is considered in the search path of commands?

I think that the hello-world program shouldn't contain any syntax errors, I have just copied it. Also, when I write

g++ -v

I get the same error message: that the command is not recognized.
I would appreciate if someone give me a hint what should I look at. Thank you.

Here is the code of the hello-world program:

```<code>#include <iostream>
using namespace std;

int main() {
  cout <<"Hello World!"<<endl;
  return 0;
}
</code>```

I have installed g++, and now when I type g++ -v, I get: Reading specs from: \d\cygnus\cygwin-b20\H-i586-cygwin32\bin..\lib\gcc-lib\i586-cygwin32\egcs-2.91.57\specs gcc version egcs-2.91.57 19980901 (egcs-1.1 release)

In the bin directory I have both g++.exe, and gcc.exe. I don't understand why I get "gcc" above and not "g++". I don't know how important this is, but I receive an error message when I try to compile the program in the DOS command prompt:

g++ hello.cpp

I get:

```<code>hello.cpp:1: parse error before character 0357
hello.cpp: In function 'int main()':
hello.cpp:'cout' undeclared (first use this function)
hello.cpp: (Each undeclared identifier is reported only once
hello.cpp: for each function it appears in.)
hello.cpp: 'endl' undeclared (first use this function)
</code>```

And here is what I get when I try to compile the program in the cygwin shell:

```<code>hello.cpp:1: parse error before character 0357
hello.cpp: In function 'int main()':
hello.cpp:'cout' undeclared (first use this function)
hello.cpp: (Each undeclared identifier is reported only once
hello.cpp: for each function it appears in.)
hello.cpp: 'endl' undeclared (first use this function)
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files
</code>```

答:
Make sure they c:\cygwin\bin is in the PATH.

Hope it helps.

Title: Using the g++ C++ compiler from cygwin

Body:
I am trying to execute my first "Hello World!" in C++. I am using Windows XP, and I have installed cygwin, in which the g++ C++ compiler is installed. I have written a small hello-world program, and saved it in hello.cpp. From the command prompt I write:

g++ hello.cpp

But I get:

'g++' is not recognized as an internal or external command, operable program or batch file.

I have installed cygwin in my D:\programs\cygwin. I have made another directory with my hello-world file in D:\cpp. Something with my installation or my paths seems to be not Ok, but I cannot figure what. I have run the exe file of cygwin, and in the installation directory I have got all necessary files, I think: bin folder, lib, Cygwin.bat, etc.

I have read that in case of such error message I should check whether the cygwin1.dll file is copied into the main folder of Windows. Is this the C:\WINDOWS directory? I have looked there, and I don't have such a file there. I have cygwin1.dll in the bin folder of cygwin: D:\programs\cygwin\bin.
Also, how do I check whether the bin folder (D:\programs\cygwin\bin) is considered in the search path of commands?

I think that the hello-world program shouldn't contain any syntax errors, I have just copied it. Also, when I write

g++ -v

I get the same error message: that the command is not recognized.
I would appreciate if someone give me a hint what should I look at. Thank you.

Here is the code of the hello-world program:

#include <iostream>
using namespace std;

int main() {
  cout <<"Hello World!"<<endl;
  return 0;
}

I have installed g++, and now when I type g++ -v, I get: Reading specs from: \d\cygnus\cygwin-b20\H-i586-cygwin32\bin..\lib\gcc-lib\i586-cygwin32\egcs-2.91.57\specs gcc version egcs-2.91.57 19980901 (egcs-1.1 release)

In the bin directory I have both g++.exe, and gcc.exe. I don't understand why I get "gcc" above and not "g++". I don't know how important this is, but I receive an error message when I try to compile the program in the DOS command prompt:

g++ hello.cpp

I get:

hello.cpp:1: parse error before character 0357
hello.cpp: In function 'int main()':
hello.cpp:'cout' undeclared (first use this function)
hello.cpp: (Each undeclared identifier is reported only once
hello.cpp: for each function it appears in.)
hello.cpp: 'endl' undeclared (first use this function)

And here is what I get when I try to compile the program in the cygwin shell:

hello.cpp:1: parse error before character 0357
hello.cpp: In function 'int main()':
hello.cpp:'cout' undeclared (first use this function)
hello.cpp: (Each undeclared identifier is reported only once
hello.cpp: for each function it appears in.)
hello.cpp: 'endl' undeclared (first use this function)
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files

LastEditorDisplayName: Rich B

OwnerDisplayName: Sasha


问:
Google Adwords and CodeIgniter GET Variable Callback URL
I am trying to implement Google Adwords with a website that has been developed using CodeIgniter, I believe it requires a "200" status code when they add a GET variable to the URL.

I've been getting emails from Google saying that it's receiving a 404 status code when it goes to my URL. When I try to add ?test=test to the end of my URL it does in fact return a 404:

Through my google searches, I have found this useful link:

http://codeigniter.com/forums/viewthread/154153/#746115

Which states I need to change my config to include these:

```<code>$config['uri_protocol']    = "PATH_INFO";
$config['enable_query_strings'] = TRUE;
</code>```

Before my uri_protocol was set to "REQUEST_URI". I have tested with ?test=test and it does work! But now all my links are not working, when I switch it to PATH_INFO, what do I need to do to fix my links?

Right now I am using Mod Rewrite to shorten the URLs so that the addresses are like mydomain.com/blog, mydomain.com/about, and my controller just points to the appropriate view. Should I not change my uri_protocol, if so how can I include a GET variable and NOT get a 404?

Any advice would help thank you!

UDPATE: Here's my htaccess file:

```<code>RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
</code>```

答:
You need to do the following
1- $config['enable_query_strings'] = TRUE;

2- $config['permitted_uri_chars'] = 'a-z 0-9~%.:_-\?=&';

AND remove the "?" from your htaccess file.

3- RewriteRule ^(.*)$ index.php/$1 [QSA,L]

Body:
I am trying to implement Google Adwords with a website that has been developed using CodeIgniter, I believe it requires a "200" status code when they add a GET variable to the URL.

I've been getting emails from Google saying that it's receiving a 404 status code when it goes to my URL. When I try to add ?test=test to the end of my URL it does in fact return a 404:

Through my google searches, I have found this useful link:

http://codeigniter.com/forums/viewthread/154153/#746115

Which states I need to change my config to include these:

$config['uri_protocol']    = "PATH_INFO";
$config['enable_query_strings'] = TRUE;

Before my uri_protocol was set to "REQUEST_URI". I have tested with ?test=test and it does work! But now all my links are not working, when I switch it to PATH_INFO, what do I need to do to fix my links?

Right now I am using Mod Rewrite to shorten the URLs so that the addresses are like mydomain.com/blog, mydomain.com/about, and my controller just points to the appropriate view. Should I not change my uri_protocol, if so how can I include a GET variable and NOT get a 404?

Any advice would help thank you!

UDPATE: Here's my htaccess file:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

ContentLicense: CC BY-SA 3.0


问:
MYSQL remove duplicates from table with two columns
Have table contents_tags

```<code>+------------+--------+
| content_id | tag_id |
+------------+--------+
|          1 |      1 |
|          1 |      2 |
|          1 |      2 |
|          2 |      3 |
|          2 |      4 |
|          2 |      4 |
</code>```

I want create unique index with two columns

```<code>alter table contents_tags ADD UNIQUE `contents_tags` (`content_id`, `tag_id`);
</code>```

But I already have duplicate entries and get error:

ERROR 1062 (23000): Duplicate entry '1-2' for key 'contents_tags'

```<code>alter IGNORE table contents_tags ADD UNIQUE `contents_tags` (`content_id`, `tag_id`);
</code>```

IGNORE - don't work in Mysql 8

How can I remove duplicates?

答:
You can try below -</p>

```<code>DELETE FROM contents_tags
WHERE
    content_id IN (
    SELECT
        content_id
    FROM (
        SELECT
            content_id,
            ROW_NUMBER() OVER (
                PARTITION BY content_id,tag_id
                ORDER BY content_id,tag_id) AS row_num
        FROM
            contents_tags

    ) t
    WHERE row_num > 1
);
</code>```

Body:
Have table contents_tags

+------------+--------+
| content_id | tag_id |
+------------+--------+
|          1 |      1 |
|          1 |      2 |
|          1 |      2 |
|          2 |      3 |
|          2 |      4 |
|          2 |      4 |

I want create unique index with two columns

alter table contents_tags ADD UNIQUE `contents_tags` (`content_id`, `tag_id`);

But I already have duplicate entries and get error:

ERROR 1062 (23000): Duplicate entry '1-2' for key 'contents_tags'

alter IGNORE table contents_tags ADD UNIQUE `contents_tags` (`content_id`, `tag_id`);

IGNORE - don't work in Mysql 8

How can I remove duplicates?

Body:
You can try below -

DELETE FROM contents_tags
WHERE
    content_id IN (
    SELECT
        content_id
    FROM (
        SELECT
            content_id,
            ROW_NUMBER() OVER (
                PARTITION BY content_id,tag_id
                ORDER BY content_id,tag_id) AS row_num
        FROM
            contents_tags

    ) t
    WHERE row_num > 1
);


问:
ERROR Error: Uncaught (in promise): NullInjectorError: StaticInjectorError(AppModule)[FormBuilder]
in my angular app when I add routes in gifts-routing.module.ts this error appears
and when i remove the routes it works
but i still need to route
so how can i solve this error

```<code>ERROR Error: Uncaught (in promise): NullInjectorError: StaticInjectorError(AppModule)[FormBuilder]:
  StaticInjectorError(Platform: core)[FormBuilder]:
    NullInjectorError: No provider for FormBuilder!
NullInjectorError: StaticInjectorError(AppModule)[FormBuilder]:
  StaticInjectorError(Platform: core)[FormBuilder]:
    NullInjectorError: No provider for FormBuilder!
</code>```

gifts.module.ts

```<code>import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { GiftsRoutingModule } from './gifts-routing.module';
import { GiftListComponent } from './components/gift-list/gift-list.component';
import { GiftFormComponent } from './components/gift-form/gift-form.component';
import { SharedModule } from '../shared/shared.module';

@NgModule({
  declarations: [GiftListComponent, GiftFormComponent],
  imports: [
    CommonModule,
    GiftsRoutingModule,
    SharedModule
  ]
})
export class GiftsModule { }
</code>```

gifts-routing.module.ts

```<code>import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LayoutComponent } from '../shared/components/layout/layout.component';
import { GiftListComponent } from './components/gift-list/gift-list.component';

const routes: Routes = [
  {
    path: '',
    component: LayoutComponent,
    children: [
      {
        path:'',
        component: GiftListComponent
      }
    ]
  }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class GiftsRoutingModule { }
</code>```

and I also import the ReactiveFormsModule and FormsModule inside my shared module

shared.module.ts

```<code>import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { SharedRoutingModule } from './shared-routing.module';
import { LayoutComponent } from './components/layout/layout.component';
import { NavbarComponent } from './components/layout/navbar/navbar.component';

import { ReactiveFormsModule, FormsModule } from '@angular/forms'
import {
  MatButtonModule,
  MatCardModule,
  MatInputModule,
  MatIconModule,
  MatTabsModule,
  MatTableModule,
  MatPaginatorModule,
  MatSortModule,
  MatProgressSpinnerModule,
  MatSlideToggleModule,
  MatDialogModule,
  MatSelectModule,
  MatDatepickerModule,
  MatToolbarModule,
  MatListModule,
  MatMenuModule,
  MatSidenavModule,
  MatTooltipModule,
  MatRadioModule,
  MatStepperModule,
  MatCheckboxModule,
  MatExpansionModule,
  MatProgressBarModule,
  MatNativeDateModule,
} from '@angular/material';
import { RouterModule } from '@angular/router';
import { FloatingButtonComponent } from './components/floating-button/floating-button.component';
import { ConfirmComponent } from './components/confirm/confirm.component';
@NgModule({
  declarations: [LayoutComponent, NavbarComponent, FloatingButtonComponent, ConfirmComponent],
  imports: [
    CommonModule,
    SharedRoutingModule,
    ReactiveFormsModule,
    RouterModule,
    FormsModule,
    CommonModule,
    MatButtonModule,
    MatMenuModule,
    MatSidenavModule,
    MatListModule,
    MatToolbarModule,
    MatIconModule,
    MatCardModule,
    MatTabsModule,
    MatInputModule,
    MatTableModule,
    MatPaginatorModule,
    MatSortModule,
    MatProgressSpinnerModule,
    MatSlideToggleModule,
    MatDialogModule,
    MatSelectModule,
    MatDatepickerModule,
    MatProgressBarModule,
    MatTooltipModule,
    MatRadioModule,
    MatStepperModule,
    MatCheckboxModule,
    MatExpansionModule,
    MatNativeDateModule,

  ],
  exports: [
    CommonModule,
    ReactiveFormsModule,
    RouterModule,
    FormsModule,
    CommonModule,
    MatButtonModule,
    MatMenuModule,
    MatSidenavModule,
    MatListModule,
    MatToolbarModule,
    MatIconModule,
    MatCardModule,
    MatTabsModule,
    MatInputModule,
    MatTableModule,
    MatPaginatorModule,
    MatSortModule,
    MatProgressSpinnerModule,
    MatSlideToggleModule,
    MatDialogModule,
    MatSelectModule,
    MatDatepickerModule,
    MatProgressBarModule,
    MatTooltipModule,
    MatRadioModule,
    MatStepperModule,
    MatCheckboxModule,
    MatExpansionModule,
  ],
  entryComponents: [ConfirmComponent]
})
export class SharedModule {

}
</code>```

what I should do to solve this error, please?

答:
Import this in your app module.ts :

```<code>import { FormsModule, ReactiveFormsModule } from '@angular/forms';
</code>```

And In Imports :

```<code>imports: [
    FormsModule,
    ReactiveFormsModule,
  ],
</code>```

Body:
in my angular app when I add routes in gifts-routing.module.ts this error appears
and when i remove the routes it works
but i still need to route
so how can i solve this error

ERROR Error: Uncaught (in promise): NullInjectorError: StaticInjectorError(AppModule)[FormBuilder]:
  StaticInjectorError(Platform: core)[FormBuilder]:
    NullInjectorError: No provider for FormBuilder!
NullInjectorError: StaticInjectorError(AppModule)[FormBuilder]:
  StaticInjectorError(Platform: core)[FormBuilder]:
    NullInjectorError: No provider for FormBuilder!

gifts.module.ts

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { GiftsRoutingModule } from './gifts-routing.module';
import { GiftListComponent } from './components/gift-list/gift-list.component';
import { GiftFormComponent } from './components/gift-form/gift-form.component';
import { SharedModule } from '../shared/shared.module';

@NgModule({
  declarations: [GiftListComponent, GiftFormComponent],
  imports: [
    CommonModule,
    GiftsRoutingModule,
    SharedModule
  ]
})
export class GiftsModule { }

gifts-routing.module.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LayoutComponent } from '../shared/components/layout/layout.component';
import { GiftListComponent } from './components/gift-list/gift-list.component';

const routes: Routes = [
  {
    path: '',
    component: LayoutComponent,
    children: [
      {
        path:'',
        component: GiftListComponent
      }
    ]
  }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class GiftsRoutingModule { }

and I also import the ReactiveFormsModule and FormsModule inside my shared module

shared.module.ts

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { SharedRoutingModule } from './shared-routing.module';
import { LayoutComponent } from './components/layout/layout.component';
import { NavbarComponent } from './components/layout/navbar/navbar.component';

import { ReactiveFormsModule, FormsModule } from '@angular/forms'
import {
  MatButtonModule,
  MatCardModule,
  MatInputModule,
  MatIconModule,
  MatTabsModule,
  MatTableModule,
  MatPaginatorModule,
  MatSortModule,
  MatProgressSpinnerModule,
  MatSlideToggleModule,
  MatDialogModule,
  MatSelectModule,
  MatDatepickerModule,
  MatToolbarModule,
  MatListModule,
  MatMenuModule,
  MatSidenavModule,
  MatTooltipModule,
  MatRadioModule,
  MatStepperModule,
  MatCheckboxModule,
  MatExpansionModule,
  MatProgressBarModule,
  MatNativeDateModule,
} from '@angular/material';
import { RouterModule } from '@angular/router';
import { FloatingButtonComponent } from './components/floating-button/floating-button.component';
import { ConfirmComponent } from './components/confirm/confirm.component';
@NgModule({
  declarations: [LayoutComponent, NavbarComponent, FloatingButtonComponent, ConfirmComponent],
  imports: [
    CommonModule,
    SharedRoutingModule,
    ReactiveFormsModule,
    RouterModule,
    FormsModule,
    CommonModule,
    MatButtonModule,
    MatMenuModule,
    MatSidenavModule,
    MatListModule,
    MatToolbarModule,
    MatIconModule,
    MatCardModule,
    MatTabsModule,
    MatInputModule,
    MatTableModule,
    MatPaginatorModule,
    MatSortModule,
    MatProgressSpinnerModule,
    MatSlideToggleModule,
    MatDialogModule,
    MatSelectModule,
    MatDatepickerModule,
    MatProgressBarModule,
    MatTooltipModule,
    MatRadioModule,
    MatStepperModule,
    MatCheckboxModule,
    MatExpansionModule,
    MatNativeDateModule,

  ],
  exports: [
    CommonModule,
    ReactiveFormsModule,
    RouterModule,
    FormsModule,
    CommonModule,
    MatButtonModule,
    MatMenuModule,
    MatSidenavModule,
    MatListModule,
    MatToolbarModule,
    MatIconModule,
    MatCardModule,
    MatTabsModule,
    MatInputModule,
    MatTableModule,
    MatPaginatorModule,
    MatSortModule,
    MatProgressSpinnerModule,
    MatSlideToggleModule,
    MatDialogModule,
    MatSelectModule,
    MatDatepickerModule,
    MatProgressBarModule,
    MatTooltipModule,
    MatRadioModule,
    MatStepperModule,
    MatCheckboxModule,
    MatExpansionModule,
  ],
  entryComponents: [ConfirmComponent]
})
export class SharedModule {

}

what I should do to solve this error, please?

Body:
Import this in your app module.ts :

import { FormsModule, ReactiveFormsModule } from '@angular/forms';

And In Imports :

imports: [
    FormsModule,
    ReactiveFormsModule,
  ],


问:
Run multiple functions using turtle.screen.onkey() in Python
For the code:

from turtle import Screen, Turtle, bgcolor

# --- functions ---

def delSec(string):
    if len(string) == 1:
        return "0" + string
    else:
        return string

def tick():
    global milisecs, ticking

    turtle.clear()

    if milisecs < 0:
        turtle.write("TIMER DONE", align='center', font=FONT)
        ticking = False
        return
    else:
        turtle.write(delSec(str(milisecs//(60*60*10)))+":"+delSec(str((milisecs%(60*60*10))//(60*10)))+":"+delSec(str((milisecs%(60*10))//10))+":"+str(milisecs%10), align='center', font=FONT)
##        turtle.write(delSec(str(milisecs//(60*60)))+":"+delSec(str((milisecs%(60*60))//(60)))+":"+delSec(str((milisecs%(60))//1)), align='center', font=FONT)
        if not paused:
              milisecs -= 1

    screen.ontimer(tick, 100)

def reset():
    global milisecs, ticking, key_reset, key_pause, key_both
    #global paused

    print("reset")

    screen.onkey(None, key_reset)  # Disable event handler inside handler
    screen.onkey(None, key_pause)  # Disable event handler inside handler
    screen.onkey(None, key_both)

    milisecs = sum(time*10)

    if not ticking:
        ticking = True
        tick()

    #paused = False

    screen.onkey(reset, key_reset)  # Reenable event handler
    screen.onkey(pause, key_pause)  # Reenable event handler
    screen.onkey(reset, key_both)
    screen.onkey(pause, key_both)

def pause():
    global paused

    print("pause/unpause")

    paused = not paused

# --- main ---

bgcolor('dodgerblue')
FONT = ("Arial", 60, "normal")

strings = input("Please enter the time: ").strip().split(' ')

time = [60 ** (len(strings) - index - 1) * int(unit) for index, unit in enumerate(strings)]

milisecs = -1
ticking = False
paused = False
key_reset = "r"
key_pause = "p"
key_both = "b"

screen = Screen()

turtle = Turtle()
turtle.hideturtle()
turtle.color('white')

reset()

screen.listen()
screen.mainloop()
```

I want to both pause and reset the timer when I click the key "b". I tried doing this by running both functions reset and pause. However, as expected, it overwrites the first command of running the first function and only runs the second function when I click b (in this case, the function pause) I also tried the line screen.onkey(pause, reset, key_both), but that created an error.

Could someone help me figure out how to run multiple functions? I can't find any parameter of .onkey() where it doesn't disable previous key-based functions. Please help!

答:
Frustratingly, what you're asking for is built-in to the mouse event functions:

```<code>onclick(fun, btn=1, add=None)
</code>```

where the add argument is used to indicate whether fun overrides the current setting or simply adds another function to execute in this circumstance.  However, this wasn't included on the various onkey*() event handlers.

Below is what I consider a generic way to go about this:

```<code>from turtle import Screen

KEY_RESET = 'r'
KEY_PAUSE = 'p'
KEY_BOTH = 'b'

def reset():
    screen.onkey(None, KEY_RESET)  # Disable event handlers inside handler
    screen.onkey(None, KEY_BOTH)

    print("reset")

    screen.onkey(reset, KEY_RESET)  # Reenable event handlers
    screen.onkey(both, KEY_BOTH)

def pause():
    screen.onkey(None, KEY_PAUSE)  # Disable event handlers inside handler
    screen.onkey(None, KEY_BOTH)

    print("pause")

    screen.onkey(pause, KEY_PAUSE)  # Reenable event handlers
    screen.onkey(both, KEY_BOTH)

def both():
    reset()
    pause()

screen = Screen()

reset()

screen.listen()
screen.mainloop()
</code>```

such that I can run multiple functions when I click b with just one
  line of code?

Yes, there's a hack we can do with lambda and a tuple but we shouldn't be thinking this way.  "Just one line of code" should not be your goal at this point.

Body:
For the code:

from turtle import Screen, Turtle, bgcolor

# --- functions ---

def delSec(string):
    if len(string) == 1:
        return "0" + string
    else:
        return string

def tick():
    global milisecs, ticking

    turtle.clear()

    if milisecs < 0:
        turtle.write("TIMER DONE", align='center', font=FONT)
        ticking = False
        return
    else:
        turtle.write(delSec(str(milisecs//(60*60*10)))+":"+delSec(str((milisecs%(60*60*10))//(60*10)))+":"+delSec(str((milisecs%(60*10))//10))+":"+str(milisecs%10), align='center', font=FONT)
##        turtle.write(delSec(str(milisecs//(60*60)))+":"+delSec(str((milisecs%(60*60))//(60)))+":"+delSec(str((milisecs%(60))//1)), align='center', font=FONT)
        if not paused:
              milisecs -= 1

    screen.ontimer(tick, 100)

def reset():
    global milisecs, ticking, key_reset, key_pause, key_both
    #global paused

    print("reset")

    screen.onkey(None, key_reset)  # Disable event handler inside handler
    screen.onkey(None, key_pause)  # Disable event handler inside handler
    screen.onkey(None, key_both)

    milisecs = sum(time*10)

    if not ticking:
        ticking = True
        tick()

    #paused = False

    screen.onkey(reset, key_reset)  # Reenable event handler
    screen.onkey(pause, key_pause)  # Reenable event handler
    screen.onkey(reset, key_both)
    screen.onkey(pause, key_both)

def pause():
    global paused

    print("pause/unpause")

    paused = not paused

# --- main ---

bgcolor('dodgerblue')
FONT = ("Arial", 60, "normal")

strings = input("Please enter the time: ").strip().split(' ')

time = [60 ** (len(strings) - index - 1) * int(unit) for index, unit in enumerate(strings)]

milisecs = -1
ticking = False
paused = False
key_reset = "r"
key_pause = "p"
key_both = "b"

screen = Screen()

turtle = Turtle()
turtle.hideturtle()
turtle.color('white')

reset()

screen.listen()
screen.mainloop()

I want to both pause and reset the timer when I click the key "b". I tried doing this by running both functions reset and pause. However, as expected, it overwrites the first command of running the first function and only runs the second function when I click b (in this case, the function pause) I also tried the line screen.onkey(pause, reset, key_both), but that created an error.

Could someone help me figure out how to run multiple functions? I can't find any parameter of .onkey() where it doesn't disable previous key-based functions. Please help!

Body:
Frustratingly, what you're asking for is built-in to the mouse event functions:

onclick(fun, btn=1, add=None)

where the add argument is used to indicate whether fun overrides the current setting or simply adds another function to execute in this circumstance.  However, this wasn't included on the various onkey*() event handlers.

Below is what I consider a generic way to go about this:

from turtle import Screen

KEY_RESET = 'r'
KEY_PAUSE = 'p'
KEY_BOTH = 'b'

def reset():
    screen.onkey(None, KEY_RESET)  # Disable event handlers inside handler
    screen.onkey(None, KEY_BOTH)

    print("reset")

    screen.onkey(reset, KEY_RESET)  # Reenable event handlers
    screen.onkey(both, KEY_BOTH)

def pause():
    screen.onkey(None, KEY_PAUSE)  # Disable event handlers inside handler
    screen.onkey(None, KEY_BOTH)

    print("pause")

    screen.onkey(pause, KEY_PAUSE)  # Reenable event handlers
    screen.onkey(both, KEY_BOTH)

def both():
    reset()
    pause()

screen = Screen()

reset()

screen.listen()
screen.mainloop()

such that I can run multiple functions when I click b with just one
  line of code?

Yes, there's a hack we can do with lambda and a tuple but we shouldn't be thinking this way.  "Just one line of code" should not be your goal at this point.


问:
$elemMatch for filtering out referenced($ref) array objects in mongodb is not working
I have 2 collections student_details and subject_details where each student can have multiple subjects which I am storing in student_details collection as reference array.

Now I need to fetch Student details along with the filtered subjects where subject_details.status=ACTIVE.

How can I achieve this using $elemMatch for $ref objects.
I was using something like below but it is not returning any records.

db.getCollection('student_details').find( { subjects: { $elemMatch: { $ref: "subject_details", status: 'ACTIVE' }}})

```<code>student_details
================
{
    "_id" : "STD-1",
    "name" : "XYZ",
    "subjects" : [
        {
            "$ref" : "subject_details",
            "$id" : "SUB-1"
        },
        {
            "$ref" : "subject_details",
            "$id" : "SUB-2"
        },
        {
            "$ref" : "subject_details",
            "$id" : "SUB-3"
        }
    ]
}

subject_details
===============
{
    "_id" : "SUB-1",
    "name" : "MATHEMATICS",
    "status" : "ACTIVE"
}

{
    "_id" : "SUB-2",
    "name" : "PHYSICS",
    "status" : "ACTIVE"
}

{
    "_id" : "SUB-3",
    "name" : "CHEMISTRY",
    "status" : "INACTIVE"
}

</code>```

答:
dbref's are troublesome when used in lookups. but you can work around it with the following aggregation pipeline:

db.student_details.aggregate([
    {
        $unwind: "$subjects"
    },
    {
        $set: {
            "fk": {
                $arrayElemAt: [{
                    $objectToArray: "$subjects"
                }, 1]
            }
        }
    },
    {
        $lookup: {
            "from": "subject_details",
            "localField": "fk.v",
            "foreignField": "_id",
            "as": "subject"
        }
    },
    {
        $match: {
            "subject.status": "ACTIVE"
        }
    },
    {
        $group: {
            "_id": "$_id",
            "name": {
                $first: "$name"
            },
            "subjects": {
                $push: {
                    $arrayElemAt: ["$subject", 0]
                }
            }
        }
    }
])
```

<p>the resulting object would be like so:</p>

<pre class="lang-java prettyprint-override"><code>{
    "_id": "STD-1",
    "name": "XYZ",
    "subjects": [
        {
            "_id": "SUB-1",
            "name": "MATHEMATICS",
            "status": "ACTIVE"
        },
        {
            "_id": "SUB-2",
            "name": "PHYSICS",
            "status": "ACTIVE"
        }
    ]
}
</code>```

Body:
I have 2 collections student_details and subject_details where each student can have multiple subjects which I am storing in student_details collection as reference array.

Now I need to fetch Student details along with the filtered subjects where subject_details.status=ACTIVE.

How can I achieve this using $elemMatch for $ref objects.
I was using something like below but it is not returning any records.

db.getCollection('student_details').find( { subjects: { $elemMatch: { $ref: "subject_details", status: 'ACTIVE' }}})

student_details
================
{
    "_id" : "STD-1",
    "name" : "XYZ",
    "subjects" : [
        {
            "$ref" : "subject_details",
            "$id" : "SUB-1"
        },
        {
            "$ref" : "subject_details",
            "$id" : "SUB-2"
        },
        {
            "$ref" : "subject_details",
            "$id" : "SUB-3"
        }
    ]
}

subject_details
===============
{
    "_id" : "SUB-1",
    "name" : "MATHEMATICS",
    "status" : "ACTIVE"
}

{
    "_id" : "SUB-2",
    "name" : "PHYSICS",
    "status" : "ACTIVE"
}

{
    "_id" : "SUB-3",
    "name" : "CHEMISTRY",
    "status" : "INACTIVE"
}

Body:
dbref's are troublesome when used in lookups. but you can work around it with the following aggregation pipeline:

db.student_details.aggregate([
    {
        $unwind: "$subjects"
    },
    {
        $set: {
            "fk": {
                $arrayElemAt: [{
                    $objectToArray: "$subjects"
                }, 1]
            }
        }
    },
    {
        $lookup: {
            "from": "subject_details",
            "localField": "fk.v",
            "foreignField": "_id",
            "as": "subject"
        }
    },
    {
        $match: {
            "subject.status": "ACTIVE"
        }
    },
    {
        $group: {
            "_id": "$_id",
            "name": {
                $first: "$name"
            },
            "subjects": {
                $push: {
                    $arrayElemAt: ["$subject", 0]
                }
            }
        }
    }
])

the resulting object would be like so:

{
    "_id": "STD-1",
    "name": "XYZ",
    "subjects": [
        {
            "_id": "SUB-1",
            "name": "MATHEMATICS",
            "status": "ACTIVE"
        },
        {
            "_id": "SUB-2",
            "name": "PHYSICS",
            "status": "ACTIVE"
        }
    ]
}


问:
Content assist doesn't work for java objects in Eclipse Juno IDE
i use Eclipse Juno, the content assist doesn't work for me specially for Java object:

Example: When i type "na" content assist work and propose "name" for me, but when i type "." to get some String methods, content assist doesn't work in this case.

```<code>public class A {

    private String name;

    public String getName() {
        return name.toString();
    }

}
</code>```

i get this exception stack trace:

```<code>org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.LinkageError: loader constraint violation: when resolving method "org.eclipse.recommenders.utils.rcp.JdtUtils.createUnresolvedType(Lorg/eclipse/jdt/internal/compiler/lookup/TypeBinding;)Lcom/google/common/base/Optional;" the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) of the current class, org/eclipse/recommenders/internal/completion/rcp/BaseRecommendersCompletionContext, and the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) for resolved class, org/eclipse/recommenders/utils/rcp/JdtUtils, have different Class objects for the type (Lorg/eclipse/jdt/internal/compiler/lookup/TypeBinding;)Lcom/google/common/base/Optional; used in the signature)
    at org.eclipse.swt.SWT.error(SWT.java:4361)
    at org.eclipse.swt.SWT.error(SWT.java:4276)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3946)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3623)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1053)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:942)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
Caused by: java.lang.LinkageError: loader constraint violation: when resolving method "org.eclipse.recommenders.utils.rcp.JdtUtils.createUnresolvedType(Lorg/eclipse/jdt/internal/compiler/lookup/TypeBinding;)Lcom/google/common/base/Optional;" the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) of the current class, org/eclipse/recommenders/internal/completion/rcp/BaseRecommendersCompletionContext, and the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) for resolved class, org/eclipse/recommenders/utils/rcp/JdtUtils, have different Class objects for the type (Lorg/eclipse/jdt/internal/compiler/lookup/TypeBinding;)Lcom/google/common/base/Optional; used in the signature
    at org.eclipse.recommenders.internal.completion.rcp.BaseRecommendersCompletionContext.getReceiverType(BaseRecommendersCompletionContext.java:319)
    at org.eclipse.recommenders.internal.completion.rcp.calls.engine.CallsCompletionProposalComputer.findReceiver(CallsCompletionProposalComputer.java:156)
    at org.eclipse.recommenders.internal.completion.rcp.calls.engine.CallsCompletionProposalComputer.computeCompletionProposals(CallsCompletionProposalComputer.java:121)
    at org.eclipse.jdt.internal.ui.text.java.CompletionProposalComputerDescriptor.computeCompletionProposals(CompletionProposalComputerDescriptor.java:333)
    at org.eclipse.jdt.internal.ui.text.java.CompletionProposalCategory.computeCompletionProposals(CompletionProposalCategory.java:340)
    at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.collectProposals(ContentAssistProcessor.java:328)
    at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.computeCompletionProposals(ContentAssistProcessor.java:284)
    at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1839)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:566)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$16(CompletionProposalPopup.java:563)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.run(CompletionProposalPopup.java:498)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:492)
    at org.eclipse.jface.text.contentassist.ContentAssistant$2.run(ContentAssistant.java:378)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    ... 23 more
</code>```

答:
There may be multiple reasons

Errors in code because when there is error in code then the assist does not work as it can not solve the references

Restart IDE: IDE is out of memory and system resources are consumed. In this case restart IDE

BUILD: If the project is not built properly, if then clean and build the project

Body:
i use Eclipse Juno, the content assist doesn't work for me specially for Java object:

Example: When i type "na" content assist work and propose "name" for me, but when i type "." to get some String methods, content assist doesn't work in this case.

public class A {

    private String name;

    public String getName() {
        return name.toString();
    }

}

i get this exception stack trace:

org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.LinkageError: loader constraint violation: when resolving method "org.eclipse.recommenders.utils.rcp.JdtUtils.createUnresolvedType(Lorg/eclipse/jdt/internal/compiler/lookup/TypeBinding;)Lcom/google/common/base/Optional;" the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) of the current class, org/eclipse/recommenders/internal/completion/rcp/BaseRecommendersCompletionContext, and the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) for resolved class, org/eclipse/recommenders/utils/rcp/JdtUtils, have different Class objects for the type (Lorg/eclipse/jdt/internal/compiler/lookup/TypeBinding;)Lcom/google/common/base/Optional; used in the signature)
    at org.eclipse.swt.SWT.error(SWT.java:4361)
    at org.eclipse.swt.SWT.error(SWT.java:4276)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3946)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3623)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1053)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:942)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
Caused by: java.lang.LinkageError: loader constraint violation: when resolving method "org.eclipse.recommenders.utils.rcp.JdtUtils.createUnresolvedType(Lorg/eclipse/jdt/internal/compiler/lookup/TypeBinding;)Lcom/google/common/base/Optional;" the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) of the current class, org/eclipse/recommenders/internal/completion/rcp/BaseRecommendersCompletionContext, and the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) for resolved class, org/eclipse/recommenders/utils/rcp/JdtUtils, have different Class objects for the type (Lorg/eclipse/jdt/internal/compiler/lookup/TypeBinding;)Lcom/google/common/base/Optional; used in the signature
    at org.eclipse.recommenders.internal.completion.rcp.BaseRecommendersCompletionContext.getReceiverType(BaseRecommendersCompletionContext.java:319)
    at org.eclipse.recommenders.internal.completion.rcp.calls.engine.CallsCompletionProposalComputer.findReceiver(CallsCompletionProposalComputer.java:156)
    at org.eclipse.recommenders.internal.completion.rcp.calls.engine.CallsCompletionProposalComputer.computeCompletionProposals(CallsCompletionProposalComputer.java:121)
    at org.eclipse.jdt.internal.ui.text.java.CompletionProposalComputerDescriptor.computeCompletionProposals(CompletionProposalComputerDescriptor.java:333)
    at org.eclipse.jdt.internal.ui.text.java.CompletionProposalCategory.computeCompletionProposals(CompletionProposalCategory.java:340)
    at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.collectProposals(ContentAssistProcessor.java:328)
    at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.computeCompletionProposals(ContentAssistProcessor.java:284)
    at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1839)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:566)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$16(CompletionProposalPopup.java:563)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.run(CompletionProposalPopup.java:498)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:492)
    at org.eclipse.jface.text.contentassist.ContentAssistant$2.run(ContentAssistant.java:378)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    ... 23 more


问:
News Feed icon is not appearing using juicer Api
I have this text to get from juicer api
test message ✈
 when save this text in sql database so icon in this text is replace to ?? double question mark i dont know why how can i fixed this issue, because i want to display this text with in my application news feed area.
Pleae help me how can i fixed this issue.

答:
@PrateekShrivastava MSSQL message column type is text

Please check: https://learn.microsoft.com/en-us/sql/t-sql/data-types/ntext-text-and-image-transact-sql?view=sql-server-ver15

text
Variable-length non-Unicode data in the code page of the server and with a maximum string length of 2^31-1 (2,147,483,647). When the server code page uses double-byte characters, the storage is still 2,147,483,647 bytes. Depending on the character string, the storage size may be less than 2,147,483,647 bytes.

Change column to nvarchar(MAX) or ntext


问:
App closing automatically on button click in main activity
Here is my logcat:

```<code>53:46.592 994-994/com.example.attendancepredictor E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.attendancepredictor, PID: 994
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.attendancepredictor/com.example.attendancepredictor.third_activity}: java.lang.ArithmeticException: divide by zero
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3138)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3289)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2012)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:227)
        at android.app.ActivityThread.main(ActivityThread.java:7211)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:575)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:903)
     Caused by: java.lang.ArithmeticException: divide by zero
        at com.example.attendancepredictor.third_activity.onCreate(third_activity.java:31)
        at android.app.Activity.performCreate(Activity.java:7315)
        at android.app.Activity.performCreate(Activity.java:7306)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3118)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3289)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2012)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:227)
        at android.app.ActivityThread.main(ActivityThread.java:7211)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:575)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:903)
2020-02-18 17:53:46.610 994-994/? I/Process: Sending signal. PID: 994 SIG: 9
</code>```

Im new to android development and i am trying to make a basic app for attendance predictor use formulas.Now when i try to get the values from edittext in the main activity when i click on submit button,the app is closing automatically.
please help me solve this
thanks :)

Main activity:

```<code>package com.example.attendancepredictor;

import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {
    Button button;
    EditText send_text;
    EditText send_text2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button button = (Button) findViewById(R.id.button);
        send_text = (EditText) findViewById(R.id.editText2);
        send_text2 = (EditText) findViewById(R.id.editText);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                // get the value which input by user in EditText
                // and convert it to string
                double n1 = Double.valueOf(send_text.getText().toString());
                double n2 = Double.valueOf(send_text2.getText().toString());

                // Create the Intent object of this class Context() to Second_activity class
                Intent intent = new Intent(getApplicationContext(), third_activity.class);

                // now by putExtra method put the value in key, value pair
                // key is message_key by this key we will receive the value, and put the string

                intent.putExtra("message_key", n1);
                intent.putExtra("message_key1", n2);

                // start the Intent
                startActivity(intent);
            }
        });
    }

    public void goTosecond_activity (View view){
        Intent intent = new Intent(this, second_activity.class);
        startActivity(intent);
    }
}
</code>```

Second activity:

```<code>package com.example.attendancepredictor;

import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class second_activity extends AppCompatActivity {
    Button predict_button;
    EditText send_text3;
    EditText send_text4;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second_activity);
        Button predict_button= (Button)findViewById(R.id.button2);
        send_text3 = (EditText)findViewById(R.id.editText4);
        send_text4=(EditText)findViewById(R.id.editText5);
        predict_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                // get the value which input by user in EditText
                // and convert it to string
                double n3 = Double.valueOf(send_text3.getText().toString());
                double n4 = Double.valueOf(send_text4.getText().toString());

                // Create the Intent object of this class Context() to Second_activity class
                Intent intent = new Intent(getApplicationContext(), third_activity.class);

                // now by putExtra method put the value in key, value pair
                // key is message_key by this key we will receive the value, and put the string

                intent.putExtra("message_key2", n3);
                intent.putExtra("message_key3", n4);

                // start the Intent
                startActivity(intent);
            }
        });
    }
}
</code>```

third activity:

```<code>package com.example.attendancepredictor;

import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

public class third_activity extends AppCompatActivity {

        TextView receiver_msg;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_third_activity);

            receiver_msg = (TextView)findViewById(R.id.textView8);

            // create the get Intent object
            Intent intent = getIntent();

            // receive the value by getStringExtra() method
            // and key must be same which is send by first activity
            int n1 = intent.getIntExtra("message_key",0);
            int n2 = intent.getIntExtra("message_key1",0);
            int n3 = intent.getIntExtra("message_key2",0);
            int n4 = intent.getIntExtra("message_key3",0);

            double n5 = ((n1+n3)/(n2+n3))*100;
            double n6 = ((n1)/(n2+n4))*100;

            // display the string into textView
            receiver_msg.setText(""+n5);
            receiver_msg.setText(""+n6);

        }
    }
</code>```

android manifest:

```<code><?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.attendancepredictor">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".third_activity"
           android:label="@string/app_name" >

        </activity>
        <activity android:name=".second_activity"
            android:label="@string/app_name">
        </activity>
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
</code>```

答:
The values you are getting from the extra is 0, hence you are getting exception when you try to divide from zero.

Use the following code to make the application not crash:

```<code>try{
double n5 = ((n1+n3)/(n2+n3))*100;
            double n6 = ((n1)/(n2+n4))*100;
}catch(Exception exec){
   exec.printStacktrace
}
</code>```

You will have to debug why you are getting zero and not the actual value which you are sending to fix the issue.

As I see you are sending two values from second activity to third activity and two values from Main Activity so always two values will be zero.

Hope this helps.

Body:
Here is my logcat:

53:46.592 994-994/com.example.attendancepredictor E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.attendancepredictor, PID: 994
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.attendancepredictor/com.example.attendancepredictor.third_activity}: java.lang.ArithmeticException: divide by zero
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3138)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3289)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2012)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:227)
        at android.app.ActivityThread.main(ActivityThread.java:7211)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:575)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:903)
     Caused by: java.lang.ArithmeticException: divide by zero
        at com.example.attendancepredictor.third_activity.onCreate(third_activity.java:31)
        at android.app.Activity.performCreate(Activity.java:7315)
        at android.app.Activity.performCreate(Activity.java:7306)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3118)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3289)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2012)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:227)
        at android.app.ActivityThread.main(ActivityThread.java:7211)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:575)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:903)
2020-02-18 17:53:46.610 994-994/? I/Process: Sending signal. PID: 994 SIG: 9

Im new to android development and i am trying to make a basic app for attendance predictor use formulas.Now when i try to get the values from edittext in the main activity when i click on submit button,the app is closing automatically.
please help me solve this
thanks :)

Main activity:

package com.example.attendancepredictor;

import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {
    Button button;
    EditText send_text;
    EditText send_text2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button button = (Button) findViewById(R.id.button);
        send_text = (EditText) findViewById(R.id.editText2);
        send_text2 = (EditText) findViewById(R.id.editText);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                // get the value which input by user in EditText
                // and convert it to string
                double n1 = Double.valueOf(send_text.getText().toString());
                double n2 = Double.valueOf(send_text2.getText().toString());

                // Create the Intent object of this class Context() to Second_activity class
                Intent intent = new Intent(getApplicationContext(), third_activity.class);

                // now by putExtra method put the value in key, value pair
                // key is message_key by this key we will receive the value, and put the string

                intent.putExtra("message_key", n1);
                intent.putExtra("message_key1", n2);

                // start the Intent
                startActivity(intent);
            }
        });
    }

    public void goTosecond_activity (View view){
        Intent intent = new Intent(this, second_activity.class);
        startActivity(intent);
    }
}

Second activity:

package com.example.attendancepredictor;

import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class second_activity extends AppCompatActivity {
    Button predict_button;
    EditText send_text3;
    EditText send_text4;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second_activity);
        Button predict_button= (Button)findViewById(R.id.button2);
        send_text3 = (EditText)findViewById(R.id.editText4);
        send_text4=(EditText)findViewById(R.id.editText5);
        predict_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                // get the value which input by user in EditText
                // and convert it to string
                double n3 = Double.valueOf(send_text3.getText().toString());
                double n4 = Double.valueOf(send_text4.getText().toString());

                // Create the Intent object of this class Context() to Second_activity class
                Intent intent = new Intent(getApplicationContext(), third_activity.class);

                // now by putExtra method put the value in key, value pair
                // key is message_key by this key we will receive the value, and put the string

                intent.putExtra("message_key2", n3);
                intent.putExtra("message_key3", n4);

                // start the Intent
                startActivity(intent);
            }
        });
    }
}

third activity:

package com.example.attendancepredictor;

import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

public class third_activity extends AppCompatActivity {

        TextView receiver_msg;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_third_activity);

            receiver_msg = (TextView)findViewById(R.id.textView8);

            // create the get Intent object
            Intent intent = getIntent();

            // receive the value by getStringExtra() method
            // and key must be same which is send by first activity
            int n1 = intent.getIntExtra("message_key",0);
            int n2 = intent.getIntExtra("message_key1",0);
            int n3 = intent.getIntExtra("message_key2",0);
            int n4 = intent.getIntExtra("message_key3",0);

            double n5 = ((n1+n3)/(n2+n3))*100;
            double n6 = ((n1)/(n2+n4))*100;

            // display the string into textView
            receiver_msg.setText(""+n5);
            receiver_msg.setText(""+n6);

        }
    }

android manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.attendancepredictor">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".third_activity"
           android:label="@string/app_name" >

        </activity>
        <activity android:name=".second_activity"
            android:label="@string/app_name">
        </activity>
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Body:
The values you are getting from the extra is 0, hence you are getting exception when you try to divide from zero.

Use the following code to make the application not crash:

try{
double n5 = ((n1+n3)/(n2+n3))*100;
            double n6 = ((n1)/(n2+n4))*100;
}catch(Exception exec){
   exec.printStacktrace
}

You will have to debug why you are getting zero and not the actual value which you are sending to fix the issue.

As I see you are sending two values from second activity to third activity and two values from Main Activity so always two values will be zero.

Hope this helps.


问:
DOM manipulation does not work in User Agent String function
I am working on a website and a part of it involves interpreting whether the website is opened on a mobile or a desktop. I am using client side User agent string for this purpose. I update the inner HTML of one of my elements based on whether the website is opened on mobile or a desktop. I have taken the function from http://detectmobilebrowsers.com/

JavaScript code

```<code>window.onload =
    (function (a) {
        (jQuery.browser = jQuery.browser || {}).mobile = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))
        if (jQuery.browser.mobile === true) {
            $("#head").html("Mohawk Mobile")
            console.log("Mobile")
        } else {
            $("#head").html("Desktop")
            console.log("Desktop")
        }
    })(navigator.userAgent || navigator.vendor || window.opera)
</code>```

HTML

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

Desktop

```

The console.log does work fine which means there is no problem in code functionality but I think there is some issue with the loading of the DOM elements. I tried to change the html outside the function and it does work.

答:
It is because your function executed before DOM fully loaded.

Write function in $(document).ready()

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

Desktop
```

Body:
I am working on a website and a part of it involves interpreting whether the website is opened on a mobile or a desktop. I am using client side User agent string for this purpose. I update the inner HTML of one of my elements based on whether the website is opened on mobile or a desktop. I have taken the function from http://detectmobilebrowsers.com/

JavaScript code

window.onload =
    (function (a) {
        (jQuery.browser = jQuery.browser || {}).mobile = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))
        if (jQuery.browser.mobile === true) {
            $("#head").html("Mohawk Mobile")
            console.log("Mobile")
        } else {
            $("#head").html("Desktop")
            console.log("Desktop")
        }
    })(navigator.userAgent || navigator.vendor || window.opera)

HTML

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

Desktop

The console.log does work fine which means there is no problem in code functionality but I think there is some issue with the loading of the DOM elements. I tried to change the html outside the function and it does work.

Body:
It is because your function executed before DOM fully loaded.

Write function in $(document).ready()

<script type="text/javascript" src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script>
function check(){
(function(a){

    (jQuery.browser=jQuery.browser||{}).mobile=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))
    if(jQuery.browser.mobile===true){
    $("#head").html("Mohawk Mobile")
    console.log("Mobile")
}
else{
    $("#head").html("Desktop")
    console.log("Desktop")
}
})(navigator.userAgent||navigator.vendor||window.opera)

}
$(document).ready(function (){
check();
});
</script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<div id="head"><a class="navbar-brand" href="#">Desktop</a></div>


问:
How we substract two column and store in another column in laravel,i am new in laravel
I have 3 columns in database:

First column Fee

Second column First_installement

Third column second_installement

Fourth column third_installement

Fourth column dues

I want

```<code>dues=fee-(first_installement+second_installement+third_installement)
</code>```

My controller

```<code>$patientfee=AddPatient::find($patient_id);
$a->fee_id=$request->input('fee_id');
$b->first_installement=$request->input('first_installement');
$c->second_installement=$request->input('second_installement');
$d->third_installement=$request->input('third_installement');
$e->dues=$request->input('dues');

$e=$a-($b+$c+$d);

$patientfee->update();
return redirect('/patient-list')->with('status','Fee Successfully  updated');
</code>```

答:
You can do that like first retrieve column values from AddPatient and then subtract.

```<code>$patientfee=AddPatient::findOrFail($patient_id);
$fee = $patientfee->fee;
$first_installement = $patientfee->first_installement;
$second_installement = $patientfee->second_installement;
$third_installement = $patientfee->third_installement;

$dues = $fee - ($first_installement+$second_installement+$third_installement);
$patientfee->dues = $dues;
$patientfee->update();
return redirect('/patient-list')->with('status','Fee Successfully  updated');
</code>```

Body:
I have 3 columns in database:

First column Fee

Second column First_installement

Third column second_installement

Fourth column third_installement

Fourth column dues

I want

dues=fee-(first_installement+second_installement+third_installement)

My controller

$patientfee=AddPatient::find($patient_id);
$a->fee_id=$request->input('fee_id');
$b->first_installement=$request->input('first_installement');
$c->second_installement=$request->input('second_installement');
$d->third_installement=$request->input('third_installement');
$e->dues=$request->input('dues');

$e=$a-($b+$c+$d);

$patientfee->update();
return redirect('/patient-list')->with('status','Fee Successfully  updated');

Body:
You can do that like first retrieve column values from AddPatient and then subtract.

$patientfee=AddPatient::findOrFail($patient_id);
$fee = $patientfee->fee;
$first_installement = $patientfee->first_installement;
$second_installement = $patientfee->second_installement;
$third_installement = $patientfee->third_installement;

$dues = $fee - ($first_installement+$second_installement+$third_installement);
$patientfee->dues = $dues;
$patientfee->update();
return redirect('/patient-list')->with('status','Fee Successfully  updated');


问:
Xamarin iOS app crash on startup
After submitting an app to iTunes Connect, it got rejected, stating that the app crashes on launch. This behavior does not occur while running the app in the emulator. Also, the app works fine on Android, Google Play did not reject it whatsoever. So my main concerns are why is this happening ?

The app is a Xamarin Forms 2.0 ( latest version ) iOS application, ran with XCode 7.3 and built for iOS 9.3. In the crash log from Apple I saw they tested it on iOS 9.3.1.

Has anyone else gone through this? The log from Apple says that Thread 0 ( main thread ) has crashed.

答:
I had the same problem with my app after updating Xamarin Studio and after trying more than 20 different solutions and searching in all forums and stackoverflow it turns out that Visual Studio for mac has a bug and sometimes it adds more than one MtouchLink configuration in *iOS.csproj file :

```<code><PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
...
<MtouchLink>SdkOnly</MtouchLink>
<MtouchLink>Full</MtouchLink>
</code>```

In my case the IDE was saving two linker behaviors configurations and the app was crashing after showing the LaunchScreen image, only in release mode

To correct it I just edited the *iOS.csproj file with SublimeText and deleted the line :
<MtouchLink>Full</MtouchLink>

Hope it helps

Title: Xamarin iOS app crash on startup

Body:
I had the same problem with my app after updating Xamarin Studio and after trying more than 20 different solutions and searching in all forums and stackoverflow it turns out that Visual Studio for mac has a bug and sometimes it adds more than one MtouchLink configuration in *iOS.csproj file :

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
...
<MtouchLink>SdkOnly</MtouchLink>
<MtouchLink>Full</MtouchLink>

In my case the IDE was saving two linker behaviors configurations and the app was crashing after showing the LaunchScreen image, only in release mode

To correct it I just edited the *iOS.csproj file with SublimeText and deleted the line :
<MtouchLink>Full</MtouchLink>

Hope it helps


问:
Merging values from 2 different datasets within a certain time interval into a single dataset (R)
I have two separate datasets: df1 and df2. I would like to create a new dataset, df3 that would match the endtime column of df1 with the sent column of df2 if the datetimes are within 20 seconds of each other.

```<code> df1

 endtime                     ID

 1/7/2020  1:35:08 AM         A
 1/7/2020  1:39:00 AM         B
 1/20/2020 1:45:00 AM         C

 df2

sent                         ID

1/7/2020  1:35:20 AM          E
1/7/2020  1:42:00 AM          F
1/20/2020 1:55:00 AM          G
1/20/2020 2:00:00 AM          E
</code>```

This is my desired output for df3. There is only one row, because there are only two values that match the condition of being within 20 seconds of the endtime and sent columns.

```<code>endtime                  sent

1/7/2020 1:35:08 AM      1/7/2020  1:35:20 AM
</code>```

Here is the dput:

```<code>df1

structure(list(endtime = structure(c(2L, 3L, 1L), .Label = c("1/10/2020 1:45:00 AM",
"1/7/2020 1:35:08 AM", "1/7/2020 1:39:00 AM"), class = "factor"),
ID = structure(1:3, .Label = c("A", "B", "C"), class = "factor")), class = "data.frame", row.names =   c(NA,
 -3L))

 df2

 structure(list(sent = structure(c(3L, 4L, 1L, 2L), .Label = c("1/20/2020 1:55:00 AM",
 "1/20/2020 2:00:00 AM", "1/7/2020 1:35:20 AM", "1/7/2020 1:42:00 AM"
 ), class = "factor"), ID = structure(c(1L, 2L, 3L, 1L), .Label = c("E",
"F", "G"), class = "factor")), class = "data.frame", row.names = c(NA,
-4L))
</code>```

This is what I have tried:

I am thinking of performing a left join and matching the values, or I can use merge(), but the tricky part is matching the values with the conditional statement. Any suggestion is appreciated.

```<code>library(dplyr)
left_join(df1, df2)
</code>```

答:
Since there is no common column to join, we can use crossing to create all combinations of rows and then filter the ones which fit the criteria.

```<code>library(dplyr)

df1 %>%
  rename(ID1 = 'ID') %>%
  tidyr::crossing(df2) %>%
  mutate_at(vars(endtime, sent), lubridate::mdy_hms) %>%
  filter(abs(difftime(sent, endtime, 'secs')) < 20)

#  endtime             ID1   sent                ID
#  <dttm>              <fct> <dttm>              <fct>
#1 2020-01-07 01:35:08 A     2020-01-07 01:35:20 E
</code>```

Body:
I have two separate datasets: df1 and df2. I would like to create a new dataset, df3 that would match the endtime column of df1 with the sent column of df2 if the datetimes are within 20 seconds of each other.

 df1

 endtime                     ID

 1/7/2020  1:35:08 AM         A
 1/7/2020  1:39:00 AM         B
 1/20/2020 1:45:00 AM         C

 df2

sent                         ID

1/7/2020  1:35:20 AM          E
1/7/2020  1:42:00 AM          F
1/20/2020 1:55:00 AM          G
1/20/2020 2:00:00 AM          E

This is my desired output for df3. There is only one row, because there are only two values that match the condition of being within 20 seconds of the endtime and sent columns.

endtime                  sent

1/7/2020 1:35:08 AM      1/7/2020  1:35:20 AM

Here is the dput:

df1

structure(list(endtime = structure(c(2L, 3L, 1L), .Label = c("1/10/2020 1:45:00 AM",
"1/7/2020 1:35:08 AM", "1/7/2020 1:39:00 AM"), class = "factor"),
ID = structure(1:3, .Label = c("A", "B", "C"), class = "factor")), class = "data.frame", row.names =   c(NA,
 -3L))

 df2

 structure(list(sent = structure(c(3L, 4L, 1L, 2L), .Label = c("1/20/2020 1:55:00 AM",
 "1/20/2020 2:00:00 AM", "1/7/2020 1:35:20 AM", "1/7/2020 1:42:00 AM"
 ), class = "factor"), ID = structure(c(1L, 2L, 3L, 1L), .Label = c("E",
"F", "G"), class = "factor")), class = "data.frame", row.names = c(NA,
-4L))

This is what I have tried:

I am thinking of performing a left join and matching the values, or I can use merge(), but the tricky part is matching the values with the conditional statement. Any suggestion is appreciated.

library(dplyr)
left_join(df1, df2)

Body:
Since there is no common column to join, we can use crossing to create all combinations of rows and then filter the ones which fit the criteria.

library(dplyr)

df1 %>%
  rename(ID1 = 'ID') %>%
  tidyr::crossing(df2) %>%
  mutate_at(vars(endtime, sent), lubridate::mdy_hms) %>%
  filter(abs(difftime(sent, endtime, 'secs')) < 20)

#  endtime             ID1   sent                ID
#  <dttm>              <fct> <dttm>              <fct>
#1 2020-01-07 01:35:08 A     2020-01-07 01:35:20 E


问:
Next.js returns 500: internal server error in Production
Created a next.js full stack application. After production build when I run next start it returns 500 : internal server. I'm using environment varibles for hitting api.

```<code>env.development file

BASE_URL=http://localhost:3000
</code>```

It was working fine in development
service.ts

```<code>import axios from 'axios';
const axiosDefaultConfig = {
  baseURL: process.env.BASE_URL, // is this line reason for error?
  headers: {
    'Access-Control-Allow-Origin': '*'
  }
};
const axio = axios.create(axiosDefaultConfig);

export class Steam {
  static getGames = async () => {
    return await axio.get('/api/getAppList');
  };
}
</code>```

答:
I dont think you have setup env.

You need to configure it for it to work. Try it without it and it should work fine!

Body:
Created a next.js full stack application. After production build when I run next start it returns 500 : internal server. I'm using environment varibles for hitting api.

env.development file

BASE_URL=http://localhost:3000

It was working fine in development
service.ts

import axios from 'axios';
const axiosDefaultConfig = {
  baseURL: process.env.BASE_URL, // is this line reason for error?
  headers: {
    'Access-Control-Allow-Origin': '*'
  }
};
const axio = axios.create(axiosDefaultConfig);

export class Steam {
  static getGames = async () => {
    return await axio.get('/api/getAppList');
  };
}