Spring MVC and Websocket Exception using Sockjs with Stompjs

Question: Hello i have an Spring MVC 4.0.4 project completely configured using annotations inside a Wildfly 8.1 Server, the only problem is when i use the following javascript code for initializing Sockjs using Stompjs i get an exception that i don't understand, for clarity this don't happened to when i used XML based config, i use the tutorial in this link
Javascript Code
var socket = new SockJS('/frontend/track');
referencesServices.stompClient = Stomp.over(socket);

Weboscket java config
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
    public static final Logger LOGGER = LogManager.getLogger(WebSocketConfig.class);

    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
        LOGGER.debug("INIT WEBSOCKET END POINTS");
        registry.addEndpoint("/track").withSockJS();//.setDisconnectDelay(30000);
    }

    @Override
    public void configureMessageBroker(MessageBrokerRegistry registry) {
        registry.enableSimpleBroker("/updates");
//      registry.enableStompBrokerRelay("/queue/", "/topic/");
        registry.setApplicationDestinationPrefixes("/app");
    }

}

Exception
17:57:40,997 ERROR [io.undertow.request] (default task-24) UT005023: Exception handling request to /frontend/track/info: org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.socket.sockjs.SockJsException: Uncaught failure in SockJS request, uri=http://localhost:8080/frontend/track/info; nested exception is java.lang.NullPointerException
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:973) [spring-webmvc-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852) [spring-webmvc-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:687) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837) [spring-webmvc-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
    at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:130) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter.doFilter(DefaultLoginPageGeneratingFilter.java:155) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:85) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:57) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344) [spring-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261) [spring-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
    at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
    at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:240) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:177) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:727) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_55]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_55]
    at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_55]
Caused by: org.springframework.web.socket.sockjs.SockJsException: Uncaught failure in SockJS request, uri=http://localhost:8080/frontend/track/info; nested exception is java.lang.NullPointerException
    at org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler.handleRequest(SockJsHttpRequestHandler.java:91) [spring-websocket-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:51) [spring-webmvc-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938) [spring-webmvc-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870) [spring-webmvc-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961) [spring-webmvc-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    ... 71 more
Caused by: java.lang.NullPointerException
    at java.util.ArrayList.<init>(ArrayList.java:164) [rt.jar:1.7.0_55]
    at io.undertow.servlet.spec.HttpServletResponseImpl.getHeaders(HttpServletResponseImpl.java:248) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
    at javax.servlet.http.HttpServletResponseWrapper.getHeaders(HttpServletResponseWrapper.java:303) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
    at javax.servlet.http.HttpServletResponseWrapper.getHeaders(HttpServletResponseWrapper.java:303) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
    at org.springframework.http.server.ServletServerHttpResponse$ServletResponseHttpHeaders.get(ServletServerHttpResponse.java:149) [spring-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.web.socket.sockjs.support.AbstractSockJsService.addCorsHeaders(AbstractSockJsService.java:366) [spring-websocket-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.web.socket.sockjs.support.AbstractSockJsService$1.handle(AbstractSockJsService.java:421) [spring-websocket-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.web.socket.sockjs.support.AbstractSockJsService.handleRequest(AbstractSockJsService.java:290) [spring-websocket-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler.handleRequest(SockJsHttpRequestHandler.java:88) [spring-websocket-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    ... 75 more

Pom.xml
<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>com.springmvcangular.backend</groupId>
    <artifactId>SpringMVCAngularBackend</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>Spring MVC Angular Backend</name>
    <description>Backend para proyectos usango Spring MVC junto con Angular JS</description>
    <properties>
        <org.aspectj-version>1.6.10</org.aspectj-version>
        <java-version>1.7</java-version>
        <org.springframework-version>4.0.4.RELEASE</org.springframework-version>
        <org.slf4j-version>1.6.6</org.slf4j-version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${org.springframework-version}</version>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <artifactId>commons-logging</artifactId>
                    <groupId>commons-logging</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${org.springframework-version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-mongodb</artifactId>
            <version>1.4.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-mongodb-log4j</artifactId>
            <version>1.4.2.RELEASE</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>3.2.3.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>3.2.3.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-websocket</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-messaging</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>
        <dependency>
            <groupId>org.mongodb</groupId>
            <artifactId>mongo-java-driver</artifactId>
            <version>2.12.0-rc3</version>
        </dependency>
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>2.3</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.2.3</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-joda</artifactId>
            <version>2.4.0-rc3</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20140107</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>javax.websocket</groupId>
            <artifactId>javax.websocket-client-api</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.2.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.3.2</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.3.2</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>
    </dependencies>
</project>

Application Initializer
public class BackendMongoWebApplicationInitializer extends
        AbstractAnnotationConfigDispatcherServletInitializer {

    public static final String SERVLET_NAME = "dispatcher";

    @Override
    public void onStartup(ServletContext servletContext)
            throws ServletException {
        // TODO Auto-generated method stub
        AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
        ctx.register(AppMongoConfig.class);
        ctx.setServletContext(servletContext);

        ServletRegistration.Dynamic servlet = servletContext.addServlet(
                SERVLET_NAME, new DispatcherServlet(ctx));
        servlet.setAsyncSupported(true);
        servletContext.setInitParameter("log4jConfigLocation",
                "classpath:log4j.xml");
        servletContext.addListener(new Log4jConfigListener());

        servletContext.addListener(new ContextLoaderListener(ctx));

        FilterRegistration.Dynamic springSecurityFilterChain = servletContext
                .addFilter(BeanIds.SPRING_SECURITY_FILTER_CHAIN,
                        new DelegatingFilterProxy());
        springSecurityFilterChain.setAsyncSupported(true);
        springSecurityFilterChain.addMappingForUrlPatterns(null, false, "/*");

        servlet.addMapping("/");
        servlet.setLoadOnStartup(1);
    }

    @Override
    protected Class<?>[] getRootConfigClasses() {
        // TODO Auto-generated method stub
        return new Class[] { AppMongoConfig.class };
    }

    @Override
    protected Class<?>[] getServletConfigClasses() {
        // TODO Auto-generated method stub
        return new Class[] {MongoSecurityConfig.class, WebSocketConfig.class};
    }

    @Override
    protected String[] getServletMappings() {
        // TODO Auto-generated method stub
        return new String[] { "/" };
    }

    @Override
    protected void customizeRegistration(Dynamic registration) {
        //registration.setInitParameter("dispatchOptionsRequest", "true");
        registration.setAsyncSupported(true);
    }

}

UPDATE
Now with the help of smoky finally the websocket works on wildfly 8, now the only problem is an exception throws when the sockjs is connecting:
Weboscket sockjs error
WebSocket connection to 'ws://localhost:8080/frontend/track/491/xe9k638d/websocket' failed: Error during WebSocket handshake: Unexpected response code: 500

Server Exception
Caused by: org.springframework.web.socket.sockjs.SockJsException: Uncaught failure in SockJS request, uri=http://localhost:8080/frontend/track/491/xe9k638d/websocket; nested exception is org.springframework.web.socket.sockjs.SockJsTransportFailureException: WebSocket handshake failure; nested exception is java.lang.NoSuchMethodError: io.undertow.servlet.websockets.ServletWebSocketHttpExchange.<init>(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V
    at org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler.handleRequest(SockJsHttpRequestHandler.java:91) [spring-websocket-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:51) [spring-webmvc-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938) [spring-webmvc-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870) [spring-webmvc-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961) [spring-webmvc-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    ... 68 more
Caused by: org.springframework.web.socket.sockjs.SockJsTransportFailureException: WebSocket handshake failure; nested exception is java.lang.NoSuchMethodError: io.undertow.servlet.websockets.ServletWebSocketHttpExchange.<init>(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V
    at org.springframework.web.socket.sockjs.transport.handler.WebSocketTransportHandler.handleRequest(WebSocketTransportHandler.java:87) [spring-websocket-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.web.socket.sockjs.transport.TransportHandlingSockJsService.handleTransportRequest(TransportHandlingSockJsService.java:254) [spring-websocket-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.web.socket.sockjs.support.AbstractSockJsService.handleRequest(AbstractSockJsService.java:317) [spring-websocket-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler.handleRequest(SockJsHttpRequestHandler.java:88) [spring-websocket-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    ... 72 more
Caused by: java.lang.NoSuchMethodError: io.undertow.servlet.websockets.ServletWebSocketHttpExchange.<init>(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V
    at org.springframework.web.socket.server.standard.UndertowRequestUpgradeStrategy.upgradeInternal(UndertowRequestUpgradeStrategy.java:90) [spring-websocket-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.web.socket.server.standard.AbstractStandardUpgradeStrategy.upgrade(AbstractStandardUpgradeStrategy.java:119) [spring-websocket-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.web.socket.server.support.DefaultHandshakeHandler.doHandshake(DefaultHandshakeHandler.java:215) [spring-websocket-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.web.socket.sockjs.transport.handler.WebSocketTransportHandler.handleRequest(WebSocketTransportHandler.java:83) [spring-websocket-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    ... 75 more

Comment: I've got the same issue actually. Just found it comes from `io.undertow.servlet.spec.HttpServletResponseImpl` which use `io.undertow.util.HeaderMap`, return `null` and cause `NullPointerException`. This library is native to Wildfly. I've not yet found any solution tho.
Comment: so the solution will be change the server to tomcat 8 for example?
Comment: Actually, this is working with Glassfish 4. So I guess it's a bug w/ Wildfly. I think it can be bypassed by modifying `AbstractSockJsService` at line 366 w/ Spring 4.0.5. I'm looking for a solution.
Comment: what do you think if i change the undertown-servlet for another using maven and then exclude the module using `jboss-deployment-structure`? do you know what module i can exclude and what jars include in my pom?
Comment: I don't think it's a good idea, because a lot of things use this module (and specially the method `getHeaders(String name)` which is indirectly causing the issue) but you can try. I think it should be better to modify `DefaultSockJsService.addCorsHeaders(...)` from Spring Socket (inherited from `AbstractSockJsService`). Tell me if you find a solution, I'll also do if so.
Comment: The library used by Wildfly can be found here : `modules\system\layers\base\io\undertow\core\main`
Comment: Apparently, undertow 1.1.0.Beta3 should fix the issue. I'm going to try. Here's the repo http://mvnrepository.com/artifact/io.undertow/undertow-servlet/1.1.0.Beta3
Comment: @DiegoFernandoMurilloValenci could you open another question for your updated issue? This one has nothing to do with the previous and should be helpful to others. Ping me when this is done, I might be able to help you on this one.
Answer: In fact, it looks like this is a Wildfly issue (see WFLY-3474 - NPE in HttpServletResponse.getHeaders).
Upgrading to a recent Undertow version (1.1.0.Beta2 +) solves that specific Exception but creates a bigger problem, since Spring Framework websocket module does not yet support this beta version.
SPR-11919 should address your first issue.
Follow SPR-11914 for the upcoming undertow 1.1 support.
Comment: I think the undertow fix will be shipped with Wildfly 9. In the meantime, you can use Spring Framework 4.0.6 as soon as it's out (in a few days) with a non-beta undertow version.
Comment: i will add a new question for this, now do you thing this will be solvet in the version 9 of wildfly and next version of spring? i'm using spring 4.0.5
Comment: actually, never mind about adding another question - unless you think that Wildfly users often try to upgrade undertow to a beta version?
Comment: As mentioned by @BrianClozel, this is working w/ Spring Framework 4.0.6 and non-beta undertow version. Thanks.
Answer: With the help of the op :
First, you need to use recent undertow libraries. There's 2 possibilities but I only tested the first one :

Update undertow libs in modules\system\layers\base\io\undertow\ :
I only updated core and servlet from 1.0.15.Final to 1.1.0.Beta3 then updated both module.xml to use the new files.

Use new undertow libs in your projet (w/ Maven for example) and disable the module using jboss-deployment-structure.xml.

The XML should look like this :
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <deployment>
        <exclusions>
            <module name="io.undertow.core" />
            <module name="io.undertow.servlet" />
        </exclusions>
</deployment>
</jboss-deployment-structure>

Second, in web.xml, you need to add <async-supported>true</async-supported> to DispatcherServlet and filters (if used).
Comment: Thanks, i'm trying the second atemp but the same error, i'm using java config so i don't know where to set `async-support` to my filters, i use `AbstractAnnotationConfigDispatcherServletInitializer` for my web initializer (replace to `web.xml`) and in `customizeRegistration` method i use `setAsyncSupported(true)` but i don't know where to set async in my `AbstractSecurityWebApplicationInitializer` (replace for  springSecurityFilterChain) so i think that without this no one of the two options works for me, i can see the undertow version chanage in my exception.
Comment: i add my Application Initializer code where i set the async support
Comment: i use the first option that you expose but my view resolver don't works anymore, maybe all my problems here is beacuse i use java config instead XML, i try my proyect in Glassfish and works like a charm, so for now i use glassfish, glad that this works for you.
Comment: I don't know how to do with a non-xml definition. I've set `async-support` as `filter` and `servlet`'s child in `web.xml`. There should have an alternative in java config. Actually, my first goal was to migrate from Glassfish to Wildfly due to future lack of support.
Comment: finally i got this to work in wildfly 8 with the first option, i think that i was replacing with beta1 and not beta3, that was the problem, now websocket works in my proyect, the only problem is an exception throwed when websocket start i will update my question for show it
Comment: Thanks a lot, approach 1 worked for me! Undertow was throwing exception when client was sending async requests, upgrading the lib helped
Answer: I have the impression that server and client can't communicate each other (the caused by error say : Caused by: org.springframework.web.socket.sockjs.SockJsException: Uncaught failure in SockJS request, uri=http://localhost:8080/frontend/track/info; nested exception is java.lang.NullPointerException).

I think it's because of the path for SockJS which is not the same in client and server. Indeed, the value of javascript sockJS is '/frontend/track' (var socket = new SockJS('/frontend/track')), whereas it's just '\track' in server side (registry.addEndpoint("/track").withSockJS()). If i have uderstood well the spring documentation, path declare in SockJS both in server and client (javascript) side should be the same, but i could make a mistake...
Comment: Thanks for answer, but the path is well, because if i change it the error will be 404 and not 500 like in my case, is an server error
Comment: Can you show us your XML code that you used before, with all config file, and the other java code class which set up the dispatcher and the listner plz


Botões em JavaScript

Question: Tenho uma página com botão de salvar, mas toda vez que ele é clicado aparece o script de que as informações foram salvas e sai da página.
Meu objetivo é que ele não saia, mas olhei o código e não entendi porque ta saindo.
Segue o botão:

            <button type="submit" class="btn btn-primary form-control" name="button" id="button">Salvar</button>

            <button type="button" name="button" id="button" class="btn btn-danger form-control">Cancelar</button>

Segue o Script:

Comment: Está faltando algum trecho de código ? Até onde me lembro history não é uma função, o history você pode chamar o back() e forward()
Comment: Não. Eu uso o sublime text e ele acusa quando algo é reconhecido ou não como uma função. Estava tentando usar window.history.back()
Comment: Abra um console em algum browser e digite window.history()
Comment: Realmente, não é uma função. Mas não entendo porque meu window.history.back() não funciona.
Comment: Agora sim kkk, seu back não funciona ?
Comment: Refaça sua pergunta novamente assim vou poder te ajudar melhor.
Comment: Certo. Quando meu botão salvar é clicado, a página retorna pra anterior. O código em jscript é esse aí, olhei várias vezes e parece tudo certo, tentei inclusive desabilitar o script mas continua acontecendo o mesmo.
Comment: Mariana, o código que você está utilizando é realmente o que está na pergunta? reveja o código
Comment: Opa. correção, window.history.back() não, window.history.forward()
Comment: O código que você postou da erro porque usa o history como function.
Comment: Ah, tem razão, o código está errado. Esse é o código que eu já mexi até dizer chega, vou editar para o original.
Comment: Tudo bem, assim que mudar comunique, tente colocar o código inteiro ok?
Answer: Respondendo sua pergunta, ele sai da página porque você está utilizando o
window.location

Explicação:
O objeto window.location pode ser usado para obter o endereço da página atual (URL) e para redirecionar o navegador para uma nova página.
Comment: Sim, eu tentei colocar o endereço da própria página que eu quero manter, mas continua voltando na página anterior
Comment: Como expliquei o window.location vai alterar sim a página independente se você passa a mesma página ou uma diferente.
Comment: Você pode estudar um pouco sobre ajax e utilizar para fazer seu cadastro, assim você permanece na página.
Comment: Certo, obrigada pela ajuda.
Comment: De nada, qualquer coisa pesquise sobre crud com ajax e php, vi que você utiliza php, se minha resposta respondeu sua pergunta não esqueça de avalia-la, até a próxima.
Comment: Eu ainda não tenho 15 pontos de reputação.
Comment: Não faz mal, só comentei porque sempre faço isso kkk, obrigado e precisando estaremos aqui.
Answer: Você precisa usar o  window.open e configura-lo de acordo com a sua necessidade:

Botões em JavaScript


hook_form_alter checking $user->uid == $node->uid

Question: I need to check if the node uid and the logged-in user's uid are identical when the user is in the node edit form, and then add a class to the form if that condition is true.* The relevant code in my custom module currently looks like this:
function custom_form_alter(&$form, $form_state, $form_id) {
    global $user;
    $node = node_load(arg(1));
    switch($form_id) {
        case "custom_type_node_form" && "$user->uid == $node->uid":
            $form['#attributes'] = array('class' => 'test-class');
    break;
    }
}

The class is getting added even if the user isn't the author.
*Use case is that all site members with role X can edit nodes of type Y, but if the member editing the node is the author, I'd like to add some CSS.
I'm using Drupal 6.31.
Answer: hey You can simply do this :-
function custom_form_alter(&$form, $form_state, $form_id)
 {
    global $user;
    $node = node_load(arg(1));
    if($form_id=='custom_type_node_form')
     {
       if($user->uid == $node->uid)
        {
          $form['#attributes'] = array('class' => 'test-class');
        }
      }
}

I hope this will work for you.
Comment: As this stands it attempts to do a `node_load(arg(1))` regardless of the form or the path - so who knows what `arg(1)` might be returning! I'd suggest using `hook_form_FORM_ID_alter()` (and you can read the node directly from the form array in `$form['#node']`).
Comment: I had to change the `if($user->uid == $node->uid)` to `if($user->uid === $node->uid)` for reasons I am choosing not to investigate at the moment, but otherwise this was great, thanks!
Comment: These conditions you need to add yourself. I just told you the way to do it.


How to integrate selenoid and allure

Question: We implement farm of browsers based on GGR + Selenoid. If there any instruction how to integrate Allure reporting with such infrastructure?

On which host allure-results folder will be generated?
Should I create a script that will go through each selenoid host and copy a
folder with results to one node?
How to not mix results from different test runs / CI jobs?
Comment: HIi @Anton I'm trying to achieve GGR+selenoid setup for my project but facing some difficulty can you please help with that. you can track my issue using this link : https://github.com/aerokube/ggr/issues/307
Answer: 1) Selenoid is just a Selenium API and has nothing to do with automated tests reports.
2) Allure test execution results are usually generated on the server where your tests are being executed (e.g. on CI-server). Allure report from these results can be either generated on the same server or you could copy results to another server and generate HTML report there. There are a lot of ways to do this depending on your infrastructure.
Comment: got you. Thanks! also this link might help to do what you describe. https://stackoverflow.com/a/50562351/1932373
Answer: Use the Allure docker container and send the results using API.
https://github.com/fescobar/allure-docker-service#send-results-through-api

How to integrate selenoid and allure


Generate multiple report types using CodeNarc in Gradle

Question: I want to generate both HTML and console report in CodeNarc in Gradle.
My build.gradle:
apply plugin: 'codenarc'
...
codenarc {
    toolVersion = '0.24.1'
    configFile = file('config/codenarc/codenarc.groovy')
    reportFormat = 'html'
}

This works fine, but I'd like also to have report displayed on console, as right now only link to HTML is displayed there. How can I request multiple report types?
Answer: Instead of running a second task to generate another report, you could make the following change to add another report format.
Then grab one of the files and write it to the console.
(You could just grab the HTML or XML report and write that to the console, but it may be hard to read without some formatting.)
Note: The reports closure will get you reports in different formats. The doLast will print the output of one of those reports to the console. If you do not need the console output, you can remove the doLast closure.
I would suggest changing your task like this:
task codenarcConsoleReport {
    doLast {
        println file("${codenarc.reportsDir}/main.txt").text
    }
}
codenarcMain {
    finalizedBy codenarcConsoleReport
    reports {
        text.enabled = true
        html.enabled = true
        xml {
            enabled =  true
            destination = file("${codenarc.reportsDir}/customFileName.xml")
        }
    }
}

Note: This will not cause your task to run twice.
Answer: In newer versions of Gradle (7+) I get a deprecation warning on:
reports {
    html.enabled = true
    xml.enabled = true
}

The format has changed to (for enabling html and xml reports)
reports {
    html.required = true
    xml.required = true
}

Answer: Best way I can think of is to create a separate task:
task codeNarcConsole(type: CodeNarc) {
  // other config
  reportFormat = 'console'
}

check.dependsOn('codeNarcConsole')

Not ideal, but workable. You could also post to Gradle Bugs about this to get it improved.
Comment: Yeah adding a task would likely cause it to run twice. Since build time is important, you could write a custom task that extends CodeNarc and overrides the report generation bits


If his overall profit for the year was $\$104.50$, and he invested $300 more in commodities than in REITs, how much was allocated to each investment?

Question: Through monthly deductions from his salary, Noah managed to accumulate 4800 per month last year for his future sabbatical trip. His savings account yielded 4.2% interest, his real estate investment trust (REIT) gained 5.75%, but his commodity portfolio dipped by 2.5%. If his overall profit for the year was $104.50, and he invested 300 more in commodities than in REITs, how much was allocated to each investment category? (Formulate a system of equations and solve it by utilizing the inverse matrix method.)
I am sure about two equations:
His overall profit for the year is 104.50: $0.042S + 0.0575R - 0.025C = 104.50$
The amount invested in commodities is 300 more than the amount invested in REITs: $C = R + 300$
But im not too sure how to get the 3rd equation. I have two candidates:
The total amount invested is 4800 per month: $S + R + C = 4800$
or
The total amount invested is 4800 per month, so in a year it would be 57600 : $S + R + C = 57600.$
Im not sure which one to use and why would i use it.
Answer: This is more of an English question than math, but it should be the second equation because the question states "accumulate 4800 per month", while the interest rates are typically per year. However, this results in a negative amount contributed to savings...
This also depends on whether "he invested 300 more in commodities than in REITs" per month or per year, which would change the second equation.
The answer also changes depending on how the interest is accrued -- the first equation might not just be 4.2% of S + the rest = 104.50 because the contributions are monthly so less interest is accrued when there is less money in the account. Assuming no compounding in the savings account, contributing $S/12$ every month, in the first month it would be 4.2%/12 of $S/12$, then 4.2%/12 of $2S/12$ the next month, etc.


Some doubts related to closed curves and simply connected space

Question: I have few  doubts.
(1) At  http://faculty.up.edu/wootton/Complex/Chapter8.pdf
I found the following result. The important part of the proof is what it says about the closed curve that it can be broken down into number of simple closed curve. If the examples given are of closed curves then i am confused what the following proof implies. Note that in the proof the fact that D is simply connected region (assumed to be open in the note) is not used to conclude that a closed curve can be broken down into a number of simple closed curve. My confusion is whether a straight line segment is a closed curve. I can see that there is a continuous surjective function from [0,1]to the line segment.
Lemma 1.4. Suppose C is a closed curve contained in a simply con-
nected region D. Then the interior of C is contained in D (by the
interior, we mean the finite region with boundary C).
Proof. Suppose that C is some closed curve. Then C may intersect
itself a number of times. However, if this happens, then C may be
broken up into a number of simple closed curves (see illustration)
(2) Whether the following definitions of simply connectedness are the same for $R^2$:
-a bounded subset E of $R^2$  is said to be simply connected if both E and $R^2\setminus E$  are connected. (https://mathworld.wolfram.com/SimplyConnected.html)
-A space X (in particular X as a subspace of $R^2$) is said to be simply connected if it is a path-connected space
and if $π_1 (X, x_0 )$ is the trivial (one-element) group for some $x_0\in X$ , and hence for
every $x_0\in X$ . We often express the fact that  $π_1 (X, x_0 )$ is the trivial group by writing
$π_1 (X, x_0 )=0$. (Munkres Topology p.333)
(3) Is it true that a simple closed curve  in any simply connected space the interior of the curve is contained in the simply connected space.
Answer: A closed curve $\gamma:[0,1]\to \mathbb{R}^2$, is one where $\gamma(0)=\gamma(1)$. Suppose $\gamma(c_0)=\gamma(c_1)$ then you can decompose the curve in $\gamma_0:[0,c_0]\cup[c_1,1]\to \mathbb{R}^2$ and $\gamma_1:[c_0,c_1]\to \mathbb{R}^2$. So supposing there is a finite number of self intersection you are ok.
The second question is harder bu you can google it, it requires a bit of algebraic topology.
The third question is false, because in a general simply connected space you cannot define an interior af a curve (e.g. think on a sphere). Although on the plane it it is true, and as proven in the notes, you just take one point $P\in Int(\gamma)\cap R$ and $Q\in Out(\gamma)\cap R$, where $R$ is the complement of your simply connected region. You join them by a path in $R$ and you find a point in $\gamma \cap R$ which is a contradiction because $\gamma$ was inside the simply connected region
Comment: I meant $R^2$ not any general simply connected space.


EPPlus: Values in column of pivot table

Question: When you create a pivot table in Excel and add fields to Rows and Values, you get an additional field [Symbol Sigma] Values in the GUI, that you can drag and drop to Columns.
I am creating a pivot table using EPPlus. How can I add this [Symbol Sigma] Values field to my column fields?
Edit: Here is some code. I dont' see how this is supposed to help, what it was asked for.
private static ExcelWorksheet CreatePivotWorksheet(ExcelPackage excel, ExcelWorksheet dataWorksheet)
{
    string worksheetName = "Pivot";

    ExcelWorksheet pivotWorksheet = excel.Workbook.Worksheets.Add(worksheetName);

    ExcelRangeBase dataRange = dataWorksheet.Cells[dataWorksheet.Dimension.Address];
    ExcelPivotTable pivotTable = pivotWorksheet.PivotTables.Add(pivotWorksheet.Cells[1,1], dataRange, "pivotTable");

    pivotTable.RowGrandTotals = false;

    pivotTable.RowFields.Add(pivotTable.Fields["BaseValue"]);
    pivotTable.RowFields.Add(pivotTable.Fields["Remaining Runtime"])
        .AddNumericGrouping(0, 500000, 30);
    pivotTable.RowFields.Add(pivotTable.Fields["Emittent"]);
    pivotTable.RowFields.Add(pivotTable.Fields["CountIfs"]);
    pivotTable.RowFields.Add(pivotTable.Fields["ISIN"]);

    var stressField = pivotTable.DataFields.Add(pivotTable.Fields["StressScenario - Percent"]);
    stressField.Function = DataFieldFunctions.Average;
    stressField.Format = "0.00%";
    var pessimisticField = pivotTable.DataFields.Add(pivotTable.Fields["PessimisticScenario - Percent"]);
    pessimisticField.Function = DataFieldFunctions.Average;
    pessimisticField.Format = "0.00%";
    var mediumField = pivotTable.DataFields.Add(pivotTable.Fields["MediumScenario - Percent"]);
    mediumField.Function = DataFieldFunctions.Average;
    mediumField.Format = "0.00%";
    var optimisticField = pivotTable.DataFields.Add(pivotTable.Fields["optimisticScenario - Percent"]);
    optimisticField.Function = DataFieldFunctions.Average;
    optimisticField.Format = "0.00%";

    // remove subtotals, this has to be done _after_ adding the field (see https://stackoverflow.com/a/34768357/5909613)
    foreach (ExcelPivotTableField rowField in pivotTable.RowFields)
    {
        rowField.SubTotalFunctions = eSubTotalFunctions.None;
    }
    return pivotWorksheet;
}

Comment: BTW where is the code?
Comment: That's not a regular field. Check [this explanation](http://yoursumbuddy.com/identify-pivot-table-values-field/). In this simple case it doesn't really matter. If you add more column fields though it does - it controls whether the totals will appear inside each column group or vice versa. Which means the important question is how to change its order.
Comment: That's the symbol for Sum/Total. The symbol doesn't matter anyway, values only appear as aggregates in a pivot table's cells. The GUI simply selects an appropriate default depending on the value type, eg sum for numbers, count for text etc. You'll have to specify this explicitly in your code
Comment: @PanagiotisKanavos I added code, but this won't help with my question.
Comment: There's no `Σ` column or field in the GUI. That's just the *values* region in the pivot table. It uses `Σ` because that's the math symbol for sums.  The fields you set there are set throu the `DataFields` collection in the API.
Comment: The code is essential to answer the question. It shows how you added the Row/Column/PageFields and whether you added anything to the `DataFields`. It looks like you only added *row*fields.
Comment: @PanagiotisKanavos I added an image with the desired result. I do indeed add `DataFields`, see `stressField` etc.
Comment: Doesn't change anything. There's still no `Σ` field, that's the Values region and you need to set them through the `DataFields` collection. The Interop/VBA/EPPlus API is the same so you can use almost any tutorial as a guide
Comment: @PanagiotisKanavos Yes, there is Values region in the bottom right. But there is also a Values field in the top right region (Columns). Or how would you call that?
Comment: A thing that *you* have to explain. What did you do to put that there? That's *doesn't* appear in the UI of simple pivot tables.
Comment: @PanagiotisKanavos In Excel (I'm using Excel2016) create a pivot table, add 1 table column to the Rows section, and 2 (numeric?) table columns in the Values section. Then this new field will appear in the Columns section. It does also appear in my pivot tables created using `EPPlus` when I open them in Excel, but in the Rows section.
Comment: @PanagiotisKanavos So can I control this from `EPPlus`?
Answer: Try to set pivotTable.DataOnRows = false to get such pivot table behaviour
Answer: try to change Values Row filed to column. Here 3 is Values filed index.
  PivotField row = (PivotField)oPivotTable.RowFields[3];
  row.Orientation = XlPivotFieldOrientation.xlColumnField;

Comment: I can not justify marking this as accepted as I cannot verify it, because I don't have the code anymore. If someone else will comment that this works, I will accept it. Thanks for taking your time to answer old questions.
Comment: @JeromeReinländer Actually I faced the same issue and fixed the issue yesterday using above code. That is why I posted the code here.. Cheers!
Answer: I have found solution for your case.
You should add a couple strings in your code for datafields.
Example for datafield "stressField":
    stressField.Field.Outline = true;
    stressField.Field.ShowInFieldList=true;

As well as for other:
    pessimisticField.Field.Outline = true;
    pessimisticField.Field.ShowInFieldList=true;

    mediumField.Field.Outline = true;
    mediumField.Field.ShowInFieldList=true;

    optimisticField.Field.Outline = true;
    optimisticField.Field.ShowInFieldList=true;

EPPlus: Values in column of pivot table


Russell's Paradox for the zero set and a set with the zero set.

Question: So I have a question:
Let: Allow set B = {x: x $\notin$ x}. Then, B $\in$ B $\iff$ B $\notin$ B ?
Does this apply for the zero set?
Because I'm a bit confused. The definition is a zero set is always in the zero set. But then if $\emptyset$ $\in$ $\emptyset$, then $\emptyset$ $\in$ $\emptyset$ $\iff$ $\emptyset$ $\notin$ $\emptyset$.
Is there a mistake I'm making? Something doesn't feel right here. Sorry if it's a confusing question. (I don't know if this has been posted before?)
Also:
Let C = {$\emptyset$}. Is there an element? Because if there's an element, what is that element? Is it the empty set? If it's the empty set, then there's no set there is there? It's nothing in the set in there. But there's a set in there. (Please explain this also).  Can somebody also explain if I placed the logic of Russell's Paradox in this set with empty set?
Thank you for the help. (Thank you everybody) ありがとう 皆さん
Comment: The axioms of set theory state that the empty set (what you're calling the zero set) is a /subset/ of every set, not /in/ every set, which should clear up the $\emptyset \in \emptyset$ problem. Further, what you call $C = \{ \emptyset\}$ is a well-defined set and the member is the empty set. Imagine you had an empty box. There's nothing in the box, but the box itself exists, right? Now imagine you put the empty box inside of another box. That gives us $C = \{ \emptyset\}$. The box $C$ isn't empty, it has an empty box in it!
Comment: SO if I say that ∅ ∈ ∅, it would be false right? Its a proper subset with ∅ $\subset$ ∅? Is that the definition? So, is it a subset of itself? I think I'm confusing a law here.
Comment: Yes, that is false. By stipulation, for any object in the universe of discourse $X$, $X \not \in \emptyset$, and $X$ is always in our universe. Further, something /cannot/ be a proper subset of itself, so $\emptyset \subseteq \emptyset$. Finally, any set always has the following two subsets: itself and the empty set. In this case "itself" and empty set coincide, which is fine.
Comment: I see. The set is there, but it holds an element (namely the $\emptyset$). But because {$\emptyset$} holds the $\emptyset$, it's not empty (theres an element called "no element" in there. Also I think I get the subset thing. Thanks.
Answer: By definition no set is an element of $\varnothing$, in particular itself. So it is not true that $\varnothing\in\varnothing\iff\varnothing\notin\varnothing$.
For the second part you're confusing "being empty" and "non-existing". If my wallet is empty, it doesn't mean that I don't have a wallet. The empty set is just a set which has no elements, it doesn't mean that it doesn't exist. $\{\varnothing\}$ has a single element, and that element is the empty set. It doesn't mean that there are no elements there, since sets can be elements of other sets as well.

In any case, the Russell paradox comes to show that not every "property" defines a set. In particular the set $\{x\mid x\notin x\}$ cannot exist. That's all that it shows. It says nothing about $\varnothing$ or otherwise.
Comment: I think I get it. So $\emptyset$ $\in$ { $\emptyset$}. There's an element in it, but it's nothing. It holds nothing. Where the empty set is nothing. I see now, and Russell's Paradox specifies only for sets with elements in it, not the empty set? (edit, I made the mistake of the $\emptyset$ $\subset$ {$\emptyset$})


Centos 5 - Using official repository to upgrade manually installed Puppet server

Question: I have Puppet server version 2.6.4 that was manually installed using RPM packages directly (instead of using Yum to fetch packages from a repository).
Now I want to upgrade it to the latest version (3.6), as safely as possible, by installing it using the Puppet Labs repository and Yum.
In case something goes wrong, how can I rollback the change? What should I do to backup the current setup before upgrading?
Comment: Which Linux distribution are you using?
Comment: I am using centos-5 64bit.
Answer: CentOS 5 has a nifty way to rollback your system. On update, it can rebuild packages with the configs that are present at that time.
Configure RPM to repackage packages that will be altered by adding the following line to /etc/rpm/macros:
 %_repackage_all_erasures 1

Create the file if not present.
Next, configure yum to handle this transaction-scenario, by adding the following line to /etc/yum.conf:
tsflags=repackage

When you decide you need to do a rollback, you can do so by using rpm --rollback. Examples:
rpm -Uhv --rollback '19:00'
rpm -Uhv --rollback '8 hours ago'
rpm -Uhv --rollback 'december 31'
rpm -Uhv --rollback 'yesterday'

Info originally taken from here.
Of course it will not hurt you, if you make a backup of your configurations, just in case ;)
Comment: seems useful, I am going to trying it.


Much different result when using numba

Question: I have here pure python code, except just making a NumPy array. My problem here is that the result I get is completely wrong when I use @jit, but when I remove it its good. Could anyone give me any tips on why this is?
@jit
def grayFun(image: np.array) -> np.array:

    gray_image = np.empty_like(image)

    for i in range(image.shape[0]):
        for j in range(image.shape[1]):
            gray = gray_image[i][j][0]*0.21 + gray_image[i][j][1]*0.72 + gray_image[i][j][2]*0.07
            gray_image[i][j] = (gray,gray,gray)

    gray_image = gray_image.astype("uint8")
    return gray_image

Comment: I'm saying you need to replace `gray = gray_image[i][j][0]*0.21 + ...` with `gray = image[i][j][0]*0.21 + ...`. as the code is currently written you're computing the value `gray` from the result of `np.empty_like`, not from `image`. This is what @jkr is pointing out
Comment: It's not good practice to use a variable with the same name as your function.  You do not need to do that as a loop; you can do that as a single line in numpy.
Comment: @TimRoberts Yes, I just changed the name for the post, forgot that I had gray in the code. will try to see how to do it as a single line. Than you
Comment: The problem with your code is that you make an array with `np.empty_like` and then you _use those values to compute the gray value_. But the contents of an array made with `np.empty_like` is garbage (it's arbitrary data and can be very large numbers).
Comment: yeah - can you check the code in the question you posted @ili? it doesn't work at all as it's currently written. I think you want to define `gray` using `image` not `gray_image`. I'm interested in taking a swing at the `@jit` issue (which is not addressed by Tim Roberts's answer) but your code doesn't work in python *or* numba right now.
Comment: @MichaelDelgado hello sir, not quite sure how I get the right result then. I can try to explain my thinking. The reason i use gray is to score some value i just put inside the gray_image, if i put it directly in gray_image i would get an error
Answer: This will return a grayscale image with your conversion formula.  USUALLY, you do not need to duplicate the columns; a grayscale image with shape (X,Y) can be used just like an image with shape (X,Y,3).
def gray(image):
   return image[:,:,0]*0.21+image[:,:,1]*0.72 + image[:,:,2]*0.07

Comment: Using matrix multiplication may be faster: `image @ [0.21, 0.72, 0.07]`
Comment: Because `numpy` works with the array as a whole.  That's what makes it such a huge win..  `image[:.:.0]` returns a 2D array sliced from your 3D array.  The `*0.21` operation then multiplies every element by that value, and the `+` operations do matrix addition to return a 2D array that is your grayscale value.
Comment: the description here is key - Tim is taking a shortcut by returning a 2D array rather than a 3D array because most image rendering tools will accept a 2D array and render it as grayscale, so there's no need to return a 3D array. Usually. But this doesn't address the thrust of your question, which I think either has to do with using an unallocated array to define gray, or is a typing or tuple issue.
Comment: sorry if this question is stupid but, with this one line of code, how will all the values in the grayscales array be changed? because it looks like it just returns the sum. The code you sent worked but I just do not understand it
Comment: This is why I did this                                                                                gray = gray_image[i][j][0]*0.21 + gray_image[i][j][1]*0.72 + gray_image[i][j][2]*0.07
gray_image[i][j] = (gray,gray,gray) Because i thought we need to change values by indexing
Answer: This should work just fine with numba. @TimRobert's answer is definitely fast, so you may just want to go with that implementation. But the biggest win is simply from vectorization. I'm sure others could find additional performance tweaks but at this point I think we've whittled down most of the runtime & issues:
# your implementation, but fixed so that `gray` is calculated from `image`
def grayFun(image: np.array) -> np.array:
    gray_image = np.empty_like(image)
    for i in range(image.shape[0]):
        for j in range(image.shape[1]):
            gray = image[i][j][0]*0.21 + image[i][j][1]*0.72 + image[i][j][2]*0.07
            gray_image[i][j] = (gray,gray,gray)
    gray_image = gray_image.astype("uint8")
    return gray_image

# a vectorized numpy version of your implementation
def grayQuick(image: np.array) -> np.array:
    return np.tile(
        np.expand_dims(
            (image[:, :, 0]*0.21 + image[:, :, 1]*0.72 + image[:, :, 2]*0.07), -1
        ),
        (1,1, 3)
    ).astype(np.uint8)

# a parallelized implementation in numba
@numba.jit
def gray_numba(image: np.array) -> np.array:
    out = np.empty_like(image)
    for i in numba.prange(image.shape[0]):
        for j in numba.prange(image.shape[1]):
            gray = np.uint8(image[i, j, 0]*0.21 + image[i, j, 1]*0.72 + image[i, j, 2]*0.07)
            out[i, j, :] = gray
    return out

# a 2D solution leveraging @TimRoberts's speedup
def gray_2D(image):
   return image[:,:,0]*0.21+image[:,:,1]*0.72 + image[:,:,2]*0.07

I loaded a reasonably large image:
In [69]: img = matplotlib.image.imread(os.path.expanduser(
    ...:     "~/Desktop/Screen Shot.png"
    ...: ))
    ...: image = (img[:, :, :3] * 256).astype('uint8')
    ...:

In [70]: image.shape
Out[70]: (1964, 3024, 3)

Now, running these three reveals a slight speedup from numba, while the fastest is the 2D solution:
In [71]: %%timeit
    ...: grey = grayFun(image)  # watch out - this takes ~21 minutes
    ...:
    ...:
2min 56s ± 1min 58s per loop (mean ± std. dev. of 7 runs, 1 loop each)

In [72]: %%timeit
    ...: grey_np = grayQuick(image)
    ...:
    ...:
556 ms ± 25.3 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

In [73]: %%timeit
    ...: grey = gray_numba(image)
    ...:
    ...:
246 ms ± 19.2 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

In [74]: %%timeit
    ...: grey = gray_2D(image)
    ...:
    ...:
117 ms ± 10.4 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)

Note that numba will be noticeably slower on the first iteration, so the vectorized numpy solutions will significantly outperform numba if you're only doing this once. But if you're going to call the function repeatedly within the same python session numba is a good option. You could of course use numba for the 2D result to get a further speedup - I'm not sure if this would outperform numpy though.
Comment: thank you sir, I have a question, the method Tim proposed. Is that not vectorized?
Comment: Tim's is definitely vectorized. I was calling the 3D method the vectorized version of your answer because it returns the same data but operates on the whole array at once. Tim's does the same thing, but is even faster because it doesn't return a 3D (tiled) copy of the array - just the 2D version.

Much different result when using numba


Linear algebra - Coordinate Systems

Question: I'm preparing for an upcoming Linear Algebra exam, and I have come across a question that goes as follows: Let U = {(s, s − t, 2s + 3t)}, where s and t are any real numbers. Find the coordinates of x = (3, 4, 3) relative to the basis B if x is in U . Sketch the set U in the xyz-coordinate system.
It seems that in order to solve this problem, I'll have to find the basis B first! how do I find that as well?
The teacher hae barely covered the coordinate systems and said she will less likely include anything from the section on the exam, but I still want to be safe. The book isn't of much help. It explains the topic but doesn't give any examples.
Another part of the question ask about proving that U is a subspace of R3, but I was able to figure that one out on my own. I'd appreciate if someone could show me how to go about solving the question above.
Comment: Once again: what is B, anyway?!
Answer: What is probably meant here for $B$ (you could also choose a different basis) is taking $s=1, t=0$ for the first basis vector and $t=1, s=0$ for the second one. Then you have $U=\{s(1,1,2)+t(0,-1,3)|s,t\in \mathbb{R}\}$ (This also gives an easy proof that this is a vector space). Now to present $x$ in this particular basis, you' have to solve the linear system of equation that is lurking in the exercise, namely $s=3, s-t=4, 2s+3t=3$.
Answer: This might be an answer, depending on how one interprets the phrase "basis $B$", which is undefined in the question as stated:
Note that $(s, s - t, 2s + 3t) = s(1, 1, 2) + t(0, -1, 3)$.  Taking $s = 1$, $t = 0$ shows that $(1, 1, 2) \in U$.  Likewise, taking $s = 0$, $t = 1$ shows $(0, -1, 3) \in U$ as well.  Incidentally, the vectors $(1, 1, 2)$ and $(0, -1, 3)$ are clearly linearly independent; to see this in detail, note that if  $(s, s - t, 2s + 3t) = s(1, 1, 2) + t(0, -1, 3) = (0,0,0)$, then we must obviously have $s = 0$, whence $s - t = -t = 0$ as well.  Assuming $B$ refers to the basis $(1, 1, 2)$, $(0, -1, 3)$ of $U$, it is easy to work out the values of $s$ and $t$ corresponding to $x$:  setting $(s, s - t, 2s + 3t) = (3, 4, 3)$, we see that we must have
$s = 3$ whence $t = -1$ follows from $s - t = 4$.  These check against $2s + 3t = 3$, as the reader may easily verify.  The desired coordinates for $x$ in the basis $B$ are thus $(3, -1)$.
Think that about covers it, if my assumption about $B$ is correct.
Can't provide a graphic, but one is easily constructed noting that the vectors $(1, 1, 2)$, $(0, -1, 3)$ span $U$ in $R^3$ (the "$xyz$" coordinate system).
Comment: No, since the two vectors spanning $U$ (see last paragraph) make up $B$.
Comment: thank you so much for such detailed answer. I found another part of the question at the back of the page asking to find a basis B of you. Think that'll result in a change to the answer you've provided?

Linear algebra - Coordinate Systems


Upgraded to 8.8.3 and now all of my modules say "No available releases found"

Question:
I just recently updated to 8.8.3 and for some reason, all of my modules now say "No available releases found". Also the one module I had that did report "No available releases found" (Video Embed for google drive), is now saying that that module is up to date. It is like they switched somehow when I updated. I might roll back but the site is currently working just fine. Any ideas?
Comment: Press 'Check manually' in '../reports/updates/update', this should solve the issue.
Answer: Clicking "Check manually" once on the Available Updates page will resolve this issue.
Please see https://www.drupal.org/project/drupal/issues/3120168 for more info.
Comment: The question is literally "Any ideas?" so I'm not sure why this doesn't answer it. It's an idea. Further, it resolves the issue that the poster was experiencing. I've experienced the exact issue and this has been tested - it's not a flippant suggestion.
Comment: This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - [From Review](/review/low-quality-posts/123819)
Comment: This answer provides a SOLUTION to the problem. However the code could be improved because the errors stem not from an actual problem but is instead a "Red Herring". The error message should probably provide some guidance?
Comment: Patching Drupal core is not the focus of a StackExchange answer. However, I've updated my answer with a link to the relevant issue.
Answer: It seems like the problem fixed itself. I am wondering if a cron job took care of it. I cleared cache and updated the DB, I just never thought to run cron.


Generating xml within twig template

Question: I am trying to generate a sitemap, which works just fine if I do it in a standard xml file. The problem I am facing is that I need to generate a xml sitemap within twig file.
So i have this file: sitemap.xml.twig with this content:
{{ <?xml version="1.0" encoding="UTF-8"?> }}

{{ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> }}
    {{ <url> }}
        {{ <loc>http://www.example.com/</loc> }}
        {{ <lastmod>2005-01-01</lastmod> }}
        {{ <changefreq>monthly</changefreq> }}
        {{ <priority>0.8</priority> }}
    {{ </url> }}
{{ </urlset> }}

But I get an error: "message":"Unexpected token
how can i make xml go into twig...?
sorry I am new to twig
Answer: {{ literal }} is the twig syntax for variable output, so you can't (and why should you?) use that to embrace your xml syntax. Simply write your xml as-is, and insert dynamic content by this twig syntax (and, of course, by {% literal %} for methods and language constructs.

Generating xml within twig template


Find last node in unknown amount of relationships

Question: I can find last node like this
MATCH p=(a)-->(b)-->(c)
WHERE a.name='Object' AND c:Prime
RETURN c

But how i would find last node if i don't know how many relationships -->()-->() between two nodes?
I am trying to find last Node name by the Lable name. Last node doesn't have any outgoing relationships.
Answer: This will find c in an arbitrarily long path where c has not outgoing relationships.
MATCH p=(a)-[*]->(c:Prime)
WHERE a.name='Object'
AND not( c-->() )
RETURN c

It is generally advisable to use relationship types (if possible / practical) in your query and put an upward boundary on the number of hops your match can make.  The example below follows only relationships of type CONNECTION in one direction to a maximum of 5 relationships.
MATCH p=(a)-[:CONNECTION*..5]->(c:Prime)
WHERE a.name='Object'
AND not( c-->() )
RETURN c

Comment: You are the best, Dave)


Framework JS para edições de imagem

Question: Bom dia,
Alguém conhece algum framework JS onde eu selecione alguma imagem e faça edições em cima dela?
Como por exemplo, adicionar algumas setas, marcações, etc.
Answer: Existem varias formas de se fazer isso, e você provavelmente não irá encontrar um que faça tudo o que você quer, da forma que quer, o que pode fazer, é pegar um que faça pouco e melhorar/ajustar para a sua necessidade.
Um que você pode usar é o StudioJS que é bem simples de utilizar.

Comment: Eu já vi esse, mas o que eu preciso não é algo muito complexo não.

Só preciso que carregue uma foto, dê para adicionar umas setas (para apontar algo) e que dê para escrever um comentário.

Não preciso de edição, recorte de imagem, nada disso.
Comment: Então você consegue fazer isso na unha e depois gerar uma imagem em cima de tudo o que fez. Vou fazer um exemplo simples.
Comment: Opa, eu agradeceria se você fizesse um exemplo =)

Framework JS para edições de imagem


Does the Central Limit Theorem only apply to the sample mean?

Question: My question: Is it only the probability distribution of the sample mean statistic of a sample which is normally distributed according to the Central Limit Theorem, or, will any statistic work like for example the sample variance?

My lack of clarity comes from reading the things below.
"A sampling distribution is the probability distribution of a given random-sample-based statistic." - Wikipedia.
"Central Limit Theorem (CLT) establishes that, in some situations, when independent random variables are added, their normalized sum tends toward a normal distribution even if the original variables themselves are not normally distributed." - Wikipedia.  (Makes it seem the CLT only works for the sampling distribution of the sample mean statistic.)

"Let $\{X_1, X_2,...,X_n\}$ be a random sequence of i.i.d. random variables drawn from a distribution with expected value $\mu$ and finite variance $\sigma^2$ - i.e. a random sample size $n$.
The CLT says that ${\bf \sqrt{n}(\frac{X_1+X_2+...+X_n}{n}-\mu)\xrightarrow{d}N(0,\sigma^2)}$ (Lindeberg-Lévy CLT)." Illustrated with the following picture:

But then when I search for "the CLT" on the internet I find pictures like these:

That talk about a sampling distribution becoming normal without any mention of that sampling distribution necessarily being that of a sample mean.
Comment: The picture isn't entirely correct as central limit theorem can fail as in the Cauchy distribution.
Comment: As far I recall the sample variance would have a chisquare distribution with $n-1$ degrees of freedom.  But the chisquare distribution is itself the sum of squared standard normal variables so will so will look normal under the CLT for large n.
Comment: My understanding is that the CLT is concerned with the sum of independent random variables and states that distribution is approximately normal for large n with some exceptions. The sample variance would have a chisquare distribution. The sum of two chisquar distributions is also chisquare but as you add more chisquare then the distribution of the sum will be chisquare but looking more normal.  I'm no expert and there will be more satisfactory answers both here and on cross validated.  I can't give more detail as I don't want to mislead.
Comment: Final comment if I may.  The CLT is concerned with summing random variables.  In this light it makes sense why the biniomal distribution tends to a normal for large n as the biniomal distribution can be view itself as the sum of Bernoulli distributions.  I guess I'm saying the distribution of sample means is just one application.
Comment: @Karl Okay, so my take away is: the sampling distribution of sample mean will be normal for sure under CLT, and, other sample statistics will in some cases be normal too but might need a larger sample size for the sampling distribution to approximate a normal distribution, but for some statistics the sampling distribution will approximate some other distribution like the Chi-square distribution. Correct?
Answer: Yes, the CLT only works for the sample mean.
The second diagram you have given is not clear, but the sampling distribution they refer to is the distribution of the sample mean.
If you work out the standard deviation of your sample and repeat it, the values will not be the same as those taken from a normal distribution. In particular, there will be a bias, which we correct for by dividing by $n-1$ instead of $n$ when we use the sample data to estimate the standard deviation of the population.
Comment: CLT also works for the sample sum...
Comment: @MSIS Look at this: https://stats.stackexchange.com/questions/45124/central-limit-theorem-for-sample-medians
Comment: The sample variance (relocated and rescaled in a CLT sense) converges in distribution to a normal distribution as a result of applying the CLT to $(X-\mu)^2$ (provided that the fourth moment of the underlying distribution is finite).  Its square-root also does, using the [delta method](https://en.wikipedia.org/wiki/Delta_method).
Comment: @ Great answer! I found that very many explanations fail completely to mention or clearly emphasise that the CLT only is applicable for one specific statistic - the sample mean.
Comment: @tomi Excellent example with the standard deviation!
Comment: Are there other results regarding the distribution of other ( sample)statistics?


Excel VBA macro failing to save workbook on coworker's computer, but fine on mine

Question: I'm encountering an issue trying to get some macros and VBA scripts working on a new coworker's computer.  I've been using the same code for years on my machine and several others without issue, but when my new analyst tries to run it, it throws an error stating it couldn't save the file.  He can manually save the file without issue, but running the script throws the error.  The really weird part is that it lists the file path, but replaces the filename with a seemingly random hex byte.
On another file, if he opens it, closes with or without saving, then I open the file and try to save it using a macro, it fails saying "cannot access file...".  If I copy and paste the file, open and run the macro again, it saves over the offending file no problem.
We've checked permissions and settings and haven't found anything that was different between the two systems.  We're both on VMs.  His hardware allowance is less than mine but otherwise they're both IT-managed and identical.  I'm at my wits' end...  Any advice on what may be the source of my grief would be helpful, even if not a solution.
Comment: Posting relevant code always helps with suggestions...
Answer: A couple of things I'd check before trying to step through debugger mode.

Coworker does not have write access to the directory (I think you said you checked already)
The new users' Trust Center Settings are not correct

File > Options > Trust Center > Trust Center Settings... > Macro Settings > Ensure the box is checked to trust the VBA model and that macros are not disabled

The new user does not have the same libraries referenced.

Alt + F11 > Tools > References... > Check if coworkers' libs match yours

Is he using a new/different version of Excel that you? A lot of older code got bojangled when Office 365 hit the scene.

After checking settings, I would ask the following:

What error is thrown when coworker attempts to run the macro?
When does the error get thrown? It could be that you have code that is attempting to edit the file (or has another file stuck in an edit) at the same time you're trying to save it.
I would see why the file name is getting corrupted. It sounds like coworkers' machine is looking to a bit of memory or memory address that is somehow getting forgotten. Like the code is referencing a variable that is out of scope.
User Access Control has been enabled on his VM that is somehow preventing him from saving the file correctly.
Your code does not properly Quit the Excel application, so its still running in the background on coworkers' machine. Have them open/close without saving a file and check Task Manager to see if Excel is still up to confirm


SSAS: change boolean to 'yes' or 'no'

Question: i'm new to Analysis Services. I have created a dimension on a boolean column. Now users want to have 'yes' and 'no' instead of 'true' and 'false' as result.
Thanks.
Answer: Create a calculated column in your DSV which provides the label you want.
<code>case when column = 0 then 'No' else 'Yes' end
</code>

SSAS: change boolean to 'yes' or 'no'


Harmonica for pop music chords

Question: Are there harmonica types out there that play the chords most frequently used in pop music—the 1, 4, 5 and 6 minor, or in the key if C, they chords of C, F, G and Am?
A standard blues harp harmonica can achieve elements of most of these, but not a full 3 notes chord for all of them.
I did find an enormous and expensive instrument chord harmonica, but i was surprised I couldn't find anything smaller or cheaper.
Answer: Let's take a standard diatonic harmonica in C. By blowing, 3 notes are produced. C E and G. That gives us the C chord. Drawing will produce the other notes in that key - namely D F A and B. By blocking one note,(B), a Dm chord can be produced, drawing on all will make a kind of G9, albeit with no root. That's about it for one harmonica. To a great extent why cross harpists use the harp a 4th above the key everyone else plays in.
Since the choice for playing is either blow or draw, and the notes have to be arranged to produce triads at minimum, the most chords any instrument could produce would be two, with an option of a dyad for a third. I have never seen a harmonica that was built in sections in order to blow or draw in different places producing the main diatonic chords, but have no doubt they could be produced - at a cost. Then, of course, they would have to be available, like blues harps, in several keys. Sales wouldn't be high, consequently their prices would.
Comment: If you just want to play chords, get 3 or 4, label them, and alternate between them. It may be the start of a comedy act, but it'll do the job!
Comment: Too bad (for me) but makes sense.  I guess I'm looking for an accordion.
Comment: I don't mind making people laugh : )

Harmonica for pop music chords


Position Alert dialog in Android Compose

Question: How to position alert dialog in Jetpack Compose to the bottom of the screen. Also, set transparent background.
Comment: Use a Box and place your content in the box and set the contentAlignment of the Box to bottomCenter.
Comment: You can't. It's not designed for that. Create your own custom dialog and position it at the bottom.
Comment: thank @Johann, any reference for custom dialogs?
Comment: Just create one like you do any composable. Nothing special here.
Comment: @Johann, may i know how to position compose to bottom of the screen, regardless of layouts or size
Answer: The solution that worked best for me, getting the idea from Vladimir's response, is to get a reference to the window from within the Dialog and set the desired gravity.
Dialog(
    onDismissRequest = [...],
    properties = [...],
) {
    val dialogWindowProvider = LocalView.current.parent as DialogWindowProvider
    dialogWindowProvider.window.setGravity(Gravity.BOTTOM)
    [...]
}

The cast shouldn't be an issue but, of course, it could be safe-casted to prevent unpleasant surprises.
Answer: Thanks, @alekseyHunter & @johann. I can able to achieve this with custom layout modifier.
Custom modifier to position alert dialog
enum class CustomDialogPosition {
    BOTTOM, TOP
}

fun Modifier.customDialogModifier(pos: CustomDialogPosition) = layout { measurable, constraints ->

    val placeable = measurable.measure(constraints);
    layout(constraints.maxWidth, constraints.maxHeight){
        when(pos) {
            CustomDialogPosition.BOTTOM -> {
                placeable.place(0, constraints.maxHeight - placeable.height, 10f)
            }
            CustomDialogPosition.TOP -> {
                placeable.place(0,0,10f)
            }
        }
    }
}

And in alert dialog implementation as
AlertDialog( ..., modifiers = Modifiers.customDialogModifier(CustomDialogPosition.BOTTOM))
{
    // block
})

Comment: This essentially creates a full-screen dialog, and it breaks `dismissOnClickOutside` because there is no 'outside'.
Comment: I just want to implement an alert like a bottom sheet.
Comment: Cool, that's what I was looking for when implementing custom tooltip modal dialogs. If you have content just in Dialog and want to use this customDialogModifier, then just wrap dialog content to the box and add this modifier.
Answer: Look so simple.
Box(Modifier.fillMaxSize()) {
            Column() {
                /* Content */
            }
             /* Box alert */
            Box(
                Modifier
                    .padding(horizontal = 32.dp, vertical = 16.dp)
                    .fillMaxWidth()
                    .background(Color.Transparent, RoundedCornerShape(8.dp))
                    .border(2.dp, Color.LightGray, RoundedCornerShape(8.dp))
                    .align(Alignment.BottomCenter)
            ) {
                Text(
                    text = "Alert",
                    modifier = Modifier
                        .padding(16.dp)
                        .fillMaxWidth(),
                    textAlign = TextAlign.Center,
                    color = Color.Black
                )
            }
        }

Answer: The solution provided by @Rameshbabu changes the position of the dialog as expected. However, as was mentioned in the comments the dialog consequently becomes "fullscreen" and it can't be dismissed by tapping on the overlay.
I found another tricky solution. You can copy the source code of androidx.compose.ui.window.AndroidDialog.kt which comes with "androidx.compose.ui". By doing this you'll be able to access the dialog's window directly and change its gravity and other parameters.
The simplest way would be to add some code in the androidx.compose.ui.window.DialogWrapper class. For example in the init function:
private class DialogWrapper(
    private var onDismissRequest: () -> Unit,
    ...
) : Dialog(ContextThemeWrapper(...){

...

init {
    val window = window ?: error("Dialog has no window")
    window.requestFeature(Window.FEATURE_NO_TITLE)
    window.setBackgroundDrawableResource(android.R.color.transparent)
    window.setGravity(Gravity.TOP) // This to be added

Hopefully, the Jetpack Compose team will make the compose Dialog more customizable in the future.
Comment: Sorry, what do you mean by copying the source code? Would this just entail cloning the git repo? and where and how would you add this to your own code


Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "application/octet-stream"

Question: I an getting this error Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "application/octet-stream". Strict MIME type checking is enforced for module scripts per HTML spec. on my browser console when trying to run my react/django application. Here's my index.html file;
INDEX.HTML
{% load static %}

<!DOCTYPE html>

    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/vite.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>BlogHost</title>

I tried using react-django-templatetags.
{% load static %}

<!DOCTYPE html>

    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/vite.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>BlogHost</title>

    {% react_render component='main.jsx' %}

Yet, I still get a blank page and an error in my console.
Comment: have you tried running `python manage.py collectstatic`, and are you sure you have correctly setup all your STATIC file settings?
Comment: Thanks, I already resolved the problem. I was using react vite with .jsx files while most of the tutorials I was following were all using the traditional react and .js files.
Answer: I figured out a solution for it. According to vite documentation for backend integration

<!DOCTYPE html>

    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/vite.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>BlogHost</title>


How do I utilize the functionality of a multi-monitor setup without physical hardware?

Question: I've spent the past few days researching whether its possible to use the Windows API (Preferably Windows 8) to develop an application that can utilize the features in a multiple physical monitor configuration, from a single physical monitor. As far as I can tell you simply cannot do it, or its just not documented at all. Below I will present my problem and the research I've under-taken in the hopes that someone can provide some knowledge I have not yet encountered.

The Problem
In Windows 7+ multi-monitor configurations are able to utilize some cool desktop features such as being able to use a single large desktop that spans multiple monitors, seamless application dragging between them, ability to toggle whether to have the taskbar span or not, etc.
The Virtual Screen (MSDN link).

I would like to gain access to this API and allow my application to use it to allow the user to effectively have multiple virtual desktops from a single physical monitor. Simple as that.

The Solution
Here I will present a number of proposed solutions I have found, and why they will not work (As far as I can tell).
1. Use the Window Station & Desktop API to create entirely new desktops and flip between them.
"A window station is a securable object that is associated with a process, and contains a clipboard, an atom table, and one or more desktop objects.
A desktop is a securable object contained within a window station. A desktop has a logical display surface and contains user interface objects such as windows, menus, and hooks."
MSDN Link.
This is a really clean and simple way to effectively create multiple desktops in windows that allows the user to switch between on a single monitor. However it has the following large caveat:
"Windows doesn't provide a way to move a window from one desktop object to another, and because a separate Explorer process must run on each desktop to provide a taskbar and start menu, most tray applications are only visible on the first desktop." Sysinternals on TechNET.
2. Attempt to create a fake display driver to force Windows to believe it has more than one monitor.
This appears to have been a valid option for a couple of existing similar applications such as ZoneScreen. However in Windows 7 it became difficult to install the unsigned driver and in Windows 8 it appears to be flat out impossible.
3. Fake it by attempting to track applications and force them to hide between user defined monitor groups.
Both commercial and free applications such as DisplayFusion and Finestra Virtual Desktops appear to use a highly convoluted and complex system of tracking launched applications and attempting to hide and unhide them as the user switches between virtual monitors.
This is the most workable solution as it largely meets all the requirements. But its a hack - Some applications don't really work with it and there are many corner cases where it will fail.

What am I missing here? Is any of my research incorrect thus far? Are there areas of the API that I haven't yet plumbed?
Comment: Small note to the Problem: Multi-monitor support exists long time ago before Windows 7. Also what do you mean in the 'setup' ?
Comment: Solution 4: look at this "old" tool from sysinternals http://technet.microsoft.com/en-us/sysinternals/cc817881.aspx
Comment: @ColdCat - Yes I have that already linked in my post. See solution 1.
Comment: ouch don't phone and write sorry. The pb with multiple monitors is that we miss some API I agree. I used to do some tricky windows moving by calculating coordinates of each windows and match to monitors. I was never pleased with any solutions.
Answer:
develop an application that can utilize the features in a multiple physical monitor configuration, from a single physical monitor

The Windows API ties each desktop to a explorer process and the taskbar,notifications etc are managed on a per-desktop basis. It is possible to create new virtual desktops using this API by creating a new desktop object. However if you are trying to create something that is the equivalent of workspaces in linux distros, then you are out of luck. The desktop object manages the applications launched under a process tree and moving applications between these desktop objects etc is not possible due to the way windows explorer handles work.

The Solution
Here I will present a number of proposed solutions I have found, and why they will not work (As far as I can tell).

The only way to achieve something close to workspaces is to fake it -
each workspace and its process have to be show in the taskbar/notification area by slots. But this is very tough to achieve and games, fullscreen apps etc are bound to break. I am not aware of how this will work out in Win8 either. So yes - workspaces in Windows are going to suck from the get-go.
Comment: Well the hope is that once I make a virtual driver that just drops the renders to null I can have the primary physical monitor switch between the various views as a user would if they wanted to swap the shared desktop sides. Unfortunately I'm struggling with my research into virtual drivers. I simply cannot find many resources for taking this path. Your final question is one I've been weighing up since I started this post - If I can't find an elegant solution I'm going to have to walk away from this sadly.
Comment: Virtual display drivers are not a complete solution either. For instance, even after you write one, you will have to manage to get these to show up in a single screen and switch between them. This might not make for a great UX as you wont have the bells and whistles other solutions provide. The memory consumed to launch each desktop and keep it running in the background will be significant, IMHO. The advantage however would be that you will have a true workspace/application switching experience. Question is - is it worth the trouble?
Comment: Sadly those are the conclusions I had already drawn in my original post.
Comment: So you are trying to achieve full fledged workspaces huh - Win 8 is sure to break, even is Win7 does ok. Is there any particular reason the existing hacks/programs are insufficient? I have played around with the Windows API and it is capable of doing a lot of things except what you are looking for.
Comment: More or less yes. I could do the process hiding 'trick' but as you say will not work in all cases and is bound to break. My last remaining item of investigation is whether I can write a virtual display driver.


How do i take a specific node and turn it into a block

Question: I created a content type of which there is only one node of, and i want to add to sidebar left. How can that be done? i would prefer not have to use a module to do this., thanks
Comment: i just tried this, did 'Add Block' and added some PHP that echoed out what i wanted but it printed the PHP. surely there's a way to do this.
Comment: i'm just going to hardwire it to the page.tpl.php
Answer: I would suggest using views for this.

Create a "Content" view and choose your content type in the "Show" dropdown
Uncheck "Create a page" and check "Create a block"
Choose "Unformatted list" and "Full posts"
Limit the block to 1 "items per page"
Click the Continue & Edit button
Add a contextual filter for Content: NID
Provide a default argument of Fixed value and enter the Node ID of the node you want to display within the block

Optionally, you can choose to create a fields based view instead of full posts which would allow you a little more control over the layout of the nodes content within the block.
If you are set on not using ANY modules to do this then you'll want to look into https://api.drupal.org/api/drupal/modules%21block%21block.api.php/function/hook_block_view_MODULE_DELTA_alter/7 which would allow you to override a blocks output in your themes template.php.
<code>/**
 * Implements hook_block_view_MODULE_DELTA_alter().
 */
function YOURTHEME_block_view_block_BLOCKDELTA_alter(&$data, $block) {
  $data['content'] = drupal_render(node_view(node_load($nid)));
}
</code>
Answer: Use Node Block. I know it's a module and you didn't want to use one, but it's lightweight and will probably do exactly what you want.


Multiclass classification when class distribution is known

Question: What is an example of an algorithm that, when i have a known distribution across discrete groups and I have some sort of model score that a person is in each group, assigns persons to groups such that the sum of the group scores are maximized, or some other objective criteria is met and we honor the known class distribution.
I have some code that assigns classified units to the group associated with the max score for the unit one by one until a group is "full". It starts with the highest scoring units, which creates an issue, as groups with a higher class probability in the predictions than the known end up being dominated by predictive units that generate a lot of data (e.g. long documents).
Has anyone else run into this or considered this before in classification problems?
Comment: Sanity check: in your question, class and group are equivalent, right? Also, by class distribution, you simply mean that you know what proportion of the persons should be in each group/class. If so, this has a Bayesian ring to it...
Comment: right, that is exactly what i mean
Answer: The completely other way to look at is as a situation where marginal category probabilities are known but the classification mechanism needs to be informed by them, e.g. when the training regime would not naturally reflect these probabilities and something needs to be reweighted, e.g. in a rare events design.
We'd then have two cases:

the known category probabilities refer to a larger population.  Then some form of case weighting are needed to prevent bias.  Assigned category marginals need not then exactly respect these population margins, but will be reasonably close to them if a random sample is classified.  King and Zheng, 2001 is an example.
the known category probabilities are for the sample (i.e. the sample is the population).  In this case you would seem to have what the computer scientists call a packing or knapsack problem.  They tend to be hard because assigned category marginals must exactly respect the known ones.  (Or perhaps there is a Lagrange approach available - I'm not familiar with this sort of thing).
Answer: Specifically, it sounds like an N-armed bandit problem.  And you have a score-based allocation strategy in your code.  It appears to differ a bit from the classic set up because you claim to know rather have to estimate 'arm' (class) probabilities, but I can't quite tell from the description.
As Ludo suggests, this sounds near enough to classic OR territory.  The machine learning literature is also interested in this sort of problem, particularly those into adversarial or worst case online learning procedures.
I'd guess your 'issue' stems from the discrepancy between your assumed and the actual scoring function / class distribution.  Or perhaps from your greedy allocation strategy.  Both might be clarified by being a bit clearer about what is estimated, what is known, and what the allocation code is supposed to be doing.
In any case, this is guesswork in the absence of an example.  Even a toy one would be helpful.
Comment: This has been very helpful, did you receive the bounty?
Answer: Isn't this a problem similar to the assignment problems dealt with in operations research. You want to allocate people to groups such that (a) the sum of group scores -- according to allocation -- is maximized, but (b) while staying within the capacity limits of the groups.


Finding the shortest distance between a point and a coplex surface

Question: I have a surface which is $z=ax+bx^2+cxy+d$, where $a,b,c$ are coefficients and $d$ is the constant. so an arbitrary point would be $(x, y, ax + bx^2 + cxy+ d)$.
there are a set of points that are not in this surface and I want to calculate the shortest distance to them, could anyone tell me what is the best way to do it?
Or if you could solve this for a point, let say $(5,4,3)$. I would really appreciate.
Comment: You can write in maths mode by surrounding your equations with dollar signs. I have done it for you this time; please check that I did not distort the meaning of your question.
Answer: Note that your surface $S$ can be represented as the graph of a function, that is,
$$
S=\{(x,y,F(x,y))\ |\ x,y\in\mathbb R\},
$$
where
$$
F:\mathbb R^2\to\mathbb R,\ (x,y)\mapsto ax+bx^2+cxy+d.
$$
The distance of a given point $(x_0,y_0,z_0)\in\mathbb R^3$ to S is the length of the normal $N$ fixed in a point $(x,y,z=F(x,y))\in S$ and pointing to $(x_0,y_0,z_0)$.
Now, every normal $N$ of $S$ is given by
$$
N=(F_x(x,y),F_y(x,y),-1),
$$
which is in your case
$$
N(x,y)=(a+2bx+cy,xc,-1).
$$
Then our desired $n$ is of the form $n=\lambda N(x,y)$ for suitable $x,y,\lambda\in\mathbb R$. So, all you have to do is to solve the equation system
$$
(x,y,F(x,y))+\lambda N(x,y)=(x_0,y_0,z_0)
$$
for $x$, $y$ and $\lambda$ to get $n$. Your desired distance is then $||n||_2$.