Q: Error Create Datasource JBOSS 7.1.1 FINAL Error when deploying the server I get this error in jboss 7.1.1 final
log Error:
09:44:28,645 INFORMACIÓN [org.jboss.modules] JBoss Modules version 1.1.1.GA
09:44:28,865 INFO  [org.jboss.msc] JBoss MSC version 1.0.2.GA
09:44:28,935 INFO  [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting
09:44:29,924 INFO  [org.xnio] XNIO Version 3.0.3.GA
09:44:29,924 INFO  [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)
09:44:29,944 INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA
09:44:29,954 INFO  [org.jboss.remoting] JBoss Remoting version 3.2.3.GA
09:44:29,975 INFO  [org.jboss.as.configadmin] JBAS016200: Activating ConfigAdmin Subsystem
09:44:29,988 INFO  [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
09:44:30,005 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 44) JBAS013101: Activating Security Subsystem
09:44:30,017 INFO  [org.jboss.as.security] (MSC service thread 1-2) JBAS013100: Current PicketBox version=4.0.7.Final
09:44:30,067 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 38) JBAS011800: Activating Naming Subsystem
09:44:30,097 INFO  [org.jboss.as.osgi] (ServerService Thread Pool -- 39) JBAS011940: Activating OSGi Subsystem
09:44:30,097 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 31) JBAS010280: Activating Infinispan subsystem.
09:44:30,109 INFO  [org.jboss.as.naming] (MSC service thread 1-4) JBAS011802: Starting Naming Service
09:44:30,125 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
09:44:30,179 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-3) JBAS015400: Bound mail session [java:jboss/mail/Default]
09:44:30,241 INFO  [org.jboss.as.connector] (MSC service thread 1-5) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final)
09:44:30,341 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-5) JBoss Web Services - Stack CXF Server 4.0.2.GA
09:44:30,350 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
09:44:30,386 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
09:44:30,390 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.fabric.jdbc.FabricMySQLDriver (version 5.1)
09:44:30,393 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 27) JBAS014612: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("jdbc-driver" => "mysql")
]): org.jboss.msc.service.DuplicateServiceException: Service jboss.jdbc-driver.mysql is already registered
    at org.jboss.msc.service.ServiceRegistrationImpl.setInstance(ServiceRegistrationImpl.java:154) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl.startInstallation(ServiceControllerImpl.java:227) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceContainerImpl.install(ServiceContainerImpl.java:560) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:201) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2228) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceBuilderImpl.install(ServiceBuilderImpl.java:307) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.as.controller.OperationContextImpl$ContextServiceBuilder.install(OperationContextImpl.java:955) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.connector.subsystems.datasources.JdbcDriverAdd.startDriverServices(JdbcDriverAdd.java:164) [jboss-as-connector-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.connector.subsystems.datasources.JdbcDriverAdd.performRuntime(JdbcDriverAdd.java:128) [jboss-as-connector-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.controller.AbstractAddStepHandler$1.execute(AbstractAddStepHandler.java:50) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:385) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.controller.AbstractOperationContext.doCompleteStep(AbstractOperationContext.java:272) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.controller.AbstractOperationContext.completeStep(AbstractOperationContext.java:200) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.connector.subsystems.datasources.DataSourceEnable$1.execute(DataSourceEnable.java:91) [jboss-as-connector-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:385) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.controller.AbstractOperationContext.doCompleteStep(AbstractOperationContext.java:272) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.controller.AbstractOperationContext.completeStep(AbstractOperationContext.java:200) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.connector.subsystems.datasources.DataSourceEnable$1.execute(DataSourceEnable.java:91) [jboss-as-connector-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:385) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.controller.AbstractOperationContext.doCompleteStep(AbstractOperationContext.java:272) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.controller.AbstractOperationContext.completeStep(AbstractOperationContext.java:200) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.controller.ParallelBootOperationStepHandler$ParallelBootTask.run(ParallelBootOperationStepHandler.java:311) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_72]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_72]
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_72]
    at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.0.0.GA.jar:2.0.0.GA]

09:44:30,836 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-4) Arrancando Coyote HTTP/1.1 en puerto http-localhost-127.0.0.1-8080

jboss-as-7.1.1.Final\standalone\configuration\standalone.xml
<?xml version='1.0' encoding='UTF-8'?>

<server xmlns="urn:jboss:domain:1.2">
    <extensions>
        <extension module="org.jboss.as.clustering.infinispan"/>
        <extension module="org.jboss.as.configadmin"/>
        <extension module="org.jboss.as.connector"/>
        <extension module="org.jboss.as.deployment-scanner"/>
        <extension module="org.jboss.as.ee"/>
        <extension module="org.jboss.as.ejb3"/>
        <extension module="org.jboss.as.jaxrs"/>
        <extension module="org.jboss.as.jdr"/>
        <extension module="org.jboss.as.jmx"/>
        <extension module="org.jboss.as.jpa"/>
        <extension module="org.jboss.as.logging"/>
        <extension module="org.jboss.as.mail"/>
        <extension module="org.jboss.as.naming"/>
        <extension module="org.jboss.as.osgi"/>
        <extension module="org.jboss.as.pojo"/>
        <extension module="org.jboss.as.remoting"/>
        <extension module="org.jboss.as.sar"/>
        <extension module="org.jboss.as.security"/>
        <extension module="org.jboss.as.threads"/>
        <extension module="org.jboss.as.transactions"/>
        <extension module="org.jboss.as.web"/>
        <extension module="org.jboss.as.webservices"/>
        <extension module="org.jboss.as.weld"/>
    </extensions>
    <management>
        <security-realms>
            <security-realm name="ManagementRealm">
                <authentication>
                    <properties path="mgmt-users.properties" relative-to="jboss.server.config.dir"/>
                </authentication>
            </security-realm>
            <security-realm name="ApplicationRealm">
                <authentication>
                    <properties path="application-users.properties" relative-to="jboss.server.config.dir"/>
                </authentication>
            </security-realm>
        </security-realms>
        <management-interfaces>
            <native-interface security-realm="ManagementRealm">
                <socket-binding native="management-native"/>
            </native-interface>
            <http-interface security-realm="ManagementRealm">
                <socket-binding http="management-http"/>
            </http-interface>
        </management-interfaces>
    </management>
    <profile>
        <subsystem xmlns="urn:jboss:domain:logging:1.1">
            <console-handler name="CONSOLE">
                <level name="INFO"/>
                <formatter>
                    <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
                </formatter>
            </console-handler>
            <periodic-rotating-file-handler name="FILE">
                <formatter>
                    <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
                </formatter>
                <file relative-to="jboss.server.log.dir" path="server.log"/>
                <suffix value=".yyyy-MM-dd"/>
                <append value="true"/>
            </periodic-rotating-file-handler>
            <logger category="com.arjuna">
                <level name="WARN"/>
            </logger>
            <logger category="org.apache.tomcat.util.modeler">
                <level name="WARN"/>
            </logger>
            <logger category="sun.rmi">
                <level name="WARN"/>
            </logger>
            <logger category="jacorb">
                <level name="WARN"/>
            </logger>
            <logger category="jacorb.config">
                <level name="ERROR"/>
            </logger>
            <root-logger>
                <level name="INFO"/>
                <handlers>
                    <handler name="CONSOLE"/>
                    <handler name="FILE"/>
                </handlers>
            </root-logger>
        </subsystem>
        <subsystem xmlns="urn:jboss:domain:configadmin:1.0"/>
        <subsystem xmlns="urn:jboss:domain:datasources:1.0">
            <datasources>
                <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
                    <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
                    <driver>h2</driver>
                    <security>
                        <user-name>sa</user-name>
                        <password>sa</password>
                    </security>
                </datasource>
                <datasource jndi-name="java:jboss/datasources/EvelingDs" pool-name="EvelingDs" enabled="true" use-java-context="true">
                    <connection-url>jdbc:mysql://localhost:3306/proyectoEveling</connection-url>
                    <driver>mysql</driver>
                    <security>
                        <user-name>infra</user-name>
                        <password>infra_pass</password>
                    </security>
                </datasource>
                <drivers>
                    <driver name="h2" module="com.h2database.h2">
                        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                    </driver>
                      <driver name="mysql" module="com.mysql"/>
                </drivers>
            </datasources>
        </subsystem>
        <subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">
            <deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000"/>
        </subsystem>
        <subsystem xmlns="urn:jboss:domain:ee:1.0"/>
        <subsystem xmlns="urn:jboss:domain:ejb3:1.2">
            <session-bean>
                <stateless>
                    <bean-instance-pool-ref pool-name="slsb-strict-max-pool"/>
                </stateless>
                <stateful default-access-timeout="5000" cache-ref="simple"/>
                <singleton default-access-timeout="5000"/>
            </session-bean>
            <pools>
                <bean-instance-pools>
                    <strict-max-pool name="slsb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>
                    <strict-max-pool name="mdb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>
                </bean-instance-pools>
            </pools>
            <caches>
                <cache name="simple" aliases="NoPassivationCache"/>
                <cache name="passivating" passivation-store-ref="file" aliases="SimpleStatefulCache"/>
            </caches>
            <passivation-stores>
                <file-passivation-store name="file"/>
            </passivation-stores>
            <async thread-pool-name="default"/>
            <timer-service thread-pool-name="default">
                <data-store path="timer-service-data" relative-to="jboss.server.data.dir"/>
            </timer-service>
            <remote connector-ref="remoting-connector" thread-pool-name="default"/>
            <thread-pools>
                <thread-pool name="default">
                    <max-threads count="10"/>
                    <keepalive-time time="100" unit="milliseconds"/>
                </thread-pool>
            </thread-pools>
        </subsystem>
        <subsystem xmlns="urn:jboss:domain:infinispan:1.2" default-cache-container="hibernate">
            <cache-container name="hibernate" default-cache="local-query">
                <local-cache name="entity">
                    <transaction mode="NON_XA"/>
                    <eviction strategy="LRU" max-entries="10000"/>
                    <expiration max-idle="100000"/>
                </local-cache>
                <local-cache name="local-query">
                    <transaction mode="NONE"/>
                    <eviction strategy="LRU" max-entries="10000"/>
                    <expiration max-idle="100000"/>
                </local-cache>
                <local-cache name="timestamps">
                    <transaction mode="NONE"/>
                    <eviction strategy="NONE"/>
                </local-cache>
            </cache-container>
        </subsystem>
        <subsystem xmlns="urn:jboss:domain:jaxrs:1.0"/>
        <subsystem xmlns="urn:jboss:domain:jca:1.1">
            <archive-validation enabled="true" fail-on-error="true" fail-on-warn="false"/>
            <bean-validation enabled="true"/>
            <default-workmanager>
                <short-running-threads>
                    <core-threads count="50"/>
                    <queue-length count="50"/>
                    <max-threads count="50"/>
                    <keepalive-time time="10" unit="seconds"/>
                </short-running-threads>
                <long-running-threads>
                    <core-threads count="50"/>
                    <queue-length count="50"/>
                    <max-threads count="50"/>
                    <keepalive-time time="10" unit="seconds"/>
                </long-running-threads>
            </default-workmanager>
            <cached-connection-manager/>
        </subsystem>
        <subsystem xmlns="urn:jboss:domain:jdr:1.0"/>
        <subsystem xmlns="urn:jboss:domain:jmx:1.1">
            <show-model value="true"/>
            <remoting-connector/>
        </subsystem>
        <subsystem xmlns="urn:jboss:domain:jpa:1.0">
            <jpa default-datasource=""/>
        </subsystem>
        <subsystem xmlns="urn:jboss:domain:mail:1.0">
            <mail-session jndi-name="java:jboss/mail/Default">
                <smtp-server outbound-socket-binding-ref="mail-smtp"/>
            </mail-session>
        </subsystem>
        <subsystem xmlns="urn:jboss:domain:naming:1.1"/>
        <subsystem xmlns="urn:jboss:domain:osgi:1.2" activation="lazy">
            <properties>
                <!-- Specifies the beginning start level of the framework -->
                <property name="org.osgi.framework.startlevel.beginning">1</property>
            </properties>
            <capabilities>
                <!-- modules registered with the OSGi layer on startup -->
                <capability name="javax.servlet.api:v25"/>
                <capability name="javax.transaction.api"/>
                <!-- bundles started in startlevel 1 -->
                <capability name="org.apache.felix.log" startlevel="1"/>
                <capability name="org.jboss.osgi.logging" startlevel="1"/>
                <capability name="org.apache.felix.configadmin" startlevel="1"/>
                <capability name="org.jboss.as.osgi.configadmin" startlevel="1"/>
            </capabilities>
        </subsystem>
        <subsystem xmlns="urn:jboss:domain:pojo:1.0"/>
        <subsystem xmlns="urn:jboss:domain:remoting:1.1">
            <connector name="remoting-connector" socket-binding="remoting" security-realm="ApplicationRealm"/>
        </subsystem>
        <subsystem xmlns="urn:jboss:domain:resource-adapters:1.0"/>
        <subsystem xmlns="urn:jboss:domain:sar:1.0"/>
        <subsystem xmlns="urn:jboss:domain:security:1.1">
            <security-domains>
                <security-domain name="other" cache-type="default">
                    <authentication>
                        <login-module code="Remoting" flag="optional">
                            <module-option name="password-stacking" value="useFirstPass"/>
                        </login-module>
                        <login-module code="RealmUsersRoles" flag="required">
                            <module-option name="usersProperties" value="${jboss.server.config.dir}/application-users.properties"/>
                            <module-option name="rolesProperties" value="${jboss.server.config.dir}/application-roles.properties"/>
                            <module-option name="realm" value="ApplicationRealm"/>
                            <module-option name="password-stacking" value="useFirstPass"/>
                        </login-module>
                    </authentication>
                </security-domain>
                <security-domain name="jboss-web-policy" cache-type="default">
                    <authorization>
                        <policy-module code="Delegating" flag="required"/>
                    </authorization>
                </security-domain>
                <security-domain name="jboss-ejb-policy" cache-type="default">
                    <authorization>
                        <policy-module code="Delegating" flag="required"/>
                    </authorization>
                </security-domain>
            </security-domains>
        </subsystem>
        <subsystem xmlns="urn:jboss:domain:threads:1.1"/>
        <subsystem xmlns="urn:jboss:domain:transactions:1.1">
            <core-environment>
                <process-id>
                    <uuid/>
                </process-id>
            </core-environment>
            <recovery-environment socket-binding="txn-recovery-environment" status-socket-binding="txn-status-manager"/>
            <coordinator-environment default-timeout="300"/>
        </subsystem>
        <subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">
            <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
            <virtual-server name="default-host" enable-welcome-root="true">
                <alias name="localhost"/>
                <alias name="example.com"/>
            </virtual-server>
        </subsystem>
        <subsystem xmlns="urn:jboss:domain:webservices:1.1">
            <modify-wsdl-address>true</modify-wsdl-address>
            <wsdl-host>${jboss.bind.address:127.0.0.1}</wsdl-host>
            <endpoint-config name="Standard-Endpoint-Config"/>
            <endpoint-config name="Recording-Endpoint-Config">
                <pre-handler-chain name="recording-handlers" protocol-bindings="##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM">
                    <handler name="RecordingHandler" class="org.jboss.ws.common.invocation.RecordingServerHandler"/>
                </pre-handler-chain>
            </endpoint-config>
        </subsystem>
        <subsystem xmlns="urn:jboss:domain:weld:1.0"/>
    </profile>
    <interfaces>
        <interface name="management">
            <inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
        </interface>
        <interface name="public">
            <inet-address value="${jboss.bind.address:127.0.0.1}"/>
        </interface>
        <!-- TODO - only show this if the jacorb subsystem is added  -->
        <interface name="unsecure">
            <!--
              ~  Used for IIOP sockets in the standard configuration.
              ~                  To secure JacORB you need to setup SSL
              -->
            <inet-address value="${jboss.bind.address.unsecure:127.0.0.1}"/>
        </interface>
    </interfaces>
    <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
        <socket-binding name="management-native" interface="management" port="${jboss.management.native.port:9999}"/>
        <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
        <socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9443}"/>
        <socket-binding name="ajp" port="8009"/>
        <socket-binding name="http" port="8080"/>
        <socket-binding name="https" port="8443"/>
        <socket-binding name="osgi-http" interface="management" port="8090"/>
        <socket-binding name="remoting" port="4447"/>
        <socket-binding name="txn-recovery-environment" port="4712"/>
        <socket-binding name="txn-status-manager" port="4713"/>
        <outbound-socket-binding name="mail-smtp">
            <remote-destination host="localhost" port="25"/>
        </outbound-socket-binding>
    </socket-binding-group>
</server>

jboss-as-7.1.1.Final\modules\com\mysql\module.xml
<module xmlns="urn:jboss:module:1.1" name="com.mysql">

    <resources>
        <resource-root path="mysql-connector-java-5.1.34-bin.jar"/>
        <!-- Insert resources here -->
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
        <module name="javax.servlet.api" optional="true"/>
    </dependencies>
</module>

Thank you for the help you can...

A: Although this one looks old for the benefit of others who happen to stumble upon the same one
please add

<driver-class>com.mysql.jdbc.Driver</driver-class>  to your driver definition in standalone.xml

  complete entry

<drivers>
 <driver name="com.mysql" module="com.mysql">
 <driver-class>com.mysql.jdbc.Driver</driver-class>
 <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
 </driver>
</drivers>


Q: unable to use R's future package for lasso regression with glmnet I recently discovered R's future package and have already successfully used it.
However I am unable to use this package together with predictions for lasso regressions.
In the following toy example I first create some toy data, then fit a lasso regression and finally I make a prediction for new data.
I do this procedure twice: once without the future package and then with the future package:
library(tidyverse)
library(glmnet)

set.seed(1)
a <- tibble(id = rep(letters[1:2], each = 100), x1 = rnorm(200), x2 = rnorm(200),
            y = 1 + 2*x2 + rnorm(200))

newdata <- as.matrix(data.frame(x1 = rnorm(200), x2 = rnorm(200)))

pred_func <- function(z) predict(z, newx = newdata)[,1]

b1 <- a %>%
  group_by(id) %>%
  nest(.key = data) %>%
  mutate(lasso = map(data, function(z){glmnet(x = as.matrix(select(z, x1, x2)), y = z$y,
                                                 intercept = T, alpha = 1)})) %>%
  mutate(myprediction = map(lasso, pred_func))

This works just fine. Now with the future package:
library(future)

plan(multiprocess)
b2 <- a %>%
  group_by(id) %>%
  nest(.key = data) %>%
  mutate(lasso = map(data, function(z){glmnet(x = as.matrix(select(z, x1, x2)), y = z$y,
                                              intercept = T, alpha = 1)})) %>%
  mutate(myprediction_future = map(lasso, ~future(pred_func(.x)))) %>%
  mutate(myprediction = values(myprediction_future))

This terminates with an error (which is in german). Basically it tells me that it cannot use predict for an object of class elnet, glmnet.
I first thought that maybe there is a different predict function in the future package but this does not seem to be the case.
Since I do not really understand what happens behind the curtains of the future functions I feel stuck with this one.
EDIT:
here is the error message in english:
Error in mutate_impl(.data, dots) :
Evaluation error: no applicable method for 'predict' applied to
an object of class "c('elnet', 'glmnet')".

A: There's a predict.glmnet() in glmnet package.
Just define a new function.
pred_func2 <- function(z) predict.glmnet(z, newx = newdata)[,1]

And run.
plan(multiprocess)
b2 <- a %>%
  group_by(id) %>%
  nest(.key=data) %>%
  mutate(lasso=map(data,
                     function(z) {
                       glmnet(x=as.matrix(select(z, x1, x2)), y=z$y,
                              intercept=TRUE, alpha=1)
                       })) %>%
  mutate(myprediction_future=map(lasso, ~future(pred_func2(.x)))) %>%
  mutate(myprediction=values(myprediction_future))

Yielding
> b2
# A tibble: 2 x 5
  id    data               lasso       myprediction_future      myprediction
  <chr> <list>             <list>      <list>                   <list>
1 a     <tibble [100 x 3]> <S3: elnet> <S3: MultisessionFuture> <dbl [200]>
2 b     <tibble [100 x 3]> <S3: elnet> <S3: MultisessionFuture> <dbl [200]>


Q: The proof of chain rule using a junk term I am looking into understanding the proofs for the Chain Rule. I came across this video by Dr. Peyam on youtube.
When proving the chain rule he states that:
$$\frac{g(y+\widetilde{h})-g(y)}{\widetilde{h}} = g'(y) + \sigma(\widetilde{h})$$
Where he refers to $\sigma$ as a junk term. And later he says that $\sigma \rightarrow 0$ as $\widetilde{h} \rightarrow 0$. Why can one use this alternative description of the derivative and why does the junk term become $0$?
Thank you very much.

A: This is a common and useful way to handle proofs involving derivatives. We know that
$$
\lim_{h\to 0}\frac{f(x+h)-f(x)}{h} = f'(x)
$$
If we define a funciton $\sigma(h)$ (I have seen $\varepsilon(h)$ used as function name for the same thing) as
$$
\sigma(h) = \frac{f(x+h)-f(x)}{h} - f'(x)
$$
then
$$
\lim_{h\to 0}\sigma(h) = \lim_{h\to 0}\frac{f(x+h)-f(x)}{h} - f'(x) = 0
$$
which proves why the "junk term" goes to zero.
Put in words, the "junk term" is the difference between the derivative and the approximation given by the difference quotiont. As $h$ gets smaller, the approximation gets better.
Bonus: It works the other way around too! If
$$
\frac{f(x+h)-f(x)}{h} = g(x) + \sigma(h)
$$
and $\lim_{h\to0}\sigma(h)=0$, then $g(x)=f'(x)$, which is equally useful for making proofs.
EDIT. By the way, $\sigma$ is really a function of both $x$ and $h$, but we tend to work with a fixed $x$ (or $y$ in your case), so we don't write $\sigma(x,h)$.


Q: PHP ftp_connect does nothing I've configured a couple of php codes that connects to my server with the use of ftp connect. It works perfectly when I'm testing it locally, it connects, it goes in, i can access stuff.
BUT
when I upload it online and try it there. The php code does nothing. It executes all lines before "ftp_connect" then from that line onwards, it doesn't get processed.
It doesn't show any errors, warnings, etc on screen but the code execution from the line of "ftp_connect" just stops.
What seems to be the problem?

A: Your host probably has error reporting turned off, try turning on error reporting with
ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);

at the top of your file, or check for a file called error_log in the directory of your script.


Q: Did the city search data from the Facebook Ads API suddenly change? The City Search call used to return a response where each city had the form:
{
  "name": "Dublin, CA",
  "key": 220522764,
  "subtext": "CA, United States"
}

Now the API returns:
{
  "name": "Dublin",
  "key": 220522764,
  "subtext": "California, United States"
}

The first format is still listed in the API docs here: https://developers.facebook.com/docs/reference/ads-api/get-autocomplete-data/
Is this a permanent change?

A: Yes, last week. No warning from Facebook.

A: Our apologies for this change - we've reverted this change and will take precaution to avoid these things in the future. Thank you for the report.
We've added another parameter to use in your query if you want to get the city name without the state. Documentation updated: https://developers.facebook.com/docs/reference/ads-api/get-autocomplete-data/


Q: "Task timed out after..." when connecting to a MongoDB database in an AWS Lambda function I am have Node.js script where in the beginning of it I connect to my MongoDB database and get a specific collection and use that within the script. I set this script up in an AWS Lambda function with a timeout of 10 seconds. When I test the AWS Lambda  with a configured test event, I get a "Task timed out after 10.00 seconds". My script is still suppose to run after it connects and finish the rest of the script. However, it stops and I get a timeout error from AWS Lambda. If I set a timeout higher, such as 15 minutes, I get the timeout error 15 minutes after I connect to the MongoDB database within the script (I got this my looking at the CloudWatch logs for the AWS Lambda function). I experimented with different timeout timings and found that for x seconds I set the timeout, my script will give the timeout error x seconds after I connect to the MongoDB database. I followed all best practices mentioned in this article about connecting to MongoDB from AWS Lambda and they are are: defining the MongoDB client connection outside the handler function and setting the context property callbackWaitsForEmptyEventLoop to false. I am not sure how to fix this. Below is some relevant code I used in my script:
main.ts:
import { connectToDatabase } from './mongodb'
import mongodb from 'mongodb'

export const handler = async (event: any, context: any, callback: any) => {
    context.callbackWaitsForEmptyEventLoop = false
    const db = await connectToDatabase().then((db: mongodb.Db) => db).catch(error => error)
    var collection: mongodb.Collection = db.collection("{collection-name}")
    // Rest of the script
}

mongodb.ts:
import mongodb, { MongoClient } from "mongodb"

let uri: undefined | string = process.env.MONGODB_URI
let dbName: undefined | string = process.env.MONGODB_DB

let cachedClient: null | mongodb.MongoClient = null
let cachedDb: null | mongodb.Db = null

export async function connectToDatabase() {
  if (cachedClient && cachedDb) {
    return cachedDb
  }

  if (!uri) {
    throw new Error(
      "Please define the MONGODB_URI environment variable inside .env.local"
    )
  }

  if (!dbName) {
    throw new Error(
      "Please define the MONGODB_DB environment variable inside .env.local"
    )
  }

  const client = await MongoClient.connect(uri, {
    useNewUrlParser: true,
    useUnifiedTopology: true,
  })

  const db = client.db(dbName)

  cachedClient = client
  cachedDb = db

  return db
}

Other info: I use serverless to push the script to AWS Lambda and also using serverless plugin "serverless-webpack" for TypeScript files.

A: The best practice linked in your article says Define the MongoDB client connection outside of your handler function. In your case you should change const db = ... to db = ... and declare db outside of your handler function and change it to let db = null like in the example in the article, so you can reuse the connections in different Lambda invocations. For example:
let db = null;

export const handler = async (event, context, callback) => {
  if (!db) {
    db = connectToDatabase();
  }

  // do something with your db

  callback();
};

Besides that, take @hoangdv 's advice and call the callback function to signal AWS Lambda that you're done with handling the event. That should do the trick.

A: I found that AWS Lambda functions can only run for a maximum of 15 minutes (even if the code is still running after that amount of time). If I wanted to run the script for more than 15 minutes, I guess I would have to use an AWS EC2 instance.
Source: https://aws.amazon.com/lambda/faqs/

A: I have a similar issue with trying so many different approaches, having a larger maximum memory, and having a longer latency time. but they fail to solve it.
Then I found a solution by not using the whole parameter, its' value may be changed, outside of functions. Because cache can store the param in memory. it may lead the program to read the value from cache memory.
So put cachedClient, cachedDb defining in function:connectToDatabase not out of function.


Q: How to get only file names from an ls -la (ll) listing? I need a long (vertical) list of all file names of all files in a directory.
How to get only file names from an ls -la (ll) listing?
Only the names, not:
drwxr-xr-x 9 USER GROUP  4096 Jul 20 10:30 filename1
drwxr-xr-x 9 USER GROUP  4096 Jul 20 10:30 filename2
drwxr-xr-x 9 USER GROUP  4096 Jul 20 10:30 filename3
drwxr-xr-x 9 USER GROUP  4096 Jul 20 10:30 filename4
drwxr-xr-x 9 USER GROUP  4096 Jul 20 10:30 filename5

Rather I need only:
filename1
filename2
filename3
filename4
filename5

A: Printing only filenames is the default behavior of ls.  When you add -l you are saying you want the "long format" output.  If you just remove -l I think that will give you what you want.   You can leave -a to include "hidden" files
Also as Stéphane mentioned you could add -1 if you still want each file on its own line, which will happen with or without -1 when redirected to a file or piped to another command.
If you want to save this to a file you can use the > or >> operators as with any command.  See Redirections and What are the shell's control and redirection operators?

A: You can redirect the output directly to file by using > or >>.
E.g. ls -l > somefile.txt will create a file called somefile.txt containing the results of ls -l. Beware, though, as the single > will overwrite everything in the file you redirect to. Using >> will append the output to the file you choose to write to.
EDIT: ls -1 >> somefile.txt is probably the command you are looking for. For all files, ls -1a >> somefile.txt.


Q: Why doesn't the 'Add' type satisfy the constraint 'number'? I tried practicing type gymnastics with typescript.And my goal is Implementing mathematical operations on numeric literals.
First of all,I implemented type BuildArray:
type BuildArray<
    Length extends number,
    Ele = unknown,
    Arr extends unknown[] = []
> = Arr['length'] extends Length
        ? Arr
        : BuildArray<Length, Ele, [...Arr, Ele]>;
type MyArray = BuildArray<3> // type MyArray = [unknown, unknown, unknown]

Then,I implemented type Add:
type Add<Num1 extends number, Num2 extends number> =
    [...BuildArray<Num1>, ...BuildArray<Num2>]['length']
type AddResult = Add<2, 5> // type AddResult = 7

However, when I tried implementing Multiply based on Add,it occured error:
type Multiply<Num1 extends number, Num2 extends number, Counter extends number = 0, Result extends number = 0> =
    Counter extends Num2?
    Result:
    Multiply<Num1, Num2, Add<Counter, 1>, Add<Num1, Result>>
type MultiplyResult = Multiply<4, 5> // type MultiplyResult = 20

Though the result is correct, it occured compile error:

Playground link
Can someone please tell me why this compilation error occurs?

A: When you are passing Counter in Add<Counter, 1>, it's extending the type number, but it's still unknown number. When it's passed from Add to BuildArray, you then have this check:
Arr['length'] extends Length?

and based on that check, you have different expected types Arr or BuildArray<Length, Ele, [...Arr, Ele]> which will again have the same issue.
Going back to Add, in the case of unknown number, TypeScript won't achieve that this length prop is the prop of an Array, which is already a number.
So you get the value correctly, but the type itself is still not sure that this is a number, because the check Arr['length'] extends Length? in BuildArray is not resolved to know that the Arr is the type that we are trying to access length from.
I am not sure if this was clear enough, but TL;DR: To achieve what you need with the minimum changes, you need to tell TypeScript that this Add type will always be a number instead of relying on TypeScript to learn that by itself.
For example, you can force this info by adding & number:
type Add<Num1 extends number, Num2 extends number> =
    [...BuildArray<Num1>, ...BuildArray<Num2>]['length'] & number
// −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−^^^^^^^^

or have any kind of type checks.
Playground link

A: This is because here you are extending with number
Counter extends number = 0, Result extends number = 0

and your Add<num1, num2> type returns a narrowed number.
For example: type AddResult = Add<2, 5> // type AddResult = 7
when you do typeof AddResult, the output would be 7 (for TS it is unknown) and not number and that's why the error occured.


Q: Doctrine2 Custom Type Not Returning Data iam regreting for last two days since came to my mind that i could create encrypted custom type, so that encryption and decryption of data would be done in that type so that i dont need to call those functions evrytime, generally to make my life easier but it turn it into living hell :/
My custom type is inserting encrypted data in the database as i intended but problem is when i need to retrive data, here is print of object that holds retrived data from database
    Uapi\CoreBundle\Entity\Request Object
(
    [id:Uapi\CoreBundle\Entity\Request:private] => 2
    [clientIPAdress:Uapi\CoreBundle\Entity\Request:private] =>
    [clientHost:Uapi\CoreBundle\Entity\Request:private] =>
    [clientISP:Uapi\CoreBundle\Entity\Request:private] =>
    [clientOS:Uapi\CoreBundle\Entity\Request:private] =>
    [clientOSVersion:Uapi\CoreBundle\Entity\Request:private] =>
    [clientBrowser:Uapi\CoreBundle\Entity\Request:private] =>
    [clientBrowserVersion:Uapi\CoreBundle\Entity\Request:private] =>
    [clientLanguage:Uapi\CoreBundle\Entity\Request:private] =>
    [clientCountry:Uapi\CoreBundle\Entity\Request:private] =>
    [clientCity:Uapi\CoreBundle\Entity\Request:private] =>
    [possibleProxy:Uapi\CoreBundle\Entity\Request:private] =>
    [proxyIPAdress:Uapi\CoreBundle\Entity\Request:private] =>
    [torExitNode:Uapi\CoreBundle\Entity\Request:private] =>
    [maliciousInput:Uapi\CoreBundle\Entity\Request:private] =>
    [maliciousInputLog:Uapi\CoreBundle\Entity\Request:private] =>
    [serverIPAdress:Uapi\CoreBundle\Entity\Request:private] =>
    [serverPort:Uapi\CoreBundle\Entity\Request:private] =>
    [requestMethod:Uapi\CoreBundle\Entity\Request:private] =>
    [requestTimeFloat:Uapi\CoreBundle\Entity\Request:private] => P�a�;
)

Here is my Encrypted type class definition
    use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Uapi\CoreBundle\Provider\EncryptionProvider;

class EncryptedType extends Type {

    const ENCRYPTED = 'encrypted';

    public function getName()
    {
        return self::ENCRYPTED;
    }

    public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) {
        return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
    }

    public function convertToDatabaseValue($value, AbstractPlatform $platform) {
        return ($value === null)? null : base64_encode(EncryptionProvider::getCrypter()->encrypt($value));
    }

    public function convertToPHPValue($value, AbstractPlatform $platform) {
        return ($value === null)? null : base64_decode(EncryptionProvider::getCrypter()->decrypt($value));
    }
}

And i did register it within boot function in core bundle class
 $connection = $this->container->get('doctrine')->getConnection();
        if(!Type::hasType('encrypted'))
        {
            Type::addType('encrypted', 'Uapi\CoreBundle\System\DBALType\EncryptedType');
            $connection->getDatabasePlatform()->registerDoctrineTypeMapping('encrypted', 'encrypted');
        }

A: I did fix this on my own, its not general issue but ill explain here.I needed to firstly define a EncryptionProvider wich is my class that implements PHPSecLib\AES.So this is correct
public function boot()
{
    new EncryptionInit();
    EncryptionProvider::setCrypter(EncryptionProvider::AES, $this->container->getParameter('uapi_core.security_key'), $x = array());

    $connection = $this->container->get('doctrine')->getConnection();
    if(!Type::hasType('encrypted'))
    {
        Type::addType('encrypted', 'Uapi\CoreBundle\System\DBALType\EncryptedType');
        $connection->getDatabasePlatform()->registerDoctrineTypeMapping('encrypted', 'encrypted');
    }

 }


Q: Using Ansible to create AWS Application Load Balancer rules I'm trying to use Ansible to create rules for an unconfigured HTTP listener on my existing ALB. I kick things off by retrieving facts for the alb and then use those facts to define an Ansible ALB resource adding the rules I want, but I'm hitting an issue.
I would like Ansible to loop through my group_vars file (which it already does for other tasks successfully) to create these multiple rules. However when looping through, instead of appending rules to the listener it destroys/creates them. So when the playbook completes you are just left with a single rule referencing whichever item is defined at the end of the vars file (in my case Surrey).
My code is below (for the sake of brevity I have excluded the parts which get & set facts):
- name: Add HTTP listener rules
  elb_application_lb:
    state: present
    name: "{{ albinfo.load_balancer_name }}"
    subnets:
      - "{{ albinfo.availability_zones[0].subnet_id }}"
      - "{{ albinfo.availability_zones[1].subnet_id }}"
      - "{{ albinfo.availability_zones[2].subnet_id }}"
    security_groups:
      - "{{ albinfo.security_groups[0] }}"
    listeners:
      - Protocol: HTTP
        Port: 80
        DefaultActions:
          - Type: forward
            TargetGroupName: default
        Rules:
          - Conditions:
              - Field: host-header
                Values: "{{ item.url }}"
            Priority: "{{ item.priority }}"
            Actions:
              - TargetGroupName: "{{ item.name }}"
                Type: forward
    purge_listeners: no
  with_items: "{{ regions }}"

And my "regions" vars file looks like this:
regions:
  - name: manchester
    priority: 1
    url:
      - manchester.example.com

  - name: surrey
    priority: 2
    url:
      - surrey.example.com

A: The way you are using with_items to iterate the elb_application_lb module will not work as you have found out. Executing multiple commands will have the effect that the last one will 'win', as it will overwrite the existing elb rule set.
What you would need to do is define each rule on a single call to elb_application_lb instead, you can not layer on rules with multiple calls to this module. You might be able to create a dict that defines all your rules instead like this:
- name: Add HTTP listener rules
  elb_application_lb:
    state: present
    name: "{{ albinfo.load_balancer_name }}"
    subnets:
      - "{{ albinfo.availability_zones[0].subnet_id }}"
      - "{{ albinfo.availability_zones[1].subnet_id }}"
      - "{{ albinfo.availability_zones[2].subnet_id }}"
    security_groups:
      - "{{ albinfo.security_groups[0] }}"
    listeners:
      - Protocol: HTTP
        Port: 80
        DefaultActions:
          - Type: forward
            TargetGroupName: default
        Rules:
          - "{{ region_rules }}"
    purge_listeners: no

Where region rules var looks like this:
    region_rules:
      - Conditions:
          - Field: host-header
            Values: manchester.example.com
        Priority: 1
        Actions:
          - TargetGroupName: manchester
            Type: forward

      - Conditions:
          - Field: host-header
            Values: surrey.example.com
        Priority: 2
        Actions:
          - TargetGroupName: surrey
            Type: forward


Q: Is there any reason to make a template template parameter non variadic? If I expect a template template parameter to have one arguement then I could declare it as follows:
template<template<typename> class T>
struct S {
    T<int> t_;
    //other code here
}

however if I later want to provide a template template parameter which takes two arguements where the second has a default value (like std::vector) T<int> t_; would still work but the template would not match template<typename> class T. I could fix this by making template<typename> class T into a variadic template template template<typename...> class T. Now my code is more flexible.
Should I make all my template template parameters variadic in future? Is there any reason I should not (assuming C++11 support is already required for my code for other reasons)?

A: First, documentation. If the parameter is variadic, the user now needs to check some other source to find out that this really wants something that will takes one template parameter.
Second, early checking. If you accidentally pass two arguments to T in S, the compiler won't tell you if it's variadic until a user actually tries to use it.
Third, error messages. If the user passes a template that actually needs two parameters, in the variadic version the compiler will give him an error message on the line where S instantiates T, with all the backtrace stuff in-between. In the fixed version, he gets the error where he instantiates S.
Fourth, it's not necessary, because template aliases can work around the issue too.
S<vector> s; // doesn't work
// but this does:
template <typename T> using vector1 = vector<T>;
S<vector1> s;

So my conclusion is, don't make things variadic. You don't actually gain flexibility, you just reduce the amount of code the user has to write a bit, at the cost of poorer readability.

A: If you know already that you will need it with high probability, you should add it. Otherwise, You Ain't Gonna Need It (YAGNI) so it would add more stuff to maintain. It's similar to the decision to have a template parameter in the first place. Especially in a TDD type of environment, you would refactor only when the need arises, rather than do premature abstraction.

Nor is it a good idea to apply rampant abstraction to every part of
  the application. Rather, it requires a dedication on the part of the
  developers to apply abstraction only to those parts of the program
  that exhibit frequent change. Resisting premature abstraction is as
  important as abstraction itself
Robert C. Martin
  Page 132, Agile Principles, Patterns and Practices in C#

The benefits of variadic templates can be real, as you point out yourself. But as long as the need for them is still speculative, I wouldn't add them.


Q: How to deliver multiple application versions without confusion? We currently work on multiple branches of our web application. The VCS of choice is SVN.
We have:

*

*v1: /trunk, live application, bugfixing

*v2: /branches/1, additional features, without trunk bugfixes
There are more steps planned. The current plan is to have a stable and client accepted v1 and then merge v2 into v1. At that point it's for sure that v3 will pop up.
The problem is that the client needs more transparency, he can currently only see and test v1. If i'd make v2 available to them too, it's very likely that they can't tell the versions apart and report v1 (fixed) bugs again for v2. It would be a mess, imo.
I also don't like the idea of a daily merge because it would be even harder to tell new and old bugs apart.
I have the feeling that this is more a problem with our development process than an technical one. Any inspirations to solve the problem or to make both sides feel more convenient about future development are welcome. Thanks.
edit
One partial problem is also that my co-workers aren't too deep into version-control, using 2 branches is already inconvenient for them. However if i find a better strategy i'll probably force them to do it right.
edit2
Thanks all for the answers. After some thinking it turns out that the whole problem is even bigger, because we keep binary files within SVN. Without very strict policies merging will be impossible and probably will be crippled anyway.

A: It seems kind of unorganized.  Merging version 2 into version 1? Eh? What version are you left with? Still version 1? With the features of version 2? Wha..?
What I like for smallish projects:
Trunk: This is where things get committed when the developer is confident that it's working.  Do internal QA testing on the trunk.
Tags: Make a new tag for each release, by copying from the trunk. Name your tags "/tags/v1.0" or "/tags/v1.1" or however you want to do it.  If you need an external client to test something, name your tag something like "/tags/v1.0-beta" and give them that to test.  Don't let them test with the trunk, because while they're testing you're still going to be developing!
Branches: When you've got a feature that's going to take some time to develop, you can't commit it to the trunk before it's done.  Make a branch.  Name it after the feature you're implementing, like "/branches/user_logins".
Bugfixes get committed to the trunk and are included in the next tagged release. If there's an emergency bugfix which must be released TODAY, but there's stuff in the trunk which can not yet be released yet, make another tag but copy from the tag of the buggy release instead of from the trunk, call it something like "v1.0.1", fix the bug there, give them a new release, and then merge that bugfix into the trunk.

A: *

*"without trunk bugfixes"

*"it would be even harder to tell new and old bugs apart."

*"I have the feeling that this is more a problem with our development process than an technical one."

Damn straight. Your development process fails to acknowledge failures in V1.  How can you hope that V2 will be better than V1 if you don't carry over the corrections in V1 to V2?!
Bug fixes are always more important than new features.  If the old features are broken and not worth fixing then remove them.
Get off your lazy ass; if you, or someone, has made the effort to fix a defect in V1, then make sure it doesn't reappear in V2. FIX IT!  If your code is so rubbish that this is a daily occurrence then stop working on V2 and focus on getting the bug fixes down to less often.  If you can't get V1 features working properly then you'll never make it to V3.
I might also suggest "mercurial" or "git" or "bazaar" rather than svn. They're much better at keeping management types at bay if you find and use the "cherrypicking" and "queue" functionalities: you can add a feature and pull the-ONE-that-management-think-will-save-them into production without pulling all the other half-baked ideas they came up with then abandoned. If politics prevent a move to distributed version control just use it yourself and only push the stuff you deliver (and they want) to svn.

A: For me it seems that you switched the terms branch and trunk. Normally trunk is the active development branch, where releases live on their own bugfix branches. It looks that you use trunk as release1 bugfix branch, while /branches/1 is the real development trunk, and are stuck since you can't create a second trunk for release2.
If I'm right I would recommend to move your current trunk into a /branches/v2 branch, and your /branches/1 branch to /trunk. With this scenario you can have as many release branches as you need (but try to keep them as low as possible), while the main development line is in /trunk.
See http://nvie.com/posts/a-successful-git-branching-model/ for more details. While it is for git, there is a lot of VCS-independent information.

A: I agree to you other fellow posters. c0rnh0li0 You need to rethink your checkin & merge policies.
Look at your repository layout and try to define rules that can easily be repeated by anyone in the team and that help to populate changes consequently from stable to unstable. For me this allows merges mostly in one direction.
Example layout for a maintainance-branch scenario
branches/v1
-approved and shipped/deploy
-Only bugfixes allowed

branches/v2
-is not approved by the client but nearly ready
-Fixes and feature-commits allowed that focus on getting v2 stable & ready
-receive bugfixes commited in v1 (merge down)

branches/v3
-is not approved by the client and far from ready
-Fixes and feature-commits allowed that focus on getting v3 stable & ready
-receive bugfixes commited in v2 (merge down)

trunk
-All syntax-error free commits allowed (mainline)
-receive merges from LATEST stable branch (merge down from v3 in this case)

The top branch is the oldest with the fewest features but the highes stability (well tested, not many featurs been added in the recent past). The trunk on the other hand is pretty unstable and receives bleeding-edge features. v2 and v3 are Somewhet in between.
You could also add featrue branches "below" the trunk which would be even more unstable than the trunk. Merge directions remain the same. I'd like to quote the mantra "merge down, copy up".
The more concurrent releases you prepare/maintain the more merges you will have to do though. But thanks to mergetracking it is not so much of a task IMHO and it ensures no bugfix is left behind and has to be re-discovered and fixed again manually.
I didnt mention tags here. If you can create them and do not release from a branch directly.
Now while this should fix your change-flow management to a great deal and help isolate high-risk development from low-risk, there is the issue left of visualizing to the client what he is testing/previewing.

Visualising application VCS origin to the client
Possibilities:

*

*If it is a web-projekt host, the versions on URLs that contain the branch-name

*For any project: Just check in a logo or text property that contains something like "version 3.x" and display it in your application

*Coolest solution is to use svn keywords and parse the value of $HeadURL$ in your app to dynamically display the branch name this build originates from


Q: Arrange three images I need to arrange three figures in a two column document as follows

A: Comments
You did not tell us about the individual/main captions and/or references. I decided to throw that in as well.
Basic Idea

*

*For a two column document use the option [twocolumn] with the \documentclass.

*Create a two column table (outer table). Put another single column table in the first column. Put the first two images (A and B) as the two rows of the inner table. Put the third image (B) in the second column of the outer table.

*Use   subcaption to take care of captions and labels. (This answer helps.)
The Solution
\documentclass[twocolumn]{article}

\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}

\usepackage{lipsum} % For dummy text only

\begin{document}

\begin{figure}[!t]
  \begin{tabular}[b]{cc}
    \begin{tabular}[b]{c}
      \begin{subfigure}[b]{0.4\columnwidth}
        \includegraphics[width=\textwidth]{A.png}
        \caption{A.}
        \label{fig:A}
      \end{subfigure}\\
      \begin{subfigure}[b]{0.4\columnwidth}
        \includegraphics[width=\textwidth]{B.png}
        \caption{B.}
        \label{fig:B}
      \end{subfigure}
    \end{tabular}
    &
    \begin{subfigure}[b]{0.4\columnwidth}
      \includegraphics[width=\textwidth]{C.png}
      \caption{C.}
      \label{fig:C}
    \end{subfigure}
  \end{tabular}
  \label{fig:ABC}
  \caption{A, B and C.}
\end{figure}

\lipsum[1-5]

\end{document}

The Output

Further Tweaking
Change the 0.4\columnwidths to tweak image sizes. Watch for overfull boxes.

A: Your question seems to involve two different parts:

*

*How to create a two-column document

*How to arrange the figures in two columns

The answer to 1. is to use the twocolumn option in the article class.
The answer to 2. is to use a minipage environment.
\documentclass[twocolumn]{article}

\usepackage{graphicx}
\usepackage{lipsum}

\begin{document}

\begin{figure}[h!]
\begin{minipage}{0.48\columnwidth}
\includegraphics[width=\columnwidth,height=4cm]{triangle}
\\[3mm]
\includegraphics[width=\columnwidth,height=4cm]{triangle}
\end{minipage}
\begin{minipage}{0.48\columnwidth}
\includegraphics[width=\columnwidth,height=83mm]{triangle}
\end{minipage}
\end{figure}

\lipsum[1-7]

\end{document}

The code to generate the triangle.pdf file is
\documentclass{standalone}

\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw[fill=green!20] (0,0) -- (1,1) -- (1,0) -- cycle;
\end{tikzpicture}
\end{document}


Q: Determinant with variables What is the following determinant?
$$\begin{vmatrix}1+a & b & c & d \\a & 1+b & c & d \\a & b & 1+c & d \\a & b & c & 1+d \end{vmatrix}$$
I calculated it as $0$ but I do not think it is right. Thanks in advance.

A: Subtract row $2$ from row $1$, row $3$ from row $2$, and row $4$ from row $3$.  You get
$$
\begin{bmatrix}
1 & -1 & 0 & 0 \\
0 & 1 & -1 & 0 \\
0 & 0 & 1 & -1 \\
a & b & c & 1+d
\end{bmatrix}
$$
If you expand along the fourth row, all the $3 \times 3$ determinants will be upper or lower triangular.  So, the determinants will be the product of the diagonals.

A: The matrix is $I-A$ where $A$ is a matrix with a triple eigenvalue $0$ and a fourth eigenvalue $-(a+b+c+d)$. So the characteristic polynomial $\det(I\lambda - A)=\lambda^3(\lambda +(a+b+c+d))$. Setting $\lambda=1$ you get $\det(I-A)=1+a+b+c+d$.
The left eigenvector for $A$ are any vectors $(x,y,z,w)$ with $x+y+z+w=0$ (these have eigenvalues $0$) and vector $(a,b,c,d)$ has eigenvalue $-(a+b+c+d)$. The vectors with eigenvalue $0$ are generated by vectors $(1,-1,0,0), (1,0,-1,0),$ and $(1,0,0,-1)$.
Right eigenvectors are a little messier. If $(x,y,z,w)^T$ satisfies $ax+by+cz+dw=0$, then it is an eigenvector with eigenvalue $0$. And $(1,1,1,1)$ has eigenvalue $-(a+b+c+d)$.

A: If you are not familiar with the concepts used in Thomas Andrews' (elegant) answer; you can try to compute the determinant by using properties to create zeroes.
For example; subtract the second row from the other rows and then add the first column to the second to get:
$$\begin{vmatrix}1+a & b & c & d \\a & 1+b & c & d \\a & b & 1+c & d \\a & b & c & 1+d \end{vmatrix} =
\begin{vmatrix}
1 & -1 & 0 & 0 \\
a & 1+b & c & d \\
0 & -1 & 1 & 0 \\
0 & -1 & 0 & 1 \end{vmatrix}
=
\begin{vmatrix}
1 & 0 & 0 & 0 \\
a & 1+a+b & c & d \\
0 & -1 & 1 & 0 \\
0 & -1 & 0 & 1 \end{vmatrix}$$
Now expand the determinant to the first row, reducing it to a $3 \times 3$-determinant. Subtracting $c$ times the second row from the first and  $d$ times the third row from the first, you get:
$$\begin{vmatrix}
 1+a+b & c & d \\
 -1 & 1 & 0 \\
 -1 & 0 & 1 \end{vmatrix}=
\begin{vmatrix}
 1+a+b+c+d & 0 & 0 \\
 -1 & 1 & 0 \\
 -1 & 0 & 1 \end{vmatrix}$$
Expanding to the first row again agrees with Thomas Andrews' answer: $1+a+b+c+d$.

A: $$\begin{vmatrix}1+a& b & c & d \\a & 1+b & c & d \\a & b & 1+c & d \\a & b & c & 1+d \end{vmatrix}=\begin{vmatrix}1 & b & c & d \\0 & 1+b & c & d \\0 & b & 1+c & d \\0 & b & c & 1+d \end{vmatrix}+\begin{vmatrix}a & b & c & d \\a & 1+b & c & d \\a & b & 1+c & d \\a & b & c & 1+d \end{vmatrix}\\
=\begin{vmatrix}1+b & c & d \\b & 1+c & d \\ b & c & 1+d \end{vmatrix}+\begin{vmatrix}a & b & c & d \\0 & 1 & 0 & 0 \\0 &0 & 1 & 0 \\0&0 & 0 & 1\end{vmatrix}\\
=\begin{vmatrix}1 & c & d \\0 & 1+c & d \\ 0 & c & 1+d \end{vmatrix}+\begin{vmatrix}b & c & d \\b & 1+c & d \\ b & c & 1+d \end{vmatrix}+a\\
=\begin{vmatrix}1+c & d \\ c & 1+d \end{vmatrix}+\begin{vmatrix}b & c & d \\0& 1 & d \\ 0 & 0& 1 \end{vmatrix}+a\\
=\begin{vmatrix}1 & d \\ 0 & 1+d \end{vmatrix}+\begin{vmatrix}c & d \\ c & 1+d \end{vmatrix}+b+a\\
=\begin{vmatrix}1+d \end{vmatrix}+\begin{vmatrix}c & d \\ 0& 1 \end{vmatrix}+b+a\\
=1+d+c+b+a.$$

A: Let $\mathrm v := \begin{bmatrix} a & b & c & d\end{bmatrix}^{\top}$. Using the Weinstein-Aronszajn determinant identity,
$$\det \begin{bmatrix}1+a & b & c & d\\ a & 1+b & c & d\\ a & b & 1+c & d\\ a & b & c & 1+d\end{bmatrix} = \det \left( \mathrm I_4 + 1_4 \mathrm v^{\top}\right) = 1 + \mathrm v^{\top} 1_4 = \color{blue}{1 + a + b + c + d}$$


Q: Cross join two dataframes by key column using condition in R I have two dataframes.
mydata1=structure(list(ID_WORKES = c(58005854L, 58005854L, 58002666L,
58002666L), ID_SP_NAR = c(463L, 1951L, 21L, 465L), KOD_DEPO = c(3786L,
3786L, 1439L, 1439L), KOD_DOR = c(58L, 58L, 92L, 92L), COLUMN_MASH = c(6L,
6L, 5L, 5L), prop_violations = structure(c(1L, 2L, 2L, 2L), .Label = c("0.2",
"1"), class = "factor"), mash_score = c(0L, 2L, 2L, 2L)), .Names = c("ID_WORKES",
"ID_SP_NAR", "KOD_DEPO", "KOD_DOR", "COLUMN_MASH", "prop_violations",
"mash_score"), class = "data.frame", row.names = c(NA, -4L))

mydata2=structure(list(ID_SP_NAR = c(463L, 1951L, 21L, 465L, 500L, 600L
)), .Names = "ID_SP_NAR", class = "data.frame", row.names = c(NA,
-6L))

i need crossjoin merge these dataframes by ID_SP_NAR. Mydata2 contatins only key variable ID_SP_NAR.
I need join this in such a way that if the id_workers does not have any codes from the ID_SP_NAR from mydata2, then these code are inserted into the dataset, but for them in variables prop_violations and mash_score must be inserted zero values.
I.E. SP_ID_NAR in mydata2 has such values
ID_SP_NAR
463
1951
21
465
500
600

ID_workes =58005854 has
463,
1951
but another not have.
and
ID_workes =58002666 has  21 and 465 and not anonter!
So desired output after cross join
   ID_WORKES ID_SP_NAR KOD_DEPO KOD_DOR COLUMN_MASH prop_violations mash_score
1   58005854       463     3786      58           6             0.2          0
2   58005854      1951     3786      58           6               1          2
3   58005854        21     3786      58           6               0          0
4   58005854       465     3786      58           6               0          0
5   58005854       500     3786      58           6               0          0
6   58005854       600     3786      58           6               0          0
7   58002666        21     1439      92           5               1          2
8   58002666       465     1439      92           5               1          2
9   58002666       500     1439      92           5               0          0
10  58002666       600     1439      92           5               0          0
11  58002666       463     1439      92           5               0          0
12  58002666      1951     1439      92           5               0          0

KOD_DEPO,KOD_DOR,COLUMN_MASH have fixed value , it must be saved too.
How to do that?
merge(mydata1,mydata2, by = ID_SP_NAR) is not working( i try use via left join doesn't work), it doesn't insert zeros as i want .

A: We could use complete from tidyr to expand the dataset based on the 'ID_WORKES' and the valuse of 'ID_SP_NAR' in the second dataset
library(tidyverse)
mydata1 %>%
   mutate_if(is.factor, as.character) %>%
   complete(ID_WORKES, ID_SP_NAR = mydata2$ID_SP_NAR,
            fill = list(prop_violations = '0', mash_score = 0)) %>%
     fill(3:5)
# A tibble: 12 x 7
#   ID_WORKES ID_SP_NAR KOD_DEPO KOD_DOR COLUMN_MASH prop_violations mash_score
#       <int>     <int>    <int>   <int>       <int> <chr>                <dbl>
# 1  58002666        21     1439      92           5 1                        2
# 2  58002666       463     1439      92           5 0                        0
# 3  58002666       465     1439      92           5 1                        2
# 4  58002666       500     1439      92           5 0                        0
# 5  58002666       600     1439      92           5 0                        0
# 6  58002666      1951     1439      92           5 0                        0
# 7  58005854        21     1439      92           5 0                        0
# 8  58005854       463     3786      58           6 0.2                      0
# 9  58005854       465     3786      58           6 0                        0
#10  58005854       500     3786      58           6 0                        0
#11  58005854       600     3786      58           6 0                        0
#12  58005854      1951     3786      58           6 1                        2


Q: What the hell is that noise and how do I get rid of it? I've now for the second time encountered a multiplayer match where there was a constant background noise. The first time I thought someone was just messing around and played some sound effect via his microphone, but I now encountered exactly the same sound effect a second time.
The effect is pretty much audible the whole match, it's not a constant hum but an oscillating one, and it's very annoying.
What causes this annoying sound and how do I make sure I don't encounter it a third time?

A: I'm pretty sure I know what you're talking about. I experienced this myself as well. It's the sound of Reave's sound effect looping over and over. I think this is a bug, as I have not yet figured out a consistent way to stop it. You can see this person cast Reave here in singleplayer, and the sound effect lasts for a good 20 seconds.
I've had it continue to loop for me even after the wave was finished and all the enemies were dead.  There doesn't seem to be anything you can do about it. :/ It's even more annoying than running effect soundlooping in the lobby menu that I've had occur.
The only way I can guarantee avoiding it is not teaming with any Drell Adepts.

A: It definitely has to do with a drell adept. I was playing for the past couple games with one, and it was going the entire time. After a while, it starts to give me a headache and makes me nauseous. I definitely need to quit after a bit of that sound playing. I really hope Bioware fixes this sound because after a while, I just have to turn the in-game sound off so that I can play in peace.

A: The sound effect is indeed caused by a bug with the Drell Adept's Reave ability as the other users have mentioned. As far as getting rid of it, this post on Reddit suggests using the Pull ability twice in quick succession at the end of a round should do the trick.
I don't have a Drell Adept to test this with, but I would recommend suggesting that your Drell teammates give it a try.

A: The Drell have a skill that makes some weird sounds, maybe that's what you're hearing.


Q: MyBatis select query with IN but without forEach how can I use a select query where I have only two values for one column without using for each loop ?

A: Without using IN, you can use OR:
SELECT * FROM `table` WHERE co1 = `value1` OR col1 = `value2`


Q: Bind do CosmosDB no Azure Functions Local Como fazer Bind do Azure CosmoDB pelo Visual Studio no Azure Functions?
Notem o código abaixo, o parâmetro inputDocument seria o Bind do CosmosDB. Quando criamos a Funcão direto no portal do Azure, o mesmo já faz isso automaticamente pois já cria as conexões no arquivo local.settings.json.
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using System.Collections.Generic;

    namespace CDPCompare
    {
        public static class CallWS
        {
            [FunctionName("TimerTriggerCSharp")]
            public static void Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, TraceWriter log, IEnumerable<dynamic> inputDocument)
            {
                foreach(var item in inputDocument)
                {
                    log.Info(item);
                }
            }
        }
    }

A: Para fazer o Bind em uma Function é necessário adicionar a seguinte configuração:
1 - Instalar o pacote Nuget Microsoft.Azure.WebJobs.Extensions.DocumentDB
2 - Incluir o atributo [DocumentDB("%DatabaseName%", "MyCollection")] seguido do parâmetro IEnumerable<dynamic> inputDocuments
3 - Adicionar a string de conexão do CosmosDB no arquivo local.settings.json "AzureWebJobsDocumentDBConnectionString":"STRING DE CONEXÃO COSMOS DB"


Q: Android app timeout how to apply? when it minimized I want to make a exam app I want to apply a feature in my app in this feature when student minimize app then exam will automatically cancelled. so they can't cheat so please tell me what will and how will I do this in Android app in adt.

A: In your exam activity, override onPause() and paste cancel exam method before super.onPause().
Edit: I think you need onPause() instead of onStop(). Learn more about Activity Life cycle

A: When you minimize app, onStop will called.

Called when you are no longer visible to the user

So inside onStop you can cancel the example
@Override
protected void onStop() {
    super.onStop();
    // cancel exam here
}


Q: Login error connecting to salesforce.com from Flex Has anyone suddenly encountered login errors from their users trying to connect to salesforce.com from a Flex app using as3salesforce.swc?
I get the following error... password removed to protect the innocent...
App Domain = null
Api Server name = na3.salesforce.com
_internalServerUrl = https://na3.salesforce.com/services/Soap/u/14.0
loading the policy file: https://na3.salesforce.com/services/Soap/cross-domain.xml
Your application must be running on a https server in order to use https to communicate with salesforce.com!
login with creds
loading the policy file: https://na3.salesforce.com/services/crossdomain.xml
Your application must be running on a https server in order to use https to communicate with salesforce.com!
invoke login
intServerUrl is null
intServerUrl = https://na3.salesforce.com/services/Soap/u/14.0
_invoke login
'5A5D3012-7717-E3C2-9B39-FFBBFF1F1B47' producer set destination to 'DefaultHTTPS'.
Method name is: login
'direct_http_channel' channel endpoint set to http://localhost/pm_server/pm/
'5A5D3012-7717-E3C2-9B39-FFBBFF1F1B47' producer sending message 'E32C7199-72C1-B258-B483-FFBC1641173D'
'direct_http_channel' channel sending message:
(mx.messaging.messages::HTTPRequestMessage)#0
  body = "<se:Envelope xmlns:se="http://schemas.xmlsoap.org/soap/envelope/"><se:Header xmlns:sfns="urn:partner.soap.sforce.com"/><se:Body><login xmlns="urn:partner.soap.sforce.com" xmlns:ns1="sobject.partner.soap.sforce.com"><username>simon.palmer@dialectyx.com</username><password>******</password></login></se:Body></se:Envelope>"
  clientId = (null)
  contentType = "text/xml; charset=UTF-8"
  destination = "DefaultHTTPS"
  headers = (Object)#1
  httpHeaders = (Object)#2
    Accept = "text/xml"
    SOAPAction = """"
    X-Salesforce-No-500-SC = "true"
  messageId = "E32C7199-72C1-B258-B483-FFBC1641173D"
  method = "POST"
  recordHeaders = false
  timestamp = 0
  timeToLive = 0
  url = "https://na3.salesforce.com/services/Soap/u/14.0"
'5A5D3012-7717-E3C2-9B39-FFBBFF1F1B47' producer connected.
Method name is: login
Error: Ignoring policy file at https://na3.salesforce.com/crossdomain.xml due to meta-policy 'by-content-type'.

'5A5D3012-7717-E3C2-9B39-FFBBFF1F1B47' producer acknowledge of 'E32C7199-72C1-B258-B483-FFBC1641173D'.
responseType: Fault
Saleforce Soap Fault: sf:INVALID_LOGIN
INVALID_LOGIN: Invalid username, password, security token; or user locked out.
Comunication Error : sf:INVALID_LOGIN : INVALID_LOGIN: Invalid username, password, security token; or user locked out. : [object Object]

A: Obviously nobody else out there is building Flex apps on top of salesforce.com..
yippee, I'm first.
Anyhow, I just found out that this is a bug at salesforce.com as at 6th December 2008.  The issue is that the scripts which handle login do not cope adequately with the redirect necessary because of load balancing on the salesforce.com servers.
It should be possible to go through the www front door of salesforce.com's api with a URL such as...
"https://www.salesforce.com/services/Soap/u/13.0";

where the 13 represents the version of their API you are targetting.  However, all users are actually assigned to a specific server, so the front door should redirect the login request to the approriate place, and it doesn't if you are coming from Flex.
A workround is to specify your server in the URL, such as...
"https://na5.salesforce.com/services/Soap/u/13.0";

...which is what I was doing.  That's fine if you are a single user accessing the same resources continually and your account remains attached to that server.  However if...

*

*You are distributing your app so anyone who has a salesforce.com enterprise account can log in OR

*Your account gets moved because of some internal load balancing (which is what happened to me)

then the approach of providing a fixed server won't work.
The bug (as far as I understand it) is that the www route doesn't adequately redirect to your host server.  Last intelligence was that it will be fixed "soon".
I wish I could mark this as the answer...


Q: Call Python from Julia I am new to Julia and I have a Python function that I want to use in Julia. Basically what the function does is to accept a dataframe (passed as a numpy ndarray), a filter value and a list of column indices (from the array) and run a logistic regression using the statsmodels package in Python. So far I have tried this:
using PyCall

py"""
import pandas as pd
import numpy as np
import random
import statsmodels.api as sm
import itertools
def reg_frac(state, ind_vars):
    rows = 2000
    total_rows = rows*13
    data = pd.DataFrame({
    'state': ['a', 'b', 'c','d','e','f','g','h','i','j','k','l','m']*rows, \
    'y_var': [random.uniform(0,1) for i in range(total_rows)], \
    'school': [random.uniform(0,10) for i in range(total_rows)], \
    'church': [random.uniform(11,20) for i in range(total_rows)]}).to_numpy()
    try:
        X, y = sm.add_constant(np.array(data[(data[:,0] == state)][:,ind_vars], dtype=float)), np.array(data[(data[:,0] == state), 1], dtype=float)
        model = sm.Logit(y, X).fit(cov_type='HC0', disp=False)
        rmse = np.sqrt(np.square(np.subtract(y, model.predict(X))).mean())
    except:
        rmse = np.nan
    return [state, ind_vars, rmse]
"""

reg_frac(state, ind_vars) = (py"reg_frac"(state::Char, ind_vars::Array{Any}))

However, when I run this, I don't expect the results to be NaN. I think it is working but I am missing something.
reg_frac('b', Any[i for i in 2:3])

  0.000244 seconds (249 allocations: 7.953 KiB)
3-element Array{Any,1}:
    'b'
    [2, 3]
 NaN

Any help is appreciated.

A: In Python code you have strs while in Julia code you have Chars - it is not the same.
Python:
>>> type('a')
<class 'str'>

Julia:
julia> typeof('a')
Char

Hence your comparisons do not work.
Your function could look like this:
reg_frac(state, ind_vars) = (py"reg_frac"(state::String, ind_vars::Array{Any}))

And now:
julia> reg_frac("b", Any[i for i in 2:3])
3-element Array{Any,1}:
  "b"
  [2, 3]
 0.2853707270515166

However, I recommed using Vector{Float64} that in PyCall gets converted in-flight into a numpy vector rather than using Vector{Any} so looks like your code still could be improved (depending on what you are actually planning to do).


Q: Loading Large Datasets in Parallel With Python Multiprocessing TLDR;

*

*I want to read many files from disk in parallel

*My code loads these files very quickly, but merging them into the main process' memory is slow

*Am I doing this correctly? Is there a better way to share memory across processes?

Background:
I'm currently working on a project with a private hospital dataset (only 3 GB!) and would like to be able to load it faster (their disks are slow). I work on a 36 CPU server, so I should be able to speed it up using multiple processes. However, I am having trouble seeing an improvement.
The setup:
I have split my dataset over 12 binary PyTorch files ('.pt') which I load with torch.load(filename). These files each contain a list of images inside a dict E.G. the 0th list: {0:ListOfImages}. I would like to load these files simultaneously with different processes, then merge them into a list in their original order. I am currently able to do that, but cannot seem to merge the data into the main process faster than it would take to load sequentially.
Sequential baseline load: 74 seconds
What I tried:

*

*multiprocessing.Pool().map() (150 Seconds)

*multiple iterations of process.start() + process.join() (300 Seconds +)

*multithreading: I load the dataset in exactly the same amount of time as sequentially (74 Seconds)

Multiprocessing code thus far:
import multiprocessing as mp
import time
CORES = 12

def loadWorker(sharedDict,filename):
  t1 = time.time()
  temp = torch.load(filename)
  print("Dict Loaded in :{} seconds".format(time.time()-t1))
  t1=time.time()
  sharedDict.update(temp)
  print("Dict updated in :{} seconds".format(time.time()-t1))

filenames = ["namingconvention{}.pt".format(i) for i in range(CORES)]

jobs=[]
manager = mp.Manager()
sharedDict = manager.dict()
t1 = time.time()
for i,filename in enumerate(filenames):
  print("starting Process: {}".format(i))
  p = mp.Process(target=loadWorker, args=(sharedDict,filename))
  jobs.append(p)
  p.start()

for i,proc in enumerate(jobs):
  print("join Process {}".format(i))
  process.join()

print("dict created of length: {} in {} seconds".format(
  len(sharedDict),time.time()-t1)
)

images = []
for i in range(CORES):
  print("Appending Images: {}".format(i))
  images = images + list(images)

print("Images appended in {} seconds".format(time.time()-t1))

Am I doing something wrong? Is there a better way to share memory between these processes?
OUTPUT:
The output of the above:
Image of the stdout
The output of the above code with CORES=1 and logger.setLevel(mp.SUBDEBUG)
Image of debug stdout


Q: Попарное суммирование рядом стоящих чисел Необходимо с использованием множества просуммировать рядом стоящие числа в первый проход, затем в следующий проход взять результат первого и просуммировать попарно стоящие числа и т.д. до тех пор пока не останется одно число. С первым проходом всё понятно, но вот как сделать чтобы в последующие проходы всё суммировалось. Что имею:
public class Main {

    public static void main(String[] args) {

        TreeSet<Integer> treeSet1 = new TreeSet<>();
        writeRandomInSet(10, treeSet1);
        System.out.println(firstSummation(treeSet1));

    }
    public static TreeSet<Integer> writeRandomInSet(int n, TreeSet<Integer> treeSet){
        for (int i = 0; i < n; i++){
            treeSet.add((int) (Math.random() * 20));
        }
        System.out.println(treeSet);
        return treeSet;
    }
    public static TreeSet<Integer> firstSummation(TreeSet<Integer> treeSet){
        TreeSet<Integer> sumTree = new TreeSet<>();
        Iterator<Integer> iterator = treeSet.iterator();
        while (iterator.hasNext()){
            int val = iterator.next();
            if (treeSet.higher(val) != null){
                int endVal = treeSet.higher(val) + val;
                sumTree.add(endVal);
                iterator.next();
            }
        }
        return sumTree;
    }
}

A: Можно присвоить назад в treeSet1 результат firstSummation и продолжать, пока не получится множество из одного элемента:
public static void main(String[] args) {
    TreeSet<Integer> treeSet1 = new TreeSet<>();
    writeRandomInSet(10, treeSet1);
    while(treeSet1.size() > 1) {
        treeSet1 = firstSummation(treeSet1);
        System.out.println(treeSet1);
    }
}

Реализация firstSummation у вас немного странная. Эффективнее будет просто брать у итератора два значения подряд:
public static TreeSet<Integer> firstSummation(TreeSet<Integer> treeSet) {
    TreeSet<Integer> sumTree = new TreeSet<>();
    Iterator<Integer> iterator = treeSet.iterator();
    while (iterator.hasNext()) {
        int val1 = iterator.next();
        if (iterator.hasNext()) {
            int val2 = iterator.next();
            sumTree.add(val1+val2);
        }
    }
    return sumTree;
}

Заметьте, что и в моей реализации, и в вашей, если на входе множество с нечётным числом элементов, то последний будет проигнорирован.


Q: Why delegate protocol method is not recognized in UINavigationController I looked at lots of threads about delegation but couldn't find why this isn't working
I have UINavigationController in storyboard in Xcode  5 and here is how the delegate is assigned:
in MasterViewController I have:
//
// MasterViewController.h
//
@protocol MyViewDelegate
@required
- (void) getBackContacts:(NSArray *)c andEmails:(NSArray *)e;
@end

@interface ListContactsViewController : UITableViewController <MyViewDelegate> {

}
@property (strong, nonatomic) NSString* myString;
@property (strong, nonatomic) ABContact* currentML;

@end

//
// MasterViewController.m
//

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    DetailtViewController *vc = [segue destinationViewController];
    vc.delegate = self;
    vc.currentML = _currentML;
    vc.contacts = _contacts;
    vc.emails = _emails;
}

- (void) getBackContacts:(NSArray *)c andEmails:(NSArray *)e
{
    _contacts = [NSMutableArray arrayWithArray:c];
    _emails   = [NSMutableArray arrayWithArray:e];
}

for DetailViewController I have:
//
// DetailViewController.h
//
@protocol MyViewDelegate;

@interface SelectContactViewController : UITableViewController {
    id< MyViewDelegate > delegate;

}
-(IBAction) save;

@property (nonatomic, strong) id< MyViewDelegate > delegate;
@property (strong, nonatomic) ABContact* currentML;
@property (strong, nonatomic) NSMutableArray* contacts;
@property (strong, nonatomic) NSMutableArray* emails;

//
// DetailViewController.m
//

- (IBAction) save
{
    // *** this line compiles with error
    [delegate getBackContacts:_contacts andEmails:_emails];
}

When I compile compiler says:
No known instance method for selector 'getBackContacts:andEmails:'


Q: SAMC21 - SDADC - VREF B - which pin? I'm planning to use an ATSAMC21G16 in one of my current projects. But I got a hard time finding the correct pin in the Datasheet for the SDADC.
On page 907 the block diagram shows, that VREFB can be selected as a reference for the SDADC.

On page 920 this is confirmed by the bit for reference selection. Also here VREFB is clearly mentioned

However, this pin is nowhere to be found in the port function multiplexing table on page 30 for the ATSAMC21G version.

I can only find it in the table for the ATSAMC21N model.
Does this mean, that only for the N package version an external reference can be selected for the SDADC? Or is there something I'm missing? If it is not available, why would they design it that way? Because with the internal reference stability and accuracy, the 16bit resolution seems to be pointless to me.

A: I just checked the SAM C 20/21 datasheet on microchip's product page for the ATSAMC21.
Maybe you have a different version of the datasheet, because in table 6-2 on page 30, it shows SDADC/VREFB on PA04 for the C21 E/G/J - peripheral function B. It's possible they forgot to include it, and then added it later after you had looked.


Q: Setting  size to be the same as window? I'm trying to use jQuery to set the height of a div so that it takes up the entire window + the height of a header (so that you can scroll the header off the page) but no more than that. I would think the height of the div would be the height of the window + the height of the header I'm trying to hide.
When I set the div to window height, however, it creates overflow. Here's the rough code:

var $body = $("#body"),
  $container = $("#container"),
  $window = $(window),
  $content = $("#mainContent"),
  $header = $("#header"),
  bodyHeight = window.innerHeight + $header.height();

$body.css("height", window.innerHeight);
$container.css("height", bodyHeight);
div {
  display: block;
  width: 100%;
  margin: 0;
}
#body {
  overflow-y: scroll;
}
#container {
  overflow-y: hidden;
}
#header {
  overflow: hidden;
}
#navbar {
  height: 10px;
  background-color: brown;
}
#mainContent {
  height: 200px;
  overflow-y: scroll;
}
#contentP {
  height: 400px
}

Header

This is content

Why is there overflow if the div is sized to fit in the window?
EDIT: So far, answers haven't helped. This is the site I'm working on. It's joomla. I want the nav bar to lock at the top of the screen.
$(document).ready(function() {

//Declare some variables
var $window = $(window),
    $body = $(".body"),
    $mainContent = $("#maincontent"),
    headerGap = parseFloat($("#headerimg").css("margin-top")),
    headerHeight = headerGap + $("#header").height() + parseFloat($("#navbar").css("margin-top")),
    navbarHeight = $("#navbar").height(),
    footerHeight = $("#footer").height();

//set the height of the body and the maincontent
resizePage();

//Set the listeners for resizing and scrolling
$window.resize(resizePage);
$window.scroll(scrollHandler);

//When you scroll, see if the navbar is at the top. Set maincontent overflow
//to scroll when the navbar is at the top of the window. Set it to hidden otherwise
function scrollHandler() {
    if ($window.scrollTop() < headerHeight - 1) {
        $mainContent.css("overflow", "hidden");
    } else {
        $mainContent.css("overflow", "auto");
    }
}

//Set the body and the mainContent to be the correct sizes when the window size is changed. In theory, the body should be:
// windowHeight + headerHeight
// maincontent should be:
// windowHeight - (headerHeight + navbarHeight + footerHeight)
// But that doesn't quite work out.
function resizePage() {
    //Deal with the changing CSS due to media queries
    if ($(window).width() > 768) {
        headerGap = parseFloat($("#headerimg").css("margin-top"));
        headerHeight = headerGap + $("#header").height() + parseFloat($("#navbar").css("margin-top")) - 1;
        $(".nav.menu.nav-pills").css("width", "92.5%");
    }
    else {
        headerHeight = $("#header").height();
    $(".nav.menu.nav-pills").css("width", $window.width());
    }
    //The header and navbar height change at certain sizes, so grab them again to be safe.
    navbarHeight = $("#navbar").height();
    footerHeight = $("#footer").height();
    var windowHeight = $window.height(),
        contentHeight = windowHeight - (footerHeight + navbarHeight);
            //if we account for headerHeight too, maincontent is too big
    resizeContent(contentHeight);
    resizeBody(windowHeight);
}

//The body should take up the whole height of the window, plus the header
//and margin heights at the top. This way, you scroll to the navbar.
// But it doesn't work this way.
// -7 and -27 are from eyeballing it.
function resizeBody(windowHeight) {
    if($window.width() > 728) {
        $body.css("height", windowHeight - 7);
        }
    else {
        $body.css("height", windowHeight - 27);
    }
}

// The content should go from the bottom of the navbar to the bottom of the footer.
//
function resizeContent(contentHeight) {
    $mainContent.css("top", (headerHeight + navbarHeight));
    $mainContent.css("bottom", (0 - headerHeight));
//For the background slideshow on the Furniture page
// Again, + 5 was eyeballed
    $("div.moduletable").css("height", contentHeight + 5);
    if ( (contentHeight + 5) < ($(window).width()) /2 ) {
        $(".wk-slideshow img").css("width", "100%");
        $(".wk-slideshow img").css("height", "auto");
        }
    else {
        $(".wk-slideshow img").css("height", contentHeight + 5);
        $(".wk-slideshow img").css("width", "auto");
    }
}
});

It works for a lot of sizes, but one you get to small resolutions it falls apart.
EDIT 2: I was able to get the effect I was going for by adding another div. I set the body to be the height of the window and the new div to be the size of the body + the height of the header. The body has "overflow-y: scroll". The container would have "overflow-y: hidden" (See updated snippet). This doesn't totally answer my question, but at least it helps?

A: I've taken a look at your code and altered it. Try this and see if this is what you're looking for.
In my example i'm looking for the element by getElementById and then I set it's style.height to window.innerHeight - 10px without taking the 10px it wouldn't show the border fully on the page. So you just remove 10px's. The example has been tested on different screen sizes.
Javascript example:

function autoResizeDiv() {
  document.getElementById('body').style.height = window.innerHeight - 10 + 'px';
  console.log(window.innerHeight - 10 + 'px');
}
window.onresize = autoResizeDiv;
autoResizeDiv();
#body {
  display: block;
  border: 5px solid black;
}
body {
  overflow: hidden;
  margin: 0;
}

A: The following worked for me:
$(".body").height($(window).height());

A: I figured out the biggest problem. I was using some absolutely positioned elements without giving a parent any other position. This made things show up wonky when I was trying to size other things. I also needed to have an extra div as a container for all the content on the page that would be the height of the window + the height of the header.
Thanks to everyone who answered, it helped!


Q: Redirection to base url with GET array in codeigniter I'm trying to make the pagination work with the get parameter. Only that, the rest of the site will use uri.
The problem is this, as soon as I append ?something=zyx it redirects to the base url.
Config:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-&=';
$config['allow_get_array']      = TRUE;

htaccess:
RewriteEngine on
RewriteCond $1 !^(index\.php|lib|robots\.txt|upload)
RewriteRule ^(.*)$ /mysite/index.php/$1 [L]

Why does this happen?
Thanks
EDIT: AFTER A LONG RESEARCH I FOUND THE PROBLEM.
I post it here in case somebody else has the same problem.
If you are planning to use GET vars in whatever form, even a hybrid solution like mine you must set:
$config['uri_protocol'] = "PATH_INFO";
in the config file.

A: Since you only want to use query strings while using pagination, the following code should be enough:
$this->load->library('pagination');

...
$config['page_query_string'] = TRUE;
...

$this->pagination->initialize($config);

echo $this->pagination->create_links();

You should check the rest of the Pagination Class documentation.


Q: Can I measure analog voltages for a circuit with multiple power supplies? I have two components in a circuit: An Arduino Uno R3 and a Wind Sensor Rev. P. See diagram below. The wind sensor requires 12V to operate, so I powered it with an external power supply (provides 12V DC at 1A). The wind sensor outputs an analog signal up to 5V with the sensor reading.
I would like to use my arduino's analog-to-digital converter to read the sensor value. But can I do this if the arduino is powered with a different power supply? I have it connected to my laptop with a 5V USB cable.
I tried reading the value but I get fluctuating readings. To debug, I made a few more connections from the analog-in pins. As seen in the diagram, I can read voltages correctly if they are from the arduino. But if I try to read any voltage from the external power supply, the value is random.
I used a multimeter to check the voltages in the external power supply are 11.20V (close enough to 12V) and the voltage from the sensor OUT pin is 1.40V (within the 0V - 5V range I expected).
So why can my arduino not measure these voltages? I assume it's because the two different power supplies are changing the frame of reference for the ADC pin. But it's not clear to me, so I would appreciate a conceptual explanation.
My intuition tells me that both power supplies should share the same GND pin. But I didn't want to connect the GND between the two power supplies together, given they operate at different voltages and currents. Is this safe to do? Or should I just get a power supply module that will allow a single power supply to output both 12V and 5V?

A: You can and must connect the grounds together. It's the common reference. The only other thing wrong with your Fritzing picture is that you are feeding the ADC 12V voltage, divide it down with a simple voltage divider with two resistors. You don't need to measure the GND with the ADC.


Q: Roulette Wheel for sampling user defined pdf Following is the pdf from which I want to sample so, I used roulette wheel sampling
Code to generate pdf
pdf=np.array([1,5,1,10,1,5,1])
pdf=pdf/np.sum(pdf)
x=np.arange(0,np.size(pdf),1)
plt.bar(x,pdf)

Code to generate cdf
def pdf2cdf(tpdf):
tcdf=np.zeros_like(tpdf)
itr=0
for i in tpdf:
    tcdf[itr]=tcdf[itr-1]+tpdf[itr]
    itr=itr+1
return tcdf
cdf=pdf2cdf(pdf)
plt.bar(x,cdf)

CDF of the given pdf
Code to sample from pdf using roulette wheel
lst=[]
uni=[]
for j in range(100000):
    tmp=np.random.uniform(0,1)
    uni.append(tmp)
    tmp2=np.argsort(np.abs(cdf-tmp))
    lst.append(tmp2[0])

histogram of uni

histogram of samples drawn

I don't understand what's going wrong. The pdf from which I sampled(first plot) and the histogram of samples (last plot) are not the same.
Can anybody please suggest the correction of any mistake I made above.

Thanks @jsk
for k in range(np.size(cdf)):
    if cdf[k]>tmp:
        break
tmp2=k

plt.hist(lst,bins=range(0,8), align='left', rwidth=1, normed=True)

A: The problem is with the command
np.argsort(np.abs(cdf-tmp)).

The command will find which element of the cdf is closest to tmp, regardless of whether or not tmp is greater than cdf.
According to your problem,
$P(0) = 1/24 \approx 0.04167$
$P(1) = 5/24 \approx 0.2083 $
so $ CDF(1) = 6/24 = 0.25$.
In your code, you will end up sampling a 0 if tmp is closer to 0.04167 than 0.25, for example tmp = 0.1 will return a 0, which means that you are assigning 0 a much higher proportion of the time than 0.04167.  What range of values for tmp will ensure that you assign a 0 with probability 0.04167?  What range of values for tmp will ensure that you will assign a 1 with the appropriate probability?
I will leave it as an exercise for you to figure out how to adjust your code in light of the problem I have identified with the current code.


Q: NDSolve breaking down I'm trying to model a situation involving charged sphere in a dynamic electric potential, and find out how the rotational motion of the sphere affects the translational dynamics in two dimensions. Here q0 refers to charge at the centre of the sphere, whereas q1 is charge deposited at its surface, which will lead to a torque. ωd is the driving frequency of the electric field. My model seems to work well in certain limits, but breaks down in the region I'm actually interested in. My equations are
Needs["DifferentialEquations`NDSolveProblems`"];
Needs["DifferentialEquations`NDSolveUtilities`"];
eqns1 = {
    x''[t] == - (1/m) E0 Cos[ωd t] (q0 x[t] + q1 Abs[Sin[ϕ[t]]] (x[t] + R Sin[ϕ[t]]))
         - γt x'[t],
    y''[t] == -(1/m) E0 Cos[ωd t] (q0 y[t] + q1 Abs[Cos[ϕ[t]]] (y[t] + R Cos[ϕ[t]]))
         - γt y'[t] - 9.8 m,
    ϕ''[t] == 1/MI E0 Cos[ωd t] q1 R (-Cos[ϕ[t]] (x[t] + R Sin[ϕ[t]]) +
         Sin[ϕ[t]] (y[t] + R Cos[ϕ[t]])) - γr ϕ'[t],
    x'[0] == xv0,
    ϕ'[0] == ϕv0,
    x[0] == x0,
    ϕ[0] == ϕ0,
    y'[0] == yv0,
    y[0] == x0};

I then have a list of parameters (which I'll at the end of the post), including the initial values. I solve the equations using
sol[p_, time_] :=
  NDSolve[eqns1 //. p, {x[t], ϕ[t], ϕ'[t], x'[t], y[t], y'[t]}, {t, 0, time},
  MaxSteps -> ∞, "ExtrapolationHandler" -> {Indeterminate &, "WarningMessage" -> False}];

Where I have experimented with a number of Methods, including "StiffnessSwitching", "BDH" , "ExplicitRungeKutta" and "ImplicitRungeKutta". This does work with certain parameters, basically when q0 is large and q1 is low, but breaks down if I try to switch those values, making q1>q0. I run this with time=1. Here are the parameters which do work:
p = {
   m -> 2000 4/3 π R^2,
   R -> 10^-7,
   E0 -> 10^14,
   MI -> 5/2 m R^2,
   q0 -> q0b eV ,
   q0b -> 100,
   q1 -> q1b eV,
   q1b -> 5,
   eV -> 1.602 10^-19,
   γt -> 1,
   γr -> 1,
   ωd -> 15000,
   xv0 -> 10^-2,
   ϕv0 -> 1,
   x0 -> 10^-9,
   y0 -> 10^-9,
   yv0 -> 10^-2,
   ϕ0 -> π/10};

However it breaks down when I send q0b-> 5, q1b-> 100. The error code I get is:
At t == 0.099279970214417`, step size is effectively zero;
singularity or stiff system suspected

Any help would be very much appreciated!

A: In the course of trying to solve this problem, I have run a number of physical and numerical parameters. The most striking behavior that I observed is extreme sensitivity of the results to those parameters.  This suggests that the system is chaotic, especially for large q1b.  To illustrate this extreme sensitivity, compute ϕ for fixed values of x and y:
sc = NDSolveValue[{ϕ''[t] == 1/MI E0 Cos[ωd t] q1 R (-Cos[ϕ[t]] (x + R Sin[ϕ[t]]) +
    Sin[ϕ[t]] (y + R Cos[ϕ[t]])) - γr ϕ'[t], ϕ'[0] == 1, ϕ[0] == π/10} //.
    p /. {x -> 4*10^-5, y -> 2*10^-5}, {ϕ, ϕ'}, {t, 0, 1/100}];
ParametricPlot[{sc[[1]][t], sc[[2]][t]/ωd /. p}, {t, 0, 1/100},
    AxesLabel -> {ϕ, ϕ'}, AspectRatio -> 1]

with q0b -> 5, q1b -> 100.

In contrast, increasing y to 2.01*10^-5 yields

Thus, although
sol[p_, time_] := NDSolve[eqns1 //. p, {x[t], y[t], φ[t],}, {t, 0, time}, MaxSteps -> ∞,
    MaxStepFraction -> 10^-3/(ωd time) /. p, Method -> "StiffnessSwitching"];

gives a stable answer, at least out to time = 1/10,

changing anything produces a very different answer.  Sometimes that different answer is unstable, sometimes not.