text:
Q: Class [ContextNamespaceHandler] for namespace [...schema/context] does not implement the [....xml.NamespaceHandler] interface I have simple spring mvc application
snippet of pom.xml:
<!-- Spring framework -->
         <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>3.2.4.RELEASE</version>
        </dependency>

        <!-- Spring MVC framework -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>3.2.4.RELEASE</version>
        </dependency>

snippet of configuration:
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <context:component-scan base-package="controller" />
    .....

exception trace:
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]; nested exception is org.springframework.beans.FatalBeanException: Class [org.springframework.context.config.ContextNamespaceHandler] for namespace [http://www.springframework.org/schema/context] does not implement the [org.springframework.beans.factory.xml.NamespaceHandler] interface
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:651)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:599)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:665)
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:518)
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:459)
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    at javax.servlet.GenericServlet.init(GenericServlet.java:160)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5123)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5407)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: org.springframework.beans.FatalBeanException: Class [org.springframework.context.config.ContextNamespaceHandler] for namespace [http://www.springframework.org/schema/context] does not implement the [org.springframework.beans.factory.xml.NamespaceHandler] interface
    at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.resolve(DefaultNamespaceHandlerResolver.java:126)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1433)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1428)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:185)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:139)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:108)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
    ... 30 more
29.10.2013 17:26:58 org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]; nested exception is org.springframework.beans.FatalBeanException: Class [org.springframework.context.config.ContextNamespaceHandler] for namespace [http://www.springframework.org/schema/context] does not implement the [org.springframework.beans.factory.xml.NamespaceHandler] interface
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:651)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:599)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:665)
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:518)
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:459)
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    at javax.servlet.GenericServlet.init(GenericServlet.java:160)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5123)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5407)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: org.springframework.beans.FatalBeanException: Class [org.springframework.context.config.ContextNamespaceHandler] for namespace [http://www.springframework.org/schema/context] does not implement the [org.springframework.beans.factory.xml.NamespaceHandler] interface
    at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.resolve(DefaultNamespaceHandlerResolver.java:126)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1433)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1428)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:185)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:139)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:108)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
    ... 30 more
29.10.2013 17:26:58 org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /Mvc threw load() exception
org.springframework.beans.FatalBeanException: Class [org.springframework.context.config.ContextNamespaceHandler] for namespace [http://www.springframework.org/schema/context] does not implement the [org.springframework.beans.factory.xml.NamespaceHandler] interface
    at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.resolve(DefaultNamespaceHandlerResolver.java:126)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1433)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1428)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:185)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:139)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:108)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:651)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:599)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:665)
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:518)
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:459)
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    at javax.servlet.GenericServlet.init(GenericServlet.java:160)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5123)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5407)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)

I am confused
What I did wrong?
UPDATE
I rewrite so
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.2.xsd">

    <context:component-scan base-package="controller" />

I see old stacktrace

A: You'll need to add spring-context jar
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>${springframework.version}</version>
</dependency>

which contains context namespace elements.

A: I resolved problem so:
replace it
<dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>3.2.4.RELEASE</version>
        </dependency>

on
<dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>3.2.4.RELEASE</version>
        </dependency>


text:
Q: Orthogonal polynomial integrals vanish What is meant when an integral "vanishes" over a certain interval?  For example, between $0$ and $\pi$:
$$\int(\cos m\theta) (\cos n\theta)d\theta=0$$
Does this imply there is no area under the curve, and that these two polynomials form a basis?

A: Notice that we don't say that
$$
\int(\cos m\theta) (\cos n\theta)d\theta=0
$$
between $0$ and $\pi$, rather, we say that (assuming $m \neq n$ and both are integers)
$$
\int_0^{\pi}(\cos m\theta) (\cos n\theta)d\theta=0
$$
And those two statements are very different. In fact, to find the antiderivative, we would note
$$
(\cos m\theta) (\cos n\theta) =
\frac12 \left(\cos((m+n)\theta)+\cos(m-n)\right)
$$
To find (assuming $m\neq n$ are integers)
$$
\begin{align}
\int(\cos m\theta) (\cos n\theta)d\theta &=
\int \frac12 \left(\cos((m+n)\theta)+\cos(m-n)\right)d\theta\\
&=\frac12\left(\frac1{m+n}\sin((m+n)\theta) + \frac1{|m-n|}\sin((m-n)\theta)\right) + C
\end{align}
$$
Finding the difference of this antiderivative between $0$ and $\pi$ gives you zero, but changing the limits will give you a different answer.
Does this mean that there is no area beneath the curve? No.  It means that the positive area cancels out with the negative area.  That is, the positive area (beneath the function) on this interval is equal to the negative area (above the function) on this interval.
Does it mean that these two polynomials form a basis?  First of all, these aren't polynomials.  Yes, these functions form a basis in a sense, but I don't think that means what you think it means.  The fact that
$$
\int_0^{\pi}(\cos m\theta) (\cos n\theta)d\theta=0
$$
Does mean that, under a certain framework, if $m\neq n$ are integers, the two functions $\cos(m\theta)$ and $\cos(n\theta)$ are orthogonal.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Why aren't variables defined inside an include defined in the $GLOBALS array? I'm trying to access a dynamically named variable that is defined inside an include file after the include is included, for example:

require "/path/to/my/include.php";
echo $_VariableDefinedInInclude; // outputs the variable
echo $GLOBALS["NameOfTheVariableDefinedInInclude"]; // nothing outputs?

Any idea why the variable is not in the $GLOBALS array? Is there a function like constant() but for standard variables that I could use to dynamically access the variable by its name?
Thanks

A: The $GLOBALS array only applies to variables set with the global keyword.  If you are including another file, it is essentially the same as the code being all in the same file.  In other words, you still have access to that variable in the same scope.  There is no need to use $GLOBALS or anything.  Additionally, if that variable is constant, you can use const (PHP 5.3) or define('KEY', $val) to define it as a constant instead.

A: Given that the variable is dynamically-named, perhaps:
echo $GLOBALS[$GLOBALS["NameOfTheVariableDefinedInInclude"]];

will do the trick.


text:
Q: Can Liquibase compare data of two of two databases with diff command using difftypes=data? I'm a new to Liquibase. I have used the following command
but is not giving expected result. Can Liquibase compare data of two of two databases?
c:\LiquiBase>liquibase --username=root --url=jdbc:mysql://localhost:3306/schema3 --driver=com.mysql.jdbc.Driver --referenceUrl=jdbc:mysql://localhost:3306/solution --referenceUsername=root --diffTypes=data diff diffChangeLog > change.xml

A: I think the problem here is that you are actually giving liquibase TWO commands (both diff and diffChangelog) and the code is using the second.

A: Liquibase can't create a data changeset with the diff or diffChangeLog command. --diffTypes=data is only available for the generateChangeLog command.
Find more information here.
So, you could get data as a Liquibase changeset only with full schema generation.

A: $ liquibase --driver=oracle.jdbc.OracleDriver         --url=jdbc:oracle:thin:@localhost:1521:orcl      --username=user         --password=password     diffChangeLog    --referenceDriver=org.sqlite.JDBC  --referenceUrl=jdbc:sqlite:/sqlite/temp.db         --referenceUsername=user         --referencePassword=password > diff.SQL


text:
Q: Save and add field in drupal doesn't exits Recently "Save content type and add field" in Drupal has been faded. What's the problem? Here is screen shot!
 http://i.stack.imgur.com/m4KvY.png

A: I installed Field UI module and cleared All cashe.

A: Save content type and add field Only shows when you are creating a new content-type,
I think you are trying to edit the content-type so this is appearing as Delete Content-type.


text:
Q: (Connected) non-contractible schemes This question is motivated by this other question and this answer, which show that irreducible algebraic varieties and more generally integral schemes are contractible as topological spaces.
What are examples of connected non-contractible schemes? I expect some gluing involved in the answer. But could such a scheme also be affine?

A: Take a union $X$ of a line $L$ and a conic $C$ in $\mathbb{A}^2$ (over some field) which intersect at two points $p$ and $q$.  Then I claim $X$ is not contractible, and in fact that $H_1(X)$ is nontrivial.  To prove this, cover $X$ by the open sets $U=X\setminus\{p\}$ and $V=X\setminus\{q\}$.  Note that $U$ and $V$ are path-connected, but $U\cap V$ is disconnected (its connected components are $L\setminus\{p,q\}$ and $C\setminus\{p,q\}$).  The Mayer-Vietoris sequence $$H_1(X)\to H_0(U\cap V)\to H_0(U)\oplus H_0(V)$$ then tells us that $H_1(X)$ must be nontrivial, since the map $H_0(U\cap V)\to H_0(U)\oplus H_0(V)$ is the same on every path-component of $U\cap V$ and thus is not injective.
The intuition here is that the space $X$ is like a circle, obtained by gluing together two contractible sets $L$ and $C$ which intersect at two points, just like a circle is obtained by gluing together two intervals that intersect at two points.  In fact, with a bit more work you can show that $X$ is weakly homotopy equivalent to a circle.
More generally, I suspect the following statement is true but have not carefully worked out a proof.  Let $X$ be a sober Noetherian topological space.  Let $P$ be the smallest collection of irreducible closed subsets of $X$ such that every irreducible component of $X$ is in $P$ and if $A,B\in P$, then every irreducible component of $A\cap B$ is in $P$.  We can consider $P$ as a poset with respect to inclusion.  Then $X$ is weakly homotopy equivalent to the nerve of $P$.
(Alternatively, you could consider the poset $Q$ which consists simply of all irreducible closed subsets of $X$, or equivalently the poset of points of $X$ with respect to the specialization order.  It should also be true that $X$ is weak equivalent to the nerve of $Q$.  This construction is somewhat more natural, but the poset $P$ above has the advantage of being finite and thus nice to compute with.)


text:
Q: Querying XML nodes using T-SQL getting wrong result set I am trying to extract the records from the an XML file but I am getting records where the records do NOT meet the criteria in the WHERE clause.
Here is my T-SQL code:
DECLARE @StartLossDate date = '2018-12-15';
DECLARE @EndLossDate date = CONVERT(date,GETDATE());

SELECT @StartLossDate as StartLossDate, @EndLossDate as EndLossDate;

-- Get result set.
SELECT DISTINCT t.SysDate, t.PolicySysID, t.PolicyNo
    a.b.value('(LossDt)[1]','date') as LossDate
    , a.b.value('(ClaimNumber)[1]','varchar(max)') as ClaimNumber
    , d.e.value('(LossTypeCd)[1]','varchar(max)') as LossTypeCd
FROM #tempXMLRecords t
    CROSS APPLY t.xmlPlus.nodes('ISO/PassportSvcRs/Reports/Report/ReportData/ISO/PassportSvcRs/PassportInqRs/Match/Claim/Loss') as a(b)
    CROSS APPLY t.xmlPlus.nodes('ISO/PassportSvcRs/Reports/Report/ReportData/ISO/PassportSvcRs/PassportInqRs/Match/Claim/Payment') as d(e)
WHERE a.b.value('(LossDt)[1]','date') BETWEEN @StartLossDate AND @EndLossDate
AND d.e.value('(LossTypeCd)[1]','varchar(4)') = 'TOWL'
ORDER BY PolicySysID asc;

The results that I'm getting is:

The TOP 2 records above do NOT HAVE a LossTypeCd of TOWL in the XML.
Any help/direction would be appreciated. I guess I'm confused on how the node definition in the CROSS APPLY is supposed to work.
Here is my XML:
<ISO>
    <PassportSvcRs>
        <Reports>
          <Report>
            <ReportData>
              <ISO>
                <PassportSvcRs>
                  <PassportInqRs>
                    <Match>
                      <Claim>
                        <Loss>
                          <LossDt>2020-11-01</LossDt>
                          <ClaimNumber>7842198101J20110105</ClaimNumber>
                        </Loss>
                        <Payment>
                          <CoverageCd>TOWL</CoverageCd>
                          <LossTypeCd>TOWL</LossTypeCd>
                          <ClaimStatusCd>C</ClaimStatusCd>
                          <LossPaymentAmt>78</LossPaymentAmt>
                        </Payment>
                      </Claim>
                    </Match>
                    <Match>
                      <Claim>
                        <Loss>
                          <LossDt>2020-10-28</LossDt>
                          <ClaimNumber>7842198101J20102805</ClaimNumber>
                        </Loss>
                        <Payment>
                          <CoverageCd>TOWL</CoverageCd>
                          <LossTypeCd>TOWL</LossTypeCd>
                          <ClaimStatusCd>C</ClaimStatusCd>
                          <LossPaymentAmt>78</LossPaymentAmt>
                        </Payment>
                      </Claim>
                    </Match>
                    <Match>
                      <Claim>
                        <Loss>
                          <LossDt>2020-10-03</LossDt>
                          <ClaimNumber>7842198101J20100305</ClaimNumber>
                        </Loss>
                        <Payment>
                          <CoverageCd>TOWL</CoverageCd>
                          <LossTypeCd>TOWL</LossTypeCd>
                          <ClaimStatusCd>C</ClaimStatusCd>
                          <LossPaymentAmt>78</LossPaymentAmt>
                        </Payment>
                      </Claim>
                    </Match>
                    <Match>
                      <Claim>
                        <Loss>
                          <LossDt>2019-10-21</LossDt>
                          <ClaimNumber>66203023279998</ClaimNumber>
                        </Loss>
                        <Payment>
                          <CoverageCd>COLL</CoverageCd>
                          <LossTypeCd>COLL</LossTypeCd>
                          <ClaimStatusCd>C</ClaimStatusCd>
                          <LossPaymentAmt>3963</LossPaymentAmt>
                        </Payment>
                      </Claim>
                    </Match>
                    <Match>
                      <Claim>
                        <Loss>
                          <LossDt>2019-05-26</LossDt>
                          <ClaimNumber>PTX19035829</ClaimNumber>
                        </Loss>
                        <Payment>
                          <CoverageCd>COMP</CoverageCd>
                          <LossTypeCd>COMP</LossTypeCd>
                          <ClaimStatusCd>C</ClaimStatusCd>
                          <LossPaymentAmt>0</LossPaymentAmt>
                        </Payment>
                      </Claim>
                    </Match>
                    <Match>
                      <Claim>
                        <Loss>
                          <LossDt>2018-10-16</LossDt>
                          <ClaimNumber>0522909605</ClaimNumber>
                        </Loss>
                        <Payment>
                          <CoverageCd>COLL</CoverageCd>
                          <LossTypeCd>COLL</LossTypeCd>
                          <ClaimStatusCd>C</ClaimStatusCd>
                          <LossPaymentAmt>0</LossPaymentAmt>
                        </Payment>
                        <Payment>
                          <CoverageCd>UM</CoverageCd>
                          <LossTypeCd>UM</LossTypeCd>
                          <ClaimStatusCd>C</ClaimStatusCd>
                          <LossPaymentAmt>0</LossPaymentAmt>
                        </Payment>
                      </Claim>
                    </Match>
                    <Match>
                      <Claim>
                        <Loss>
                          <LossDt>2017-11-05</LossDt>
                          <ClaimNumber>0481373215</ClaimNumber>
                        </Loss>
                        <Payment>
                          <CoverageCd>TOWL</CoverageCd>
                          <LossTypeCd>TOWL</LossTypeCd>
                          <ClaimStatusCd>C</ClaimStatusCd>
                          <LossPaymentAmt>23</LossPaymentAmt>
                        </Payment>
                      </Claim>
                    </Match>
                    <Match>
                      <Claim>
                        <Loss>
                          <LossDt>2017-10-07</LossDt>
                          <ClaimNumber>0478275043</ClaimNumber>
                        </Loss>
                        <Payment>
                          <CoverageCd>COLL</CoverageCd>
                          <LossTypeCd>COLL</LossTypeCd>
                          <ClaimStatusCd>C</ClaimStatusCd>
                          <LossPaymentAmt>2866</LossPaymentAmt>
                        </Payment>
                        <Payment>
                          <CoverageCd>RENT</CoverageCd>
                          <LossTypeCd>RENT</LossTypeCd>
                          <ClaimStatusCd>W</ClaimStatusCd>
                          <LossPaymentAmt>0</LossPaymentAmt>
                        </Payment>
                      </Claim>
                    </Match>
                    <Match>
                      <Claim>
                        <Loss>
                          <LossDt>2017-06-09</LossDt>
                          <ClaimNumber>JM177514</ClaimNumber>
                        </Loss>
                        <Payment>
                          <CoverageCd>COLL</CoverageCd>
                          <LossTypeCd>COLL</LossTypeCd>
                          <ClaimStatusCd>C</ClaimStatusCd>
                          <LossPaymentAmt>2374</LossPaymentAmt>
                        </Payment>
                      </Claim>
                    </Match>
                    <Match>
                      <Claim>
                        <Loss>
                          <LossDt>2016-01-16</LossDt>
                          <ClaimNumber>7842382435D16011605</ClaimNumber>
                        </Loss>
                        <Payment>
                          <CoverageCd>COLL</CoverageCd>
                          <LossTypeCd>COLL</LossTypeCd>
                          <ClaimStatusCd>C</ClaimStatusCd>
                          <LossPaymentAmt>4175</LossPaymentAmt>
                        </Payment>
                        <Payment>
                          <CoverageCd>RENT</CoverageCd>
                          <LossTypeCd>RENT</LossTypeCd>
                          <ClaimStatusCd>C</ClaimStatusCd>
                          <LossPaymentAmt>0</LossPaymentAmt>
                        </Payment>
                      </Claim>
                    </Match>
                  </PassportInqRs>
                </PassportSvcRs>
              </ISO>
            </ReportData>
          </Report>
        </Reports>
    </PassportSvcRs>
</ISO>

Thanks.

A: I do not believe the query contains logic to ensure that the payment data and loss data belong to the same claim.
Looking at the freshly posted XML, I see that claims may contain multiple payments, but (apparently) only one Loss. You may need one cross apply to select the claims, and then a second cross apply to select payments relative to each claim.
The following stripped down query seems to work.
DECLARE @Xml XML = '...' -- See posted XML above
DECLARE @tempXMLRecords TABLE(xmlPlus XML)
INSERT @tempXMLRecords VALUES (@Xml)
SELECT
    c.value('(Loss/LossDt)[1]','date') as LossDate
    , c.value('(Loss/ClaimNumber)[1]','varchar(max)') as ClaimNumber
    , p.value('(LossTypeCd)[1]','varchar(max)') as LossTypeCd
FROM @tempXMLRecords t
CROSS APPLY t.xmlPlus.nodes('ISO/PassportSvcRs/Reports/Report/ReportData/ISO/PassportSvcRs/PassportInqRs/Match/Claim') as C(c)
CROSS APPLY c.nodes('./Payment') as P(p)
ORDER BY 1,2,3

A: Please try the following solution.
It supports multiple payments for a single claim.
When it is happening the LossTypeCd column will have multiple claims.
If you don't need that it is very easy to adjust having just one single claim in that column.
SQL
DECLARE @tbl TABLE (ID INT IDENTITY PRIMARY KEY, xmlPlus XML);
INSERT INTO @tbl (xmlPlus) VALUES
(N'<?xml version="1.0"?>
<ISO>
    <PassportSvcRs>
        <Reports>
            <Report>
                <ReportData>
                    <ISO>
                        <PassportSvcRs>
                            <PassportInqRs>
                                <Match>
                                    <Claim>
                                        <Loss>
                                            <LossDt>2020-11-01</LossDt>
                                            <ClaimNumber>7842198101J20110105</ClaimNumber>
                                        </Loss>
                                        <Payment>
                                            <CoverageCd>TOWL</CoverageCd>
                                            <LossTypeCd>TOWL</LossTypeCd>
                                            <ClaimStatusCd>C</ClaimStatusCd>
                                            <LossPaymentAmt>78</LossPaymentAmt>
                                        </Payment>
                                    </Claim>
                                </Match>
                                <Match>
                                    <Claim>
                                        <Loss>
                                            <LossDt>2020-10-28</LossDt>
                                            <ClaimNumber>7842198101J20102805</ClaimNumber>
                                        </Loss>
                                        <Payment>
                                            <CoverageCd>TOWL</CoverageCd>
                                            <LossTypeCd>TOWL</LossTypeCd>
                                            <ClaimStatusCd>C</ClaimStatusCd>
                                            <LossPaymentAmt>78</LossPaymentAmt>
                                        </Payment>
                                    </Claim>
                                </Match>
                                <Match>
                                    <Claim>
                                        <Loss>
                                            <LossDt>2020-10-03</LossDt>
                                            <ClaimNumber>7842198101J20100305</ClaimNumber>
                                        </Loss>
                                        <Payment>
                                            <CoverageCd>TOWL</CoverageCd>
                                            <LossTypeCd>TOWL</LossTypeCd>
                                            <ClaimStatusCd>C</ClaimStatusCd>
                                            <LossPaymentAmt>78</LossPaymentAmt>
                                        </Payment>
                                    </Claim>
                                </Match>
                                <Match>
                                    <Claim>
                                        <Loss>
                                            <LossDt>2019-10-21</LossDt>
                                            <ClaimNumber>66203023279998</ClaimNumber>
                                        </Loss>
                                        <Payment>
                                            <CoverageCd>COLL</CoverageCd>
                                            <LossTypeCd>COLL</LossTypeCd>
                                            <ClaimStatusCd>C</ClaimStatusCd>
                                            <LossPaymentAmt>3963</LossPaymentAmt>
                                        </Payment>
                                    </Claim>
                                </Match>
                                <Match>
                                    <Claim>
                                        <Loss>
                                            <LossDt>2019-05-26</LossDt>
                                            <ClaimNumber>PTX19035829</ClaimNumber>
                                        </Loss>
                                        <Payment>
                                            <CoverageCd>COMP</CoverageCd>
                                            <LossTypeCd>COMP</LossTypeCd>
                                            <ClaimStatusCd>C</ClaimStatusCd>
                                            <LossPaymentAmt>0</LossPaymentAmt>
                                        </Payment>
                                    </Claim>
                                </Match>
                                <Match>
                                    <Claim>
                                        <Loss>
                                            <LossDt>2018-10-16</LossDt>
                                            <ClaimNumber>0522909605</ClaimNumber>
                                        </Loss>
                                        <Payment>
                                            <CoverageCd>COLL</CoverageCd>
                                            <LossTypeCd>COLL</LossTypeCd>
                                            <ClaimStatusCd>C</ClaimStatusCd>
                                            <LossPaymentAmt>0</LossPaymentAmt>
                                        </Payment>
                                        <Payment>
                                            <CoverageCd>UM</CoverageCd>
                                            <LossTypeCd>UM</LossTypeCd>
                                            <ClaimStatusCd>C</ClaimStatusCd>
                                            <LossPaymentAmt>0</LossPaymentAmt>
                                        </Payment>
                                    </Claim>
                                </Match>
                                <Match>
                                    <Claim>
                                        <Loss>
                                            <LossDt>2017-11-05</LossDt>
                                            <ClaimNumber>0481373215</ClaimNumber>
                                        </Loss>
                                        <Payment>
                                            <CoverageCd>TOWL</CoverageCd>
                                            <LossTypeCd>TOWL</LossTypeCd>
                                            <ClaimStatusCd>C</ClaimStatusCd>
                                            <LossPaymentAmt>23</LossPaymentAmt>
                                        </Payment>
                                    </Claim>
                                </Match>
                                <Match>
                                    <Claim>
                                        <Loss>
                                            <LossDt>2017-10-07</LossDt>
                                            <ClaimNumber>0478275043</ClaimNumber>
                                        </Loss>
                                        <Payment>
                                            <CoverageCd>COLL</CoverageCd>
                                            <LossTypeCd>COLL</LossTypeCd>
                                            <ClaimStatusCd>C</ClaimStatusCd>
                                            <LossPaymentAmt>2866</LossPaymentAmt>
                                        </Payment>
                                        <Payment>
                                            <CoverageCd>RENT</CoverageCd>
                                            <LossTypeCd>RENT</LossTypeCd>
                                            <ClaimStatusCd>W</ClaimStatusCd>
                                            <LossPaymentAmt>0</LossPaymentAmt>
                                        </Payment>
                                    </Claim>
                                </Match>
                                <Match>
                                    <Claim>
                                        <Loss>
                                            <LossDt>2017-06-09</LossDt>
                                            <ClaimNumber>JM177514</ClaimNumber>
                                        </Loss>
                                        <Payment>
                                            <CoverageCd>COLL</CoverageCd>
                                            <LossTypeCd>COLL</LossTypeCd>
                                            <ClaimStatusCd>C</ClaimStatusCd>
                                            <LossPaymentAmt>2374</LossPaymentAmt>
                                        </Payment>
                                    </Claim>
                                </Match>
                                <Match>
                                    <Claim>
                                        <Loss>
                                            <LossDt>2016-01-16</LossDt>
                                            <ClaimNumber>7842382435D16011605</ClaimNumber>
                                        </Loss>
                                        <Payment>
                                            <CoverageCd>COLL</CoverageCd>
                                            <LossTypeCd>COLL</LossTypeCd>
                                            <ClaimStatusCd>C</ClaimStatusCd>
                                            <LossPaymentAmt>4175</LossPaymentAmt>
                                        </Payment>
                                        <Payment>
                                            <CoverageCd>RENT</CoverageCd>
                                            <LossTypeCd>RENT</LossTypeCd>
                                            <ClaimStatusCd>C</ClaimStatusCd>
                                            <LossPaymentAmt>0</LossPaymentAmt>
                                        </Payment>
                                    </Claim>
                                </Match>
                            </PassportInqRs>
                        </PassportSvcRs>
                    </ISO>
                </ReportData>
            </Report>
        </Reports>
    </PassportSvcRs>
</ISO>');
-- DDL and sample data population, end

DECLARE @StartLossDate DATE = '2018-12-15'
    , @EndLossDate DATE = CAST(GETDATE() AS DATE);

SELECT ID
    , c.value('(Loss/LossDt/text())[1]', 'DATE') AS LossDate
    , c.value('(Loss/ClaimNumber/text())[1]', 'VARCHAR(100)') AS ClaimNumber
    , c.query('data(Payment/LossTypeCd)').value('.', 'VARCHAR(100)') AS LossTypeCd
FROM @tbl
    CROSS APPLY xmlplus.nodes('/ISO/PassportSvcRs/Reports/Report/ReportData/ISO/PassportSvcRs/PassportInqRs/Match/Claim') AS t(c)
WHERE c.value('(Loss/LossDt/text())[1]', 'DATE') BETWEEN @StartLossDate AND @EndLossDate
    AND c.exist('Payment/LossTypeCd[./text()="TOWL"]') = 1;

Output
+----+------------+---------------------+------------+
| ID |  LossDate  |     ClaimNumber     | LossTypeCd |
+----+------------+---------------------+------------+
|  1 | 2020-11-01 | 7842198101J20110105 | TOWL       |
|  1 | 2020-10-28 | 7842198101J20102805 | TOWL       |
|  1 | 2020-10-03 | 7842198101J20100305 | TOWL       |
+----+------------+---------------------+------------+


text:
Q: Newsletter subscribe/unsubscribe email notification event observer I am writing my own admin email notifications module.
So far it has New Order and Low Stock observers set up and working just fine.
I want to add the Newsletter subscribe/unsubscribe observer to it and what I have works fine but when changing newsletter subscription status of a Customer (by saving the Customer in dashboard) it seems to send notification emails twice (first with current subscription status and then for new changed one ... for example if I change customer from Subscribed to Unsubscribed it will send email that there is new subscriber then email that subscriber has been unsubscribed
Observer
<?php
namespace Hapex\AdminEmailNotifications\Observer;

use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Stdlib\DateTime\DateTime;
use Hapex\AdminEmailNotifications\Helper\Data;
use Hapex\AdminEmailNotifications\Helper\Email;
use Magento\Framework\Message\ManagerInterface;

class NewsletterObserver implements ObserverInterface
{

    protected $date;

    protected $helperData;

    protected $helperEmail;

    protected $messageManager;

    public function __construct(
        DateTime $date,
        Data $helperData,
        Email $helperEmail,
        ManagerInterface $messageManager
    ) {
        $this->date = $date;
        $this->helperData = $helperData;
        $this->helperEmail = $helperEmail;
        $this->messageManager = $messageManager;
    }

    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        try {
            $event = $observer->getEvent();
            $subscriber = $event->getSubscriber();
            $enable = $this->helperData->isEnabled();
            if ($enable)
            {
                $subscriberStatus = $subscriber->getSubscriberStatus();
                // subscriberStatus = 1 subscribe
                // subscriberStatus = 3 unsubscribed
                if ($subscriberStatus == '1'  && $this->helperData->isNewsletterSubscribeEnabled())
                {
                    $this->sendMailNewsletterSubscribe($subscriber);
                }
                else if ($subscriberStatus == '3' && $this->helperData->isNewsletterUnsubscribeEnabled())
                {
                    $this->sendMailNewsletterUnsubscribe($subscriber);
                }
            }
        }
        catch (\Exception $e) {
                $this->messageManager->addErrorMessage("Error : " . $e->getMessage());
        }
    }

    private function sendMailNewsletterSubscribe($subscriber)
    {
        try {
            $storeId = $subscriber->getStoreId();
            $email = $subscriber->getEmail();
            $receivers = $this->helperData->getNewsletterReceivers($storeId);
            $emailTemplate = $this->helperData->getNewsletterSubscribeEmailTemplate($storeId);
            $templateVar = ['varEmail' => 'Email: '.$email,];
            $this->helperEmail->sendEmail($receivers, $emailTemplate, $templateVar, $storeId);
        }
        catch (\Exception $e) {
                $this->messageManager->addErrorMessage("Error : " . $e->getMessage());
        }
    }

    private function sendMailNewsletterUnsubscribe($subscriber)
    {
        try {
            $storeId = $subscriber->getStoreId();
            $email = $subscriber->getEmail();
            $receivers = $this->helperData->getNewsletterReceivers($storeId);
            $emailTemplate = $this->helperData->getNewsletterUnsubscribeEmailTemplate($storeId);
            $templateVar = ['varEmail' => 'Email: '.$email,];
            $this->helperEmail->sendEmail($receivers, $emailTemplate, $templateVar, $storeId);
        }
        catch (\Exception $e) {
                $this->messageManager->addErrorMessage("Error : " . $e->getMessage());
        }
    }
}

Event
<event name="newsletter_subscriber_save_after">
        <observer name="hapex_newsletter_observer" instance="Hapex\AdminEmailNotifications\Observer\NewsletterObserver" />
    </event>

Is there a good way to maybe save the status before the event triggered then take it in the observer and if it has changed do its thing so it will fire only once ... any other way to make so it doesn't fire twice on Customer update?
Thanks

A: You can use plugin for this, like I have created a plugin where only when customer get unsubscribe from frontend then I have added some customization, for this I have added plugin for
Magento\Newsletter\Model\Subscriber

Class's unsubscribe() method with after plugin
My code is, In di.xml
<type name="Magento\Newsletter\Model\Subscriber">
        <plugin disabled="false" name="Nerdsinn_Queue_Plugin_Magento_Newsletter_Model_Subscriber" sortOrder="10" type="Nerdsinn\Queue\Plugin\Magento\Newsletter\Model\Subscriber"/>
    </type>

and then in /Nerdsinn/Queue/Plugin/Magento/Newsletter/Model/Subscriber.php
namespace Nerdsinn\Queue\Plugin\Magento\Newsletter\Model;

/**
 * Class Subscriber
 *
 * @package Nerdsinn\Queue\Plugin\Magento\Newsletter\Model
 */
class Subscriber
{

    public function afterUnsubscribe(
        \Magento\Newsletter\Model\Subscriber $subject,
        $result
    ) {
        //Your plugin code
        return $result;
    }
}

Here on $result you can getData() to access available data


text:
Q: Real projective plane isomorphic to quotient space of sphere Show that the real projective plane $\mathbb{R}P^2$ is homeomorphic to $S^2/ \langle x \sim -x \rangle$.
I know that $S^2/ \langle x \sim -x \rangle$ is the quotient space of the quotient map $g:S^2 \rightarrow S^2/\langle x \sim -x \rangle$, given by $g(x)=\{x,-x\}$ for all $x \in S^2$. So to construct a homeomorphism $f:\langle x \sim -x \rangle \rightarrow \mathbb{R}P^2$, I would define $f(\{x,-x\})=tx$. Where $t$ is a parameter.
Then similarly to the last homeomorphism problem I did, I want to show that $f$ is a continuous bijection from a compact space to a Hausdorff space. I know $S^2/\langle x \sim -x \rangle$ is compact since it is the surjective image of the continuous quotient map $g$ and $S^2$ is compact. I know $\mathbb{R}P^2$ is Hausdorff, but the proof seems difficult.
$f$ is injective since $f(\{x,-x\})=f(\{y,-y\})\implies tx=ty \implies \{x,-x\}=\{y,-y\}$.
$f$ is surjective, since given any $tx \in \mathbb{R}P^2$, $\tilde{x}=\frac{x}{||x||} \in S^2$, so that $f(\{\tilde{x},-\tilde{x}\})=tx$.
Then all that is left to show is that $f$ is continuous (after showing that $\mathbb{R}P^2$ is Hausdorff), how should I go about showing that $f$ is continuous? Normally I would use a theorem and the projection functions to do this, but I know that the projective plane cannot be embedded into $\mathbb{R}^3$, so I do not think this would suffice.
I want to use the following to show continuity:if $q: X \to Y$ is a quotient map then $g: Y \to Z$ is continuous iff $g \circ q: X \to Z$ is continuous. So continuity from a quotient space is determined by the composition with the quotient map.
I tried to show the composition mapping $f \circ g:S^2 \rightarrow \mathbb{R}P^2$ is continuous, but this map is given by $(f\circ g)(x)=tx$ so I do not know how continuity would follow from that.
Also I know that a basis for $\mathbb{R}P^2$ is given by the collection of subsets of lines specified by open double cones with the cone point at the origin, so I think it would be difficult to show if $U$ is open in $\mathbb{R}P^2$ then $f^{-1}(U)$ is open in $S^2/\langle x \sim -x \rangle$. Any ideas?


text:
Q: How can I create new book and assign two authors with it using Rails miniTest? Doing TDD
I facing a problem creating a book and assigning two authors with it. There is a failure in the creation. It says that there is an AssociationTypeMismatch: Author(#15100) expected, got nil which is an instance of NilClass(#40. I suppose that the format "authors: []" is not have been read well by something.
This is the test:
def test_has_many_and_belongs_to_mapping
 apress = Publisher.find_by(name: 'Apress')
 assert_equal 2, apress.books.size

 book = Book.new(
  title: 'Rails E-Commerce 3nd Edition',
  authors: [
    Author.find_by(first_name: 'Christian', last_name: 'Hellsten'),
    Author.find_by(first_name: 'Jarkko', last_name: 'Laine')
  ],
  published_at: Time.now,
  isbn: '123-123-123-x',
  blurb: 'E-Commerce on Rails',
  page_count: 300,
  price: 30.5
 )

 # apress.books << book

 # apress.reload
 # book.reload

 # assert_equal 3, apress.books.size
 # assert_equal 'Apress', book.publisher.name
end

This is the error:

MY ERD:

My schema:

A: I think what you are missing is a meaningful setup of data needed before this test runs. Even though those publishers and books may exist in your development environment/database, the test suite usually is configured to wipe the database clean between runs.
If you have fixtures defined, then you can reference them like this:
test/fixtures/publishers.yml
apress:
  id: 1
  name: Apress

test/fixtures/authors.yml
hellsten:
  id: 1
  first_name: Christian
  last_name: Hellsten

laine:
  id: 2
  first_name: Jarkko
  last_name: Laine

test/fixtures/books.yml
beginning_ruby:
  title: Beginning Ruby
  publisher_id: 1

ruby_recipes:
  title: Ruby Recipes
  publisher_id: 1

So that the test would look more like this:
def test_has_many_and_belongs_to_mapping
 apress = publishers(:apress)
 assert_equal 2, apress.books.size

 book = Book.new(
  title: 'Rails E-Commerce 3nd Edition',
  authors: [
    Author.find_by(first_name: 'Christian', last_name: 'Hellsten'),
    Author.find_by(first_name: 'Jarkko', last_name: 'Laine')
  ],
  published_at: Time.now,
  isbn: '123-123-123-x',
  blurb: 'E-Commerce on Rails',
  page_count: 300,
  price: 30.5
 )

 apress.books << book

 apress.reload
 book.reload

 assert_equal 3, apress.books.size
 assert_equal 'Apress', book.publisher.name
end

Or instead of using fixtures, you could create the content before the test:
So that the test would look more like this:
setup do
  publisher = Publisher.create!(name: 'Apress')
  publisher.books.create!(title: 'Beginning Ruby')
  publisher.books.create!(title: 'Ruby Recipes')
  Author.create!(first_name: 'Christian', last_name: 'Hellsten')
  Author.create!(first_name: 'Jarkko', last_name: 'Laine')
end

def test_has_many_and_belongs_to_mapping
 apress = Publisher.find_by(name: 'Apress')
 assert_equal 2, apress.books.size

 book = Book.new(
  title: 'Rails E-Commerce 3nd Edition',
  authors: [
    Author.find_by(first_name: 'Christian', last_name: 'Hellsten'),
    Author.find_by(first_name: 'Jarkko', last_name: 'Laine')
  ],
  published_at: Time.now,
  isbn: '123-123-123-x',
  blurb: 'E-Commerce on Rails',
  page_count: 300,
  price: 30.5
 )

 apress.books << book

 apress.reload
 book.reload

 assert_equal 3, apress.books.size
 assert_equal 'Apress', book.publisher.name
end

That way your database has those values, and your find_by() calls should return data, and not nil.


text:
Q: Persistent OPcache in CLI mode I have a PHP script that executes background script in CLI mode via:
exec('php file.php > /dev/null &');
OPcache is enabled in both modes, however I have noticed that in cli mode opcache resets on every call. Is it possible to make it persist? If not, what's the point of enabling opcache in cli mode?


text:
Q: Excel VBA, 2003 - Convert string to 2-dimensional array I inherited an old Excel (.xls) spreadsheet starting from 2005.
For some reason the spreadsheet uses the name manager for quite large data stored as strings instead of referring to a table with the data. This is what I am trying to change so it will be easier to change the data currently stored in the name manager (at the moment it is not possible to change any of the data as the character limit in the name manager has somehow been exceeded).
I would like to make use of as much of the current VBA code as possible which is why I currently have a setup where I use VBA to convert data from the spreadsheet to a string in the form of
"CELL"\"CELL"\"...""CELL";"CELL"\"CELL"\"CELL";

Where I (or the old code) make use of backslash, \, as a delimiter for a new column and semicolon, ;, as a delimiter for a new row.
I want to convert my string to an 2-dimensional array called 'arkArray' so I can make use of the following code:
arkCellData = arkArray(i, j)

What is the best way to do so?

A: Here is a typical method:
Sub Fill2D()
    Dim s As String, r As Range
    Dim kolumn As Long, roww As Long
    Dim arr1, arr2, a1, a2

    kolumn = 0
    roww = 1
    s = "alpha\beta\gamma;mike\jim\john;red\blue\green"

    arr1 = Split(s, ";")

    For Each a1 In arr1
        roww = 1
        kolumn = kolumn + 1
        arr2 = Split(a1, "\")
        For Each a2 In arr2
            Cells(roww, kolumn) = a2
            roww = roww + 1
        Next a2
    Next a1

End Sub

(you would change the starting values of kolumn and roww to pick a different starting point)
Once the 2-D array is in cells, you would verify it and then copy it into an internal VBA array.

A: How to make a two dimensional array.
Sub test()
    Dim myArray(), vS, vS2
    Dim vMax()
    Dim s As String
    Dim myMax As Integer, i As Integer,  j As Integer
    Dim r As Long

    s = "apple\banana\John;some\reason\use\Tom;table\data\limit;"

    If Right(s, 1) = ";" Then
        s = Left(s, Len(s) - 1)
    End If

    vS = Split(s, ";")
    ReDim vMax(UBound(vS))

    For i = 0 To UBound(vS)
        vS2 = Split(vS(i), "\")
        vMax(i) = UBound(vS2) + 1
    Next i

    myMax = WorksheetFunction.Max(vMax)
    r = UBound(vS) + 1

    ReDim myArray(1 To r, 1 To myMax)

    For i = 1 To UBound(myArray)
        vS2 = Split(vS(i - 1), "\")
        For j = 1 To UBound(vS2) + 1
            myArray(i, j) = vS2(j - 1)
        Next j
    Next i
    Range("a1").Resize(r, myMax) = myArray

End Sub


text:
Q: Overriding argparse -h behaviour part 2 I am using python's argparse and would like to use the -h flag for my own purposes. Here's the catch -- I still want to have --help be available, so it seems that parser = argparse.ArgumentParser('Whatever', add_help=False) is not quite the solution.
Is there an easy way to re-use the -h flag while still keeping the default functionality of --help?

A: Initialize ArgumentParser with add_help=False, add --help argument with action="help":
import argparse

parser = argparse.ArgumentParser(add_help=False)
parser.add_argument('--help', action="help")
parser.add_argument('-h', help='My argument')

args = parser.parse_args()
...

Here's what on the command-line:
$ python test_argparse.py --help
usage: test_argparse.py [--help] [-h H]

optional arguments:
  --help
  -h H    My argument

Hope this is what you need.


text:
Q: How to read an argument at a server from a telnet client in socket programming c Here's the scenario:
I connect to a server using telnet utility in Linux. After the connection is established client should enter and argument which should be read by a server.
Here's the server code:
int main(void)
{
int new_fd;
char *string;
// Establish the connection

if (send(new_fd, "Enter Command: ", 15, 0) == -1)
            perror("send");

// Here I want to accept the argument from the server
return 0;
}

When I telnet into server using: telnet servername portnumber
client receives : Enter Command: in front of which I want to type in the argument.
for e.g. Enter Command: Hey There!
All I want to do is read Hey There! store it in string at the server and print it. How can I do that?

A: To receive anything over a socket you'll need to call recv and check that for as long as the return value is larger than 0, you write the incoming data to wherever you wish.
 ssize_t recv(int sockfd, void *buf, size_t len, int flags);

These calls return the number of bytes received, or -1 if an error occurred. The return value will be 0 when the peer has performed an orderly shutdown.

From here


text:
Q: ¿Porqué devuelve NULL si en la BD existe un valor? Estoy haciendo una cuenta de usuario donde puede ver sus detalles de suscripción.
Al  hacer el pago se le asigna un ID único y este valor se inserta correctamente en la tabla de BD subscriptions.
El problema viene cuando el usuario accede a su cuenta mediante un link, no se recupera el valor de este ID único ($unique_id).
Haciendo var_dump arroja NULL y con otros campos no da NULL.
¿Dónde puede estar el fallo?
index.php
<?php

$sql2 = "SELECT unique_id,status FROM subscriptions";
$result2 = $mysqli->query($sql2);
$row2=$result2->fetch_assoc();
$status= $row2["status"];
$unique_id = $row2["unique_id"];
?>

<a href="pago/manage.php?subscription_id=<?php echo $unique_id; ?>">Mi cuenta

manage.php
En esta página deberia  mostrar el valor del ID único ($unique_id) pero sale NULL:
 <?php
$sql2 = "SELECT unique_id,status FROM subscriptions";
$result2 = $mysqli->query($sql2);
$row2=$result2->fetch_assoc();
$status= $row2["status"];
$unique_id = $row2["unique_id"];

var_dump($unique_id);
?>

A: si entiendo bien tu pregunta lo que sucede es cuando regresas por medio del link a el detalle de la subscripción te muestra NULL.
Lo que veo en este código es que en manage.php te falta colocar el WHERE en tu consulta.
$sql2 = "SELECT unique_id,status FROM subscriptions";
debería estar de la siguiente forma.
$sql2 = "SELECT unique_id,status FROM subscriptions WHERE unique_id='id'";

con esto recuperara los datos de la transacción que enviaste mediante el link.


text:
Q: Assign part of BufferedImage to another BufferedImage I am doing one application in Java and I want to do this:
I have a BufferedImage with a large image loaded and I want to assign a part of it to another BufferedImage.
Let's say
BufferedImage2 = BufferedImage1.GetWindow(From x1 y1  to x2 y2);

BufferedImage2 will be just a small part of the greater BufferedImage1.

A: You could try BufferedImage.getSubimage()
int width = x2 - x1;
int height = y2 - y1;
BufferedImage bufferedImage2 = bufferedImage1.getSubimage(x1, y1, width, height);

A: For instance drawing in the image buffer:
BufferedImage img2 = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = img2.createGraphics();
g.drawImage(bufferedImage1, x, y, width, height, null);
g.dispose();

There are several drawImage methods, see the javadoc. You probably want this drawImage.


text:
Q: if a VNC server connection failed, would an active process keep running? This may be a silly question,

*

*If I am running infinite loop processes in a shell from a VNC created desktop ubuntu GUI. After some time if the VNC server was not able to connect (because of a brute force attack or something, with error - connection refused), Will the processes still be running? or does it gets killed?

*If i use nomachine, and nomachine gets hung, will the process running, get killed, or will it be still running on the server?
Note : I use cronjobs to trigger python scripts which will run all day, so stability is important, hence above questions

A: Connections can be refused for many reasons. Attempting to connect to the wrong port, or the VNC service might be down, or the machine might be so CPU bound that it times out before responding.
Have you tried to ssh to the machine, using a command line instead of VNC? That will tell you a lot. If ssh also fails the problem is not with VNC. From ssh, run top and look at the load at the top right of the screen. Load factors over 1.0 could be problematic.
http://www.brendangregg.com/blog/2017-08-08/linux-load-averages.html
It is more likely that other problems are causing the issue, instead of an attack.

A: if server is up the things you do on VNC should be up and running


text:
Q: Xcode build number for new version Hope it's not off topic question. So usually I use my version for app:

*

*1.0

*1.1

*1.2

So let's say I uploaded 50 builds to iTunes for the version 1.0
So it means that latest version of app has kind of 1.0.50 (indicating that the last build is 50)
So my question is should I bump build number for new version 1.1 to make it 1.1.1 or do I need to use 1.1.51 because previous build was 50.
Doest it make sense, is there any rules about it? I know that technically there is no worry about it, but if we say about some system and about team that usually want to check latest build or kind of maybe we should follow with some build number rules.

A: I use following:
AppName_<Major>.<Minor>.<Patch/Upgrade>.<BuildNo>

Major - Major version is a definite release of the product. It increased when there are significant changes in functionality.
Minor - Minor version is incremented when only new features or major bug fixes have been added.
Upgrade/Patch - Upgrade refers to the replacement of a product with a newer version of product.It is incremented only when upgrade is provided on designated major release.Patch version starts with 0 and incremented only when bug has been resolved.
Build No - Build Number is incremented when new build is created.


text:
Q: Running a function on every page in head tag Nuxt Js I have managed to make my function accessible using the plugin attribute in the nuxt.config.js file and can then call the function under mounted on each page.
I need this function to run in the head tag and be accessible on each page.
Is there a quick way for me to do this rather than just adding to each page individually?
I tried adding it as a script under the head section in the nuxt.config.js but that caused me some problems as the script needed to contain a function.
Thanks!

A: To run a function every route, you can use watch route in your root layout
watch: {
  $route() {
    //logic go here
  }
}


text:
Q: kestrel + nginx intermittent 502 I have an ASP.NET core 1.0 app running on ubuntu 16.04 behind nginx/1.10.0. However, I notice that intermittently nginx throws the following error (in nginx error-log)
2017/06/08 05:19:19 [error] 11572#11572: *119049 upstream prematurely closed connection while reading response header from upstream, client: <ipaddress>, server: <servername>, request: "POST /<uri> HTTP/1.1", upstream: "http://127.0.0.1:5000/<uri>", host: "<servername>"

which results in a 502 Bad Gateway to the client although the request completes successfully in the application
2017-06-08 05:19:14.399 [DBG] Executed action method "<Controller.Action>", returned result "Microsoft.AspNetCore.Mvc.CreatedAtRouteResult

Could this be an nginx configuration issue or ASP.NET/Kestrel issue? Can someone give me hints to debug this?
Further notes:
I also see the following in the application log just after request completion
2017-06-08 05:19:14.399 [DBG] Executed action method "<Controller.Action>", returned result "Microsoft.AspNetCore.Mvc.CreatedAtRouteResult
2017-06-08 05:19:18.632 [DBG] Some connections failed to close gracefully during server shutdown.
2017-06-08 05:19:22.402 [DBG] Hosting starting
2017-06-08 05:19:22.689 [DBG] Hosting started

and the nginx error is just around the same time 2017/06/08 05:19:19
Also, normally in the logs I see messages around Executing ObjectResult and Executed time etc. which I don't see with the above request
2017-06-08 00:10:14.391 [DBG] Selected output formatter '"Microsoft.AspNetCore.Mvc.Formatters.JsonOutputFormatter"' and content type '"application/json"' to write the response.
2017-06-08 00:10:14.391 [INF] Executing ObjectResult, writing value "Microsoft.AspNetCore.Mvc.ControllerContext".
2017-06-08 00:10:14.504 [INF] Executed action "<Controller.Action>" in 1875.3845ms


text:
Q: Google Chrome Plugin development - Monitor network requests? Is it possible to monitor network traffic with a google chrome plugin for the local page? For example, I want to monitor every time a web page requests a specific file (based on regex match), and if a user clicks the plugin, it opens a new tab to that file.

A: The "proper" way would be to use webRequest API, but it is still experimental:
//background.html
chrome.experimental.webRequest.onCompleted.addListener(function(details) {
    console.log("resource", details.url);
});

Meanwhile you can catch resources that are loading with the following code:
document.addEventListener("beforeload", function(event) {
    console.log("resource", event.url);
}, true);

This needs to go into a content script that runs with "run_at": "document_start".


text:
Q: Django render to new template is not working I am trying to render new template 'quesHome.html' via jquery ajax call. But page is not redirected to quesHome page. Also i am not getting any errors. I am a beginner to Django please correct me if i am wrong.
Below is my view:
def getSearchQuesions(req):
    print("getSearchQuesions")
    topic = Topic.objects.all()
    form = CreateQuestion()
    ques_id = req.GET['ques_id']
    question = Question.objects.filter(pk=ques_id)
    return render(req,'quesHome.html',{'topic':topic ,'question':question,'form':form})

Below is my js code:
function getFilteredQuestions(ques_id) {
    $.ajax({
        type: 'GET',
        url: '/getSearchQuesions/',
        data: { "ques_id": ques_id },
        success: function () {
            console.log("success");
        }
    });
}

Below is my urls.py:
 url(r'^getSearchQuesions/$', for_views.getSearchQuesions, name='getSearchQuesions'),

Below is my quesHome.html:
{%extends 'master_page.html'%}
{% block quesHome %}

            <input type="hidden" value="{%csrf_token%}" id="hid_csrf" />
            {% for t in topic %}

{{t.name}}

            {% endfor %}

            {% for q in question %}

{{q.name}}

{{q.answer}}

            {% endfor %}

{% endblock %}

A: You're sending a return to the ajax query which is then going to try and do something with it.
Instead of using the ajax call, try something like:
window.location = '/getSearchQuesions/'+ques_id

A: What you are doing is making a request via ajax and your view is returning a template. You are expecting a redirection to the page with the question id. You can simply not make this ajax call and if there is a link to which you intended to bind this ajax, let it behave normally if it is an anchor tag. Because then you will be redirected without having the need for ajax call.


text:
Q: Windows 10 microsoft account and local account I got a new laptop and while setting it up, it asked microsoft account. So I gave my microsoft account. Now I could use the laptop using that account for regular browsing and other activities. But the problem is when I am trying to execute some commands, it says I am not administrator or I need to run the cmd as administrator.
What I don't get is, I am logging into the windows using microsoft account. I see a folder in C:/Users/. Now am I a local user or a admin user?
Microsoft account creates a local user by default for windows?
Why do I need to run command prompt as an administrator for some commands? Am I not admin for my own system? If not, who am I while using the system? Microsoft account user or local user?

A: The first Windows Account (Vista and above) is a member of the Administrator's group. Check that but it will be if this was the first user.
That said, some programs still require approval to run (I have several here) so if you are being challenged for a few - no issue.
This is true (and the same) for a Microsoft Account and a Local Account. They work the same way

A: To get you out of this situation of not having an administrator account,
the following procedure is used when a local administrator loses his rights
and may also work in your case. You will be creating a new local account
and giving it administrator permissions, then you can login using this new
account as administrator.

*

*Open Settings > Accounts > Family & other users

*Click Add someone else to this PC

*Click I don't have this person's sign-in information

*Click Add a user without a Microsoft account

*Type a user name and click Next to add a new local account (non-admin)

*Press Win+R and in the Run dialog type cmd and hit
Enter

*In the Command Prompt type shutdown /r /o and press Enter

*After Windows 10 restarts, in the "Choose an option" screen, click
Troubleshoot > Advanced options > Startup Settings and then click Restart

*On the "Startup Settings" screen, press 4 to enable Safe mode

*After Windows 10 starts into safe mode:

*

*Open Control Panel

*Go to User Accounts > Manage another account

*Select the new local account you added and click Change the account type

*Select Administrator and click Change Account Type to change the account from a standard user to an administrator

*Restart into normal mode and sign-in with the new Administrator account.

For more details with screenshots see the article
Lost Administrator Rights in Windows 10, What to Do.


text:
Q: Trouble navigating to main class with Heroku/Procfile I am trying to navigate to my main class file in order to host it through Heroku but I cannot seem to navigate to it through my Procfile.
   2020-07-14T00:26:21.819970+00:00 heroku[web.1]: Starting process with command `java -cp target/classes/com/marcuzzo/JDABot Bot.class`
    2020-07-14T00:26:22.000000+00:00 app[api]: Build succeeded
    2020-07-14T00:26:23.780252+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
    2020-07-14T00:26:23.783762+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
    2020-07-14T00:26:23.872167+00:00 app[web.1]: Error: Could not find or load main class Bot.class
    2020-07-14T00:26:23.928585+00:00 heroku[web.1]: Process exited with status 1
    2020-07-14T00:26:23.978108+00:00 heroku[web.1]: State changed from starting to crashed
    2020-07-14T00:26:23.982448+00:00 heroku[web.1]: State changed from crashed to starting
    2020-07-14T00:26:26.759237+00:00 heroku[web.1]: Starting process with command `java -cp target/classes/com/marcuzzo/JDABot Bot.class`
    2020-07-14T00:26:29.372233+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
    2020-07-14T00:26:29.378057+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
    2020-07-14T00:26:29.489053+00:00 app[web.1]: Error: Could not find or load main class Bot.class
    2020-07-14T00:26:29.564012+00:00 heroku[web.1]: Process exited with status 1
    2020-07-14T00:26:29.609043+00:00 heroku[web.1]: State changed from starting to crashed

Procfile: web: java -cp target/classes/com/marcuzzo/JDABot Bot.class
POM File:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.marcuzzo</groupId>
  <artifactId>JDABot</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>JDABot</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>net.dv8tion</groupId>
        <artifactId>JDA</artifactId>
        <version>4.2.0_178</version>
    </dependency>
  </dependencies>
  <repositories>
    <repository>
    <id>jcenter</id>
    <name>jcenter-bintray</name>
    <url>https://jcenter.bintray.com</url>
</repository>
  </repositories>
<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.1</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>com.marcuzzo.JDABot</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Even though my main class path is target/classes/com/marcuzzo/JDABot/Bot.class it doesn't seem to be able to find it. Can anyone tell me why this is?
EDIT:
Directory = C:\Users\mattm\Desktop\Projects\JDABot
Path of Bot.class:
C:\Users\mattm\Desktop\Projects\JDABot\target\classes\com\marcuzzo\JDABot
EDIT: Heroku Logs

     2020-07-14T01:15:55.000000+00:00 app[api]: Build started by user mattmarcuzzo@gmail.com
2020-07-14T01:16:11.013386+00:00 app[api]: Deploy 3b17fa92 by user mattmarcuzzo@gmail.com
2020-07-14T01:16:11.013386+00:00 app[api]: Release v43 created by user mattmarcuzzo@gmail.com
2020-07-14T01:16:11.546025+00:00 heroku[web.1]: State changed from crashed to starting
2020-07-14T01:16:13.000000+00:00 app[api]: Build succeeded
2020-07-14T01:16:14.216417+00:00 heroku[web.1]: Starting process with command `sh -c "java -cp target/classes/ com.marcuzzo.JDABot"`
2020-07-14T01:16:16.606060+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2020-07-14T01:16:16.619387+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2020-07-14T01:16:16.757017+00:00 app[web.1]: Error: Could not find or load main class com.marcuzzo.JDABot
2020-07-14T01:16:16.820083+00:00 heroku[web.1]: Process exited with status 1
2020-07-14T01:16:16.859983+00:00 heroku[web.1]: State changed from starting to crashed
2020-07-14T01:16:16.862873+00:00 heroku[web.1]: State changed from crashed to starting
2020-07-14T01:16:20.017311+00:00 heroku[web.1]: Starting process with command `sh -c "java -cp target/classes/ com.marcuzzo.JDABot"`

EDIT:
C:\Users\mattm\Desktop\Projects\JDABot\target\classes\com\marcuzzo\JDABot

07/13/2020  07:17 PM    <DIR>          .
07/13/2020  07:17 PM    <DIR>          ..
07/13/2020  07:10 PM               782 Bot.class
               1 File(s)            782 bytes
               2 Dir(s)  39,904,493,568 bytes free`


text:
Q: c++ .NET background worker invoke I'm trying to change mu UI control using a backgroundworker. I read about Control->Invoke() class but I don't know ho to use it in C++.
This is what I got:
System::Void check_new() {
                p = ((Label^)napisy[IdNadawca])->Location;
                System::Windows::Forms::PictureBox^ pb = (gcnew System::Windows::Forms::PictureBox());
                koperty[System::Convert::ToInt32(((Label^)napisy[IdNadawca])->Name)] = pb;
                pb->Location = System::Drawing::Point(p);
                pb->Left = 755;
                pb->Name = (System::Convert::ToString(IdNadawca));
                pb->Size = System::Drawing::Size(30, 20);
                pb->TabIndex = 2;
                pb->TabStop = false;
                pb->Image= (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"koperta_mala")));
                Controls->Add(pb);
            }

This function (called by backgroundworker) creates a picturebox in UI.
The thing is, I don't know how to access UI using background thread.


text:
Q: Find the longest subsequence containing as many 1 as 0 time O(n) I had a question in an interview and I couldn't find the optimal solution (and it's quite frustrating lol)
So you have a n-list of 1 and 0.
110000110101110..
The goal is to extract the longest sub sequence containing as many 1 as 0.
Here for example it is "110000110101" or "100001101011" or "0000110101110"
I have an idea for O(n^2), just scanning all possibilities from the beginning to the end, but apparently there is a way to do it in O(n).
Any ideas?
Thanks a lot!

A: Consider '10110':

*

*Create a variable S. Create array A=[0].

*Iterate from first number and add 1 to S if you notice 1 and subtract 1 from S if you notice 0 and append S to A.

*

*For our example sequence A will be: [0, 1, 0, 1, 2, 1]. A is simply an array which stores a difference between number of 1s and 0s preceding the index. The sequence has to start and end at the place which has the same difference between 1s and 0s. So now our task is to find the longest distance between same numbers in A.

*Now create 2 empty dictionaries (hash maps) First and Last.

*Iterate through A and save position of first occurrence of every number in A in dictionary First.

*Iterate through A (starting from the end) and save position of the last occurrence of each number in A in dictionary Last.

*

*So for our example array First will be {0:0, 1:1, 2:4} and Last will be {0:2, 1:5, 2:4}

*Now find the key(max_key) for which the difference between corresponding values in First and Last is the largest. This max difference is the length of the subsequence. Subsequence starts at First[max_key] and ends at Last[max_key].
I know it is a bit hard to understand but it has complexity O(n) - four loops, each has complexity N. You can replace dictionaries with arrays of course but it is more complicated then using dictionaries.
Solution in Python.
def find_subsequence(seq):
    S = 0
    A = [0]
    for e in seq:
        if e=='1':
            S+=1
        else:
            S-=1
        A.append(S)
    First = {}
    Last = {}
    for pos, e in enumerate(A):
        if e not in First:
            First[e] = pos
    for pos, e in enumerate(reversed(A)):
        if e not in Last:
            Last[e] = len(seq) - pos
    max_difference = 0
    max_key = None
    for key in First:
        difference = Last[key] - First[key]
        if difference>max_difference:
            max_difference = difference
            max_key  = key
    if max_key is None:
        return ''
    return seq[First[max_key]:Last[max_key]]

find_sequene('10110') # Gives '0110'
find_sequence('1') # gives ''

J.F. Sebastian's code is more optimised.

EXTRA
This problem is related to Maximum subarray problem. Its solution is also based on summing elements from start:
def max_subarray(arr):
    max_diff = total = min_total = start = tstart = end = 0
    for pos, val in enumerate(arr, 1):
        total += val
        if min_total > total:
            min_total = total
            tstart =  pos
        if total - min_total > max_diff:
            max_diff = total - min_total
            end = pos
            start = tstart
    return max_diff, arr[start:end]


text:
Q: Bootstrap menu bar overlapping logo on collapse When navbar collapse (when it shows the toggle icon), the menu (home, services, portfolio, about,contact) is over the logo. If I take the position:absolute from the logo (nag-bar-brand) the menu appears in the center.  If there away to have the menu below the logo. I hope you understand my question. English is not my first language. Thank you.
HTML

<button class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse">

`enter code here`

</button>

Home

Service

Portfolio

About

Blog

Contact

css:
.navbar {
background-color:#FFF;
border-radius: 0 px;
min-height: 85px;
}

.navbar-nav{
padding-top: 20px;
letter-spacing: 0.05em;
}

.navbar-nav > li{
padding-left:20px;
}

.navbar .nav >li > a:hover{
color: #19bcb9;
}
.navbar-brand{
position:absolute;
}

A: If the image is too big this will happen. Limit the image with max-height max-width

A: simply put the image size to 100%. this should work!
.img {
img-size:100%;
}


text:
Q: Deploy Azure WebApp from Visual Studio Team Services (VSO) I try to setup my deployment source in azure portal for a given web app.
When i navigate to Web App > Deployment Source > Choose Source > Visual Studio Team Services i am not able to choose my Visual Studio Team Services account.

after selecting Visual Studio Team Services a cannot choose any project. Believe me, there are projects...

A: There are two things that you need to make sure of for this to work:

*

*your VSTS account needs to be backed by AAD

*you need to link it in the Azure portal

For more detail on exactly what this means, see this wiki page.


text:
Q: Meteor 1.4 packages with import I want to use imports in my Meteor Atmosphere package. Something like:
import { Meteor } from 'meteor/meteor'

But I always get this error:
import { Meteor } from 'meteor/meteor';
SyntaxError: Unexpected reserved word

I already added ecmascript to my package dependencies, but that doesn't help.
Package.onUse(function (api) {
  // Npm.depends({});

  api.versionsFrom('1.4.1');

  api.use([
    'ecmascript',
    'es5-shim',
    'mongo',
    'templating',
    'reactive-var',
    'trever:quill',
    'aramk:quill',
    'aldeed:simple-schema'
  ], 'client');

  api.addFiles([
    'blog.html',
    'blog.css',
    'blog.js',
    'edit-entry.html',
    'edit-entry.css',
    'edit-entry.js',
  ], 'client');

  api.addFiles([
    'blog-server.js',
  ], 'server');
});

How can I use ES6 features in Meteors Atmosphere packages?
Is there a sample package file structure?

A: The problem was that I didn't add the external packages to client AND server:
api.use([
    'ecmascript',
    'es5-shim',
    'mongo',
    'templating',
    'reactive-var',
    'momentjs:moment@2.15.2',
    'kadira:flow-router@2.12.1',
    'aldeed:simple-schema@1.5.3',
    'aldeed:collection2@2.10.0',
    'aldeed:autoform@5.8.1',
    'blaze-html-templates',
    'kadira:blaze-layout@2.3.0'
  ], ['client', 'server']);


text:
Q: trying to download full HTML pages I am tring to download few hundreds of HTML pages in order to parse them and calculate some measures.
I tried it with linux WGET, and with a loop of the following code in python:
url = "https://www.camoni.co.il/411788/168022"
html = urllib.request.urlopen(url).read()

but the html file I got doen't contain all the content I see in the browser in the same page. for example text I see on the screen is not found in the HTML file. only when I right click the page in the browser and "Save As" i get the full page.
the problem - I need a big anount of pages and can not do it by hand.
URL example - https://www.camoni.co.il/411788/168022 - thelast number changes
thank you

A: That's because that site is not static. It uses JavaScript (in this example jQuery lib) to fetch additional data from server and paste on page.
So instead of trying to GET raw HTML you should inspect requests in developer tools. There's a POST request on https://www.camoni.co.il/ajax/tabberChangeTab with such data:
tab_name=tab_about
memberAlias=ד-ר-דינה-ראלט-PhD
currentURL=/411788/ד-ר-דינה-ראלט-PhD

And the result is HTML that pasted on page after.
So instead of trying to just download page you should inspect page and requests to get data or use headless browser such as Google Chrome to emulate 'Save As' button and save data.


text:
Q: Codeigniter, PHP constructor - missing argument even if it is present I am getting such a warning:
A PHP ERROR WAS ENCOUNTERED
Severity: Warning
Message: Missing argument 1 for User_model::__construct(), called in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\CI_PP\system\core\Loader.php on line 303 and defined
Filename: models/user_model.php
Line Number: 20

while running app in CodeIgniter, NetBeans, PHP 5.4.
This is the code of models/user_model.php(playing around, ignore avoiding OOP principles, please):
<?php

  class User_model extends MY_Model {

    public $_table = 'pp_user';
    public $primary_key = 'u_id';
    public $firstname;
    public $lastname;
    public $emailAddress;
    public $password;
    public $gender;
    public $deliveryAddress;
    public $address;
    public $city;
    public $zip;
    public $country;
    public $isAdmin;

//this is line nr.20:
    public function __construct($firstname, $lastname, $emailAddress, $password, $gender, $address, $deliveryAddress, $city, $zip, $country, $isAdmin) {
        parent::__construct();

        $this->firstname = $firstname;
        $this->lastname = $lastname;
        $this->emailAddress = $emailAddress;
        $this->password = $password; //TODO!
        if ($gender == 'male') {
            $this->gender = 0;
        } else if ($gender == 'female') {
            $this->gender = 1;
        } else {
            $this->gender = -1;
        }
        $this->deliveryAddress = $deliveryAddress;
        $this->address = $address;
        $this->city = $city;
        $this->zip = $zip;
        $this->country = $country;
        $this->isAdmin = $isAdmin;
    }
}

I am calling constructor in registration.php(controller):
            $firstname = $this->input->post('tf_first_name');
        $lastname = $this->input->post('tf_last_name');
        $emailAddress = $this->input->post('tf_email_address');
        $password = $this->input->post('tf_password_base');
        $gender = $this->input->post('tf_gender');
        $address = $this->input->post('tf_address');
        $deliveryAddress = $this->input->post('tf_delivery_addres');
        $city = $this->input->post('tf_city');
        $zip = $this->input->post('tf_zip');
        $country = $this->input->post('tf_country');
        $isAdmin = FALSE;

        $user_instance = new User_model(
                        $firstname,
                        $lastname,
                        $emailAddress,
                        $password,
                        $gender,
                        $address,
                        $deliveryAddress,
                        $city,
                        $zip,
                        $country,
                        $isAdmin);

If I change contor arguments from:
public function __construct($firstname, $lastname, $emailAddress, $password, $gender, $address, $deliveryAddress, $city, $zip, $country, $isAdmin)

to:
public function __construct($firstname="", $lastname="", ...) {

then it works, but I do not like such a solution. I have been searching for a hints all over the web but according to PHP OOP tutorials and PHP manual it looks ok.
Loader.php on line 303 is doing this:
$CI->$name = new $model();

I tried to changed parameters to direct ones when instantiating object, I tried to remove relation to parent class but the problem remains the same.
I am really curious what might be the problem, any idea?

A: you have to do this
public function __construct($firstname="", $lastname="", ...) {

else you have pass the arguments when you create the object of the class
because when you create the object of class the construct method execute that time so you have pass all argument value during the creating object of class or you have to use above method

A: This is happening because CodeIgniter is calling User_model::__construct() when the application is loaded. CodeIgniter has to load all models before you can use them which means you can't, or rather shouldn't, pass parameters to them. You need to move that code from the __construct to another function like add_user within the User_model class that you can pass the data into.
<?php

class User_model extends MY_Model {

    public $_table = 'pp_user';
    public $primary_key = 'u_id';
    public $firstname;
    public $lastname;
    public $emailAddress;
    public $password;
    public $gender;
    public $deliveryAddress;
    public $address;
    public $city;
    public $zip;
    public $country;
    public $isAdmin;

    public function __construct() {
        parent::__construct();
    }

    public function add($firstname, $lastname, $emailAddress, $password, $gender, $address, $deliveryAddress, $city, $zip, $country, $isAdmin) {
        $this->firstname = $firstname;
        $this->lastname = $lastname;
        $this->emailAddress = $emailAddress;
        $this->password = $password; //TODO!
        if ($gender == 'male') {
            $this->gender = 0;
        } else if ($gender == 'female') {
            $this->gender = 1;
        } else {
            $this->gender = -1;
        }
        $this->deliveryAddress = $deliveryAddress;
        $this->address = $address;
        $this->city = $city;
        $this->zip = $zip;
        $this->country = $country;
        $this->isAdmin = $isAdmin;
    }
}

Then call the model like this.
$firstname = $this->input->post('tf_first_name');
$lastname = $this->input->post('tf_last_name');
$emailAddress = $this->input->post('tf_email_address');
$password = $this->input->post('tf_password_base');
$gender = $this->input->post('tf_gender');
$address = $this->input->post('tf_address');
$deliveryAddress = $this->input->post('tf_delivery_addres');
$city = $this->input->post('tf_city');
$zip = $this->input->post('tf_zip');
$country = $this->input->post('tf_country');
$isAdmin = FALSE;

$this->load->model('User_model');
$this->User_model->add($firstname,
                $lastname,
                $emailAddress,
                $password,
                $gender,
                $address,
                $deliveryAddress,
                $city,
                $zip,
                $country,
                $isAdmin);


text:
Q: JavaScript cross-domain call from HTTP to HTTPS any options I don't want to duplicate original question but I'd like to hear some options whether it's possible in general to make asynchronous call from HTTPS site to HTTP one.
It's important on my case because based on user location it will be determined to which real node request will go. So, option with additional proxy won't work (make call from application backend).
Option to manually turn of browser setting is not allowable.
Yeah in general it will be cross dpomain call and it will be good to hear some ideas whether it's feasible at all.
I saw number of threads where possible solutions are discussed:
- Use JSONP and it was said that this is not possible to do;
- Use CORS but as it was noted in documentation: https to http is not allowed.
- use iframe or another workaround.
Any ideas under which browsers it's feasiblly to implement this ?


text:
Q: Symfony 4 store entity in session I have a multi-page form that collects some data and then will be saving it to multiple tables. What is the correct way to save an entity to session in symfony 4?  I see the documentation here that states:

In Doctrine an entity objects has to be "managed" by an EntityManager
  to be updateable. Entities saved into the session are not managed in
  the next request anymore. This means that you have to register these
  entities with an EntityManager again if you want to change them or use
  them as part of references between other entities. You can achieve
  this by calling EntityManager#merge().

and

Entities that are serialized into the session normally contain references to other entities as well. Think of the user entity has a reference to his articles, groups, photos or many other different entities. If you serialize this object into the session then you don't want to serialize the related entities as well. This is why you should call EntityManager#detach() on this object or implement the __sleep() magic method on your entity.

Do I need to do this with symfony? How would I?
Perhaps a better question would be - should I even be using entities with sessions or should I store them in a class and just load all the class information into the entity at the end?

A: Depending on your needs, this can be applicable.
One of the purposes of storing entities in session -as mentionned in the docs- is "Multi-step forms". Using an Entity from the session in a Form can get you the following error:

Entity Your\Entity passed to the choice field must be managed. Maybe persist them in the entity manager?

You can read this SO question about this issue.


text:
Q: iOS bluetooth pairing with other phone programmatically I need to connect the bluetooth handset programmatically in one of my iOS projects. I do not want to go through iPhone settings to connect the bluetooth handset.
I searching in Google finely i got one link  THIS
In this Link provide source Code .I download and then run that file .it's open simulator like this
When I click scan button it showing Error "Turn Bluetooth on first" and then I pressed Bluetooth on button no use.
Any Bluetooth Device are not showing.
SO please give me any idea about HOW to Connected iPhone Bluetooth pairing with other Phones Bluetooth Programmatically.
First tell me it's possible in simulator or not?


text:
Q: Временная таблица SQL теперь я еще со временной табличкой не разберусь. В селекте выводятся все записи как положено, а в основную таблицу добавляется только одна. Может не в том порядке я что делаю, вот так вкратце это выглядит:
create table #table (id int,a int,b int,c int)
SET @i=1
WHILE @i<=100
BEGIN
/*расчет переменных*/
insert into #table (id int,a int,b int,c int) values (@i,@aa,@bb,@cc)
SET @i=@i+1
END
insert into Table values (@i,@aa,@bb,@cc)
select * from #table order by a
drop table #table

A: Последний запрос должен выглядеть так:
insert into Table select * from #table


text:
Q: Deleting Keychain when uninstalling iOS app I have been reading several posts regarding this issue, for example Delete keychain items when an app is uninstalled and iOS autodelete Keychain items after uninstall?. They say that, when you uninstall an app, its Keychain is not deleted, but the posts may be deprecated, is that the current behaviour?
On the other hand, if Keychain is not really automatically deleted when the user uninstalls an app, I'm not clear about the way to do that yourself.
EDIT: If Keychain are not deleted when apps are uninstalled, what actually happens to all those residual Keychain? Does the system not handle that?

A: Try using UserDefaults to store a boolean that tracks when data is saved to the keychain.
Example:
func someFunctionThatSavesToKeychain {
    // Save to keychain
    UserDefaults.standard.set(true, forKey: "isSavedToKeychain")
    // Do other stuff
}

Then in AppDelegate in the didFinishLaunchingWithOptionsMethod
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    if !UserDefaults.standard.bool(forKey: "isSavedToKeychain") {
        // Delete data from Keychain
    }
}

Since UserDefaults is cleared on application uninstall, the next time the user installs the application, that key-value will be gone therefore on start up, your AppDelegate will delete the residual Keychain data.
I've searched far and wide as well, this workaround is the closest you can get.

A: There is no trigger to perform code when the app is deleted from the device. Access to the keychain is dependent on the provisioning profile that is used to sign the application. Therefore no other applications would be able to access this information in the keychain.
I don't think you need to delete it. I'm not sure how to delete it but I believe if you did set the keychain value to some certain then you can also assign the value of nil or just empty string "". But this is not quite sure, just assuming.
Hope it helps!