答:
If you don't have limitations on what to use, I would advise you to maybe take a look at angular material, especially the table component which integrates filtering, pagination, ...

https://material.angular.io/components/table/overview

overall very simple to use

Title: Angular 7 Table with Pagination, Sort, and Filter

Body:
Hi does anyone knows how to make a table with pagination, sort and filter in angular. I'm using Creative Tim's Argon Dashboard for Angular and I'm confused how I am going to integrate it to my project

Here's the documentation of the template click me

Here's a sample code of the table

          Project
          Budget
          Status
          Users
          Completion

                Argon Design System

            $2,500 USD

               pending

              60%

                Action
                Another action
                Something else here

                Angular Now UI Kit PRO

            $1,800 USD

               completed

              100%

                Action
                Another action
                Something else here

                Black Dashboard

            $3,150 USD

               delayed

              72%

                Action
                Another action
                Something else here

                React Material Dashboard

            $4,400 USD

               on schedule

              90%

                Action
                Another action
                Something else here

                Vue Paper UI Kit PRO

            $2,200 USD

               completed

              100%

                Action
                Another action
                Something else here

Here's a sample code of the pagination used

    1

2

3

I don't know about the filter. I really don't know how to start I'm kinda new to this. I came from AngularJS 1.6.x

edit: I would like to know I can still use the table design from the template if I integrated some of your suggestions


来源: stackexchange

问:
Schema.org for portfolio homepage
I am building a portfolio home for a friend of mine. He is an artist and his homepage should include a lot of interactive elements, so I decided to build it using React. However, this implies that the overall markup of the page will be nearly empty on load and I would like to include JSON-LD formatted data to regain search engines' attention.

So within the index.html file I have this:

```

But is this the right @type, would Person be more accurate here? I even stumbled over the EntryPoint schema, which as well seams to be good because the main index is indeed the »Entrypoint« from the programs point of view.

答:
In principle, each entity can be represented with Schema.org, not just one. You don’t have to decide whether to use WebPage or Person, you can use both.

But this is what your snippet shows anyway, as the value for the author property would (ideally) be a Person item. This Person could also be the value of other properties, like about/mainEntity, publisher etc.

For the semantics of the data, it’s irrelevant which entity is the top-level item in the JSON-LD, if that is what you’re asking.

The EntryPoint type is not suitable, as it’s intended for protocols/APIs/etc., not just any webpage/website.

ContentLicense: CC BY-SA 4.0

Title: Schema.org for portfolio homepage

Body:
I am building a portfolio home for a friend of mine. He is an artist and his homepage should include a lot of interactive elements, so I decided to build it using React. However, this implies that the overall markup of the page will be nearly empty on load and I would like to include JSON-LD formatted data to regain search engines' attention.

So within the index.html file I have this:

But is this the right @type, would Person be more accurate here? I even stumbled over the EntryPoint schema, which as well seams to be good because the main index is indeed the »Entrypoint« from the programs point of view.


问:
Rails remove subarray from array
In my Rails 5 app I have something like this:

```<code>a = [1,2,3]

a.map do |entry|
  entry.delete if condition == true
end
</code>```

This removes the entry if the condition is true.

Now I have this:

```<code>a = [[1,2],[2,3],[3,4]]

a.map do |entry|
  entry.delete if condition == true
end
</code>```

This loops through a but now entry is an array and delete should remove the entire entry but instead I get:

```<code>wrong number of arguments (given 0, expected 1)
</code>```

Dos anybody know how I can loop through an array of arrays and remove an entire subarray?

答: instead of using map you should use flat_map see: https://apidock.com/ruby/Enumerable/flat_map</p>

Title: Rails remove subarray from array

Body:
In my Rails 5 app I have something like this:

a = [1,2,3]

a.map do |entry|
  entry.delete if condition == true
end

This removes the entry if the condition is true.

Now I have this:

a = [[1,2],[2,3],[3,4]]

a.map do |entry|
  entry.delete if condition == true
end

This loops through a but now entry is an array and delete should remove the entire entry but instead I get:

wrong number of arguments (given 0, expected 1)

Dos anybody know how I can loop through an array of arrays and remove an entire subarray?


问:
PHP: compare substrings
Really quick noob question with php:

I'm trying to create a conditional statement where I can check if a variable partially matches a substring.

More specific in my case:

$cal is the name of a file, I want it so if $cal contains ".cfg" it echos some text.

pseudocode:

```<code><?php if ($cal == "*.cfg")
 {
    echo "Hello ";
 }
?>
</code>```

答:
In this case, you can simply look at the last four characters of $cal using substr:

```<code>if (substr($cal, -4) === '.cfg') {
    echo "Hello ";
}
</code>```

You should look into regular expressions for more complex problems.

ContentLicense: CC BY-SA 3.0

Title: PHP: compare substrings

Body:
Really quick noob question with php:

I'm trying to create a conditional statement where I can check if a variable partially matches a substring.

More specific in my case:

$cal is the name of a file, I want it so if $cal contains ".cfg" it echos some text.

pseudocode:

<?php if ($cal == "*.cfg")
 {
    echo "Hello ";
 }
?>

Body:
In this case, you can simply look at the last four characters of $cal using substr:

if (substr($cal, -4) === '.cfg') {
    echo "Hello ";
}

You should look into regular expressions for more complex problems.


问:
Return null if value does not exist
I have a table with project data, and I want to return NULL or "Not_Exist" as a result if the project_ID was not found.

For example:

```<code>SELECT a.[Project ID], a.[Stage]
FROM Projects a
WHERE a.[Project ID]  IN ('CR324S', 'a')
</code>```

CR324S exists in the table but 'a' is not there, so the results that I want would be:

```<code>Project ID     Stage
-----------------------------
CR324S         Implementation
a              Not_Exist
</code>```

答:
You can try below -

first construct a set of value using union

then use left join and put your condition in ON Clause

```<code>SELECT a.[pid], coalesce(b.[Stage],'Not_Exist') as stage
from
(
    select 'CR324S' as pid
    union
    select 'a'
)A left join Projects B on A.pid=B.[Project ID] and [Project ID]  IN ('CR324S','a')
</code>```

OR

```<code>SELECT a.[pid], coalesce(b.[Stage],'Not_Exist') AS stage
FROM   (VALUES ('CR324S'), ('a')) A(pid)
LEFT JOIN Projects B on A.pid=B.[Project ID] AND [Project ID]  IN ('CR324S','a')
</code>```

Title: Return null if value does not exist

Body:
I have a table with project data, and I want to return NULL or "Not_Exist" as a result if the project_ID was not found.

For example:

SELECT a.[Project ID], a.[Stage]
FROM Projects a
WHERE a.[Project ID]  IN ('CR324S', 'a')

CR324S exists in the table but 'a' is not there, so the results that I want would be:

Project ID     Stage
-----------------------------
CR324S         Implementation
a              Not_Exist

Body:
You can try below -

first construct a set of value using union

then use left join and put your condition in ON Clause

SELECT a.[pid], coalesce(b.[Stage],'Not_Exist') as stage
from
(
    select 'CR324S' as pid
    union
    select 'a'
)A left join Projects B on A.pid=B.[Project ID] and [Project ID]  IN ('CR324S','a')

OR

SELECT a.[pid], coalesce(b.[Stage],'Not_Exist') AS stage
FROM   (VALUES ('CR324S'), ('a')) A(pid)
LEFT JOIN Projects B on A.pid=B.[Project ID] AND [Project ID]  IN ('CR324S','a')


问:
How can i format log4j time to specific timezone?
Below is my log4j2 layout :

```<code>layout = %d{DATE} %-5p - %m%n.
</code>```

It'll print time in log as -> 2019-05-28 11:48:36,977 INFO  - Hello World.

Which is my system datetime(IST),but I want to print log datetime in GMT format.

is it possible to format timezone in log4j2?

答:
Yes, you can use a pattern in the appender, in example for the console appender:

```<code><appenders>
    <Console name='Console' target='SYSTEM_OUT'>
        <PatternLayout pattern='%d{dd/MM/yyyy HH:mm:ss} - %msg%n'/>
    </Console>
</appenders>
</code>```

Check their documentation at "Pattern Layout" section for all possible commands

Body:
Below is my log4j2 layout :

layout = %d{DATE} %-5p - %m%n.

It'll print time in log as -> 2019-05-28 11:48:36,977 INFO  - Hello World.

Which is my system datetime(IST),but I want to print log datetime in GMT format.

is it possible to format timezone in log4j2?

Body:
Yes, you can use a pattern in the appender, in example for the console appender:

<appenders>
    <Console name='Console' target='SYSTEM_OUT'>
        <PatternLayout pattern='%d{dd/MM/yyyy HH:mm:ss} - %msg%n'/>
    </Console>
</appenders>

Check their documentation at "Pattern Layout" section for all possible commands


问:
log4j2 : Async logger is NOT starting
I have recently upgraded my application to use log4j2. I am trying to make use of its async logger feature. However looks like its not creating one.
As per Log4j Async config, it says,

To make all loggers asynchronous, add the disruptor jar to the classpath and set the system property Log4jContextSelector to org.apache.logging.log4j.core.async.AsyncLoggerContextSelector.
I also set the status="trace" in log4j.xml to see if it configures and instantiate async logger. But looks like it failing.

2017-01-25 01:58:30,799 main TRACE Reregistering context (1/1): 'AsyncContext@18b4aac2' org.apache.logging.log4j.core.async.AsyncLoggerContext@6bf08014
  2017-01-25 01:58:30,800 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=AsyncContext@18b4aac2'
  2017-01-25 01:58:30,800 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=AsyncContext@18b4aac2,component=StatusLogger'
  2017-01-25 01:58:30,800 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=AsyncContext@18b4aac2,component=ContextSelector'
  2017-01-25 01:58:30,801 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=AsyncContext@18b4aac2,component=Loggers,name='
  2017-01-25 01:58:30,801 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=AsyncContext@18b4aac2,component=Appenders,name='
  2017-01-25 01:58:30,801 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=AsyncContext@18b4aac2,component=AsyncAppenders,name='
  2017-01-25 01:58:30,801 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=AsyncContext@18b4aac2,component=AsyncLoggerRingBuffer'
  2017-01-25 01:58:30,802 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=AsyncContext@18b4aac2,component=Loggers,name=,subtype=RingBuffer'
  2017-01-25 01:58:30,803 main DEBUG Registering MBean org.apache.logging.log4j2:type=AsyncContext@18b4aac2
  2017-01-25 01:58:30,805 main DEBUG Registering MBean org.apache.logging.log4j2:type=AsyncContext@18b4aac2,component=AsyncLoggerRingBuffer
  2017-01-25 01:58:30,806 main DEBUG Registering MBean org.apache.logging.log4j2:type=AsyncContext@18b4aac2,component=StatusLogger
  2017-01-25 01:58:30,807 main DEBUG Registering MBean org.apache.logging.log4j2:type=AsyncContext@18b4aac2,component=ContextSelector
  2017-01-25 01:58:30,816 main TRACE Using default SystemClock for timestamps.
  2017-01-25 01:58:30,816 main TRACE Using DummyNanoClock for nanosecond timestamps.
  2017-01-25 01:58:30,817 main DEBUG Reconfiguration complete for context[name=AsyncContext@18b4aac2] at URI /etc/opt/sun/im/default/config/log4j2.xml (org.apache.logging.log4j.core.async.AsyncLoggerContext@6bf08014) with optional ClassLoader: null
  2017-01-25 01:58:30,817 main DEBUG Shutdown hook enabled. Registering a new one.
  2017-01-25 01:58:30,818 main DEBUG LoggerContext[name=AsyncContext@18b4aac2, org.apache.logging.log4j.core.async.AsyncLoggerContext@6bf08014] started OK.

As I don't see anything like "Starting AsyncLogger disruptor".

Then as suggested, I tried using asyncLogger tag, I could see it printing,

2017-01-25 00:27:26,970 main TRACE AsyncLoggerConfigDisruptor creating new disruptor for this configuration.
  2017-01-25 00:27:26,971 main TRACE property AsyncLoggerConfig.WaitStrategy=TIMEOUT
  2017-01-25 00:27:26,987 main DEBUG Starting AsyncLoggerConfig disruptor for this configuration with ringbufferSize=4096, waitStrategy=TimeoutBlockingWaitStrategy, exceptionHandler=org.apache.logging.log4j.core.async.AsyncLoggerConfigDefaultExceptionHandler@7f284218...
  2017-01-25 00:27:26,988 main TRACE AsyncLoggerConfig[xmppd] starting...

But again at later stage it throws exception for class not found,

2017-01-25 00:27:31,658 main ERROR Unable to invoke factory method in class class org.apache.logging.log4j.core.async.AsyncLoggerConfig for element AsyncLogger. java.lang.reflect.InvocationTargetException
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:498)
          at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:132)
          at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:942)
          at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:882)
          at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:874)
          at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:498)
          at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:227)
          at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:239)
          at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:530)
          at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:603)
          at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:620)
          at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:226)
          at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:242)
          at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
          at org.apache.logging.log4j.LogManager.getContext(LogManager.java:174)
          at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:618)
          at org.apache.logging.log4j.LogManager.getRootLogger(LogManager.java:652)
          Caused by: java.lang.NoClassDefFoundError: com/lmax/disruptor/EventFactory
          at org.apache.logging.log4j.core.config.AbstractConfiguration.getAsyncLoggerConfigDelegate(AbstractConfiguration.java:197)
          at org.apache.logging.log4j.core.async.AsyncLoggerConfig.(AsyncLoggerConfig.java:81)
          at org.apache.logging.log4j.core.async.AsyncLoggerConfig.createLogger(AsyncLoggerConfig.java:188)
          ... 23 more
  Caused by: java.lang.ClassNotFoundException: com.lmax.disruptor.EventFactory
          at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
          ... 26 more

I have verified, the disruptor jar which I included has this class. I am using disruptor-3.3.6.jar.

Also How to verify that the async logger has started ?

Any help would be appreciated.

答:
Add these dependancy in your Pom file:  </p>

```<code><!-- Exclude Spring Boot's Default Logging -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Add Log4j2 Dependency -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j2</artifactId>
        </dependency>

        <dependency>
             <groupId>com.lmax</groupId>
             <artifactId>disruptor</artifactId>
                     <version>3.3.7</version>
        </dependency>
</code>```

Title: log4j2 : Async logger is NOT starting

Body:
Add these dependancy in your Pom file:

<!-- Exclude Spring Boot's Default Logging -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Add Log4j2 Dependency -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j2</artifactId>
        </dependency>

        <dependency>
             <groupId>com.lmax</groupId>
             <artifactId>disruptor</artifactId>
                     <version>3.3.7</version>
        </dependency>


问:
Bootstrap Avoid navbar-toggle button to close opened sub menus on mobile
I have a code based on Bootstrap 3.3.7

There are different menu items and sub menus on my menu, I want to have all sub menu items to be open on mobile, Means no need to click on any menu items to display it's sub menus, So I wrote a JS code to open all sub menus on mobile:

```<code>function opensubmenus() {
  if ($(window).width() < 768) {
    $("#top-navbar-collapse li").addClass('open');
  } else {
    $("#top-navbar-collapse li").removeClass('open');
  }
}

$(window).resize(opensubmenus);
opensubmenus();
</code>```

But the problem is when I click on a navbar-toggle button, It closes all submenus, But I need to keep them open on mobile devices all the time
You can check my online sample on this site: https://dedidata.com

Here I have shown a screenshot: https://pasteboard.co/IfSMCIu.jpg

I don't like to disable navbar-toggle button completely, I need it to toggle the whole navbar, But I don't like it close the submenus, My JS code opens the submenus, But navbar-toggle closes those submenus

答:
The following code expands the sub menus when a click occurs on navbar-toggle
and it change the aria-expanded to the correct value based on the open/close state of sub menu

```<code>function opensubmenus() {
    if ($(window).width() < 768) {
        $("#top-navbar-collapse li").addClass('open');
        $("#top-navbar-collapse li a").attr('aria-expanded','true');
    }else{
        $("#top-navbar-collapse li").removeClass('open');
        $("#top-navbar-collapse li a").attr('aria-expanded','false');
    }
}

$('#top-menu .navbar-toggle').click(function(){
    setTimeout(opensubmenus, 100);
});

$(window).resize(opensubmenus);
opensubmenus();
</code>```

Thanks to @abelito for his hint

Body:
I have a code based on Bootstrap 3.3.7

There are different menu items and sub menus on my menu, I want to have all sub menu items to be open on mobile, Means no need to click on any menu items to display it's sub menus, So I wrote a JS code to open all sub menus on mobile:

function opensubmenus() {
  if ($(window).width() < 768) {
    $("#top-navbar-collapse li").addClass('open');
  } else {
    $("#top-navbar-collapse li").removeClass('open');
  }
}

$(window).resize(opensubmenus);
opensubmenus();

But the problem is when I click on a navbar-toggle button, It closes all submenus, But I need to keep them open on mobile devices all the time
You can check my online sample on this site: https://dedidata.com

Here I have shown a screenshot: https://pasteboard.co/IfSMCIu.jpg

I don't like to disable navbar-toggle button completely, I need it to toggle the whole navbar, But I don't like it close the submenus, My JS code opens the submenus, But navbar-toggle closes those submenus

Body:
The following code expands the sub menus when a click occurs on navbar-toggle
and it change the aria-expanded to the correct value based on the open/close state of sub menu

function opensubmenus() {
    if ($(window).width() < 768) {
        $("#top-navbar-collapse li").addClass('open');
        $("#top-navbar-collapse li a").attr('aria-expanded','true');
    }else{
        $("#top-navbar-collapse li").removeClass('open');
        $("#top-navbar-collapse li a").attr('aria-expanded','false');
    }
}

$('#top-menu .navbar-toggle').click(function(){
    setTimeout(opensubmenus, 100);
});

$(window).resize(opensubmenus);
opensubmenus();

Thanks to @abelito for his hint


问:
What are the differences between Cloud Dataflow and Dataprep
Both Dataprep and Dataflow can be used for ETL tasks. In fact Dataprep seems to use Dataflow jobs. Is it that the only difference that Dataprep provides tools to write dataflow jobs with a user interface ?</p>

答: Both dataflow and dataprep can transform data for sure. The main difference is who is using the technology. Does your project need self-service data transformation by data users such as data engineers or business users such as analysts and data scientists? Then dataprep is the choice. This is no coding. Ultimately it generates dataflow jobs. Cloud dataprep offers advanced transformations such as pivoting, unpivoting, aggregations, time series, joins, unions, standardization, and hundreds of other data functions exposed with an intuitive visual interface. Data needs to be in CDS or BigQuery though.</p>


问:
blank line with psql in postgres. How could I remove it?
I do a simple query in Postgres and always shows me a blank line after the result. I need to remove these blank line because I make a cumulative report all days and the blank line must not appear. Here is an example code:</p>

```<code>[user@machine ~/try]$ psql -t postgresql://user:pass@machine/conn << EOF
? SELECT version();
? EOF
 PostgreSQL 9.5.5 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3), 64-bit

[user@machine ~/try]$
</code>```

答:
If you want psql to be quiet, tell it to be:

~> psql --no-align --tuples-only --quiet --command='SELECT version()'
PostgreSQL 11.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.3.1 20190223 (Red Hat 8.3.1-2), 64-bit
~>
```

Body:
I do a simple query in Postgres and always shows me a blank line after the result. I need to remove these blank line because I make a cumulative report all days and the blank line must not appear. Here is an example code:

[user@machine ~/try]$ psql -t postgresql://user:pass@machine/conn << EOF
? SELECT version();
? EOF
 PostgreSQL 9.5.5 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3), 64-bit

[user@machine ~/try]$


问:
I am unable to access routes in production build of my react app
My local build had routing working well and good, once when I created a production build I am unable to access routes in my production build

I have tried all the solutions which I have come across

```<code>import { Route, Link, BrowserRouter as Router } from 'react-router-dom';
function render(component) {
    ReactDOM.render(
        <ApolloProvider client={apolloClient}>
        <Router>
            <div>
                <Route exact path="/" component={Login}/>
                <Route path="/constlist" component={ConstituencyList}/>
                <Route path="/addRep" component={AddRep}/>
                <Route exact path="/roundList/:id" component={RoundList}/>
                <Route exact path="/updateVotes/:cid/:rid" component={UpdateVotes}/>
                <Route exact path="/analysis/:id" component={AnalysisPage}/>
                <Route exact path="/replist" component={RepList}/>
                <Route exact path="/admin" component={AdminLogin}/>
                <Route exact path="/addCandidate" component={AddCandidate}/>
                <Route exact path="/homepage" component={HomePage}/>
            </div>
        </Router>
    </ApolloProvider>, document.getElementById('root'));
}

render(<App />);
</code>```

Actual output: Routing must have been enabled

答:
This issue is not specific to your code. But it happens with any SPA hosted on a web server.

Cause: When you try to hit xyz.com/page1 then webserver assumes that you are trying to get index.html inside 'page1' folder inside your root. That does not work because you don't have 'page1' folder in your root. So webserver gives 404 error. This mostly happens when you directly try to open xyz.com/page1 but it works well when you first open xyz.com and then navigate to xyz.com/page1 . This is becuase when you first load xyz.com your react router has bootstrapped in the browser hand subsequent routing is taken care of.

Resolution: You need to tell webserver to always default to your root's index.html. So when it does not find a folder while looking for index.html inside it, it takes root's index.html. This can be done by changing webserver's config. For example in nginx you can do this:

```<code>location / {
    root   /usr/share/nginx/html;
    index  index.html index.htm;
    try_files $uri /index.html;
}
</code>```

Other webservers may have different setting/config to achieve the same.

Body:
My local build had routing working well and good, once when I created a production build I am unable to access routes in my production build

I have tried all the solutions which I have come across

import { Route, Link, BrowserRouter as Router } from 'react-router-dom';
function render(component) {
    ReactDOM.render(
        <ApolloProvider client={apolloClient}>
        <Router>

                <Route exact path="/" component={Login}/>
                <Route path="/constlist" component={ConstituencyList}/>
                <Route path="/addRep" component={AddRep}/>
                <Route exact path="/roundList/:id" component={RoundList}/>
                <Route exact path="/updateVotes/:cid/:rid" component={UpdateVotes}/>
                <Route exact path="/analysis/:id" component={AnalysisPage}/>
                <Route exact path="/replist" component={RepList}/>
                <Route exact path="/admin" component={AdminLogin}/>
                <Route exact path="/addCandidate" component={AddCandidate}/>
                <Route exact path="/homepage" component={HomePage}/>

        </Router>
    </ApolloProvider>, document.getElementById('root'));
}

render(<App />);

Actual output: Routing must have been enabled

Body:
This issue is not specific to your code. But it happens with any SPA hosted on a web server.

Cause: When you try to hit xyz.com/page1 then webserver assumes that you are trying to get index.html inside 'page1' folder inside your root. That does not work because you don't have 'page1' folder in your root. So webserver gives 404 error. This mostly happens when you directly try to open xyz.com/page1 but it works well when you first open xyz.com and then navigate to xyz.com/page1 . This is becuase when you first load xyz.com your react router has bootstrapped in the browser hand subsequent routing is taken care of.

Resolution: You need to tell webserver to always default to your root's index.html. So when it does not find a folder while looking for index.html inside it, it takes root's index.html. This can be done by changing webserver's config. For example in nginx you can do this:

location / {
    root   /usr/share/nginx/html;
    index  index.html index.htm;
    try_files $uri /index.html;
}

Other webservers may have different setting/config to achieve the same.


问:
Accepting args in $emit - Vue
A very simple alert implementation using $emit, but when passing arguments it behaves as if the event had never even occurred. On the event, I want to set the value of alert to the result.

I am listening on mount as:

```<code>this.$eventHub.$on('alert', data =>
  this.alert = data
})
</code>```

Will Work:

this.alert is undefined, but set.

```<code>this.$eventHub.$emit('alert')
</code>```

Won't Work:

this.alert is never set & event is never heard.

```<code>
this.$eventHub.$emit('alert', {'message':'Signal Test', 'color':'error'})
</code>```

What is occurring here?

答:
You can use this.$emit from the vue component.
Take this example:

<template>
    <myComponent @customEvent="myCallback($event)" />
</template>
```

<p>And the script:</p>

<pre class="lang-js prettyprint-override"><code>export default {
  methods: {
    myCallback(data) {
      console.log(data); // here you have your event data
    }
  }
}
</code>```

And in your child component:

export default {
  methods: {
    onClick() {
      // this.$emit(eventname, data);
      this.$emit('customEvent', 'some data');
    }
  }
}
```

Title: Accepting args in $emit - Vue

Body:
A very simple alert implementation using $emit, but when passing arguments it behaves as if the event had never even occurred. On the event, I want to set the value of alert to the result.

I am listening on mount as:

this.$eventHub.$on('alert', data =>
  this.alert = data
})

Will Work:

this.alert is undefined, but set.

this.$eventHub.$emit('alert')

Won't Work:

this.alert is never set & event is never heard.

this.$eventHub.$emit('alert', {'message':'Signal Test', 'color':'error'})

What is occurring here?

Body:
You can use this.$emit from the vue component.
Take this example:

<template>
    <myComponent @customEvent="myCallback($event)" />
</template>

And the script:

export default {
  methods: {
    myCallback(data) {
      console.log(data); // here you have your event data
    }
  }
}

And in your child component:

export default {
  methods: {
    onClick() {
      // this.$emit(eventname, data);
      this.$emit('customEvent', 'some data');
    }
  }
}


问:
How to instantiate View from ViewModel even if I don't want to display it right after?
I want to search through a few views' controls but I only have access to their ViewModels, because these views aren't displayed and there is no living instance of the view.
Is there a way to instantiate a View through its ViewModel in code? I have to instantiate several of them in one place, having only the VM type.
I'd like the code to be generic.

Edit - more specific information:
I have a lot of different settings views. I want to search through them because right now, the user has to search manually - meaning the user has to go to every tab and look for the word he needs.
My VM is, of course, taking data from inputs but I am not interested in data - I'm interested in labels and texts which are shown to the user.

I'm using WPF, MVVM and Caliburn.Micro.

答:
Yes you can do it. u need to understand that the views are also a class so u just need to create an object like any other class and when u call the ShowDialog. the method in view call it will display on UI

```<code>View MyView= new View();
ViewModel MyViewmodel= new ViewModel();
MyView.DataContext=MyViewmodel;
</code>```

In this part of code it will create object of View and ViewModel and assign the dataContext Prop to Your Vm but not Displayed Any where.

```<code>List<View> AllView= new List<View>()
AllView.Add(MyView);
</code>```

Here I saved your view in list. and these can be static or global. and whenever I need to access these, I will do

```<code>AllView[0].ShowDialog();
</code>```

I'm displaying the first view. I think u got the idea. as per generic method u can check it create an object. it's not that hard. as per me it's not necessary.

Body:
Yes you can do it. u need to understand that the views are also a class so u just need to create an object like any other class and when u call the ShowDialog. the method in view call it will display on UI

View MyView= new View();
ViewModel MyViewmodel= new ViewModel();
MyView.DataContext=MyViewmodel;

In this part of code it will create object of View and ViewModel and assign the dataContext Prop to Your Vm but not Displayed Any where.

List<View> AllView= new List<View>()
AllView.Add(MyView);

Here I saved your view in list. and these can be static or global. and whenever I need to access these, I will do

AllView[0].ShowDialog();

I'm displaying the first view. I think u got the idea. as per generic method u can check it create an object. it's not that hard. as per me it's not necessary.


问:
adb devices list empty on Toshiba AS100 tablet
I'm running into an issue with the android SDK where it doesn't recognize devices (Toshiba AS100) under windows, adb devices list is empty:

```<code>$adb devices
List of devices attached
</code>```

Have tried:

Tutorial: "Enable ADB USB Drivers for
Nvidia Tegra based Android Tablets"

Setting: Settings --> Applications -->
Development --> USB Debugging

According to the tutorial, it works on HTC & Toshiba AC100, but failed on Toshiba AS100. I can find "Android Phone" "Android Composite ADB Interface" items under "Device Manager", but the adb devices list is still empty. Is there an solution to this problem? Thank you.

答: It works! I removed all the emulators and restored all run configures to default. With a third-party usb adb driver, eclispe finds the device automatically. However,it cannot work when sdk's adb running, and cannot show in devices list. Thanks...</p>

Body:
I'm running into an issue with the android SDK where it doesn't recognize devices (Toshiba AS100) under windows, adb devices list is empty:

$adb devices
List of devices attached

Have tried:

Tutorial: "Enable ADB USB Drivers for
Nvidia Tegra based Android Tablets"

Setting: Settings --> Applications -->
Development --> USB Debugging

According to the tutorial, it works on HTC & Toshiba AC100, but failed on Toshiba AS100. I can find "Android Phone" "Android Composite ADB Interface" items under "Device Manager", but the adb devices list is still empty. Is there an solution to this problem? Thank you.


问:
Angular component styles
I have a CSS class in the style.css which should apply to any components within my app. I have a component A that needs this class which works fine. And this component has another component B inside it which needs this class too. But this class won't work in this inner component B. Any ideas?

style.css:

```<code>.my-hover:hover {...}
</code>```

component A:

```<code>....
<div class="my-hover"></div>
<app-component-b *ngIf="aCondition"></app-component-b>
</code>```

component B:

```<code><div class="my-hover"></div>
</code>```

If I prefix my CSS class with ::ng-deep, then this class will not work in A or B.

答:
This should work, as in this example : https://stackblitz.com/edit/angular-ewfqqw .

You should check angular.json, you imported

```<code> "styles": [
     "src/styles.css"
 ],
</code>```

Title: Angular component styles

Body:
I have a CSS class in the style.css which should apply to any components within my app. I have a component A that needs this class which works fine. And this component has another component B inside it which needs this class too. But this class won't work in this inner component B. Any ideas?

style.css:

.my-hover:hover {...}

component A:

....

<app-component-b *ngIf="aCondition"></app-component-b>

component B:

If I prefix my CSS class with ::ng-deep, then this class will not work in A or B.

Body:
This should work, as in this example : https://stackblitz.com/edit/angular-ewfqqw .

You should check angular.json, you imported

 "styles": [
     "src/styles.css"
 ],


问:
how to set a priority high accuracy location for the following code
someone  already did this code in the project. But how to set a priority high accuracy in the location manager. They use location manager to get the current location. </p>

<p>So any one can help out. This not working if any possibilities to change the logic . </p>

```<code>public class GPSTracker extends Service implements LocationListener {

    private final Context mContext;

// flag for GPS status
boolean isGPSEnabled = false;

// flag for network status
boolean isNetworkEnabled = false;

// flag for GPS status
public boolean canGetLocation = false;

Location location; // location
double latitude; // latitude
double longitude; // longitude

// The minimum distance to change Updates in meters
       private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 1;
                      // 10 meters to 1 meters change by me ..

// The minimum time between updates in milliseconds
private static final long MIN_TIME_BW_UPDATES = 1000 * 60 * 1;
                   // 1 minute

// Declaring a Location Manager
protected LocationManager locationManager;

public GPSTracker(Context context) {
    this.mContext = context;
    getLocation();
}

public  Location getLocation() {
    try {
        locationManager = (LocationManager) mContext.getSystemService(LOCATION_SERVICE);

        // getting GPS status
        isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);

        // getting network status
        isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

        if (!isGPSEnabled && !isNetworkEnabled) {
            // no network provider is enabled
        } else {
            this.canGetLocation = true;
            // First get location from Network Provider
            if (isNetworkEnabled) {
                locationManager.requestLocationUpdates(
                        LocationManager.NETWORK_PROVIDER,
                        MIN_TIME_BW_UPDATES,
                        MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                Log.d("Network", "Network");
                if (locationManager != null) {
                    location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                    if (location != null) {
                        latitude = location.getLatitude();
                        longitude = location.getLongitude();
                    }
                }
            }
            // if GPS Enabled get lat/long using GPS Services
            if (isGPSEnabled) {
                if (location == null) {
                    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
                            MIN_TIME_BW_UPDATES,
                            MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                    Log.d("GPS Enabled", "GPS Enabled");
                    if (locationManager != null ) {
                        location = locationManager
                                .getLastKnownLocation(LocationManager.GPS_PROVIDER);
                        if (location != null) {
                            latitude = location.getLatitude();
                            longitude = location.getLongitude();
                        }
                    }
                }
            }
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

    return location;
}

/**
 * Stop using GPS listener
 * Calling this function will stop using GPS in your app
 * */
//@RequiresApi(api = Build.VERSION_CODES.M)
public void stopUsingGPS(){
    if (locationManager != null) {
        if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
                || checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
            locationManager.removeUpdates(GPSTracker.this);
        }
    }
}

public double getLatitude()
{
    if(location != null){
        latitude = location.getLatitude();
    }

    // return latitude
    return latitude;
}

/**
 * Function to get longitude
 * */

public double getLongitude()
{
    if(location != null)
    {
        longitude = location.getLongitude();
    }

    // return longitude
    return longitude;
}

/**
 * Function to get latitude
 * */

/**
 * Function to check GPS/wifi enabled
 * @return boolean
 * */
public boolean canGetLocation() {
    return this.canGetLocation;
}

/**
 * Function to show settings alert dialog
 * On pressing Settings button will lauch Settings Options
 * */
public void showSettingsAlert(){
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);

    // Setting Dialog Title
    alertDialog.setTitle("GPS is settings");

    // Setting Dialog Message
    alertDialog.setMessage("GPS is not enabled. Do you want to go to settings menu?");

    // On pressing Settings button
    alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog,int which) {
            Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            mContext.startActivity(intent);
        }
    });

    // on pressing cancel button
    alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    // Showing Alert Message
    alertDialog.show();
}

@Override
public void onLocationChanged(Location location){
}

@Override
public void onProviderDisabled(String provider){
}

@Override
public void onProviderEnabled(String provider){
}

@Override
public void onStatusChanged(String provider, int status, Bundle extras){
}

@Override
public IBinder onBind(Intent arg0) {
    return null;
}

}
</code>```

答:
You shoul add criteria:</p>

```<code>    LocationManager locationManager = (LocationManager) this
        .getSystemService(Context.LOCATION_SERVICE);

Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE); // Choose your accuracy requirement.

locationManager.getBestProvider(criteria, true)
</code>```

Body:
someone  already did this code in the project. But how to set a priority high accuracy in the location manager. They use location manager to get the current location.

So any one can help out. This not working if any possibilities to change the logic .

public class GPSTracker extends Service implements LocationListener {

    private final Context mContext;

// flag for GPS status
boolean isGPSEnabled = false;

// flag for network status
boolean isNetworkEnabled = false;

// flag for GPS status
public boolean canGetLocation = false;

Location location; // location
double latitude; // latitude
double longitude; // longitude

// The minimum distance to change Updates in meters
       private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 1;
                      // 10 meters to 1 meters change by me ..

// The minimum time between updates in milliseconds
private static final long MIN_TIME_BW_UPDATES = 1000 * 60 * 1;
                   // 1 minute

// Declaring a Location Manager
protected LocationManager locationManager;

public GPSTracker(Context context) {
    this.mContext = context;
    getLocation();
}

public  Location getLocation() {
    try {
        locationManager = (LocationManager) mContext.getSystemService(LOCATION_SERVICE);

        // getting GPS status
        isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);

        // getting network status
        isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

        if (!isGPSEnabled && !isNetworkEnabled) {
            // no network provider is enabled
        } else {
            this.canGetLocation = true;
            // First get location from Network Provider
            if (isNetworkEnabled) {
                locationManager.requestLocationUpdates(
                        LocationManager.NETWORK_PROVIDER,
                        MIN_TIME_BW_UPDATES,
                        MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                Log.d("Network", "Network");
                if (locationManager != null) {
                    location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                    if (location != null) {
                        latitude = location.getLatitude();
                        longitude = location.getLongitude();
                    }
                }
            }
            // if GPS Enabled get lat/long using GPS Services
            if (isGPSEnabled) {
                if (location == null) {
                    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
                            MIN_TIME_BW_UPDATES,
                            MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                    Log.d("GPS Enabled", "GPS Enabled");
                    if (locationManager != null ) {
                        location = locationManager
                                .getLastKnownLocation(LocationManager.GPS_PROVIDER);
                        if (location != null) {
                            latitude = location.getLatitude();
                            longitude = location.getLongitude();
                        }
                    }
                }
            }
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

    return location;
}

/**
 * Stop using GPS listener
 * Calling this function will stop using GPS in your app
 * */
//@RequiresApi(api = Build.VERSION_CODES.M)
public void stopUsingGPS(){
    if (locationManager != null) {
        if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
                || checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
            locationManager.removeUpdates(GPSTracker.this);
        }
    }
}

public double getLatitude()
{
    if(location != null){
        latitude = location.getLatitude();
    }

    // return latitude
    return latitude;
}

/**
 * Function to get longitude
 * */

public double getLongitude()
{
    if(location != null)
    {
        longitude = location.getLongitude();
    }

    // return longitude
    return longitude;
}

/**
 * Function to get latitude
 * */

/**
 * Function to check GPS/wifi enabled
 * @return boolean
 * */
public boolean canGetLocation() {
    return this.canGetLocation;
}

/**
 * Function to show settings alert dialog
 * On pressing Settings button will lauch Settings Options
 * */
public void showSettingsAlert(){
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);

    // Setting Dialog Title
    alertDialog.setTitle("GPS is settings");

    // Setting Dialog Message
    alertDialog.setMessage("GPS is not enabled. Do you want to go to settings menu?");

    // On pressing Settings button
    alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog,int which) {
            Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            mContext.startActivity(intent);
        }
    });

    // on pressing cancel button
    alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    // Showing Alert Message
    alertDialog.show();
}

@Override
public void onLocationChanged(Location location){
}

@Override
public void onProviderDisabled(String provider){
}

@Override
public void onProviderEnabled(String provider){
}

@Override
public void onStatusChanged(String provider, int status, Bundle extras){
}

@Override
public IBinder onBind(Intent arg0) {
    return null;
}

}

Body:
You shoul add criteria:

    LocationManager locationManager = (LocationManager) this
        .getSystemService(Context.LOCATION_SERVICE);

Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE); // Choose your accuracy requirement.

locationManager.getBestProvider(criteria, true)


问:
Can a REST API built with Flask and Python be accessed from an external network?
I'm trying to use a REST API, built using Flask and Python, to create a server from my Raspberry Pi and access it from my iPhone. I have a very simple question: can I access the server from a network other than the one it is created on? So, for example, if the server is created on my home wifi, can I access it from my workplace wifi? If so, how?

Currently, I can access the server from any device connected to the same network. I have seen many similar posts online about similar problems, but I cannot find a direct answer to my question above.

Here is my code:

from flask import Flask, jsonify, request

app = Flask(__name__)

@app.route("/test")
def hello():
    return jsonify({"about":"Hello World"})

if __name__ == '__main__':
    app.run(host="0.0.0.0", port=2000,debug=True)
```

If I go onto Safari on my iPhone when connected to mobile data and type in "http://RaspberryPiIP:2000/test", then the page will not load and "take too long to respond." However, if I do the same thing on my home wifi, which the raspberry pi is also connected to, the page will load as expected.

答: In order to access some thing on the internet you need static IP address which will not change like dynamic IPs that your ISP assigns to you. However there are services like this that will provide you with dns name pointed to your dynamic IP address also you need to do some port forwarding which is not safe.</p>

Body:
I'm trying to use a REST API, built using Flask and Python, to create a server from my Raspberry Pi and access it from my iPhone. I have a very simple question: can I access the server from a network other than the one it is created on? So, for example, if the server is created on my home wifi, can I access it from my workplace wifi? If so, how?

Currently, I can access the server from any device connected to the same network. I have seen many similar posts online about similar problems, but I cannot find a direct answer to my question above.

Here is my code:

from flask import Flask, jsonify, request

app = Flask(__name__)

@app.route("/test")
def hello():
    return jsonify({"about":"Hello World"})

if __name__ == '__main__':
    app.run(host="0.0.0.0", port=2000,debug=True)

If I go onto Safari on my iPhone when connected to mobile data and type in "http://RaspberryPiIP:2000/test", then the page will not load and "take too long to respond." However, if I do the same thing on my home wifi, which the raspberry pi is also connected to, the page will load as expected.


问:
Build pipes with multiple async HTTP requests
I need to make first HTTP request and get from response array of object.
Then I need to make HTTP request for every object in array (probably in loop) to get extra info. All this inside Angular. I try with pipes but have some difficulties.</p>

答:
Your explanation is quite vague, and without a pseudocode example or an actual example of what you've tried to do, this is hard to answer.

But what I gather is that you need:

API call 1:

```<code>{ ids: [1, 2, 3] }
</code>```

API call 2 takes an ID (api(1), api(2), api(3) etc.) and returns:

```<code>{ something: 'else', id: 1 }
</code>```

In RxJS you would want to switchMap for every ID you get, so you can switch the subscription to a new Observable. If you want all of these to come in when they come in you would merge these. If you want them to come in predictably and in order you would concat them.

Basic example:

```<code>this.http.get<{id: number[]}>('api1').pipe(
   switchMap(ids => {
      return concat(ids.forEach(id => {
           return this.http.get<{ something: string, id: number}>('api2/' + id)
      })
   }).subscribe(console.log)
</code>```

Body:
Your explanation is quite vague, and without a pseudocode example or an actual example of what you've tried to do, this is hard to answer.

But what I gather is that you need:

API call 1:

{ ids: [1, 2, 3] }

API call 2 takes an ID (api(1), api(2), api(3) etc.) and returns:

{ something: 'else', id: 1 }

In RxJS you would want to switchMap for every ID you get, so you can switch the subscription to a new Observable. If you want all of these to come in when they come in you would merge these. If you want them to come in predictably and in order you would concat them.

Basic example:

this.http.get<{id: number[]}>('api1').pipe(
   switchMap(ids => {
      return concat(ids.forEach(id => {
           return this.http.get<{ something: string, id: number}>('api2/' + id)
      })
   }).subscribe(console.log)


问:
Angular 7 Table with Pagination, Sort, and Filter
Hi does anyone knows how to make a table with pagination, sort and filter in angular. I'm using Creative Tim's Argon Dashboard for Angular and I'm confused how I am going to integrate it to my project

Here's the documentation of the template click me

Here's a sample code of the table

```<code><div class="table-responsive">
    <table class="table align-items-center table-flush">
      <thead class="thead-light">
        <tr>
          <th scope="col">Project</th>
          <th scope="col">Budget</th>
          <th scope="col">Status</th>
          <th scope="col">Users</th>
          <th scope="col">Completion</th>
          <th scope="col"></th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <th scope="row">
            <div class="media align-items-center">
              <a href="#" class="avatar rounded-circle mr-3">
                <img alt="Image placeholder" src="assets/img/theme/bootstrap.jpg">
              </a>
              <div class="media-body">
                <span class="mb-0 text-sm">Argon Design System</span>
              </div>
            </div>
          </th>
          <td>
            $2,500 USD
          </td>
          <td>
            <span class="badge badge-dot mr-4">
              <i class="bg-warning"></i> pending
            </span>
          </td>
          <td>
            <div class="avatar-group">
              <a href="#" class="avatar avatar-sm" data-toggle="tooltip" data-original-title="Ryan Tompson">
                <img alt="Image placeholder" src="assets/img/theme/team-1-800x800.jpg" class="rounded-circle">
              </a>
              <a href="#" class="avatar avatar-sm" data-toggle="tooltip" data-original-title="Romina Hadid">
                <img alt="Image placeholder" src="assets/img/theme/team-2-800x800.jpg" class="rounded-circle">
              </a>
              <a href="#" class="avatar avatar-sm" data-toggle="tooltip" data-original-title="Alexander Smith">
                <img alt="Image placeholder" src="assets/img/theme/team-3-800x800.jpg" class="rounded-circle">
              </a>
              <a href="#" class="avatar avatar-sm" data-toggle="tooltip" data-original-title="Jessica Doe">
                <img alt="Image placeholder" src="assets/img/theme/team-4-800x800.jpg" class="rounded-circle">
              </a>
            </div>
          </td>
          <td>
            <div class="d-flex align-items-center">
              <span class="mr-2">60%</span>
              <div>
                <div class="progress">
                  <div class="progress-bar bg-warning" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%;"></div>
                </div>
              </div>
            </div>
          </td>
          <td class="text-right">
            <div ngbDropdown placement="bottom-right">
              <a class="btn btn-sm btn-icon-only text-light"  ngbDropdownToggle>
                <i class="fas fa-ellipsis-v"></i>
              </a>
              <div ngbDropdownMenu class=" dropdown-menu-right dropdown-menu-arrow">
                <a class="dropdown-item" href="#">Action</a>
                <a class="dropdown-item" href="#">Another action</a>
                <a class="dropdown-item" href="#">Something else here</a>
              </div>
            </div>
          </td>
        </tr>
        <tr>
          <th scope="row">
            <div class="media align-items-center">
              <a href="#" class="avatar rounded-circle mr-3">
                <img alt="Image placeholder" src="assets/img/theme/angular.jpg">
              </a>
              <div class="media-body">
                <span class="mb-0 text-sm">Angular Now UI Kit PRO</span>
              </div>
            </div>
          </th>
          <td>
            $1,800 USD
          </td>
          <td>
            <span class="badge badge-dot">
              <i class="bg-success"></i> completed
            </span>
          </td>
          <td>
            <div class="avatar-group">
              <a href="#" class="avatar avatar-sm" data-toggle="tooltip" data-original-title="Ryan Tompson">
                <img alt="Image placeholder" src="assets/img/theme/team-1-800x800.jpg" class="rounded-circle">
              </a>
              <a href="#" class="avatar avatar-sm" data-toggle="tooltip" data-original-title="Romina Hadid">
                <img alt="Image placeholder" src="assets/img/theme/team-2-800x800.jpg" class="rounded-circle">
              </a>
              <a href="#" class="avatar avatar-sm" data-toggle="tooltip" data-original-title="Alexander Smith">
                <img alt="Image placeholder" src="assets/img/theme/team-3-800x800.jpg" class="rounded-circle">
              </a>
              <a href="#" class="avatar avatar-sm" data-toggle="tooltip" data-original-title="Jessica Doe">
                <img alt="Image placeholder" src="assets/img/theme/team-4-800x800.jpg" class="rounded-circle">
              </a>
            </div>
          </td>
          <td>
            <div class="d-flex align-items-center">
              <span class="mr-2">100%</span>
              <div>
                <div class="progress">
                  <div class="progress-bar bg-success" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%;"></div>
                </div>
              </div>
            </div>
          </td>
          <td class="text-right">
            <div ngbDropdown  placement="bottom-right">
              <a class="btn btn-sm btn-icon-only text-light"  ngbDropdownToggle>
                <i class="fas fa-ellipsis-v"></i>
              </a>
              <div ngbDropdownMenu class=" dropdown-menu-right dropdown-menu-arrow">
                <a class="dropdown-item" href="#">Action</a>
                <a class="dropdown-item" href="#">Another action</a>
                <a class="dropdown-item" href="#">Something else here</a>
              </div>
            </div>
          </td>
        </tr>
        <tr>
          <th scope="row">
            <div class="media align-items-center">
              <a href="#" class="avatar rounded-circle mr-3">
                <img alt="Image placeholder" src="assets/img/theme/sketch.jpg">
              </a>
              <div class="media-body">
                <span class="mb-0 text-sm">Black Dashboard</span>
              </div>
            </div>
          </th>
          <td>
            $3,150 USD
          </td>
          <td>
            <span class="badge badge-dot mr-4">
              <i class="bg-danger"></i> delayed
            </span>
          </td>
          <td>
            <div class="avatar-group">
              <a href="#" class="avatar avatar-sm" data-toggle="tooltip" data-original-title="Ryan Tompson">
                <img alt="Image placeholder" src="assets/img/theme/team-1-800x800.jpg" class="rounded-circle">
              </a>
              <a href="#" class="avatar avatar-sm" data-toggle="tooltip" data-original-title="Romina Hadid">
                <img alt="Image placeholder" src="assets/img/theme/team-2-800x800.jpg" class="rounded-circle">
              </a>
              <a href="#" class="avatar avatar-sm" data-toggle="tooltip" data-original-title="Alexander Smith">
                <img alt="Image placeholder" src="assets/img/theme/team-3-800x800.jpg" class="rounded-circle">
              </a>
              <a href="#" class="avatar avatar-sm" data-toggle="tooltip" data-original-title="Jessica Doe">
                <img alt="Image placeholder" src="assets/img/theme/team-4-800x800.jpg" class="rounded-circle">
              </a>
            </div>
          </td>
          <td>
            <div class="d-flex align-items-center">
              <span class="mr-2">72%</span>
              <div>
                <div class="progress">
                  <div class="progress-bar bg-danger" role="progressbar" aria-valuenow="72" aria-valuemin="0" aria-valuemax="100" style="width: 72%;"></div>
                </div>
              </div>
            </div>
          </td>
          <td class="text-right">
            <div ngbDropdown  placement="top-right">
              <a class="btn btn-sm btn-icon-only text-light"  ngbDropdownToggle>
                <i class="fas fa-ellipsis-v"></i>
              </a>
              <div ngbDropdownMenu class=" dropdown-menu-right dropdown-menu-arrow">
                <a class="dropdown-item" href="#">Action</a>
                <a class="dropdown-item" href="#">Another action</a>
                <a class="dropdown-item" href="#">Something else here</a>
              </div>
            </div>
          </td>
        </tr>
        <tr>
          <th scope="row">
            <div class="media align-items-center">
              <a href="#" class="avatar rounded-circle mr-3">
                <img alt="Image placeholder" src="assets/img/theme/react.jpg">
              </a>
              <div class="media-body">
                <span class="mb-0 text-sm">React Material Dashboard</span>
              </div>
            </div>
          </th>
          <td>
            $4,400 USD
          </td>
          <td>
            <span class="badge badge-dot">
              <i class="bg-info"></i> on schedule
            </span>
          </td>
          <td>
            <div class="avatar-group">
              <a href="#" class="avatar avatar-sm" data-toggle="tooltip" data-original-title="Ryan Tompson">
                <img alt="Image placeholder" src="assets/img/theme/team-1-800x800.jpg" class="rounded-circle">
              </a>
              <a href="#" class="avatar avatar-sm" data-toggle="tooltip" data-original-title="Romina Hadid">
                <img alt="Image placeholder" src="assets/img/theme/team-2-800x800.jpg" class="rounded-circle">
              </a>
              <a href="#" class="avatar avatar-sm" data-toggle="tooltip" data-original-title="Alexander Smith">
                <img alt="Image placeholder" src="assets/img/theme/team-3-800x800.jpg" class="rounded-circle">
              </a>
              <a href="#" class="avatar avatar-sm" data-toggle="tooltip" data-original-title="Jessica Doe">
                <img alt="Image placeholder" src="assets/img/theme/team-4-800x800.jpg" class="rounded-circle">
              </a>
            </div>
          </td>
          <td>
            <div class="d-flex align-items-center">
              <span class="mr-2">90%</span>
              <div>
                <div class="progress">
                  <div class="progress-bar bg-info" role="progressbar" aria-valuenow="90" aria-valuemin="0" aria-valuemax="100" style="width: 90%;"></div>
                </div>
              </div>
            </div>
          </td>
          <td class="text-right">
            <div ngbDropdown   placement="top-right">
              <a class="btn btn-sm btn-icon-only text-light"  ngbDropdownToggle>
                <i class="fas fa-ellipsis-v"></i>
              </a>
              <div ngbDropdownMenu class=" dropdown-menu-right dropdown-menu-arrow">
                <a class="dropdown-item" href="#">Action</a>
                <a class="dropdown-item" href="#">Another action</a>
                <a class="dropdown-item" href="#">Something else here</a>
              </div>
            </div>
          </td>
        </tr>
        <tr>
          <th scope="row">
            <div class="media align-items-center">
              <a href="#" class="avatar rounded-circle mr-3">
                <img alt="Image placeholder" src="assets/img/theme/vue.jpg">
              </a>
              <div class="media-body">
                <span class="mb-0 text-sm">Vue Paper UI Kit PRO</span>
              </div>
            </div>
          </th>
          <td>
            $2,200 USD
          </td>
          <td>
            <span class="badge badge-dot mr-4">
              <i class="bg-success"></i> completed
            </span>
          </td>
          <td>
            <div class="avatar-group">
              <a href="#" class="avatar avatar-sm" data-toggle="tooltip" data-original-title="Ryan Tompson">
                <img alt="Image placeholder" src="assets/img/theme/team-1-800x800.jpg" class="rounded-circle">
              </a>
              <a href="#" class="avatar avatar-sm" data-toggle="tooltip" data-original-title="Romina Hadid">
                <img alt="Image placeholder" src="assets/img/theme/team-2-800x800.jpg" class="rounded-circle">
              </a>
              <a href="#" class="avatar avatar-sm" data-toggle="tooltip" data-original-title="Alexander Smith">
                <img alt="Image placeholder" src="assets/img/theme/team-3-800x800.jpg" class="rounded-circle">
              </a>
              <a href="#" class="avatar avatar-sm" data-toggle="tooltip" data-original-title="Jessica Doe">
                <img alt="Image placeholder" src="assets/img/theme/team-4-800x800.jpg" class="rounded-circle">
              </a>
            </div>
          </td>
          <td>
            <div class="d-flex align-items-center">
              <span class="mr-2">100%</span>
              <div>
                <div class="progress">
                  <div class="progress-bar bg-success" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%;"></div>
                </div>
              </div>
            </div>
          </td>
          <td class="text-right">
            <div ngbDropdown   placement="top-right">
              <a class="btn btn-sm btn-icon-only text-light"  ngbDropdownToggle>
                <i class="fas fa-ellipsis-v"></i>
              </a>
              <div ngbDropdownMenu class=" dropdown-menu-right dropdown-menu-arrow">
                <a class="dropdown-item" href="#">Action</a>
                <a class="dropdown-item" href="#">Another action</a>
                <a class="dropdown-item" href="#">Something else here</a>
              </div>
            </div>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</code>```

Here's a sample code of the pagination used

```<code><nav aria-label="...">
<ul class="pagination pagination-sm">
  <li class="page-item disabled">
    <a class="page-link" href="#" tabindex="-1">1</a>
  </li>
  <li class="page-item"><a class="page-link" href="#">2</a></li>
  <li class="page-item active"><a class="page-link" href="#">3</a></li>
</ul>
</code>```

I don't know about the filter. I really don't know how to start I'm kinda new to this. I came from AngularJS 1.6.x

edit: I would like to know I can still use the table design from the template if I integrated some of your suggestions

答:
Another nice free library with data table and more is PrimeNG.

It's easy to integrate and have many controls. Basic styling is free, full-fledged designs are paid if you want them.

Body:
Hi does anyone knows how to make a table with pagination, sort and filter in angular. I'm using Creative Tim's Argon Dashboard for Angular and I'm confused how I am going to integrate it to my project

Here's the documentation of the template click me

Here's a sample code of the table

          Project
          Budget
          Status
          Users
          Completion

                Argon Design System

            $2,500 USD

               pending

              60%

                Action
                Another action
                Something else here

                Angular Now UI Kit PRO

            $1,800 USD

               completed

              100%

                Action
                Another action
                Something else here

                Black Dashboard

            $3,150 USD

               delayed

              72%

                Action
                Another action
                Something else here

                React Material Dashboard

            $4,400 USD

               on schedule

              90%

                Action
                Another action
                Something else here

                Vue Paper UI Kit PRO

            $2,200 USD

               completed

              100%

                Action
                Another action
                Something else here

Here's a sample code of the pagination used

    1

2

3

I don't know about the filter. I really don't know how to start I'm kinda new to this. I came from AngularJS 1.6.x

edit: I would like to know I can still use the table design from the template if I integrated some of your suggestions


问:
Game AI OO Framework
Is there an artificial intelligence (AI) programming framework for game software engineers? I'm specifically looking for a library of object-oriented classes that I can use in a game. Specifically, I would like to know the best way to program NPC decision making that is purely object oriented. I have googled and gotten a lot of useless links to machine learning and theoretical AI websites that have absolutely nothing to do with practical software engineering. Any frameworks I've found are all either out of date or too academic to be useful. Specifically, I'm looking for Java or Objective-C libraries. </p>

答:
So you're looking for AI middleware/frameworks? Here's bunch:

AI Implant

GRIP Character Control System

AI Gamedev Sandbox (as was already mentioned in the comments, requires premium access)

Kynapse

Wikipedia also lists bunch of other AI middleware, but these were the ones I have some experience in.

Title: Game AI OO Framework


问:
How can I filter by search term condition in Laravel?
Each made a code to filter search terms by gender, nationality, purpose and age, but these apps are all working separately. I want to make this a result.
I'd like to know how to respond to various conditions at once. For example, if the sex and age are heard at once, I have to return the results on it, and I want to know how.
There are two things I want to solve here.
1.Apply condition overlay of all search results
2.When entering a page without searching, no list was printed</p>

```<code>//base Object
    $penpals =  $this->penpalModel->getUsers();

    //name search
    if (!empty($request->name)) {
        $users = $this->userModel->where('name', 'like', '%' . $request->name . '%')->get();
        if (!empty($users)) {

            $penpals->whereIn('user_id', $users);
        }
    }

    //gender search
    if (!empty($request->gender) && $request->gender !== 'all') {
        $penpals->leftJoin('users', 'penpals.user_id', '=', 'users.id')
        ->select('penpals.*', 'users.gender')
        ->where('users.gender', $request->gender);
    }

    // country search
    if (!empty($request->country) && $request->country !== 'all') {
    $penpals->leftJoin('users', 'penpals.user_id', '=', 'users.id')
    ->select('penpals.*', 'users.country')
    ->where('users.country', $request->country);
    }

     // goal search
     if (!empty($request->goal) && $request->goal !== 'all') {

        $penpals = $this->penpalModel->where('goal_id',$request->goal)->latest();
     }

    //age search
    if($request->ageMin != 1 || $request->ageMax != 100 ){

        $ageMin = floor($request->ageMin);
        $ageMax = floor($request->ageMax);

        $penpals = $this->penpalModel->leftJoin('users', 'penpals.user_id', '=', 'users.id')
        ->select('penpals.*', 'users.age')
        ->whereBetween('users.age', [$ageMin, $ageMax])
        ->orderBy('penpals.created_at','desc');

    }

    //search result
    $penpalsData = $penpals->orderBy('penpals.created_at','desc')->paginate(12);
$penpalsCount = count($penpalsData);

    return view('penpal.index')->with([
        'penpals'       => $penpalsData,
        'penpalsCount'  => $penpalsCount
        ]);
</code>```

答:
What I would do is build the object as you go along the search filters.

What you're doing currently is applying the filter and ending it abruptly and to each.

Apply each filter that is present first, then on the end execute the search.

Do it like so:

```<code>add filter (age).
add filter (nationality).
-> then finally execute search.
</code>```

Not:

```<code>filter (age) -> search. execute.
filter (nationality) -> search. execute.
</code>```

Here's the idea (of course this is not tested):

```<code><?php

// $penpals =  $this->penpalModel->getUsers()->latest()->paginate(12);
// base penpals object
$penpals = $this->penpalModel;
// start out with the initial original object, untouched

// if nickname is present, add filter nickname
if (!empty($request->name)) {
    $users = $this->userModel->where('name', 'like', '%' . $request->name . '%')->get();
    if (!empty($users)) {
        // apply | attached user ids found
        $penpals->whereIn('user_id', $users);
    }
}
// dont cut off the query and execute yet, continually check other filters
if (!empty($request->gender) && $request->gender !== 'all') {
    $penpals->leftJoin('users', 'penpals.user_id', '=', 'users.id')
    ->select('penpals.*', 'users.gender')
    ->where('users.gender', $request->gender);
}
// again, continue to the next set of filters (country search)
// and so on, the same syntax, build off of the base object and continually connect filters

// then on the end, EXECUTE it!

$penpalsData = $penpals->orderBy('penpals.created_at','desc')->paginate(12); // execute then builder after several layers of filters are applied!
$penpalsCount = count($penpalsData);

return view('penpal.index')->with([
    'penpals'       => $penpalsData,
    'penpalsCount'  => $penpalsCount
]);
</code>```

Just follow this idea or concept, this isn't your copy the answer and works type. Modify it and fit it properly to your business logic.

Body:
Each made a code to filter search terms by gender, nationality, purpose and age, but these apps are all working separately. I want to make this a result.
I'd like to know how to respond to various conditions at once. For example, if the sex and age are heard at once, I have to return the results on it, and I want to know how.
There are two things I want to solve here.
1.Apply condition overlay of all search results
2.When entering a page without searching, no list was printed

//base Object
    $penpals =  $this->penpalModel->getUsers();

    //name search
    if (!empty($request->name)) {
        $users = $this->userModel->where('name', 'like', '%' . $request->name . '%')->get();
        if (!empty($users)) {

            $penpals->whereIn('user_id', $users);
        }
    }

    //gender search
    if (!empty($request->gender) && $request->gender !== 'all') {
        $penpals->leftJoin('users', 'penpals.user_id', '=', 'users.id')
        ->select('penpals.*', 'users.gender')
        ->where('users.gender', $request->gender);
    }

    // country search
    if (!empty($request->country) && $request->country !== 'all') {
    $penpals->leftJoin('users', 'penpals.user_id', '=', 'users.id')
    ->select('penpals.*', 'users.country')
    ->where('users.country', $request->country);
    }

     // goal search
     if (!empty($request->goal) && $request->goal !== 'all') {

        $penpals = $this->penpalModel->where('goal_id',$request->goal)->latest();
     }

    //age search
    if($request->ageMin != 1 || $request->ageMax != 100 ){

        $ageMin = floor($request->ageMin);
        $ageMax = floor($request->ageMax);

        $penpals = $this->penpalModel->leftJoin('users', 'penpals.user_id', '=', 'users.id')
        ->select('penpals.*', 'users.age')
        ->whereBetween('users.age', [$ageMin, $ageMax])
        ->orderBy('penpals.created_at','desc');

    }

    //search result
    $penpalsData = $penpals->orderBy('penpals.created_at','desc')->paginate(12);
$penpalsCount = count($penpalsData);

    return view('penpal.index')->with([
        'penpals'       => $penpalsData,
        'penpalsCount'  => $penpalsCount
        ]);

Body:
What I would do is build the object as you go along the search filters.

What you're doing currently is applying the filter and ending it abruptly and to each.

Apply each filter that is present first, then on the end execute the search.

Do it like so:

add filter (age).
add filter (nationality).
-> then finally execute search.

Not:

filter (age) -> search. execute.
filter (nationality) -> search. execute.

Here's the idea (of course this is not tested):

<?php

// $penpals =  $this->penpalModel->getUsers()->latest()->paginate(12);
// base penpals object
$penpals = $this->penpalModel;
// start out with the initial original object, untouched

// if nickname is present, add filter nickname
if (!empty($request->name)) {
    $users = $this->userModel->where('name', 'like', '%' . $request->name . '%')->get();
    if (!empty($users)) {
        // apply | attached user ids found
        $penpals->whereIn('user_id', $users);
    }
}
// dont cut off the query and execute yet, continually check other filters
if (!empty($request->gender) && $request->gender !== 'all') {
    $penpals->leftJoin('users', 'penpals.user_id', '=', 'users.id')
    ->select('penpals.*', 'users.gender')
    ->where('users.gender', $request->gender);
}
// again, continue to the next set of filters (country search)
// and so on, the same syntax, build off of the base object and continually connect filters

// then on the end, EXECUTE it!

$penpalsData = $penpals->orderBy('penpals.created_at','desc')->paginate(12); // execute then builder after several layers of filters are applied!
$penpalsCount = count($penpalsData);

return view('penpal.index')->with([
    'penpals'       => $penpalsData,
    'penpalsCount'  => $penpalsCount
]);

Just follow this idea or concept, this isn't your copy the answer and works type. Modify it and fit it properly to your business logic.


问:
war file huge after upgrading to gradle-5
I have a multi-module-gradle-build.
Some projects have a build.gradle, others have a build.gradle.kts.

Upgrading gradle from 4.10 to 5.4.1 has a strange effect on war projects if and only if they are defined in build.gradle.kts.

```<code>$ unzip -l myproject.war
                       ... // WEB-INF/classes left out
        0  2019-05-27 15:23   WEB-INF/lib/
125552613  2019-05-27 15:10   WEB-INF/lib/gradle-api-5.4.1.jar
  8566737  2019-05-27 15:10   WEB-INF/lib/groovy-all-1.0-2.5.4.jar
     1607  2019-05-27 15:10   WEB-INF/lib/gradle-installation-beacon-5.4.1.jar
</code>```

These jars are not needed and bloat the war file.

They were not contained when built with gradle-4.10.

They are not contained in projects with build.gradle.

How to get rid of them?

I cannot paste the entire build logic. But one of the projects build.gradle.kts that suffers the phenomenon looks so:

```<code>import groovy.lang.Closure

plugins {
    `kotlin-dsl`
}

fun gradleScript(name: String) = rootDir.resolve("gradle-scripts/$name.gradle")

apply(from = gradleScript("java8-project"))
apply(from = gradleScript("war-no-version"))
apply(from = gradleScript("deploy-jboss"))
apply(from = gradleScript("kotlin"))
apply(from = gradleScript("jpa-provider"))

val testJpaWith: Closure<String> by extra
//testJpaWith("openjpa")
testJpaWith("hibernate")

val test by tasks.getting(Test::class) {
    useJUnitPlatform()
}

dependencies {
    compileOnly(Libs.javaee_api)

    testCompileOnly(Libs.javaee_api)
    testImplementation(Libs.assertj_core)
    testRuntimeOnly("org.glassfish:javax.json:1.0.4")

    testImplementation(Libs.javalin)
    testRuntimeOnly("com.fasterxml.jackson.core:jackson-databind:2.9.6")
    testImplementation("khttp:khttp:1.0.0")
    testImplementation(project(":test-jpa"))

    testImplementation(Libs.junit_jupiter_api)
    testRuntimeOnly(Libs.junit_jupiter_engine)
}
</code>```

答:
Answering my own question:

Replacing

```<code>plugins {
    `kotlin-dsl`
}
</code>```

by

```<code>plugins {
    id("org.jetbrains.kotlin.jvm")
}
</code>```

solved the issue

Body:
I have a multi-module-gradle-build.
Some projects have a build.gradle, others have a build.gradle.kts.

Upgrading gradle from 4.10 to 5.4.1 has a strange effect on war projects if and only if they are defined in build.gradle.kts.

$ unzip -l myproject.war
                       ... // WEB-INF/classes left out
        0  2019-05-27 15:23   WEB-INF/lib/
125552613  2019-05-27 15:10   WEB-INF/lib/gradle-api-5.4.1.jar
  8566737  2019-05-27 15:10   WEB-INF/lib/groovy-all-1.0-2.5.4.jar
     1607  2019-05-27 15:10   WEB-INF/lib/gradle-installation-beacon-5.4.1.jar

These jars are not needed and bloat the war file.

They were not contained when built with gradle-4.10.

They are not contained in projects with build.gradle.

How to get rid of them?

I cannot paste the entire build logic. But one of the projects build.gradle.kts that suffers the phenomenon looks so:

import groovy.lang.Closure

plugins {
    `kotlin-dsl`
}

fun gradleScript(name: String) = rootDir.resolve("gradle-scripts/$name.gradle")

apply(from = gradleScript("java8-project"))
apply(from = gradleScript("war-no-version"))
apply(from = gradleScript("deploy-jboss"))
apply(from = gradleScript("kotlin"))
apply(from = gradleScript("jpa-provider"))

val testJpaWith: Closure<String> by extra
//testJpaWith("openjpa")
testJpaWith("hibernate")

val test by tasks.getting(Test::class) {
    useJUnitPlatform()
}

dependencies {
    compileOnly(Libs.javaee_api)

    testCompileOnly(Libs.javaee_api)
    testImplementation(Libs.assertj_core)
    testRuntimeOnly("org.glassfish:javax.json:1.0.4")

    testImplementation(Libs.javalin)
    testRuntimeOnly("com.fasterxml.jackson.core:jackson-databind:2.9.6")
    testImplementation("khttp:khttp:1.0.0")
    testImplementation(project(":test-jpa"))

    testImplementation(Libs.junit_jupiter_api)
    testRuntimeOnly(Libs.junit_jupiter_engine)
}

Body:
Answering my own question:

Replacing

plugins {
    `kotlin-dsl`
}

by

plugins {
    id("org.jetbrains.kotlin.jvm")
}

solved the issue


问:
How to know the source/medium from which user visited my google play store app Url
I want to find out from which source user has entered to my google play store App Url. In Google Play Console in User Acquisition -> Acquisition Report where it displays list of Acquisition channels with the number of store listing visitors and first time installers, one of the channel Play Store(Organic) has 2 categories in it 1) Search 2) Explore
I understand Search represents the category for users who visited by searching from google play store
Whereas I have no idea which category of users represent Explore? Want to know from where in google play store users has explored & found my App? Please help me understand with this information, I have been struggling to understand how numbers in the Explore has drastically come down from last month
<img src="https://i.stack.imgur.com/rrSvX.jpg" alt="enter image description here">  </p>

答:
The complete description of what each section means is in the help document on the support center.

Play Store (Organic): Unique users who saw your app's store listing by browsing or searching on the Play Store app.

Search: Unique users who found your app on Google Play from search results. These users are also counted in the Play Store (Organic) row.

Explore: Unique users who found your app on Google Play but not from search results (for example, browsing a category or similar apps cards). These users are also counted in the Play Store (Organic) row.

So these are users who found your app just by browsing.


问:
How to make a list from string values (dates in a cell separated by delimeter)
I have a table shown like this (there is only one column where all dates are written in one cell, separated by a delimiter). How to make a list of dates out of those values and calculate MAX and MIN value in a particular row?

```<code>values
1. 01. 2019;5. 07. 2016;3. 05. 2014;1. 04. 2019;7. 04. 2016
2. 01. 2019;6. 07. 2016;2. 01. 2019;3. 01. 2019;8. 04. 2016
3. 01. 2019;7. 07. 2016;4. 01. 2019;9. 07. 2016
8. 07. 2016;8. 07. 2016;9. 07. 2016;4. 01. 2019;10. 04. 2016
5. 01. 2019;3. 04. 2019;8. 04. 2016;11. 04. 2016
6. 01. 2019;2. 04. 2019;6. 01. 2019;6. 07. 2016
</code>```

I tried to do List.Max([values]), but this doesn't work.

答:
I would first add an Index column (to preserve the row context), then Split the values column, By Delimiter, into Rows (advanced option). This will produce a row for each delimited sub-string (date).

Then I would convert the resulting values column to a Date datatype using Change Type Using Locale. It might need some string manipulation first e.g. Replace spaces with empty strings.

Finally I would Group By the Index column (added above) while aggregating the Max and Min of the values column.

Body:
I have a table shown like this (there is only one column where all dates are written in one cell, separated by a delimiter). How to make a list of dates out of those values and calculate MAX and MIN value in a particular row?

values
1. 01. 2019;5. 07. 2016;3. 05. 2014;1. 04. 2019;7. 04. 2016
2. 01. 2019;6. 07. 2016;2. 01. 2019;3. 01. 2019;8. 04. 2016
3. 01. 2019;7. 07. 2016;4. 01. 2019;9. 07. 2016
8. 07. 2016;8. 07. 2016;9. 07. 2016;4. 01. 2019;10. 04. 2016
5. 01. 2019;3. 04. 2019;8. 04. 2016;11. 04. 2016
6. 01. 2019;2. 04. 2019;6. 01. 2019;6. 07. 2016

I tried to do List.Max([values]), but this doesn't work.


问:
App testing return "NullInjectorError: No provider for Location!"
Testing an app in Angular 7 with Karma, I can't remove the error in subj.

I have searched various places (mostly here) but either the solutions don't work or are not relevant to my case.

App.component.html:

```<code><app-header></app-header>
<router-outlet></router-outlet>
</code>```

Header.component.ts:

```<code>import { Component, OnInit, ViewChild, ElementRef, AfterViewInit, EventEmitter, Output } from '@angular/core';
import { Router } from '@angular/router';
import { Location } from '@angular/common';

@Component({
    selector: 'app-header',
    templateUrl: './header.component.html',
    styleUrls: ['./header.component.less']
})
export class HeaderComponent implements AfterViewInit, OnInit {
    constructor(private location: Location, private router: Router) {
        setInterval(() => {
            this.now = new Date();
        }, 1000);
    }
...
    onKeyDown(event: KeyboardEvent): void {
        event.preventDefault();
        if (event.which === this.KEY_ESCAPE){
            if (this.router.url !== '/'){
                this.location.back();
            }
        }
    }
</code>```

App.component.spec.ts:

```<code>import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
import { HeaderComponent } from './header/header.component';
import { RouterOutlet } from '@angular/router';

describe('AppComponent', () => {
  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [
        AppComponent,
        HeaderComponent,
        RouterOutlet
      ],
    }).compileComponents();
  }));

  it('should create the app', () => {
    const fixture = TestBed.createComponent(AppComponent);
    const app = fixture.debugElement.componentInstance;
    expect(app).toBeTruthy();
  });
</code>```

```<code>AppComponent should create the app
Error: StaticInjectorError(DynamicTestModule)[HeaderComponent -> Location]:
  StaticInjectorError(Platform: core)[HeaderComponent -> Location]:
    NullInjectorError: No provider for Location!
</code>```

答: Fixed it: all I needed to do was to import RouterModule.forRoot([]), which seems to be a common mistake as it fixes a lot of StaticInjectorError(DynamicTestModule) errors.

Body:
Testing an app in Angular 7 with Karma, I can't remove the error in subj.

I have searched various places (mostly here) but either the solutions don't work or are not relevant to my case.

App.component.html:

<app-header></app-header>
<router-outlet></router-outlet>

Header.component.ts:

import { Component, OnInit, ViewChild, ElementRef, AfterViewInit, EventEmitter, Output } from '@angular/core';
import { Router } from '@angular/router';
import { Location } from '@angular/common';

@Component({
    selector: 'app-header',
    templateUrl: './header.component.html',
    styleUrls: ['./header.component.less']
})
export class HeaderComponent implements AfterViewInit, OnInit {
    constructor(private location: Location, private router: Router) {
        setInterval(() => {
            this.now = new Date();
        }, 1000);
    }
...
    onKeyDown(event: KeyboardEvent): void {
        event.preventDefault();
        if (event.which === this.KEY_ESCAPE){
            if (this.router.url !== '/'){
                this.location.back();
            }
        }
    }

App.component.spec.ts:

import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
import { HeaderComponent } from './header/header.component';
import { RouterOutlet } from '@angular/router';

describe('AppComponent', () => {
  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [
        AppComponent,
        HeaderComponent,
        RouterOutlet
      ],
    }).compileComponents();
  }));

  it('should create the app', () => {
    const fixture = TestBed.createComponent(AppComponent);
    const app = fixture.debugElement.componentInstance;
    expect(app).toBeTruthy();
  });

AppComponent should create the app
Error: StaticInjectorError(DynamicTestModule)[HeaderComponent -> Location]:
  StaticInjectorError(Platform: core)[HeaderComponent -> Location]:
    NullInjectorError: No provider for Location!


问:
Rails 5.2.3: Sidekiq Scheduler gives NameError: uninitialized constant in Production
In my Rails 5.2.3 app I have config/sidekiq.yml which looks like this:

```<code>:verbose: true
:concurrency: 30
:queues:
  - [mailers, 7]
  - [critical, 6]
  - [default, 5]
  - [low, 4]

:logfile: ./log/sidekiq.log

:schedule:
  ScheduledNotices:
    queue: low
    cron: '0 0 * * * *' # every hour
</code>```

My ScheduledNotices is placed in lib\scheduled_notices.rb

At the moment in development environment Scheduler works as expected, however in production I get this error: NameError: uninitialized constant ScheduledNotices

In my application.rb I have:

```<code>config.autoload_paths += %W(#{config.root}/lib)
</code>```

What am I doing wrong, please?

答:
It can be realated to path autoload issue, check this for more details: https://github.com/rails/rails/issues/13142#issuecomment-275492070

What you should do is to change:

```<code>config.autoload_paths += %W(#{config.root}/lib)
</code>```

to

```<code>config.eager_load_paths << Rails.root.join('lib')
</code>```

Body:
In my Rails 5.2.3 app I have config/sidekiq.yml which looks like this:

:verbose: true
:concurrency: 30
:queues:
  - [mailers, 7]
  - [critical, 6]
  - [default, 5]
  - [low, 4]

:logfile: ./log/sidekiq.log

:schedule:
  ScheduledNotices:
    queue: low
    cron: '0 0 * * * *' # every hour

My ScheduledNotices is placed in lib\scheduled_notices.rb

At the moment in development environment Scheduler works as expected, however in production I get this error: NameError: uninitialized constant ScheduledNotices

In my application.rb I have:

config.autoload_paths += %W(#{config.root}/lib)

What am I doing wrong, please?

Body:
It can be realated to path autoload issue, check this for more details: https://github.com/rails/rails/issues/13142#issuecomment-275492070

What you should do is to change:

config.autoload_paths += %W(#{config.root}/lib)

to

config.eager_load_paths << Rails.root.join('lib')


问:
Unknown Smarty Tag from module
I have to fix a Prestashop site made by another team. They did their own navigation menu manager module.

When the template try to render the menu, here is what i get:

```<code> Fatal error: Uncaught --> Smarty Compiler: Syntax error in template "C:\laragon\www\encloque_fresh\themes\en-cloque\header.tpl" on line 105 "{menu key='bloctopmenu' module="blocktopmenu" tpl_container="topmenu" tpl_item="item" max_level=3}" unknown tag "menu" <-- thrown in C:\laragon\www\encloque_fresh\tools\smarty\sysplugins\smarty_internal_templatecompilerbase.php on line 105
</code>```

And here is the line

```<code><div class="row">
  {menu key='bloctopmenu' module="blocktopmenu" tpl_container="topmenu" tpl_item="item" max_level=3}
</div>
</code>```

Any help ?

Prestashop 1.6.0.9
PHP 5.4

答:
There is some thinking wrong.

'{menu key='bloctopmenu' module="blocktopmenu" tpl_container="topmenu" tpl_item="item" max_level=3}'

menu is function form tpl in 1.7:
https://github.com/PrestaShop/ps_mainmenu/blob/master/ps_mainmenu.tpl

Probably you need to remove this module, and install original blocktopmenu
https://github.com/PrestaShop/blocktopmenu

Title: Unknown Smarty Tag from module

Body:
I have to fix a Prestashop site made by another team. They did their own navigation menu manager module.

When the template try to render the menu, here is what i get:

 Fatal error: Uncaught --> Smarty Compiler: Syntax error in template "C:\laragon\www\encloque_fresh\themes\en-cloque\header.tpl" on line 105 "{menu key='bloctopmenu' module="blocktopmenu" tpl_container="topmenu" tpl_item="item" max_level=3}" unknown tag "menu" <-- thrown in C:\laragon\www\encloque_fresh\tools\smarty\sysplugins\smarty_internal_templatecompilerbase.php on line 105

And here is the line

  {menu key='bloctopmenu' module="blocktopmenu" tpl_container="topmenu" tpl_item="item" max_level=3}

Any help ?

Prestashop 1.6.0.9
PHP 5.4


问:
`node-pre-gyp install --fallback-to-build` failed during MeanJS installation on OSX
I just bought myself a mac book after using Windows for a long time.

I was trying to work on a MeanJS project that I had been working on.
Doing npm install on the project throws error

```<code>Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/Aayush/Work/lishn/repo/lishn-alpha/node_modules/grunt-node-inspector/node_modules/node-inspector/node_modules/v8-debug/build/debug/v0.4.6/node-v46-darwin-x64/debug.node --module_name=debug --module_path=/Users/Aayush/Work/lishn/repo/lishn-alpha/node_modules/grunt-node-inspector/node_modules/node-inspector/node_modules/v8-debug/build/debug/v0.4.6/node-v46-darwin-x64' (1)
npm ERR! Darwin 15.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.1.1
npm ERR! npm  v2.14.4
npm ERR! code ELIFECYCLE
>
> npm ERR! v8-debug@0.4.6 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the v8-debug@0.4.6 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! This is most likely a problem with the v8-debug package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get their info via:
npm ERR!     npm owner ls v8-debug
npm ERR! There is likely additional logging output above.
</code>```

I tried clearing cache.

I tried installing node-pre-gyp with sudo and --unsafe-perm

I also tried to fresh install a MEAN project, with the same error.

I can't seem to find what the problem is here.

```<code>Node Version - 5.0.0

NPM Version - 3.3.10
</code>```

答:
I was solved this problem too:
Just reinstall node to LTS version by nvm:

```<code>nvm install --lts

nvm use --lts
</code>```

Then rm -rf node_modules
And npm i

Body:
I just bought myself a mac book after using Windows for a long time.

I was trying to work on a MeanJS project that I had been working on.
Doing npm install on the project throws error

Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/Aayush/Work/lishn/repo/lishn-alpha/node_modules/grunt-node-inspector/node_modules/node-inspector/node_modules/v8-debug/build/debug/v0.4.6/node-v46-darwin-x64/debug.node --module_name=debug --module_path=/Users/Aayush/Work/lishn/repo/lishn-alpha/node_modules/grunt-node-inspector/node_modules/node-inspector/node_modules/v8-debug/build/debug/v0.4.6/node-v46-darwin-x64' (1)
npm ERR! Darwin 15.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.1.1
npm ERR! npm  v2.14.4
npm ERR! code ELIFECYCLE
>
> npm ERR! v8-debug@0.4.6 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the v8-debug@0.4.6 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! This is most likely a problem with the v8-debug package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get their info via:
npm ERR!     npm owner ls v8-debug
npm ERR! There is likely additional logging output above.

I tried clearing cache.

I tried installing node-pre-gyp with sudo and --unsafe-perm

I also tried to fresh install a MEAN project, with the same error.

I can't seem to find what the problem is here.

Node Version - 5.0.0

NPM Version - 3.3.10

Body:
I was solved this problem too:
Just reinstall node to LTS version by nvm:

nvm install --lts

nvm use --lts

Then rm -rf node_modules
And npm i


问:
Removed golang but go command still works?
I'm running Mac OSX Yosemite.

I'm trying update from golang 1.4 to golang 1.6. I uninstalled golang but I noticed I could still run the go command go version =  go1.4.2 darwin/amd64. Why is this so?

The directions aren't super clear IMO. They say

To remove an existing Go installation This is usually /usr/local/go
(done) Remove etc/paths.d/go

I edited the bash by running go version go1.4.2 darwin/amd64

答:
You can try this

```<code>sudo apt-get remove golang-go
</code>```

Then do this

```<code>sudo apt-get remove --auto-remove golang-go
</code>```

Body:
You can try this

sudo apt-get remove golang-go

Then do this

sudo apt-get remove --auto-remove golang-go