问:
IntelliJ Spring Configuration Issue
I am trying to configure a basic Spring Application using IntelliJ IntelliJ IDEA 2017.1.3 I created a spring project and included dependencies. The problem is that the project is not being deployed in the Tomcat Server 8.5.15 and giving the following stack trace:

```<code>SEVERE [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.listenerStart Error configuring application listener of class [org.springframework.web.context.ContextLoaderListener]
 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1285)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:512)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:493)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:119)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4667)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
    at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1702)
    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.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
    at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:482)
    at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:431)
    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.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
    at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
    at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
    at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
    at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401)
    at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
    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 sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:324)
    at sun.rmi.transport.Transport$1.run(Transport.java:200)
    at sun.rmi.transport.Transport$1.run(Transport.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
</code>```

My Web.xml file is:

```<code><?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app>
</code>```

ApplicationContext.xml file:

```<code><?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/cache"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/cache
                           http://www.springframework.org/schema/cache/spring-cache.xsd">

    <mvc:annotation-driven />
</beans>
</code>```

Sample Controller which I created for testing:

```<code>package com.test.controller;

import com.test.beans.TestBean;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class MainController {
    @RequestMapping(value = "/initTest/{name}",method = RequestMethod.GET)
    public @ResponseBody TestBean getSomeMessage(@PathVariable String name, ModelMap model){
        return new TestBean(name);
    }
}
</code>```

TestBean Class:

```<code>package com.test.beans;

public class TestBean {
    private String name;

    public TestBean(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }
}
</code>```

My pom.xml file:

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>groupId</groupId>
    <artifactId>TestSpring</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-framework-bom</artifactId>
                <version>4.3.8.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-web</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-beans</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-jms</artifactId>
            </dependency>

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-orm</artifactId>
            </dependency>

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-oxm</artifactId>
            </dependency>

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-test</artifactId>
            </dependency>

            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>1.2.17</version>
            </dependency>

            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>1.7.2</version>
                <type>jar</type>
            </dependency>

            <dependency>
                <groupId>com.google.code.gson</groupId>
                <artifactId>gson</artifactId>
                <version>2.2.2</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

</project>
</code>```

答:
Thinking your pom.xml is causing this issue.  Try the following structure:

```<code><dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-framework-bom</artifactId>
            <version>4.3.8.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
<!-- List them here -->
</dependencies>
</code>```

Aside:

I'd definitely lean toward using Java config over XML

Consider Spring Boot to reduce time getting set up

You can use @GetMapping for shorthand

You can remove ModelMap as a method parameter

You probably want to add an exclusion for commons-logging:

```<code><dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <exclusions>
        <exclusion>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
        </exclusion>
    </exclusions>
</dependency>
</code>```

Title: IntelliJ Spring Configuration Issue

Body:
I am trying to configure a basic Spring Application using IntelliJ IntelliJ IDEA 2017.1.3 I created a spring project and included dependencies. The problem is that the project is not being deployed in the Tomcat Server 8.5.15 and giving the following stack trace:

SEVERE [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.listenerStart Error configuring application listener of class [org.springframework.web.context.ContextLoaderListener]
 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1285)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:512)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:493)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:119)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4667)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
    at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1702)
    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.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
    at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:482)
    at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:431)
    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.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
    at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
    at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
    at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
    at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401)
    at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
    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 sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:324)
    at sun.rmi.transport.Transport$1.run(Transport.java:200)
    at sun.rmi.transport.Transport$1.run(Transport.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

My Web.xml file is:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app>

ApplicationContext.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/cache"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/cache
                           http://www.springframework.org/schema/cache/spring-cache.xsd">

    <mvc:annotation-driven />
</beans>

Sample Controller which I created for testing:

package com.test.controller;

import com.test.beans.TestBean;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class MainController {
    @RequestMapping(value = "/initTest/{name}",method = RequestMethod.GET)
    public @ResponseBody TestBean getSomeMessage(@PathVariable String name, ModelMap model){
        return new TestBean(name);
    }
}

TestBean Class:

package com.test.beans;

public class TestBean {
    private String name;

    public TestBean(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }
}

My pom.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>groupId</groupId>
    <artifactId>TestSpring</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-framework-bom</artifactId>
                <version>4.3.8.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-web</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-beans</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-jms</artifactId>
            </dependency>

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-orm</artifactId>
            </dependency>

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-oxm</artifactId>
            </dependency>

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-test</artifactId>
            </dependency>

            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>1.2.17</version>
            </dependency>

            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>1.7.2</version>
                <type>jar</type>
            </dependency>

            <dependency>
                <groupId>com.google.code.gson</groupId>
                <artifactId>gson</artifactId>
                <version>2.2.2</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

</project>

Body:
Thinking your pom.xml is causing this issue.  Try the following structure:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-framework-bom</artifactId>
            <version>4.3.8.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
<!-- List them here -->
</dependencies>

Aside:

I'd definitely lean toward using Java config over XML

Consider Spring Boot to reduce time getting set up

You can use @GetMapping for shorthand

You can remove ModelMap as a method parameter

You probably want to add an exclusion for commons-logging:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <exclusions>
        <exclusion>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
        </exclusion>
    </exclusions>
</dependency>


来源: stackexchange

问:
DHTMLXGantt and Laravel - Data doesn't display in extended templates
Background

Following this tutorial from Jan 2016, ( https://dhtmlx.com/blog/using-dhtmlxgantt-with-laravel/ ) I began experimenting with DHTMLXGantt (v4.1) and Laravel (v5.4) and ran into some troubles getting the sample data from a mysql/mariadb database to display in the gantt chart. The initial troubles had to do with the DHTMLX connector not staying current with some Laravel changes. For the sake of others who may read this and are struggling with the same issues, the two basic problems I already solved were:

(1) I was referred to this [updated] connector which was compatible with Laravel's recent versions ( https://github.com/mperednya/connector-php/tree/modern ). And,

(2) I specified a date range that matched the dates of the sample data (from 2013), such as...

```<code>gantt.config.start_date = new Date(2013, 04, 01);
gantt.config.end_date = new Date(2013, 04, 30);
</code>```

At this point I was able to successfully use Laravel as a backend server for the DHTMLXGantt chart (including read-write with the sample data).

Problem

The problem I am having now is trying to move from the simplistic sample, to something slightly more complex. Specifically, when I employ Laravel's extended templating I get the gantt chart painted on screen, but no project/task data displays in the chart.

To explain this a little more specifically, a simple Laravel view with the whole page contained within it works as expected. For example, this blade file (gantt.blade.php) works.

```<code><!DOCTYPE html>
<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <script src="codebase/dhtmlxgantt.js"></script>
    <link rel="stylesheet" href="codebase/dhtmlxgantt.css">
    <link rel="stylesheet" href="codebase/skins/dhtmlxgantt_skyblue.css" type="text/css" media="screen" title="no title" charset="utf-8">
</head>

<body>
<div class="container">
    <h1>Placeholder Header</h1>
    <div id="gantt_here" style='width:100%; height:500px;'></div>
    <script type="text/javascript">

        gantt.config.xml_date = "%Y-%m-%d %H:%i:%s";
        gantt.config.step = 1;
        gantt.config.scale_unit= "week";
        gantt.config.autosize = "xy";
        gantt.config.fit_tasks = true;

        gantt.config.columns = [
            {name:"text",       label:"Task name",  width:"*", tree:true },
            {name:"start_date", label:"Start time", align: "center" },
            {name:"duration",   label:"Duration",   align: "center" },
            {name:"add",        label:"",           width:44 }
        ];

        gantt.init("gantt_here");
        gantt.load("./gantt_data", "xml");
        var dp = new gantt.dataProcessor("./gantt_data");
        dp.init(gantt);
    </script>
    <h1>Placeholder Footer</h1>
</div>
</body>
</code>```

But if I try using an extended app layout with the intention of building out a standard look & feel across all pages, the Gantt chart appears and is formated as I expect, but no data appears within the gantt chart. Here is top-level layout file (app.blade.php)

```<code><!DOCTYPE html>
<html lang="{{ config('app.locale') }}">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>{{ config('app.name', 'Laravel') }}</title>

    <!-- Styles -->
    <link href="{{ asset('css/app.css') }}" rel="stylesheet">
    <link rel="stylesheet" href="codebase/dhtmlxgantt.css">
    <link rel="stylesheet" href="codebase/skins/dhtmlxgantt_skyblue.css" type="text/css" media="screen" title="no title" charset="utf-8">

    <!-- Scripts -->
    <script>
        window.Laravel = {!! json_encode([
            'csrfToken' => csrf_token(),
        ]) !!};
    </script>
    <script src="codebase/dhtmlxgantt.js"></script>
</head>
<body>

<div id="app">
    <!-- menus and other bootstrap styling removed for brevity -->
    @yield('content')
</div>

<!-- Scripts -->
<script src="{{ asset('js/app.js') }}"></script>
</body>
</html>
</code>```

And here's the "content" view (index.blade.php)...

```<code>@extends('layouts.app')
@section('content')

<div id="gantt_here" style='width:100%; height:500px;'></div>
    <script type="text/javascript">
        gantt.config.xml_date = "%Y-%m-%d %H:%i:%s";
        gantt.config.step = 1;
        gantt.config.scale_unit= "week";
        gantt.config.autosize = "xy";
        gantt.config.fit_tasks = true;

        gantt.config.columns = [
            {name:"text",       label:"Task name",  width:"*", tree:true },
            {name:"start_date", label:"Start time", align: "center" },
            {name:"duration",   label:"Duration",   align: "center" },
            {name:"add",        label:"",           width:44 }
            ];

        gantt.init("gantt_here");
        gantt.load("./gantt_data", "xml");
        var dp = new gantt.dataProcessor("./gantt_data");
        dp.init(gantt);
    </script>
</div>
@endsection
</code>```

Other things I've tried:

Using Chrome developer tools, I can see that the xml data was properly delivered to the browser in both examples. This made me think maybe it is a timing problem of some sort. So I put a couple links on the page just to test clearing the chart and reloading it. But still no change.

```<code><a onclick="gantt.clearAll()" href="javascript:void(0);">Clear</a>
<a onclick="gantt.load('./gantt_data', 'xml')" href="javascript:void(0);">Refresh</a>
</code>```

I also tried moving the div block "gantt_here" to various other places above and below Laravel's template directives. It fails in all cases, except when this div block is outside (either above or below) the "app" div tag in "app.blade.php" which, of course, defeats the purpose I am trying to achieve.

My goal is to use this chart within Laravel's extended templating capabilities. But I can't figure out what's wrong. Any ideas?

答: After further troubleshooting, I discovered the problem. It turns out that in app.blade.php, I was loading the app.js at the bottom of the body tag. When I moved this up to the HTML header area, the data began to display properly.</p>

ContentLicense: CC BY-SA 3.0

Body:
Background

Following this tutorial from Jan 2016, ( https://dhtmlx.com/blog/using-dhtmlxgantt-with-laravel/ ) I began experimenting with DHTMLXGantt (v4.1) and Laravel (v5.4) and ran into some troubles getting the sample data from a mysql/mariadb database to display in the gantt chart. The initial troubles had to do with the DHTMLX connector not staying current with some Laravel changes. For the sake of others who may read this and are struggling with the same issues, the two basic problems I already solved were:

(1) I was referred to this [updated] connector which was compatible with Laravel's recent versions ( https://github.com/mperednya/connector-php/tree/modern ). And,

(2) I specified a date range that matched the dates of the sample data (from 2013), such as...

gantt.config.start_date = new Date(2013, 04, 01);
gantt.config.end_date = new Date(2013, 04, 30);

At this point I was able to successfully use Laravel as a backend server for the DHTMLXGantt chart (including read-write with the sample data).

Problem

The problem I am having now is trying to move from the simplistic sample, to something slightly more complex. Specifically, when I employ Laravel's extended templating I get the gantt chart painted on screen, but no project/task data displays in the chart.

To explain this a little more specifically, a simple Laravel view with the whole page contained within it works as expected. For example, this blade file (gantt.blade.php) works.

<!DOCTYPE html>

    <meta http-equiv="Content-type" content="text/html; charset=utf-8">

    <link rel="stylesheet" href="codebase/dhtmlxgantt.css">
    <link rel="stylesheet" href="codebase/skins/dhtmlxgantt_skyblue.css" type="text/css" media="screen" title="no title" charset="utf-8">

Placeholder Header

Placeholder Footer

But if I try using an extended app layout with the intention of building out a standard look & feel across all pages, the Gantt chart appears and is formated as I expect, but no data appears within the gantt chart. Here is top-level layout file (app.blade.php)

<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>{{ config('app.name', 'Laravel') }}</title>

    <link href="{{ asset('css/app.css') }}" rel="stylesheet">
    <link rel="stylesheet" href="codebase/dhtmlxgantt.css">
    <link rel="stylesheet" href="codebase/skins/dhtmlxgantt_skyblue.css" type="text/css" media="screen" title="no title" charset="utf-8">

    @yield('content')

And here's the "content" view (index.blade.php)...

@extends('layouts.app')
@section('content')

@endsection

Other things I've tried:

Using Chrome developer tools, I can see that the xml data was properly delivered to the browser in both examples. This made me think maybe it is a timing problem of some sort. So I put a couple links on the page just to test clearing the chart and reloading it. But still no change.

Clear
Refresh

I also tried moving the div block "gantt_here" to various other places above and below Laravel's template directives. It fails in all cases, except when this div block is outside (either above or below) the "app" div tag in "app.blade.php" which, of course, defeats the purpose I am trying to achieve.

My goal is to use this chart within Laravel's extended templating capabilities. But I can't figure out what's wrong. Any ideas?


问:
Chrome Image Placement Issue. 1px buffer?
I'm having a hard time explaining this.  But, basically, in Google Chrome I have an issue where I placed an image to the bottom of a div and there is a 1px border or "buffer at the bottom that I can't remove.

Here's what I see!

Chrome:

Opera:

I want the Chrome one to look like the Opera one.

Here is the code!

This is the CSS

Mind the sloppiness.  This website is in a rough draft right now.

```<code>@media screen and (max-width: 450px) {
  * {
    padding: 0;
    margin: 0;
    outline: none;
  }

  .mmenu {
    z-index: -1;
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: #aaa;
  }

  .mobileBody {
    z-index: 1;
    background-color: #fff;
  }

  .mhead {
    background-image: url(../img/head.jpg);
    background-size: cover;
    background-position: center;
    margin: 0;
    padding: 0;
    position: relative;
  }

  .logo {
    margin: auto;
  }

  img.logoImg {
    width: 175px;
    height: auto;
    margin: auto;
    margin-top: 15px;
  }

  .mhead img.cut {
    margin: 0;
    margin-top: 1px;
    padding: 0;
    width: 100%;
    height: auto;
    position: absolute;
    bottom: 0;
    left: 0;
    vertical-align: bottom;
  }

  .card {
    background-color: #fff;
    width: 100%;
    height: auto;
  }

  .final {
    display: flex;

  }

  .flavImg {
    display: flex;
    justify-content: center;
    align-items:center;
    width: 45%;
  }

  .flavImg img {
     height: 80%;
     width: auto;
  }

  .flavDesc {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-flow: column;
  }

  .flavDesc h1 {
    font-size: 21pt;
    text-align: left;
    font-family: 'Dancing Script', cursive;
    -webkit-font-smoothing: subpixel-antialiased;
    margin-bottom: 5px;
  }

  .flavDesc p {
    font-size: 11pt;
    text-align: left;
    font-family: 'Ledger', serif;
    line-height: 125%;
    -webkit-font-smoothing: subpixel-antialiased;
    margin-top: 5px;
  }

  .edit {
    display: none;
  }
}
</code>```

This is in Jade.

Mind the sloppiness.  This website is in a rough draft right now.

```<code>doctype html
html
  head
    title Conecopia Gelato - Ice Cream The Italian Way!

    meta(name="description" content="Conecopia Gelato LLC. is a small family owned Italian ice cream (gelato) stand located within the Springfield Town Center Smart Market in Springfield VA.  At Conecopia we strive to make the most flavorful ice cream possible for our customers to enjoy.")
    meta(name="keywords" content="Gealto,Ice cream,Farmers market,Italian,flavor,fruit,juice,summer,virginia,VA,springfield,springfield town center,saturday,smart market")
    meta(name="author" content="Anthony F. DeSante")
    meta(name="viewport" content="width=device-width, initial-scale=1.0")

    link(href="https://fonts.googleapis.com/css?family=Dancing+Script|Ledger" rel="stylesheet")

    link(rel="stylesheet" type="text/css" href="ast/css/index.css")

  body
    .computer
    .mobile
      .mmenu
        ul.mmainNav
          a(href="#")
            li Home
          a(href="#")
            li Flavors
          a(href="#")
            li Contact Us
          a(href="#")
            li About
        ul.mlowerNav
          a(href="#")
            li Home
        .msocialmedia
          //Social Media Icons Go Here.
      .mobileBody
        .mhead
          .logo
            img(src="./ast/img/logo.png").logoImg
          img(src="./ast/img/cut.png").cut
        .mWeekFlavs.dispHor
          .row
            .card
              .final
                .flavImg
                  img(src="./ast/img/icecream.png")
                .flavDesc
                  .flavName
                    h1 Flavor Name
                  .flavText
                    p Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis aliquam vulputate diam, nulla mattis, sed dictum velit vulputate. Praesent sed justo eu odio laoreet ornare. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
              .edit.ifAdmin
                form(method="post" action="#")
                  input(type="file" name="image" accept="image/*")
                  input(name="flavName" type="text" placeholder="Flavor Name" value="")
                  textarea(row="5" col="auto")
                  input(type="reset")
                  input(name="save" type="submit" value="Save")
          .statusBar
            span#head

        .mAllFlavs.dispHor
br
br
br
br
br
br
br

br
br
br
br
br

br
br
br
br
br
br
br
br
br
br
br
br
br
br
br
br
br
</code>```

This is the HTML (Processed through PrePros)
It's here for those who don't like Jade?

```<code><!DOCTYPE html>
<html>
  <head>
    <title>Conecopia Gelato - Ice Cream The Italian Way!</title>
    <meta name="description" content="Conecopia Gelato LLC. is a small family owned Italian ice cream (gelato) stand located within the Springfield Town Center Smart Market in Springfield VA.  At Conecopia we strive to make the most flavorful ice cream possible for our customers to enjoy.">
    <meta name="keywords" content="Gealto,Ice cream,Farmers market,Italian,flavor,fruit,juice,summer,virginia,VA,springfield,springfield town center,saturday,smart market">
    <meta name="author" content="Anthony F. DeSante">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://fonts.googleapis.com/css?family=Dancing+Script|Ledger" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="ast/css/index.css">
  </head>
  <body>
    <div class="computer"></div>
    <div class="mobile">
      <div class="mmenu">
        <ul class="mmainNav"><a href="#">
            <li>Home</li></a><a href="#">
            <li>Flavors</li></a><a href="#">
            <li>Contact Us</li></a><a href="#">
            <li>About</li></a></ul>
        <ul class="mlowerNav"><a href="#">
            <li>Home</li></a></ul>
        <div class="msocialmedia">
          <!--Social Media Icons Go Here.-->
        </div>
      </div>
      <div class="mobileBody">
        <div class="mhead">
          <div class="logo"><img class="logoImg" src="./ast/img/logo.png"></div><img class="cut" src="./ast/img/cut.png">
        </div>
        <div class="mWeekFlavs dispHor">
          <div class="row">
            <div class="card">
              <div class="final">
                <div class="flavImg"><img src="./ast/img/icecream.png"></div>
                <div class="flavDesc">
                  <div class="flavName">
                    <h1>Flavor Name</h1>
                  </div>
                  <div class="flavText">
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis aliquam vulputate diam, nulla mattis, sed dictum velit vulputate. Praesent sed justo eu odio laoreet ornare. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>
                  </div>
                </div>
              </div>
              <div class="edit ifAdmin">
                <form method="post" action="#">
                  <input type="file" name="image" accept="image/*">
                  <input name="flavName" type="text" placeholder="Flavor Name" value="">
                  <textarea row="5" col="auto"></textarea>
                  <input type="reset">
                  <input name="save" type="submit" value="Save">
                </form>
              </div>
            </div>
          </div>
          <div class="statusBar"><span id="head"></span></div>
        </div>
        <div class="mAllFlavs dispHor"></div>
      </div>
    </div>
  </body>
</html><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</code>```

So if anybody has a way to remove the 1px "buffer" please send it in!

答:
To ensure no extra default padding/margins are added (and it does vary from browser to browser) put this at the TOP of your css

```<code>* {
  margin: 0;
  padding: 0;
}
</code>```

This will get rid of any default auto-added margins and padding. I added this to your css (i  removed the extra 1px margin also, and some excess html/css)

Got this and don't see any issue (I'm using the latest Chrome)

Hope this helps

Body:
I'm having a hard time explaining this.  But, basically, in Google Chrome I have an issue where I placed an image to the bottom of a div and there is a 1px border or "buffer at the bottom that I can't remove.

Here's what I see!

Chrome:

Opera:

I want the Chrome one to look like the Opera one.

Here is the code!

This is the CSS

Mind the sloppiness.  This website is in a rough draft right now.

@media screen and (max-width: 450px) {
  * {
    padding: 0;
    margin: 0;
    outline: none;
  }

  .mmenu {
    z-index: -1;
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: #aaa;
  }

  .mobileBody {
    z-index: 1;
    background-color: #fff;
  }

  .mhead {
    background-image: url(../img/head.jpg);
    background-size: cover;
    background-position: center;
    margin: 0;
    padding: 0;
    position: relative;
  }

  .logo {
    margin: auto;
  }

  img.logoImg {
    width: 175px;
    height: auto;
    margin: auto;
    margin-top: 15px;
  }

  .mhead img.cut {
    margin: 0;
    margin-top: 1px;
    padding: 0;
    width: 100%;
    height: auto;
    position: absolute;
    bottom: 0;
    left: 0;
    vertical-align: bottom;
  }

  .card {
    background-color: #fff;
    width: 100%;
    height: auto;
  }

  .final {
    display: flex;

  }

  .flavImg {
    display: flex;
    justify-content: center;
    align-items:center;
    width: 45%;
  }

  .flavImg img {
     height: 80%;
     width: auto;
  }

  .flavDesc {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-flow: column;
  }

  .flavDesc h1 {
    font-size: 21pt;
    text-align: left;
    font-family: 'Dancing Script', cursive;
    -webkit-font-smoothing: subpixel-antialiased;
    margin-bottom: 5px;
  }

  .flavDesc p {
    font-size: 11pt;
    text-align: left;
    font-family: 'Ledger', serif;
    line-height: 125%;
    -webkit-font-smoothing: subpixel-antialiased;
    margin-top: 5px;
  }

  .edit {
    display: none;
  }
}

This is in Jade.

Mind the sloppiness.  This website is in a rough draft right now.

doctype html
html
  head
    title Conecopia Gelato - Ice Cream The Italian Way!

    meta(name="description" content="Conecopia Gelato LLC. is a small family owned Italian ice cream (gelato) stand located within the Springfield Town Center Smart Market in Springfield VA.  At Conecopia we strive to make the most flavorful ice cream possible for our customers to enjoy.")
    meta(name="keywords" content="Gealto,Ice cream,Farmers market,Italian,flavor,fruit,juice,summer,virginia,VA,springfield,springfield town center,saturday,smart market")
    meta(name="author" content="Anthony F. DeSante")
    meta(name="viewport" content="width=device-width, initial-scale=1.0")

    link(href="https://fonts.googleapis.com/css?family=Dancing+Script|Ledger" rel="stylesheet")

    link(rel="stylesheet" type="text/css" href="ast/css/index.css")

  body
    .computer
    .mobile
      .mmenu
        ul.mmainNav
          a(href="#")
            li Home
          a(href="#")
            li Flavors
          a(href="#")
            li Contact Us
          a(href="#")
            li About
        ul.mlowerNav
          a(href="#")
            li Home
        .msocialmedia
          //Social Media Icons Go Here.
      .mobileBody
        .mhead
          .logo
            img(src="./ast/img/logo.png").logoImg
          img(src="./ast/img/cut.png").cut
        .mWeekFlavs.dispHor
          .row
            .card
              .final
                .flavImg
                  img(src="./ast/img/icecream.png")
                .flavDesc
                  .flavName
                    h1 Flavor Name
                  .flavText
                    p Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis aliquam vulputate diam, nulla mattis, sed dictum velit vulputate. Praesent sed justo eu odio laoreet ornare. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
              .edit.ifAdmin
                form(method="post" action="#")
                  input(type="file" name="image" accept="image/*")
                  input(name="flavName" type="text" placeholder="Flavor Name" value="")
                  textarea(row="5" col="auto")
                  input(type="reset")
                  input(name="save" type="submit" value="Save")
          .statusBar
            span#head

        .mAllFlavs.dispHor
br
br
br
br
br
br
br

br
br
br
br
br

br
br
br
br
br
br
br
br
br
br
br
br
br
br
br
br
br

This is the HTML (Processed through PrePros)
It's here for those who don't like Jade?

<!DOCTYPE html>

    <title>Conecopia Gelato - Ice Cream The Italian Way!</title>
    <meta name="description" content="Conecopia Gelato LLC. is a small family owned Italian ice cream (gelato) stand located within the Springfield Town Center Smart Market in Springfield VA.  At Conecopia we strive to make the most flavorful ice cream possible for our customers to enjoy.">
    <meta name="keywords" content="Gealto,Ice cream,Farmers market,Italian,flavor,fruit,juice,summer,virginia,VA,springfield,springfield town center,saturday,smart market">
    <meta name="author" content="Anthony F. DeSante">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://fonts.googleapis.com/css?family=Dancing+Script|Ledger" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="ast/css/index.css">

Home

Flavors

Contact Us

About

Home

Flavor Name

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis aliquam vulputate diam, nulla mattis, sed dictum velit vulputate. Praesent sed justo eu odio laoreet ornare. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

                <form method="post" action="#">
                  <input type="file" name="image" accept="image/*">
                  <input name="flavName" type="text" placeholder="Flavor Name" value="">
                  <textarea row="5" col="auto"></textarea>
                  <input type="reset">
                  <input name="save" type="submit" value="Save">
                </form>

So if anybody has a way to remove the 1px "buffer" please send it in!

Body:
To ensure no extra default padding/margins are added (and it does vary from browser to browser) put this at the TOP of your css

* {
  margin: 0;
  padding: 0;
}

This will get rid of any default auto-added margins and padding. I added this to your css (i  removed the extra 1px margin also, and some excess html/css)

Got this and don't see any issue (I'm using the latest Chrome)

Hope this helps


问:
ASP.NET 2.5 prefixing ctl00 and ASP.NET 4 not prefixing ctl00
Does anyone know why ASP.NET 4 has dropped the ctl00 prefix on ASP controls?

Is there a setting I have missed?

答: If you just want to add 'ct100' prefix to your control's IDs, add Master page to your WebPage. But how said above, try to avoid using hardcode with controls ids in your sources and read Metthew's comments for generation custom ID</p>

ContentLicense: CC BY-SA 2.5


问:
re-use pillar values in salt(-ssh)
I am currently getting familiar with salt and wonder how I could re-use the values of pillars in other places (sections) in .sls files.

In buildout, I would be able to reference a variable from another section with ${sectionname:varname} to re-use a once defined value. This is especially handy, when dealing with directories (basedir, appdir). buildout example:

```<code>['foo']
  path = /highway/to/hell

['bar']
  path = ${foo:path}/lastexit
</code>```

When I try to reference another variable in an .sls file, even if it is in the same file, I get always None. salt example:

```<code>foo:
  path: /highway/to/hell

bar:
  path: {{ salt['pillar.get']('foo:path') }}/lastexit
</code>```

salt-ssh minion1 pillar.get bar:path results in None/lastexit

I have the feeling, that I'm missing something here. Could someone point out, how one does re-use values in salt .sls

答:
You can use jinja to assign a value, e.g.:

```<code>{% set base_path = salt['pillar.get']('foo:path','/highway/to/hell') %}

foo:
  path: {{ base_path }}

bar:
  path: {{ base_path }}/lastexit
</code>```

In this case "/highway/to/hell" is set as a default in case no value is assigned in the pillar or no pillar is found. For more info, see https://docs.saltstack.com/en/latest/topics/jinja/index.html

Title: re-use pillar values in salt(-ssh)

Body:
I am currently getting familiar with salt and wonder how I could re-use the values of pillars in other places (sections) in .sls files.

In buildout, I would be able to reference a variable from another section with ${sectionname:varname} to re-use a once defined value. This is especially handy, when dealing with directories (basedir, appdir). buildout example:

['foo']
  path = /highway/to/hell

['bar']
  path = ${foo:path}/lastexit

When I try to reference another variable in an .sls file, even if it is in the same file, I get always None. salt example:

foo:
  path: /highway/to/hell

bar:
  path: {{ salt['pillar.get']('foo:path') }}/lastexit

salt-ssh minion1 pillar.get bar:path results in None/lastexit

I have the feeling, that I'm missing something here. Could someone point out, how one does re-use values in salt .sls

Body:
You can use jinja to assign a value, e.g.:

{% set base_path = salt['pillar.get']('foo:path','/highway/to/hell') %}

foo:
  path: {{ base_path }}

bar:
  path: {{ base_path }}/lastexit

In this case "/highway/to/hell" is set as a default in case no value is assigned in the pillar or no pillar is found. For more info, see https://docs.saltstack.com/en/latest/topics/jinja/index.html


问:
Netsuite ODBC Error: pyodbc execute is raising `[HY000] The directory name is invalid.` error
My challenge is to connect to Netsuite using ODBC driver from Cdata. I have finished setting up the driver.
The output for my odbcinst -j:

```<code>unixODBC 2.2.14
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLSETPOSIROW Size.: 8
</code>```

I am trying to fetch data with this python code:

```<code>import pyodbc

cnxn = pyodbc.connect('DSN=NetSuite;User=username;Password=passwd')
pcursor = cnxn.cursor()
pcursor.execute("SELECT * FROM Accounts")
rows = pcursor.fetchall()

for row in rows:
    print(row)
</code>```

Where username and passwd are the credentials for the Netsuite Account. It is however, retuning the following error:

```<code>Traceback (most recent call last):
  File "odbctest.py", line 5, in <module>
  pcursor.execute("SELECT * FROM Accounts")
pyodbc.Error: ('HY000', '[HY000] The directory name is invalid. (-1) (SQLExecDirectW)')
</code>```

Any help is greatly appreciated.

答: I was calling the wrong driver name. Make sure that you are accessing the correct values in odbcinst.ini and odbc.ini.

Body:
My challenge is to connect to Netsuite using ODBC driver from Cdata. I have finished setting up the driver.
The output for my odbcinst -j:

unixODBC 2.2.14
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLSETPOSIROW Size.: 8

I am trying to fetch data with this python code:

import pyodbc

cnxn = pyodbc.connect('DSN=NetSuite;User=username;Password=passwd')
pcursor = cnxn.cursor()
pcursor.execute("SELECT * FROM Accounts")
rows = pcursor.fetchall()

for row in rows:
    print(row)

Where username and passwd are the credentials for the Netsuite Account. It is however, retuning the following error:

Traceback (most recent call last):
  File "odbctest.py", line 5, in <module>
  pcursor.execute("SELECT * FROM Accounts")
pyodbc.Error: ('HY000', '[HY000] The directory name is invalid. (-1) (SQLExecDirectW)')

Any help is greatly appreciated.


问:
SQL count rows of one table in relation to another table
I have 3 different tables :

Client

```<code>+----+-----------+----------+
| id | firstName | lastName |
+----+-----------+----------+
|  1 | John      | Doe      |
|  2 | Jane      | Doe      |
+----+-----------+----------+
</code>```

Loan

```<code>+----+--------+-----------+----------------+
| id | amount | client_id | institution_id |
+----+--------+-----------+----------------+
|  1 |    200 |         2 |              3 |
|  2 |    400 |         1 |              1 |
+----+--------+-----------+----------------+
</code>```

Institution

```<code>+----+---------------+
| id |     name      |
+----+---------------+
|  1 | Institution A |
|  2 | Institution B |
|  3 | Institution C |
+----+---------------+
</code>```

I am looking to create a list of the number of loans a client has with each institution (for every row in the institution table). Including when a client has 0 loans with an institution.

Something that looks like :

```<code>+-----------+-----------+----------+--------------------------+-----------+
| client_id | firstName | lastName | financialInstitutionName | loanCount |
+-----------+-----------+----------+--------------------------+-----------+
|         1 | John      | Doe      | Institution A            |         1 |
|         1 | John      | Doe      | Institution B            |         0 |
|         1 | John      | Doe      | Institution C            |         0 |
|         2 | Jane      | Doe      | Institution A            |         0 |
|         2 | Jane      | Doe      | Institution B            |         0 |
|         2 | Jane      | Doe      | Institution C            |         1 |
+-----------+-----------+----------+--------------------------+-----------+
</code>```

I have tried all manners of joins, subqueries and where clauses but without success. The concept that I do not grasp is how to get a row per institution, per client (total count institution x client). I would love if that query was possible without subqueries or union joins.

Thank you for your time!

答:
```<code>SELECT
    loan.client_id,
    client.firstName,
    client.lastName,
    institution.name as financialInstitutionName,
    COUNT(loan.id) as loanCount
FROM client
INNER JOIN loan ON client.id = loan.client_id
INNER JOIN institution ON loan.institution_id = institution.id
GROUP BY client.id;
</code>```

Body:
I have 3 different tables :

Client

+----+-----------+----------+
| id | firstName | lastName |
+----+-----------+----------+
|  1 | John      | Doe      |
|  2 | Jane      | Doe      |
+----+-----------+----------+

Loan

+----+--------+-----------+----------------+
| id | amount | client_id | institution_id |
+----+--------+-----------+----------------+
|  1 |    200 |         2 |              3 |
|  2 |    400 |         1 |              1 |
+----+--------+-----------+----------------+

Institution

+----+---------------+
| id |     name      |
+----+---------------+
|  1 | Institution A |
|  2 | Institution B |
|  3 | Institution C |
+----+---------------+

I am looking to create a list of the number of loans a client has with each institution (for every row in the institution table). Including when a client has 0 loans with an institution.

Something that looks like :

+-----------+-----------+----------+--------------------------+-----------+
| client_id | firstName | lastName | financialInstitutionName | loanCount |
+-----------+-----------+----------+--------------------------+-----------+
|         1 | John      | Doe      | Institution A            |         1 |
|         1 | John      | Doe      | Institution B            |         0 |
|         1 | John      | Doe      | Institution C            |         0 |
|         2 | Jane      | Doe      | Institution A            |         0 |
|         2 | Jane      | Doe      | Institution B            |         0 |
|         2 | Jane      | Doe      | Institution C            |         1 |
+-----------+-----------+----------+--------------------------+-----------+

I have tried all manners of joins, subqueries and where clauses but without success. The concept that I do not grasp is how to get a row per institution, per client (total count institution x client). I would love if that query was possible without subqueries or union joins.

Thank you for your time!


问:
How do you remove last comma in a PHP for loop to build a JSON string
When building a JSON string from a php for loop from an SQL query there is an unnessary comma at the end of the build string. How do I control the final comma.

```<code>$count =  label::grabAll()->count();

echo '{"data": { "graph": {';

for ($x = 0; $x < $count; $x++){

if($x <= 3){
    $cm = ',';
}else{
    $cm .= '';
}

    echo '"'.$x.'": "'.label::grabAll()->results()[$x]->count.'"'.$cm;

}
</code>```

I get this result from the code above.

How do I remove the final comma?

答:
Use plain old objects / arrays and use json_encode. For example

```<code>$graph = array_map(function($result) {
    return $result->count;
}, label::graball()->results());

echo json_encode(['data' => ['graph' => $graph]]);
</code>```

Demo ~ https://eval.in/812302

Body:
When building a JSON string from a php for loop from an SQL query there is an unnessary comma at the end of the build string. How do I control the final comma.

$count =  label::grabAll()->count();

echo '{"data": { "graph": {';

for ($x = 0; $x < $count; $x++){

if($x <= 3){
    $cm = ',';
}else{
    $cm .= '';
}

    echo '"'.$x.'": "'.label::grabAll()->results()[$x]->count.'"'.$cm;

}

I get this result from the code above.

How do I remove the final comma?

Body:
Use plain old objects / arrays and use json_encode. For example

$graph = array_map(function($result) {
    return $result->count;
}, label::graball()->results());

echo json_encode(['data' => ['graph' => $graph]]);

Demo ~ https://eval.in/812302


问:
Is it possible to set a static ip in a Netboot.iso
I need to deploy CentOS7 systems without using DHCP. So I was hoping someone would know if its possible to append a static IP in the isolinux.cfg file and create a custom netboot iso.

I would be very grateful for any help.

Thanks,
John

答:
I found this addition at can be added to the label in the isolinux.cfg that will configure a static ip.

ip=ip::gateway:netmask:hostname:interface:none


问:
AWS: Code deploy installation failed
I'm trying to setup deployment from github repository via AWS.

I have an issue during these steps:

```<code>http://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent-operations-install.html#codedeploy-agent-operations-install-linux
</code>```

This command fails:

```<code>wget https://bucket-name.s3.amazonaws.com/latest/install
</code>```

It returns:

```<code>[ec2-user@ip-172-31-11-55 ~]$ wget https://bucket-name.s3.amazonaws.com/latest/install
--2017-06-04 10:18:18--  https://bucket-name.s3.amazonaws.com/latest/install
Resolving bucket-name.s3.amazonaws.com (bucket-name.s3.amazonaws.com)... 54.231.114.146
Connecting to bucket-name.s3.amazonaws.com (bucket-name.s3.amazonaws.com)|54.231.114.146|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2017-06-04 10:18:18 ERROR 403: Forbidden.
</code>```

I've allowed all the ports for inbound/outbound traffic for my instance.

What is wrong?

答: Yeah, as @smart said, the "bucket-name" should be replace for different name in different region, like aws-codedeploy-us-east-2 for instances in the US East (Ohio) region etc..</p>

Title: AWS: Code deploy installation failed

Body:
I'm trying to setup deployment from github repository via AWS.

I have an issue during these steps:

http://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent-operations-install.html#codedeploy-agent-operations-install-linux

This command fails:

wget https://bucket-name.s3.amazonaws.com/latest/install

It returns:

[ec2-user@ip-172-31-11-55 ~]$ wget https://bucket-name.s3.amazonaws.com/latest/install
--2017-06-04 10:18:18--  https://bucket-name.s3.amazonaws.com/latest/install
Resolving bucket-name.s3.amazonaws.com (bucket-name.s3.amazonaws.com)... 54.231.114.146
Connecting to bucket-name.s3.amazonaws.com (bucket-name.s3.amazonaws.com)|54.231.114.146|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2017-06-04 10:18:18 ERROR 403: Forbidden.

I've allowed all the ports for inbound/outbound traffic for my instance.

What is wrong?


问:
UE4 Shoot Projectile BluePrint - Projectile spawns but doesn't move
I am trying to shoot different projectiles based on which weapon is currently selected. The projectiles spawn but don't move anywhere. I currently have 2 projectile BluePrints (Parent and child):

```<code>BP_Projectile (Parent)
BP_PistolBullet (Child)
</code>```

The parent class has a float called ProjectileSpeed. I have set the value of the float in the child class to 5000.0 for testing.

For the moment the child class contains a Cylinder with a box collision just so I can see something render. I have enabled 'Simulate Physics' on the cylinder.

I have then created an array called CollectedWeapons in my character blueprint with a type of BP_Projectile and added a single element with the value set to the class of BP_PistolBullet (I know a projectile isn't a weapon, but thats going to be expanded later :P )

The rest can be seen in my 'Shoot' BluePrint:

If you need any more information please let me know. Thanks in advance.

EDIT:

BP_PistolBullet components as requested.

EDIT:

Trying to make projectile shoot forward, but can't get it right. I've tried multiple different things, but this is the latest attempt:

答:
It happens because you tring to access Cylinder Static Mesh component by using "Get Child Component" node. "Get Child Component" returns one component from set of directly attached components. When you enable physics simulation on component it is automaticly detached from it's parent component, so it could behave independently. It leads to situation when simulated components are not present in results of "Get Child Component" of your "Default Scene Root".

You could solve it quickly by saving physicaly simulated child component to some variable present in BaseProjectile. But I think perfect design will be to use "Projectile Movement Component" in base blueprint or to apply force directly in blueprint in "BeginPlay" event.

Body:
I am trying to shoot different projectiles based on which weapon is currently selected. The projectiles spawn but don't move anywhere. I currently have 2 projectile BluePrints (Parent and child):

BP_Projectile (Parent)
BP_PistolBullet (Child)

The parent class has a float called ProjectileSpeed. I have set the value of the float in the child class to 5000.0 for testing.

For the moment the child class contains a Cylinder with a box collision just so I can see something render. I have enabled 'Simulate Physics' on the cylinder.

I have then created an array called CollectedWeapons in my character blueprint with a type of BP_Projectile and added a single element with the value set to the class of BP_PistolBullet (I know a projectile isn't a weapon, but thats going to be expanded later :P )

The rest can be seen in my 'Shoot' BluePrint:

If you need any more information please let me know. Thanks in advance.

EDIT:

BP_PistolBullet components as requested.

EDIT:

Trying to make projectile shoot forward, but can't get it right. I've tried multiple different things, but this is the latest attempt:


问:
How can I resolve "Error: No developer directory found at /Developer"?
I just upgraded XCode to 4.3.1.
I'm using a script to build (and then deploy through Testflight) my app.
But I now receive this error:

Error: No developer directory found at /Developer. Run /usr/bin/xcode-select to update the developer directory path.

I've no /Developer dir in my machine: how can I fix it?

答:
This solved for me:

Mostly this error occurs when you have installed a newer version of xcode. And the command line tools are yet to be initialized.

To resolve this: Go under Xcode Preferences > Locations (tab) > And the bottom options is Command Line Tools. Please select the Xcode version for tools.

Example (For Xcode 8.3.3): Go under Xcode Preferences > Locations (tab) > And the bottom options is Command Line Tools. Select Xcode 8.3.3 (7D1014).


问:
Python add moving average to data frame
I have a fairly large data frame in python and I am trying to add a new column for moving average.  I can add the moving average for the table as a whole, the problem is I need to do multiple moving averages based off of the values in column b.  For example:

```<code>Column B          Column C
1                 4
2                 5
3                 6
1                 7
2                 8
3                 9
</code>```

so the new column would have the moving averages for 1,2,3,....

Thanks for the help.

答:
```<code>MA_WINDOW = 2
data = ('C:\\Users\\Benjamin\\Desktop\\XSO.csv')
df = pd.read_csv(data, names=['Indicie', 'Date', 'Open', 'High', 'Low','Close', 'Vol', 'MA'])
df['MA'] = df.Close.rolling(window=MA_WINDOW).mean()
print(df)
</code>```

Title: Python add moving average to data frame

Body:
I have a fairly large data frame in python and I am trying to add a new column for moving average.  I can add the moving average for the table as a whole, the problem is I need to do multiple moving averages based off of the values in column b.  For example:

Column B          Column C
1                 4
2                 5
3                 6
1                 7
2                 8
3                 9

so the new column would have the moving averages for 1,2,3,....

Thanks for the help.


问:
What's the best strategy for get/setting metadata on Ruby methods at runtime?
I have a class with some methods. It's supersekret but I've reproduced what I can here.

```<code>Class RayGun
  # flashes red light
  # requires confirmation
  # makes "zowowowowowow" sound
  def stun!
    # ...
  end

  # flashes blue light
  # does not require confirmation
  # makes "trrrtrtrtrrtrtrtrtrtrtr" sound
  def freeze!
    # ...
  end

  # doesn't flash any lights
  # does not require confirmation
  # makes Windows startup sound
  def killoblast!
    # ...
  end
end
</code>```

I want to be able to, at runtime, interrogate the class about one of the methods and receive a hash or struct like so:

```<code>  {:lights => 'red', :confirmation => false, :sound => 'windows'}
</code>```

What's the best way of doing this? Obviously you could have separate YAML file alongside and set up a convention to relate the two, but ideally I want code and metadata in one place.

The most promising idea I can come up with is something like this:

```<code>class RayGun
  cattr_accessor :metadata
  def self.register_method(hsh)
    define_method(hsh.name, hsh.block)
    metadata[hsh[:name]] = hsh
  end

  register_method({
    :name => 'stun!',
    :lights => 'red',
    :confirmation => 'true',
    :sound => 'zowowo',
    :block => Proc.new do
      # code goes here
   })

   # etc.
end
</code>```

Anyone got some better ideas? Am I barking up a very wrong tree?

答: There's the YARD tool which lets you add metadata to methods.  I'm pretty sure it just sticks the metadata into the rdoc files you generate, but you could easily build off of that to get runtime information.

OwnerDisplayName: EmbiggensTheMind

Body:
I have a class with some methods. It's supersekret but I've reproduced what I can here.

Class RayGun
  # flashes red light
  # requires confirmation
  # makes "zowowowowowow" sound
  def stun!
    # ...
  end

  # flashes blue light
  # does not require confirmation
  # makes "trrrtrtrtrrtrtrtrtrtrtr" sound
  def freeze!
    # ...
  end

  # doesn't flash any lights
  # does not require confirmation
  # makes Windows startup sound
  def killoblast!
    # ...
  end
end

I want to be able to, at runtime, interrogate the class about one of the methods and receive a hash or struct like so:

  {:lights => 'red', :confirmation => false, :sound => 'windows'}

What's the best way of doing this? Obviously you could have separate YAML file alongside and set up a convention to relate the two, but ideally I want code and metadata in one place.

The most promising idea I can come up with is something like this:

class RayGun
  cattr_accessor :metadata
  def self.register_method(hsh)
    define_method(hsh.name, hsh.block)
    metadata[hsh[:name]] = hsh
  end

  register_method({
    :name => 'stun!',
    :lights => 'red',
    :confirmation => 'true',
    :sound => 'zowowo',
    :block => Proc.new do
      # code goes here
   })

   # etc.
end

Anyone got some better ideas? Am I barking up a very wrong tree?

OwnerDisplayName: Gaius


问:
How can I store 0xFF to a char in C?
How can I store something in this format: "0xff" to a char array after declaring the array. I'll demonstrate what I mean below.

When writing a code such as this, works just fine:

```<code> int main (void){
       unsigned char array[] = {0xff,0xa4};
       return 0;
 }
</code>```

But, what I need is slightly more complicated. I need to assign something such as 0xff to the array after having already declared it. How can I get this to work and obtain the exact same result as in the piece of code above? With the code below I keep receiving the error "multi-character character constant [-Wmultichar]" and "large integer implicitly truncated to unsigned type [-Woverflow]".

```<code>int main(void){
      unsigned char array[2];
      array[0] = '0xff';
      array[1] = '0xa4';
      return 0;
}
</code>```

答:
Use array[0] = '\xff'; to set a single char to a hex numerical.

Or  array[0] = 0xff; as you did in the first part of your code, successfully.

Title: How can I store 0xFF to a char in C?

Body:
How can I store something in this format: "0xff" to a char array after declaring the array. I'll demonstrate what I mean below.

When writing a code such as this, works just fine:

 int main (void){
       unsigned char array[] = {0xff,0xa4};
       return 0;
 }

But, what I need is slightly more complicated. I need to assign something such as 0xff to the array after having already declared it. How can I get this to work and obtain the exact same result as in the piece of code above? With the code below I keep receiving the error "multi-character character constant [-Wmultichar]" and "large integer implicitly truncated to unsigned type [-Woverflow]".

int main(void){
      unsigned char array[2];
      array[0] = '0xff';
      array[1] = '0xa4';
      return 0;
}


问:
How to populate query with result from different table?
I have two tables. Table A and table B. Table A has a column that is a reference to the primary key to table B. I want to run a select query on table A and then populate the column that referrers to B with all of the data in that row of B.

```<code>SELECT * from A a LEFT JOIN B b ON a."b_id" = b."id"  WHERE ...
</code>```

That gives a result with each row containing all of the columns of A and all of the columns of B. It is a confusing mess to figure out which column is from which table. I want to be able to do something like.

```<code>row.A."column name"
row.B."column name"
</code>```

I don't want to have to rename every single column using AS. There must be a better way to do this.

答:
Not a 100% sure what your asking but what I think your asking is.

You want a way to have only column B values to show? If so you could do:

```<code>SELECT B.*
FROM A
JOIN B
  ON A.b_id = B.id
</code>```

That will only get you the B columns and data, If you want A also maybe do but you want to have it separate from b maybe do:

```<code>SELECT B.*,'|' AS ['|'], A.*
FROM A
JOIN B
  ON A.b_id = B.id
</code>```

Hopefully this is helpful, if not to you maybe another reader.

Body:
I have two tables. Table A and table B. Table A has a column that is a reference to the primary key to table B. I want to run a select query on table A and then populate the column that referrers to B with all of the data in that row of B.

SELECT * from A a LEFT JOIN B b ON a."b_id" = b."id"  WHERE ...

That gives a result with each row containing all of the columns of A and all of the columns of B. It is a confusing mess to figure out which column is from which table. I want to be able to do something like.

row.A."column name"
row.B."column name"

I don't want to have to rename every single column using AS. There must be a better way to do this.

Body:
Not a 100% sure what your asking but what I think your asking is.

You want a way to have only column B values to show? If so you could do:

SELECT B.*
FROM A
JOIN B
  ON A.b_id = B.id

That will only get you the B columns and data, If you want A also maybe do but you want to have it separate from b maybe do:

SELECT B.*,'|' AS ['|'], A.*
FROM A
JOIN B
  ON A.b_id = B.id

Hopefully this is helpful, if not to you maybe another reader.


问:
Google Analytics API: tiny differences in results between GA API and Google Analytics UI
I'm querying GA Report API v4 to get some metrics for AdWords Keywords.

As dimension I use:

```<code>ga:keyword
</code>```

As metrics I use:

```<code>ga:adClicks,
ga:adCost,
ga:CPC,
ga:sessions,
ga:bounceRate,
ga:pageviewsPerSession,
ga:goalConversionRateAll,
ga:transactions,
ga:transactionRevenue
</code>```

When I compare results pulled from API with results that I'm getting by Google Analytics UI, I found out that certain metrics in some Keywords has tiny differences.

Also when I tried GA API v3 I had same result.

What is the reason?

Why some returned metrics for Keywords are fully identical to results in UI, but certain not?

I tried various date ranges: 1 day, week, month but in all cases I got some tiny differences in some metrics of certain Keywords.

Here is screenshot with example of differences in metrics how it looks like:
In red color means the difference, green color - means that values are identical

答:
Problem: The reason for the discrepancy is that you are calling two different reports.

Report 1) UI Report.

As you have seen, this report is made up of two parts the first being Clicks, Cost, and CPC which are from the Google AdWords API, and the other metrics (sessions, bounce, etc.) which is from Google Analytics.

Because you are going into AdWords > Keywords, you are actually setting a filter to select only AdWords traffic.

Report 2) Custom Report.

This report is pulling the keywords dimension without any filters. This means that the report will also have data for organic keywords, and any UTM_term parameters set.

Because sessions from organic keywords have no AdWords data, the first three columns will be the same, however the Google Analytics specific columns will show variation in the metrics.

Solution:
To get your reports the same, you need to add a filter to your API request, such as ga:adwordsCustomerID or ga:source=google & ga:medium=cpc.

Body:
I'm querying GA Report API v4 to get some metrics for AdWords Keywords.

As dimension I use:

ga:keyword

As metrics I use:

ga:adClicks,
ga:adCost,
ga:CPC,
ga:sessions,
ga:bounceRate,
ga:pageviewsPerSession,
ga:goalConversionRateAll,
ga:transactions,
ga:transactionRevenue

When I compare results pulled from API with results that I'm getting by Google Analytics UI, I found out that certain metrics in some Keywords has tiny differences.

Also when I tried GA API v3 I had same result.

What is the reason?

Why some returned metrics for Keywords are fully identical to results in UI, but certain not?

I tried various date ranges: 1 day, week, month but in all cases I got some tiny differences in some metrics of certain Keywords.

Here is screenshot with example of differences in metrics how it looks like:
In red color means the difference, green color - means that values are identical


问:
In sqlalchemy, is there a way to sort so that empty cells are at the end irrespective or sort order?
I have a pretty standard setup and want to sort by a column:

someselect.order_by(asc(table1.mycol))

However, I want rows with '' or NULL for mycol to appear at the end of the results. Is there a way to do this?

答:
On databases that support NULLS LAST, you can sort NULLs at the end by doing

```<code>SELECT * FROM table1 ORDER BY mycol ASC NULLS LAST;
</code>```

You need to convert '' to NULLs so you can do this (which I recommend doing anyway), either in the data or as part of the query:

```<code>SELECT * FROM table1 ORDER BY (CASE mycol WHEN '' THEN NULL ELSE mycol END) ASC NULLS LAST;
</code>```

Alternatively, a more portable approach is

```<code>SELECT * FROM table1 ORDER BY (CASE WHEN mycol IS NULL OR mycol = '' THEN 1 ELSE 0 END) ASC, mycol;
</code>```

To write this in SQLAlchemy:

```<code>.order_by(case([(or_(tabel1.mycol.is_(None), table1.mycol == ""), 1)],
               else_=0), table1.mycol)
</code>```

Body:
On databases that support NULLS LAST, you can sort NULLs at the end by doing

SELECT * FROM table1 ORDER BY mycol ASC NULLS LAST;

You need to convert '' to NULLs so you can do this (which I recommend doing anyway), either in the data or as part of the query:

SELECT * FROM table1 ORDER BY (CASE mycol WHEN '' THEN NULL ELSE mycol END) ASC NULLS LAST;

Alternatively, a more portable approach is

SELECT * FROM table1 ORDER BY (CASE WHEN mycol IS NULL OR mycol = '' THEN 1 ELSE 0 END) ASC, mycol;

To write this in SQLAlchemy:

.order_by(case([(or_(tabel1.mycol.is_(None), table1.mycol == ""), 1)],
               else_=0), table1.mycol)


问:
How to get topic vector of new documents and compare with pre-defined topic model in Mallet?
I'm trying to somehow compare a sole document's topic distribution (using LDA) with, other files and their topic distributions within a previously created topic model, using MALLET.

I know that this can be done through MALLET commands in terminal but I'm having problems in finding a way to implement this in Java.

To give a gist of what the functionality of my program is:

The already created topic model was created with a large corpus of texts. I want to use this to compare topic distributions with a tweet that contains a certain hashtag and to then pull out the file most similar to the tweet from the corpus.

Ive read through Mallet's Java API docs but they seem very confusing and not really explanatory.

If anyone could give me a few tips I'd appreciate it

答:
First, take a look at these:

Developer's guide

Tutorial slides after slide 97

Code examples in the source directory: src/cc/mallet/examples

Now, these examples show the basic functionality, but they don't show how to save and load the model if you need to separate training from testing. Basically what you need is to save both the model and the instances after training (since you need to train and test with the same pipeline), and load them before testing.

Save model and pipeline after training:

```<code>model.write(new File("model.dat"));
instances.save(new File("pipeline.dat"));
</code>```

Load model and pipeline before testing:

```<code>ParallelTopicModel model = ParallelTopicModel.read(new File("model.dat"));
InstanceList instances = InstanceList.load(new File("pipeline.dat"));
</code>```

Hope this helps.

Body:
First, take a look at these:

Developer's guide

Tutorial slides after slide 97

Code examples in the source directory: src/cc/mallet/examples

Now, these examples show the basic functionality, but they don't show how to save and load the model if you need to separate training from testing. Basically what you need is to save both the model and the instances after training (since you need to train and test with the same pipeline), and load them before testing.

Save model and pipeline after training:

model.write(new File("model.dat"));
instances.save(new File("pipeline.dat"));

Load model and pipeline before testing:

ParallelTopicModel model = ParallelTopicModel.read(new File("model.dat"));
InstanceList instances = InstanceList.load(new File("pipeline.dat"));

Hope this helps.