text:
Q: How to use "for-each" loop & remove empty tags from output xml with xslt? I am trying to create an xslt file that will transform my xml. The file needs to use a loop so that if there are duplicate employees then there is only one parent Employee tag and not multiple. I'm able to get this part to work with my xslt file. The issue I am having are with the empty tags showing up under WorkAssingment. If there is no data for any of the WorkAssignment child fields then I'd like it so that the empty child tags are omitted.
I am a beginner with xml and xslt and do not have a coding background. I found some previous posts, however when trying out those solutions I wasn't successful. I was also a bit confused as most solutions I am finding are showing a xsl:template tag that closes before the body. I believe I need mine to close after the body as if it doesn't the loop won't work.
xml transform and remove empty tags
how to remove empty tags from output xml
Below is an example of:

*

*What I am looking to transform

*The results I am currently getting

*The results I am trying to get

*A copy of my xslt

<!-- This is the xml I am looking to convert -->
   <Employee>
        <XRefCode>123</XRefCode>
        <EmployeeNumber>123</EmployeeNumber>
        <FirstName>Test</FirstName>
        <LastName>Person1</LastName>
        <WorkAssignment>
            <JobXrefCode>job1</JobXrefCode>
            <DeptXrefCode>dept1</DeptXrefCode>
            <OrgXrefCode>org1</OrgXrefCode>
            <IsPrimary>1</IsPrimary>
            <EffectiveStart>2022-01-01</EffectiveStart>
            <BusinessTitle>Job1_Dept1</BusinessTitle>
        </WorkAssignment>
    </Employee>
    <Employee>
        <XRefCode>123</XRefCode>
        <EmployeeNumber>123</EmployeeNumber>
        <FirstName>Test</FirstName>
        <LastName>Person1</LastName>
        <WorkAssignment>
            <JobXrefCode>job2</JobXrefCode>
            <DeptXrefCode>dept2</DeptXrefCode>
            <OrgXrefCode>org1</OrgXrefCode>
            <IsPrimary>0</IsPrimary>
            <EffectiveStart>2022-01-01</EffectiveStart>
            <ReasonXrefCode>Reason1</ReasonXrefCode>
        </WorkAssignment>
    </Employee>

<!-- This is the output I am currently getting -->
    <Employee>
        <XRefCode>123</XRefCode>
        <EmployeeNumber>123</EmployeeNumber>
        <FirstName>Test</FirstName>
        <LastName>Person1</LastName>
        <WorkAssignment>
            <JobXrefCode>job1</JobXrefCode>
            <DeptXrefCode>dept1</DeptXrefCode>
            <OrgXrefCode>org1</OrgXrefCode>
            <IsPrimary>1</IsPrimary>
            <EffectiveStart>2022-01-01</EffectiveStart>
            <EffectiveEnd/>
            <ReasonXrefCode/>
            <Rate/>
            <FTE/>
            <PositionTermXRefCode/>
            <EmploymentIndicatorXRefCode/>
            <TipTypeGroupXrefCode/>
            <LaborPercentage/>
            <WorkLocationOverrideXrefCode/>
            <BusinessTitle>Job1_Dept1</BusinessTitle>
            <IsVirtualEmployee/>
            <LedgerCode/>
            <MultiJurisdictionAllocationPercentage/>
        </WorkAssignment>
        <WorkAssignment>
            <JobXrefCode>job2</JobXrefCode>
            <DeptXrefCode>dept2</DeptXrefCode>
            <OrgXrefCode>org1</OrgXrefCode>
            <IsPrimary>0</IsPrimary>
            <EffectiveStart>2022-01-01</EffectiveStart>
            <EffectiveEnd/>
            <ReasonXrefCode>Reason1</ReasonXrefCode>
            <Rate/>
            <FTE/>
            <PositionTermXRefCode/>
            <EmploymentIndicatorXRefCode/>
            <TipTypeGroupXrefCode/>
            <LaborPercentage/>
            <WorkLocationOverrideXrefCode/>
            <BusinessTitle/>
            <IsVirtualEmployee/>
            <LedgerCode/>
            <MultiJurisdictionAllocationPercentage/>
        </WorkAssignment>
    </Employee>

<!-- This is the output I want to get -->
    <Employee>
        <XRefCode>123</XRefCode>
        <EmployeeNumber>123</EmployeeNumber>
        <FirstName>Test</FirstName>
        <LastName>Person1</LastName>
        <WorkAssignment>
            <JobXrefCode>job1</JobXrefCode>
            <DeptXrefCode>dept1</DeptXrefCode>
            <OrgXrefCode>org1</OrgXrefCode>
            <IsPrimary>1</IsPrimary>
            <EffectiveStart>2022-01-01</EffectiveStart>
            <BusinessTitle>Job1_Dept1</BusinessTitle>
        </WorkAssignment>
        <WorkAssignment>
            <JobXrefCode>job2</JobXrefCode>
            <DeptXrefCode>dept2</DeptXrefCode>
            <OrgXrefCode>org1</OrgXrefCode>
            <IsPrimary>0</IsPrimary>
            <EffectiveStart>2022-01-01</EffectiveStart>
            <ReasonXrefCode>Reason1</ReasonXrefCode>
        </WorkAssignment>
</Employee>

BELOW IS MY XSLT

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
                  xmlns:cs="urn:cs"
>

    <!-- List all paytypes under a single Export record, for each employee -->
    <xsl:output method="xml"/>

    <!-- generates a unique list of employee numbers, no duplicates. Referenced via the name 'ListEmpNumber'. The Employee numbers are
        found under Export/Record/EmployeeNumber in the xml. -->
    <xsl:key name="ListXref" match="/EmployeeImport/Employee" use="XRefCode" />

    <xsl:template match="/">
        <EmployeeImport>
            <!-- loop over the first record for an employee found in the list, matching on the EmployeeNumber -->
            <xsl:for-each select="EmployeeImport/Employee[generate-id(.) = generate-id(key('ListXref', XRefCode))]">
                <Employee>
                    <!-- store the found employee number in a variable so it can be referenced -->
                    <xsl:variable name="EmpXrefSearch" select="XRefCode"/>

                    <XRefCode>
                        <xsl:value-of select="XRefCode"/>
                    </XRefCode>
                    <EmployeeNumber>
                        <xsl:value-of select="EmployeeNumber"/>
                    </EmployeeNumber>
                    <FirstName>
                        <xsl:value-of select="FirstName"/>
                    </FirstName>
                    <LastName>
                        <xsl:value-of select="LastName"/>
                    </LastName>

                    <!-- add whatever else you need in order from Employee!-->

                    <!-- Find all export records for the given employee, loop and display the pay type -->
                    <xsl:for-each select="/EmployeeImport/Employee[XRefCode=$EmpXrefSearch]/WorkAssignment">
                        <WorkAssignment>
                            <JobXrefCode>
                                <xsl:value-of select="JobXrefCode"/>
                            </JobXrefCode>
                            <DeptXrefCode>
                                <xsl:value-of select="DeptXrefCode"/>
                            </DeptXrefCode>
                            <OrgXrefCode>
                                <xsl:value-of select="OrgXrefCode"/>
                            </OrgXrefCode>
                            <IsPrimary>
                                <xsl:value-of select="IsPrimary"/>
                            </IsPrimary>
                            <EffectiveStart>
                                <xsl:value-of select="EffectiveStart"/>
                            </EffectiveStart>
                            <EffectiveEnd>
                                <xsl:value-of select="EffectiveEnd"/>
                            </EffectiveEnd>
                            <ReasonXrefCode>
                                <xsl:value-of select="ReasonXrefCode"/>
                            </ReasonXrefCode>
                            <Rate>
                                <xsl:value-of select="Rate"/>
                            </Rate>
                            <FTE>
                                <xsl:value-of select="FTE"/>
                            </FTE>
                            <PositionTermXRefCode>
                                <xsl:value-of select="PositionTermXRefCode"/>
                            </PositionTermXRefCode>
                            <EmploymentIndicatorXRefCode>
                                <xsl:value-of select="EmploymentIndicatorXRefCode"/>
                            </EmploymentIndicatorXRefCode>
                            <TipTypeGroupXrefCode>
                                <xsl:value-of select="TipTypeGroupXrefCode"/>
                            </TipTypeGroupXrefCode>
                            <LaborPercentage>
                                <xsl:value-of select="LaborPercentage"/>
                            </LaborPercentage>
                            <WorkLocationOverrideXrefCode>
                                <xsl:value-of select="WorkLocationOverrideXrefCode"/>
                            </WorkLocationOverrideXrefCode>
                            <BusinessTitle>
                                <xsl:value-of select="BusinessTitle"/>
                            </BusinessTitle>
                            <IsVirtualEmployee>
                                <xsl:value-of select="IsVirtualEmployee"/>
                            </IsVirtualEmployee>
                            <LedgerCode>
                                <xsl:value-of select="LedgerCode"/>
                            </LedgerCode>
                            <MultiJurisdictionAllocationPercentage>
                                <xsl:value-of select="MultiJurisdictionAllocationPercentage"/>
                            </MultiJurisdictionAllocationPercentage>
                        </WorkAssignment>
                    </xsl:for-each>

                    <!--<xsl:for-each select="/EmployeeImport/Employee[XRefCode=$EmpXrefSearch]/RateLevel"> -->
                        <RateLevel>
                            <JobSetXrefCode>
                                <xsl:value-of select="RateLevel/JobSetXrefCode"/>
                            </JobSetXrefCode>
                            <JobSetLevelXrefCode>
                                <xsl:value-of select="RateLevel/JobSetLevelXrefCode"/>
                            </JobSetLevelXrefCode>
                        </RateLevel>
                    <!--</xsl:for-each>-->

                </Employee>
            </xsl:for-each>
        </EmployeeImport>
    </xsl:template>
</xsl:stylesheet>

A: It seems you just want to copy the elements from the input instead of explicitly creating new and then partially empty elements:
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">

  <xsl:output method="xml" indent="yes"/>

  <xsl:strip-space elements="*"/>

  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:key name="ListXref" match="/EmployeeImport/Employee" use="XRefCode" />

  <xsl:template match="Employee[generate-id() = generate-id(key('ListXref', XRefCode)[1])]">
    <xsl:copy>
      <xsl:apply-templates select="*[not(self::WorkAssignment)] | key('ListXref', XRefCode)/WorkAssignment"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="Employee[not(generate-id() = generate-id(key('ListXref', XRefCode)[1]))]"/>

</xsl:stylesheet>

A: AFAICT, you want to do simply:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:key name="ListXref" match="Employee" use="XRefCode" />

<xsl:template match="/EmployeeImport">
    <xsl:copy>
        <xsl:for-each select="Employee[generate-id(.) = generate-id(key('ListXref', XRefCode))]">
            <xsl:copy>
                <xsl:copy-of select="XRefCode|EmployeeNumber|FirstName|LastName"/>
                <xsl:copy-of select="key('ListXref', XRefCode)/WorkAssignment"/>
            </xsl:copy>
        </xsl:for-each>
    </xsl:copy>
</xsl:template>

</xsl:stylesheet>

Demo: https://xsltfiddle.liberty-development.net/nbBfrGa
For better understanding, learn about Muenchian grouping.

P.S. xsl:for-each is not a "loop".


text:
Q: Private npm/git dependencies on Google App Engine I'm using Google App Engine's new custom runtimes to develop some applications, and the need has risen to extract code to be pulled in as dependencies. These dependencies are either added from a private npm repository, or private git repositories.
How can I set up my GAE project to use such private repositories, without checking in sensitive details into the repository itself? (Git and/or npm doesn't matter; would prefer git.)

A: The traditional way to do this is to have a file with the creds on the server. When your app needs the creds, it reads the file and sends them through the (assuming) secure channel to whoever needs to inspect them. If you were running on pure compute engine, having a persistent disk isn't a problem, but then you have to manage and spin up instances to load balance yourself.
Thinking about the traditional persistent disk hardware-linked to the runtime as merely a specific class of persistent data-store, you might see where I'm going: access to your GCS Bucket/Datastore/Cloud SQL (all of them a kind of persistent data-store) is secured by the use of OAuth with your project's service account or the datacenter-level security of a Cloud SQL unix socket in the last case, ensuring the creds aren't accessible to anybody but you while being stored.
Compare: the disk files containing the creds were protected in the traditional example by the fact that no other computer could access the disk without the explicit permission of the operating system, which would have to be deliberately configured to accept such a connection (and then you would be implementing some kind of authorization/authentication scheme to ensure the security of this connection).
OAuth2.0 is widely used in the google cloud platform, which ensures the same connections to the instance's persistent store (whichever you choose) can take place while also being already supplied with a strong authorization/authentication scheme. In the case of Cloud SQL, the auth system can be as simple as your username and pass with a secure tunnel. The question merely becomes one of transferring the creds from your machine to where they can be accessed by the runtime.
So, you can:

*

*Use the the gsutil tool to put an object containing the creds and set this object's ACL so that it belongs exclusively to your app's service account

*Use the remote API to put a Datastore entity containing the creds

*Connect to your Cloud SQL instance through a locally-running client and insert the data. (Note for this option that you're not using OAuth from your local client, but hopefully a secure tunnel and the authentication factor of a db username and password. When the managed VM wants to access the instance, it takes place within google's network, so you can be assured of the security of that connection).
...and at this point you can access the creds, wherever they're stored, from your managed VM.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to keep all of the output of a program on the Windows command line? Say you have a program that gives a lot of output. It seems that Command Prompt unfortunately doesn't keep all of it (there's only so far you can scroll up).
Is there a way to keep all of it?

A: To just capture output to a file, see other answers. You can also increase the amount to text you can scroll back and see up to a limit.
With the command prompt window open, click the [C:] icon in the title bar to bring up the menu and select properties. Under the Layout tab, change the Screen Buffer Size->Height to 9999. That will allow you to scroll back that many lines in the window.

A: Are you using Windows XP if so you could append to your command | more
Alternatively you could use

command redirection operators

.
This page has more info for you.

A: Output the results to a file, like this:
C:> RunMyProgram.exe > outputfile.txt

A: Increasing the buffer size is the best way if you just want to scroll up and see the output, which you can configure in properties.
If you are appending to a file, you'll also probably want the errors in case there are any:
C:\>somecommand.exe > "C:\path\to\output.txt" 2>&1
If you want a pager, there is more or less for Windows.
example:
C:\>somecommand.exe | less
you can then use f to page forward or b to go backward.

A: you can increase the buffer size on command history (defaults to 50) on properties. you could try to something like 500 or even 5000, than you should be able to  scroll up a lot more.
another way is to redirect the output to a file using the ">" char:
ex:
C:> someCommand > output.txt
than open the txt file and you should see the output for the command there.

A: This question is old, but I'd like to add a newer Windows feature as an option.  As stated in other answers, Less and More are easy to use, but if you need ultimate flexibility, you can redirect the stdout stream to a file with >.  However, this leaves messy temporary files behind.  Since Windows Vista, you can instead pipe the stdout stream directly to the clipboard with the clip command, like this:
c:\> someprogram.exe param1 param2 | clip

With that, you can then paste the output of the program or command into Notepad or other editor, do searches, make notes, copy or save elsewhere, etc.  When you're done, just close the editor and it's gone with no cleanup necessary.
Note that if you're using CMD, this |clip command will not pass a newline at the end.  In PowerShell, it will.  If you want to do this in PowerShell without the newline, you can use |scb instead.  This is a short alias for the Set-Clipboard cmdlet.  |clip is available in both CMD and PowerShell.  |scb is available only in PowerShell.


text:
Q: SEVERE: Unable to instrument com.google.apphosting.api.DatastorePb$PutRequest. Security restrictions may not be entirely emulated I Created a Google Cloud Module in Android Studio as the backend. Now I am trying to run the test locally using this guide. Unfortunately I am getting the following error:
ment.agent.impl.Transformer transform
SEVERE: Unable to instrument com.google.apphosting.api.DatastorePb$PutRequest. Security restrictions may not be entirely emulated.
java.lang.RuntimeException
    at com.google.appengine.repackaged.org.objectweb.asm.MethodVisitor.visitParameter(MethodVisitor.java:115)
    at com.google.appengine.repackaged.org.objectweb.asm.ClassReader.readMethod(ClassReader.java:959)
    at com.google.appengine.repackaged.org.objectweb.asm.ClassReader.accept(ClassReader.java:693)
    at com.google.appengine.repackaged.org.objectweb.asm.ClassReader.accept(ClassReader.java:506)
    at com.google.appengine.tools.development.agent.impl.Transformer.rewrite(Transformer.java:146)
    at com.google.appengine.tools.development.agent.impl.Transformer.transform(Transformer.java:113)
    at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
    at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:198)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at com.google.appengine.api.datastore.AsyncDatastoreServiceImpl.<init>(AsyncDatastoreServiceImpl.java:153)
    at com.google.appengine.api.datastore.DatastoreServiceFactoryImpl.getAsyncDatastoreService(DatastoreServiceFactoryImpl.java:20)
    at com.google.appengine.api.datastore.DatastoreServiceFactoryImpl.getDatastoreService(DatastoreServiceFactoryImpl.java:13)
    at com.google.appengine.api.datastore.DatastoreServiceFactory.getDatastoreService(DatastoreServiceFactory.java:20)
    at com.google.appengine.api.datastore.DatastoreServiceFactory.getDatastoreService(DatastoreServiceFactory.java:40)
    at com.google.apphosting.utils.servlet.TransactionCleanupFilter.getDatastoreService(TransactionCleanupFilter.java:86)
    at com.google.apphosting.utils.servlet.TransactionCleanupFilter.init(TransactionCleanupFilter.java:36)
    at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:662)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
    at org.mortbay.jetty.Server.doStart(Server.java:224)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at com.google.appengine.tools.development.JettyContainerService.startContainer(JettyContainerService.java:271)
    at com.google.appengine.tools.development.AbstractContainerService.startup(AbstractContainerService.java:284)
    at com.google.appengine.tools.development.ManualInstanceHolder.startUp(ManualInstanceHolder.java:77)
    at com.google.appengine.tools.development.AbstractModule.startup(AbstractModule.java:87)
    at com.google.appengine.tools.development.Modules.startup(Modules.java:105)
    at com.google.appengine.tools.development.DevAppServerImpl.doStart(DevAppServerImpl.java:262)
    at com.google.appengine.tools.development.DevAppServerImpl.access$000(DevAppServerImpl.java:45)
    at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:217)
    at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:215)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:215)
    at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:277)
    at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:48)
    at com.google.appengine.tools.development.DevAppServerMain.run(DevAppServerMain.java:225)
    at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:216)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

Note: I can access the page on http://localhost:8080/ but I am not sure what this error exactly means.


text:
Q: Should (or will) a proposed site's "Great On-Topic Example" questions be automatically included in its beta? I've read some great on-topic example questions on Area 51.
My questions:

*

*Should a proposed site's "Great On-Topic Example" questions be automatically included in its beta?

*Will a proposed site's "Great On-Topic Example" questions be automatically included in its beta?

A: No.
Because all that exists of the question is the title and perhaps a comment or two of clarification.
For the question to be useful on the site it will have to have all the details that would enable someone to answer it correctly.
That doesn't mean that those who proposed questions for the site shouldn't post the full question - in fact that's what I'm going attempt to do with the sites I've signed up to.


text:
Q: How to get NIC Power Management (Whether the adapter in power saving mode or not )settings in C#? I want to show the Information in UI if the adapter device in power saving mode or not? I tried to get the setting from c# but I don't know how to get that. I tried to get the settings in ManagementObject but it doesn't have the value? How do I get that?
ManagementObjectSearcher mbs = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_NetworkAdapter");

RegistryKey registry = Registry.LocalMachine;
RegistryKey registryKey = registry.OpenSubKey(path);
foreach (ManagementObject adapterInfo in mbs.Get())
{
try
{
    string pnpDeviceId = (string)adapterInfo["PNPDeviceID"];
    string guid = (string)adapterInfo["GUID"];


text:
Q: My X_App is in playstore, How will i get to know which user has installed my app and which user has uninstalled my app in android I have deployed my X_App into play store and i want to know which user has installed my app and which user has uninstalled my app in android?
Can someone please help me in this. I want to track the user who has uninstalled my app and uninstall count in android?
Thanks in advance..

A: While you can't point to a particular user who has either installed or un-installed your app, you could get your daily installed/un-installed statistics in the following category -
Android Version
Device
Tablets
Country
Language
App version
Carrier

from the google play dev console.
If you need further insights into your uninstalls you could take a look at this site - https://www.uninstall.io/

A: There are plenty more ways of tracking uninstalls. You can run a ping service from the device to the server periodically. You can also send blank notifications intermittently to make sure the app is still on the device. You can ignore rendering these notifications to your users.
If you are looking for a tool that does app engagement and analytics then you can check out clevertap.com They provide uninstall tracking right out of the box.
If you were looking for a pure technical explanation of how GCM and Apple track uninstalls then you can read about it here. Track App Uninstalls effectively (https://blog.clevertap.com/track-app-uninstalls-effectively/) I have also covered alternative methods if you wanted to implement the uninstall tracking yourself!
Good luck.


text:
Q: Mapping a nested Oracle CURSOR (ResultSet) with myBatis 3? Hello to the community I have problems when returning a cursor associated with a procedure.
PROCEDURE USP_SEL_TAB_ANIOS(po_Lr_Recordset OUT SYS_REFCURSOR) IS
    BEGIN
         SELECT A.COD_ANIO , A.DESCRIPCION FROM BAH_MAE_ANIO A ;
    END ;

package contains two classes:
public class ItemBean implements Serializable {

    private Integer icodigo;
    private String descripcion;
    private String descripcionCorta;

    // get and set

}

-
public class ResultItemBean implements Serializable {

    private static final long serialVersionUID = 1L;

    private List<ItemBean> itemBeans;

    // get and set

}

Mapper
public interface ControlCalidadMapper {

    public abstract List<ItemBean> listarAnios(ItemBean item) throws Exception;

}

ControlCalidadMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="pe.com.sigbah.mapper.gestion_almacenes.ControlCalidadMapper">

    <resultMap id="mapAnio" type="pe.com.sigbah.common.bean.ItemBean">
        <result property="descripcionCorta" column="COD_ANIO" />
        <result property="descripcion" column="DESCRIPCION" />
    </resultMap>

    <parameterMap id="getAnio" type="pe.com.sigbah.common.bean.ResultItemBean">
<!--        <parameter property="start_from" jdbcType="INTEGER" mode="IN"  /> -->
        <parameter property="itemBeans" jdbcType="CURSOR" mode="OUT" resultMap="mapAnio" />
    </parameterMap>

    <select id="listarAnios" parameterMap="getAnio" statementType="CALLABLE">
        {call BAH_PKG_GENERAL.USP_SEL_TAB_ANIOS(?)}
    </select>

</mapper>

Service
@Service
public class ControlCalidadServiceImpl extends GenericServiceImpl implements ControlCalidadService {

    private static final long serialVersionUID = 1L;

    @Autowired
    private ControlCalidadMapper controlCalidadMapper;

    /* (non-Javadoc)
     * @see pe.com.sigbah.service.gestion_almacenes.ControlCalidadService#listarAnios(pe.com.sigbah.common.bean.ItemBean)
     */
    @Override
    public List<ItemBean> listarAnios(ItemBean item) throws Exception {
        return controlCalidadMapper.listarAnios(item);
    }

}

Error:
DEBUG: pe.com.sigbah.mapper.gestion_almacenes.ControlCalidadMapper.listarAnios - ooo Using Connection [jdbc:oracle:thin:@200.48.54.22:1521:INTEGRAL, UserName=SINPAD, Oracle JDBC driver]
DEBUG: pe.com.sigbah.mapper.gestion_almacenes.ControlCalidadMapper.listarAnios - ==>  Preparing: {call BAH_PKG_GENERAL.USP_SEL_TAB_ANIOS(?)}
DEBUG: pe.com.sigbah.mapper.gestion_almacenes.ControlCalidadMapper.listarAnios - ==> Parameters:
ERROR: pe.com.sigbah.web.controller.gestion_almacenes.ControlCalidadController - nested exception is org.apache.ibatis.reflection.ReflectionException: Could not set property 'itemBeans' of 'class pe.com.sigbah.common.bean.ItemBean' with value '[ItemBean [icodigo=null, descripcion=Seleccione, descripcionCorta=%], ItemBean [icodigo=null, descripcion=Año del buen servicio al ciudadano, descripcionCorta=2017], ItemBean [icodigo=null, descripcion=null, descripcionCorta=2018], ItemBean [icodigo=null, descripcion=null, descripcionCorta=2019], ItemBean [icodigo=null, descripcion=null, descripcionCorta=2020]]' Cause: org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'itemBeans' in 'class pe.com.sigbah.common.bean.ItemBean'
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: Could not set property 'itemBeans' of 'class pe.com.sigbah.common.bean.ItemBean' with value '[ItemBean [icodigo=null, descripcion=Seleccione, descripcionCorta=%], ItemBean [icodigo=null, descripcion=Año del buen servicio al ciudadano, descripcionCorta=2017], ItemBean [icodigo=null, descripcion=null, descripcionCorta=2018], ItemBean [icodigo=null, descripcion=null, descripcionCorta=2019], ItemBean [icodigo=null, descripcion=null, descripcionCorta=2020]]' Cause: org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'itemBeans' in 'class pe.com.sigbah.common.bean.ItemBean'

I hope you can help me with the mapper
I hope you can help me with the mapper
I hope you can help me with the mapper

A: you should pass a ResultItemBean  object in the Mapper, like this:
public abstract List<ItemBean> listarAnios(ResultItemBean items) throws Exception;

in your ControlCalidadMapper.xml file you define your parameterMap as a
 pe.com.sigbah.common.bean.ResultItemBean so you sould pass this object as parameter.


text:
Q: Facebook extend sso access token error I'm using facebook SDK 3.0.1 for android.
I see at Facebook developers -> Insights -> Developer -> Activity & Errors
some erros.
I have an error that happens to 100% of my users : auth.extendssoaccesstoken (error code  10 : Application does not have permission for this action).
I've read that this problems may happens after removing the deprecated permission offline_access.
What could that be?
and how can I solve that problem?
Thanks

A: Have you checked if your Application is in Sandbox Mode ? The Sandbox Mode only allows the developer to access the application. You can change this from your App Settings on Facebook.


text:
Q: Location based AR I am new for Augmented Reality though I know Android development.
I am trying to create an app whose main aim is to overlay the camera preview with some image if the device camera is pointing to a particular building or place. The camera preview will be overlaid with some image if and only if camera is pointing to correct building and correct direction. The overlay image & its related data will be uploaded from back-end. I have gone through mixar but it is not giving the correct solution.
In this I am not getting the Elevation / altitude concept. From where I will get this. Which opensource sdk is better for this app? How to crack this application?

A: For altitude you should forget it. The altitude return by GPS is terrible. Just crossing from one side of the street to the other side, the altitude returned by GPS could be different by 50 meter. Also, the direction of the back camera using sensors will not be accurate enough for buildings close together. If you restrict your app for known buildings or places then you can adjust using some image recognition but still it is very hard.

A: try to download wikitude sample app from wikitude website.it contain sample project simpleArbrowser that is what u are searching.hope this will help u

A: I don't know of any opensource sdk but I used Wikitude SDK which is quite useful for you implementation.The main advantage about wikitude sdk is that you can use your own server for back-end data. Which is not possible with the other alternative that is layar. And @Hoan is right about getting altitude information from GPS data is really inacurate but you can give it a go as the inaccuracy is only visible if you are really near the Point of Interest. It works okay for a distance greater than 250 meters or so(not confirmed). The only problem you might get is from the compass deflections which are really great when you are near a high EM field or near metals. But that's a chance you'd have to take and nothing can be done about it.

A: If you want to place AR objects based on the LAT and LONG of the location with a given altitude.
Well, now that's possible using Google's ARCore Geospatial API.
Docs:
https://developers.google.com/ar/develop/geospatial


text:
Q: Angular 1.6.5 with Webpack load template for uiModal I'm trying to open a modal window. The background is showing up but there is no modal window.
My code:
let template = require('../modal/newModel.html');

let modal = $uibModal.open({
    template,
    controller: 'NewModelCtrl as NewModel',
    windowClass: 'modal-rule-create'
});

modal.result.then((model) => {
    self.list.push(model);
}, (event) => {
    console.log('Close modal window:', event);
});

webpack.config.js
 {
     test: /\.html$/,
     use: 'html-loader'
 }

Why is that? Thanks in advance

A: I have updated the fiddle by changing the structure of the div's and added jquery references updated fiddle
In your case make sure you have added Jquery before bootstrap.js, try to see the version mismatch or try to change -
let modal = $uibModal.open({
    templateUrl = '../modal/newModel.html',
    controller: 'NewModelCtrl',
    controllerAs: 'NewModel',
    windowClass: 'modal-rule-create'
});

You can refer to this questions as they have similar problem like yours -
Can't open a modal window in angularjs, using bootstrap
ui.bootstrap modal loading html but not showing anything

A: Would be useful if you setup a plunker. Anyway if you want to use an alias for your controller the code should be like:
let modal = $uibModal.open({
  template,
  controller: 'NewModelCtrl',
  controllerAs: 'NewModel',
  windowClass: 'modal-rule-create'
});

Maybe that's messing your modal.
Hope it helps.

A: Here the html code, window rendering did not happen

A: Found a problem.
Maybe someone will be useful:
Angular 1.6.5
Angular-ui-bootstrap 2.5.0
There is the following code:
$httpProvider.interceptors.push([
    '$injector',
    function ($injector) {
        return $injector.get('AuthInterceptor');
    }
]);

And:
.factory('AuthInterceptor', function ($rootScope, $q, AUTH_EVENTS, Filters)
{
    return {
        request: function (config) {
            let regEx = /.+\.html$/;
            let template = regEx.test(config.url);

            if (!template) {
                if (config.url !== "/uaa/oauth/token" &&
            Filters.get('token')) {
                    config.headers.Authorization = 'Bearer ' +
            Filters.get('token');
                }
            }

            return config;
        },
        response: function (response) {
            let regEx = new RegExp('.+\.html$');
            let template = regEx.test(response.config.url);
            let data;

            if (!template) {
                if (response.status && response.status !== 200) {
                    return $q.reject(response);
                }

                data = response.data || response;
                return $q.resolve(data);
            }

            return response;
        },
        responseError: function (response) {
            $rootScope.$broadcast({
                401: AUTH_EVENTS.notAuthenticated,
                403: AUTH_EVENTS.notAuthorized,
                419: AUTH_EVENTS.sessionTimeout,
                440: AUTH_EVENTS.sessionTimeout,
                500: 'bad-request'
            }[response.status], response);
            return $q.reject(response);
        }
    };
})

In old version of my code, angular try return template cache of modal window. But in my code after processing it was not returned.


text:
Q: Crear arbol de directorios (lista) a partir de rutas - PHP Tengo que entregar un proyecto mañana y se me ha ocurrido una cosa de última hora, tras hacer una consulta a MySQL me llegan varias rutas:
/Fotos

/Fotos/Viajes

/Fotos/Viajes/Madrid

/Fotos/Viajes/Barcelona

Cada ruta es una fila en la base de datos, por cada registro hago un explode() y lo convierto en un array, pero ahí me bloqueo y no se como continuar.
Teniendo estos datos llegados de registros diferentes de MySQL, necesitaria generar una lista con subniveles para que quede de la siguiente manera:

Fotos

Viajes

Madrid

Barcelona

Gracias a todos


text:
Q: Why are input MOSFETs in Laptop power supply always in pairs? For example, on https://youtu.be/CW87dyYIimE?t=340 (and related work on motherboard), it says the managment chip uses two MOSFETs as a switch (as overheat protection, emergency poweroff on 10-second powerbutton press etc).
While the story makes sense and I can understand how it would work, I'm wondering why such MOSFETs need to come in pair?
To my (begginers) view, it looks like one MOSFET should be enough to act as switch for mentioned purposes. So why are there two MOSFET connected in series? What else am I missing?

A: You're missing the fact that discrete MOSFETs generally have their substrates tied directly to their source terminals. This creates a "body diode" in parallel with the drain-source path, and this means that such a MOSFET can only block current in one direction.
Therefore, many applications use two identical MOSFETs back-to-back (sources and gates tied together) so that when they're off, they can block current in either direction.

A: It's basically meant as a bidirectional switch. I found this nice article about it: https://www.homemade-circuits.com/bidirectional-switch/


text:
Q: Xamarin Android app crashes on Galaxy Note 8 My Xamarin Forms Android app (Release mode) crashes on Galaxy Note 8 (Oreo 8.0). It shows the splash and dies immediately. Following is the crash log I received on console dashboard. But I'm unable to find the cause of this. It dies before AppCenter crash reporting kicks in. So this is the only log I got. Any idea what could be wrong here?

*

*Build: Release

*Works on other Oreo 8.0 and 7.1 devices

*Min SDK: 21

*Target SDK: 26

*Linker: Link SDK assemblies

*Multi dex ON

*Max heap 1G

*Supports all CPU architectures

_________
android.runtime.JavaProxyThrowable: at Xamarin.Forms.Platform.Android.AppCompat.Platform.LayoutRootPage (Xamarin.Forms.Page page, System.Int32 width, System.Int32 height) [0x00034] in <99988d4ab8d144898ef5bc7586876d75>:0 at Xamarin.Forms.Platform.Android.AppCompat.Platform.Xamarin.Forms.Platform.Android.IPlatformLayout.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x0000a] in <99988d4ab8d144898ef5bc7586876d75>:0
    at Xamarin.Forms.Platform.Android.PlatformRenderer.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x00018] in <99988d4ab8d144898ef5bc7586876d75>:0
    at Android.Views.ViewGroup.n_OnLayout_ZIIII (System.IntPtr jnienv, System.IntPtr native__this, System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x00008] in <88e8d1026f2645cab4d71803e1b2caba>:0
    at (wrapper dynamic-method) System.Object.268905bf-8ee6-4d7b-ac7e-88443c1482d9(intptr,intptr,bool,int,int,int,int)
      at md51558244f76c53b6aeda52c8a337f2c37.PlatformRenderer.n_onLayout (Native Method)
      at md51558244f76c53b6aeda52c8a337f2c37.PlatformRenderer.onLayout (PlatformRenderer.java:55)
      at android.view.View.layout (View.java:20841)
      at android.view.ViewGroup.layout (ViewGroup.java:6401)
      at android.widget.RelativeLayout.onLayout (RelativeLayout.java:1080)
      at android.view.View.layout (View.java:20841)
      at android.view.ViewGroup.layout (ViewGroup.java:6401)
      at android.widget.FrameLayout.layoutChildren (FrameLayout.java:323)
      at android.widget.FrameLayout.onLayout (FrameLayout.java:261)
      at android.view.View.layout (View.java:20841)
      at android.view.ViewGroup.layout (ViewGroup.java:6401)
      at android.widget.FrameLayout.layoutChildren (FrameLayout.java:323)
      at android.widget.FrameLayout.onLayout (FrameLayout.java:261)
      at android.view.View.layout (View.java:20841)
      at android.view.ViewGroup.layout (ViewGroup.java:6401)
      at android.widget.FrameLayout.layoutChildren (FrameLayout.java:323)
      at android.widget.FrameLayout.onLayout (FrameLayout.java:261)
      at android.view.View.layout (View.java:20841)
      at android.view.ViewGroup.layout (ViewGroup.java:6401)
      at android.widget.LinearLayout.setChildFrame (LinearLayout.java:1791)
      at android.widget.LinearLayout.layoutVertical (LinearLayout.java:1635)
      at android.widget.LinearLayout.onLayout (LinearLayout.java:1544)
      at android.view.View.layout (View.java:20841)
      at android.view.ViewGroup.layout (ViewGroup.java:6401)
      at android.widget.FrameLayout.layoutChildren (FrameLayout.java:323)
      at android.widget.FrameLayout.onLayout (FrameLayout.java:261)
      at com.android.internal.policy.DecorView.onLayout (DecorView.java:944)
      at android.view.View.layout (View.java:20841)
      at android.view.ViewGroup.layout (ViewGroup.java:6401)
      at android.view.ViewRootImpl.performLayout (ViewRootImpl.java:2911)
      at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2598)
      at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1742)
      at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:7763)
      at android.view.Choreographer$CallbackRecord.run (Choreographer.java:911)
      at android.view.Choreographer.doCallbacks (Choreographer.java:723)
      at android.view.Choreographer.doFrame (Choreographer.java:658)
      at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:897)
      at android.os.Handler.handleCallback (Handler.java:789)
      at android.os.Handler.dispatchMessage (Handler.java:98)
      at android.os.Looper.loop (Looper.java:164)
      at android.app.ActivityThread.main (ActivityThread.java:6940)
      at java.lang.reflect.Method.invoke (Native Method)
      at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
      at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)

A: I believe the suggestion from Bejasc of cleaning and deleting the obj and bin directories and creating a new release will resolve your problem.  I had the same crashes with releases running on Samsung Galaxy Note 8 Devices - on both Nougat and Oreo.  Bejasc's suggestion solved them.


text:
Q: how to reduce migrations of existing website that is developed in laravel I have 1000+ migrations of a website and tables are only 300-400, now i want to reduce the number of migrations without loosing any data is there any possibility to do it.

A: In Laravel 8 you'll be able to dump the database and throw away migrations thanks to this PR
In the mean time, you can take a look at the PR code and implement it in your current version https://github.com/laravel/framework/pull/32275/files.
The main idea is to use mysqldump (or pgdump, depending on your database) to dump your current database state and run a migration to import it.


text:
Q: Why can the average/midpoint of two numbers be described as the sum of the numbers divided by two? Say I have two numbers, A and B. The "average" or the midpoint of the two numbers is given by $$\frac{A+B}{2}$$
My question is, why does this formula work?
Intuitively, I can derive the equation as follows. The "midpoint" of the two numbers can be given by:
$$A+\frac{B-A}{2}$$
$$=\frac{2A}{2}+\frac{B-A}{2}$$
$$=\frac{A+B}{2}$$
But why? Why is it when you add two numbers and divided it by two you get its "midpoint"? I can't seem to find a way to intuitively visualize this. Please help, thank you!

A: Let's have this visualization:
$\mathtt{|----|------+------|----|}\\
O\hphantom{----}A\hphantom{------}\ \ I\hphantom{------}\ \ \,B\hphantom{---}A+B$

*

*$I$ is the midpoint of $[A,B]$

*but $\operatorname{dist}(O,A)=\operatorname{dist}(B,A+B)=a$
Thus $I$ is also the midpoint of $[O,A+B]$.
And since you agree it is $I=O+\dfrac{(A+B)-O}2$ and that $O$ can be identified to the zero of point addition, then $I=\dfrac{A+B}{2}$.

A: Suppose I have two measuring cups.  One has $A$ ounces of water and the other has $B$ ounces.   Also suppose that $B$ is bigger than $A$ and I want the same amount of liquid in each cup.
So I can pour some of the $B$ cup into the $A$ cup until the amounts are equal.  How much is in each cup?  I have a total of $A+B$ ounces and they are equally divided into 2 cups.  So each cup has $(A+B)/2$ ounces.


text:
Q: Get all objects of a given structure, and their global names Suppose I have the following objects:
gray       =    (132, 132, 132)
green      =    (0, 104, 0)
red        =    (168, 0, 68)

How can I obtain all such globals() of this form (RGB) and the name of the corresponding objects?

A: Using isinstance, you can check the type of the objects. And using vars, you will get mapping of variable names to values.
gray = (132, 132, 132)
green = (0, 104, 0)
red = (168, 0, 68)
somethingelse = 0

for key, value in vars().items():
    is_rgb = (
        isinstance(value, tuple) and
        len(value) == 3 and
        all(isinstance(x, int) for x in value)
    )
    if is_rgb:
        print(key)

Another way: try-except
gray = (132, 132, 132)
green = (0, 104, 0)
red = (168, 0, 68)
somethingelse = 0

for key, value in vars().items():
    try:
        _, _, _ = value
        if isinstance(value, tuple):
            print(key)
    except (TypeError, ValueError):
        pass

A: What about the following shortcut?
ls = [(key, value) for key, value in globals().items() if isinstance(value, tuple) and len(value) == 3]

which creates a list of tuples containing your colors.
Edit:
The previous solution would match also tuples of the form
("hello", "blah", 7)

That is, tuples whose elements could also not be ints.
To prevent this, use the following solution which only accepts tuples whose elements are all ints.
ls = [(key, value) for key, value in globals().items() if isinstance(value, tuple) and len(value) == 3 and all(isinstance(e, int) for e in value) ]

This is similar to what falsetru is doing but just in a compacted way.


text:
Q: Unwanted space between row of inline-block elements and another row It isn't a table, I just used "row" for lack of a better word.
My problem is that I've got a set of display:inline-block elements and an element under those, but there's a gap between them. Note that I'm not talking about the space between the inline elements, I'm talking about the space between the row of inline elements and the other element. I've tried the solution mentioned here, setting a line-height and font-size, but that didn't help at all (which is why it isn't in the code below)
Here's my code:
HTML

CSS
body{
    background:#eee;
    width: 100%;
}
#letterhead {
    position: absolute;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    width: 100%;
    height: 12rem;
    font: 32px Tahoma;
    color: #777;
    padding: 2rem;
}
    .logo {
        display: inline-block;
        width: 7rem;
        height: 7rem;
        background: #000;
    }
    .name {
        display: inline-block;
        height: 7rem;
        width: calc((100% - 7rem) / 2);
        background: #fff;
    }
    .subtext {
        //position: absolute;
        margin: 0;
        padding: 0;
        top: 9rem;
        text-align: center;
        width: 100%;
        height: 1rem;
        background: #555;
    }

I made a Fiddle here.
Thanks in advance.

A: But it is because of your font-size and line-height. Set them to 0 on #letterhead and the unwanted white-space will dissapear. You wil have to set your font-size and line-height back on the children of #letterhead if you want to put content in them.
example:
http://jsfiddle.net/skeurentjes/69MkQ/1/

A: Just add margin:0 -4px 0 0 to your inline-block divs. And everything will be good. To remove space between rows you must set vertical:align:top. Check the DEMO
CSS
.logo {
        ...
        display: inline-block;
        margin:0 -4px 0 0;
        vertical:align:top
        ...
    }
    .name {
        ...
        display: inline-block;
        margin:0 -4px 0 0;
        vertical:align:top
        ...
    }


text:
Q: How to set range for an editText preference? I have an editText preference in my Settings Activity.
I want to get a number from 0-99 from the user.
How can i do that?
<EditTextPreference
    android:defaultValue="90"
    android:key="key_a"
    android:inputType="number"
    android:title="@string/pref_title"/>

Using this code i have restricted the input to numbers,but i want to further restrict the user from entering more than 2 digits.
If restriction is not possible,any validation method to check if the entered input is <= 99 and if the entered input is invalid, i would like to change the value to its previously saved value.

A: Adding android:maxLength="2" solved it.  Thanks @Suraj Nair


text:
Q: How can I get these Json code with Beautifulsoup? JSON

 <script>
 var data2sales=
 [{
   "key": "Owners",
   "bar": true,
   "values": [
     [1490400000000, 1591, "", "", ""],
     [1490486400000, 1924, "#2B6A94", "", ""],
     [1490572800000, 1982, "", "", ""],
     [1490659200000, 1606, "", "", ""]]
 }]
 </script>

My code to get Json in Python

 notices = str(soup.select('script')[30])
 split_words=notices.split('var data2sales= ')
 split_words=split_words[1]
 temp=split_words[44:689]
 temp = 'var data2sales= {' +temp + '}'
 print(temp)
 newDict = json.loads((temp))
 print(newDict)

I'm new to BeautifulSoup in Python and I'm trying to extract a dict from BeautifulSoup. As you can see in my code, I remake the JSON code with python and save in the newDict variable. But it doesn't work. Is there anyone can teach me, how can I extract that JSON code? Thank you.

A: Assuming the script above is within a string text, you can do something like the following:
import json
from bs4 import BeautifulSoup

soup = BeautifulSoup(text, 'html.parser')
script_text = soup.find('script').get_text()
relevant = script_text[script_text.index('=')+1:] #removes = and the part before it
data = json.loads(relevant) #a dictionary!
print json.dumps(data, indent=4)

Output:
[
    {
        "key": "Owners",
        "bar": true,
        "values": [
            [
                1490400000000,
                1591,
                "",
                "",
                ""
            ],
            [
                1490486400000,
                1924,
                "#2B6A94",
                "",
                ""
            ],
            [
                1490572800000,
                1982,
                "",
                "",
                ""
            ],
            [
                1490659200000,
                1606,
                "",
                "",
                ""
            ]
        ]
    }
]

A: I just use len(eval(data.get_text())['data']['song']['list'])


text:
Q: a tag as a submit button? Hi I am trying to get "a" tag as a submit button.  I found a code somewhere in the web. But it didn't work.
Submit

Is there any code for to achieve my need?

A: This is an improve of @ComFreek ans:
<form id="myform">

  Submit
</form>

So the  will not trigger action and reload your page. Specially if your are developing with a framework with SPA.

A: Give the form an id, and then:
document.getElementById("yourFormId").submit();
Best practice would probably be to give your link an id too, and get rid of the event handler:
document.getElementById("yourLinkId").onclick = function() {
    document.getElementById("yourFormId").submit();
}

A: Try this code:
<form id="myform">

  Submit
</form>

But users with disabled JavaScript won't be able to submit the form, so you could add the following code:

  <input type="submit" value="Submit form!" />

A: Supposing the form is the direct parent you can do:
submit

If not you can access through the forms name attribute like this:
submit

See both examples here: http://jsfiddle.net/WEZDC/1/

A: Try something like below
 Submit

A: document.getElementById('myForm').action="javascript:function("+a+","+b+")";
You can change the action attribute, and put some variables as params of a function.

A: in my opinion the easiest way would be somthing like this:
<?php>
echo 'Submit';
</?>

within the "link.php" you can request the value like this:
$_REQUEST['submit']


text:
Q: iptables alternative for nat in windows When setting up a comms server I usually use iptables in linux to forward any incoming connections on a particular port to another server, e.g.
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination
DNAT       tcp  --  anywhere             anywhere            tcp dpt:telnet to:x.x.x.x:23

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination
MASQUERADE  all  --  anywhere             anywhere

Does anyone know how to do this with windows?

A: You need to install RRAS. Then you can follow the steps listed in this page.


text:
Q: Dojo Datagrid with editable DateTextBox get inconsistent default value I have a datagrid with a column of type date. It is editable using dijit's DateTextBox. The problem is when it gets instantiated, it takes the value as actual value -1day.
I have a jsfiddle demonstrating the problem here.
I can only get the date in this format "yyyy-MM-dd".
Here is the structure for the column with date:
{
  name:'Start Date', field:'startdate',
  editable:true, relWidth: 100,
  type: dojox.grid.cells.DateTextBox,
  constraint:{datePattern:'yyyy-MM-dd', selector:'date', locale: 'en-us'},
  formatter:function (d) {
     if(typeof(d) === "string"){
        d = dojo.date.stamp.fromISOString(d)
      }
      return dojo.date.locale.format(d, this.constraint)
   }
 }


text:
Q: Do Direct Payment does not working in Paypal sandbox Hi I want to test payment in paypal test account but I am facing error
ACK: "Failure"
AMT: "100.00"
BUILD: "9915774"
CORRELATIONID: "39d5ad29e8411"
CURRENCYCODE: "USD"
L_ERRORCODE0: "10501"
L_LONGMESSAGE0: "This transaction cannot be processed due to an invalid merchant configuration."
L_SEVERITYCODE0: "Error"
L_SHORTMESSAGE0: "Invalid Configuration"
TIMESTAMP: "2014-03-18T07:29:45Z"
VERSION: "85.0"
my config.php file is
$sandbox = TRUE;
// Set PayPal API version and credentials.
$api_version = '85.0';
$api_endpoint = $sandbox ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp';
$api_username = $sandbox ? 'shafiq2626-facilitator@hotmail.com' : 'shafiq2626-facilitator@hotmail.com';
$api_password = $sandbox ? 'XXXXXX' : 'XXXXX';
$api_signature = $sandbox ? 'XXXXXXXXXXXXXXXXXXXXXXxx' : 'XXXXXXXXXXXXXXXXXXXXXXXXXXxxx';

my dodirect method is
<?php
// Include config file
 require_once('includes/config.php');

 // Store request params in an array
 $request_params = array
                (
                'METHOD' => 'DoDirectPayment',
                'USER' => $api_username,
                'PWD' => $api_password,
                'SIGNATURE' => $api_signature,
                'VERSION' => $api_version,
                'PAYMENTACTION' => 'Sale',
                'IPADDRESS' => $_SERVER['REMOTE_ADDR'],
                'CREDITCARDTYPE' => $_REQUEST['cardtype'],
                'ACCT' => $_REQUEST['pay_cardnumber'],
                'EXPDATE' => $_REQUEST['crd_month'].$_REQUEST['crd_year'],
                'CVV2' => $_REQUEST['security_code'],
                'FIRSTNAME' => $_REQUEST['vpb_fname'],
                'LASTNAME' => $_REQUEST['vpb_lname'],
                'STREET' => $_REQUEST['street'],
                'CITY' => $_REQUEST['city'],
                'STATE' => $_REQUEST['state'],
                'COUNTRYCODE' => 'US',
                'ZIP' => $_REQUEST['zip'],
                'AMT' => '100.00',
                'CURRENCYCODE' => 'USD',
                'DESC' => 'Testing Payments Pro'
                );

// Loop through $request_params array to generate the NVP string.
$nvp_string = '';
foreach($request_params as $var=>$val)
{
$nvp_string .= '&'.$var.'='.urlencode($val);
}

 // Send NVP string to PayPal and store response
 $curl = curl_init();
    curl_setopt($curl, CURLOPT_VERBOSE, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($curl, CURLOPT_TIMEOUT, 30);
    curl_setopt($curl, CURLOPT_URL, $api_endpoint);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $nvp_string);

  $result = curl_exec($curl);

 // Parse the API response
 $result_array = NVPToArray($result);

print_r($result_array);

// Function to convert NTP string to an array
function NVPToArray($NVPString)
{
$proArray = array();
while(strlen($NVPString))
{
    // name
    $keypos= strpos($NVPString,'=');
    $keyval = substr($NVPString,0,$keypos);
    // value
    $valuepos = strpos($NVPString,'&') ? strpos($NVPString,'&'): strlen($NVPString);
    $valval = substr($NVPString,$keypos+1,$valuepos-$keypos-1);
    // decoding the respose
    $proArray[$keyval] = urldecode($valval);
    $NVPString = substr($NVPString,$valuepos+1,strlen($NVPString));
}
return json_encode($proArray);
}

What can be the problem and how this will fix please.

A: That particular error has to do with not having Pro enabled on your account.  Facilitator accounts do not have Pro enabled by default so you'd either need to enable it on that account or create a separate account inside your developer portal that has Pro enabled on it.  To enable pro on an existing business sandbox account follow the directions below.

*

*Login to developer.paypal.com

*Click the Applications Tab

*Click Sandbox Accounts on the left menu

*Click the arrow to the left of your facilitator account to expand the options

*Click the Profile link

*Click "Upgrade to Pro" next to your Business account type


text:
Q: "Eclipse IDE for Web and JavaScript Developers" doesn't have Java Script project I downloaded "Eclipse IDE for Web and JavaScript Developers" for my windows 64-bit from the below link.
https://www.eclipse.org/downloads/packages/release/2020-06/r/eclipse-ide-web-and-javascript-developers
I tried to create java script project (New-->Project-->Java script project) but couldn't find java script details in the wizard window. No luck even after installing java script related plugins.
Could someone let me know if I missed anything while installing or plugins to install ?
Eclipse wizard window

A: In theory, as with non-IDE editors like VSCode, you don't need a special project type for working with JavaScript any more. Go do what you were going to do to make your application or script, and just remember to open your JavaScript files with the Generic Text Editor (if they don't already).


text:
Q: oracle PLS-00103 Error after executing a simple query this is the code that I ran in the Oracle SQL Developer and the error has come next:
It is a very simple query so what's wrong whit it?
DECLARE zero varchar(20);
DECLARE emptys;
begin
zero := '0';
emptys := null;
IF(emptys = zero)   then
DBMS_OUTPUT.put_line('yes');
ELSE
dbms_output.Put_line('no');
end if;
end;

Error starting at line : 1 in command -
DECLARE zero varchar(20);
DECLARE emptys;
begin
zero := '0';
emptys := null;
IF(emptys = zero)   then
DBMS_OUTPUT.put_line('yes');
ELSE
dbms_output.Put_line('no');
end if;

end;
Error report -
ORA-06550: line 2, column 5:
PLS-00103: Encountered the symbol "DECLARE" when expecting one of the following:
begin function pragma procedure subtype type
 current cursor delete
exists prior
The symbol "begin was inserted before "DECLARE" to continue.
ORA-06550: line 13, column 74:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
( begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with

 << continue close current delete fetch lock
insert open rollback savepoint set sql execute commit forall
merge pipe purge json_exists json_value json_query
json_object json_array
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

A: DECLARE indicates the beginning of the variable declaration section.  You'd only have one such section.  You don't repeat that keyword for every variable you declare.
You haven't provided a data type for the variable emptys.  I'll assume you want that to be varchar2(20)
DECLARE
  zero varchar(20);
  emptys varchar2(20);
begin
  zero := '0';
  emptys := null;
  IF(emptys = zero)   then
    DBMS_OUTPUT.put_line('yes');
  ELSE
    dbms_output.Put_line('no');
  end if;
end;


text:
Q: how to group all toast notifications from one app in windows 10 action center In window universal apps, using WNS(windows notification service) is there any way to group all toast notifications sent from one app inside the action center just like how all unread whatsapp conversations are shown as one notification in Android.
I see there is a WNS header called WNS-Group and WNS-Tag but setting/using those in anyway does not group the toasts
Can someone suggest if this is doable in Windows, if it is how ?
Thanks

A: Nope, you can't visually group notifications together (yet). The group and tag headers are to allow you to manage (e.g. dismiss) notifications together as a group.


text:
Q: Create a HyperV disk from an existing folder I want to create a virtual disk to attach to a hyper-v VM. This disk will be used to store a lot of files (around eight GB's worth) and will be attached to a hyper V VM.
I don't want to waste time creating the disk, then copying all eight gigs of worth of files then attaching the VM.
Is there a way to create a disk image and have its contents be a folder I specify?

A: You may create VHD just from partition not folder.
https://technet.microsoft.com/en-us/sysinternals/ee656415.aspx


text:
Q: Combine two message payload I'm using node-red on one of my projects. And I'm having trouble handling two message payloads in one node. I DO NOT want to deal with them SEPARATELY, instead I want this node to combine both inputs into ONE.
All the answers I found online were talked about how to deal with them in sequence, I DO NOT want that. I need to make them into ONE message payload and pass to the next node.
Anyone has any insight on this?

A: Use the Join node.

This can be set to combine 2 incoming messages so that the new msg.payload is an array containing the msg.payload of the input messages.

A: Do also check out node-red-contrib-fusion which may or may not be overkill depending on your specific use case.


text:
Q: Beautifoulsoup .getText() eror for teknik in teknik_ayrıntılar:
detayler = teknik.find_all("tr")
    for i in detayler:
        teknik = i.find("th",attrs={"class":"prodDetSectionEntry"}).get_text()
        değer = i.find("td",attrs={"class":"a-size-base"}).get_text()
        print(teknik +"="+ değer)

When I write "teknik.get_text()" and "değer.get_text() python send this eror
"AttributeError: 'NoneType' object has no attribute 'get_text'"
Do you know that?
I'm using Python 3.7.3.

A: As the documentation says, if that error happens, there is no tag matching your query.


text:
Q: Adobe ExtendScript Toolkit Finding an Object's Properties and Methods I'm new to Adobe Scripting, and Javascripting in general, and I'm reading the guide "ADOBE INTRODUCTION TO SCRIPTING" and the "JAVASCRIPT TOOLS GUIDE". But something is bugging me.
In the first one it says that to find the properties and methods of a Object I have to use the Model Object View, but this doesn't exist for the After Effects and Premiere(the Applications I'm mostly working with). I've been using reflect.properties/methods to get this info, but that's gets very time-consuming when I need to get methods/properties of many Objects.
My question is: How can I effectively get this info? Is there any online resource with this kind of info? The PDF's are okay, but its not the fastest way to find many properties.

A: Adobe After Effects comes with a scripting guide outlining pretty much all properties and methods for the objects it has.  The problem is that Adobe has not had an opportunity to create a scripting guide for the latest versions of AE.  But there are some resources available to you for that as well.  Like the blog posts made by the QE team for AE.
If you use the ExtendScript Toolkit (ESTK) IDE you'll also have access to a "data browser" panel that will outline the methods and properties available to you as you debug.  When I need to inspect any object while developing scripts for AE, I'll place a breakpoint in the ESTK IDE and then open up my data browser to see everything available to scripting.  Hope that helps!


text:
Q: Trying to plot cross validation I've come up with this wonderful plot. I need you to help me draw it:

MWE:

\documentclass[tikz,border=7pt]{standalone}
\usetikzlibrary{matrix}
\begin{document}
  \begin{tikzpicture}
    \matrix (M) [matrix of nodes,
        nodes={minimum height = 7mm, minimum width = 2cm, outer sep=0, anchor=center, draw},
        column 1/.style={nodes={draw=none}, minimum width = 4cm},
        row sep=1mm, column sep=-\pgflinewidth, nodes in empty cells,
        e/.style={fill=yellow!10}
      ]
      {
        Experiment 1 & |[e]| & & & & \\
        Experiment 2 & & |[e]| & & & \\
        Experiment 3 & & & |[e]| & & \\
        Experiment 4 & & & & |[e]| & \\
        Experiment 5 & & & & & |[e]| \\
      };
      \draw (M-1-2.north west) ++(0,2mm) coordinate (LT) edge[|<->|, >= latex] node[above]{Total number of datasets} (LT-|M-1-6.north east);
  \end{tikzpicture}
\end{document}

A: A drawing like this can be made in many different ways. For this particular drawing I would suggest using a \foreach loop rather than \matrix environment, as it provides more flexibility for making the contours of the bars and individual blocks.
The example below can furthermore easily be scaled by changing the scale=0.7 of the whole picture and the scale=0.5 of the right-hand side of the picture in the scope environment. The secondary purpose of the scope environment is to define a node of its bounding box to draw the arrow that connects both halfs of the pictures together.
\documentclass[tikz,border=7pt]{standalone}
\usetikzlibrary{positioning,arrows.meta}
\begin{document}
  \begin{tikzpicture}[node distance=0mm,minimum height=1cm,outer sep=3mm,scale=0.7,>=Latex,font=\footnotesize,
  indication/.style={minimum height=0cm,outer sep=0mm},
  oneblock/.style={transform shape,minimum width=1cm,draw},
  fullset/.style={transform shape,minimum width=10cm,draw}]
    % left part of picture
    \node[fullset,anchor=west] at (0,0) (A) {};
    \node[above=of A.north,indication] (ATXT) {TRAINING SET};
    \node[oneblock,minimum width=2cm,anchor=west,right=of A,fill=lightgray,outer sep=0mm] (A1) {};
    \path (ATXT) -| (A1) node[midway] {TEST SET};
    \node[fullset,anchor=west] at (0,-4) (B) {};
    \foreach \x in {0,1,...,9}
    {
        \draw (B.west) +(\x,0) node[oneblock,anchor=west,draw] {};
    }
    \draw[->] (A) -- (B) node[midway,fill=white,indication] {divide into 10 folds of equal size};

    % right part of picture
    \begin{scope}[xshift=15cm,scale=0.5,local bounding box=rightside box]
    \foreach \x in {0,1}
    {
        \foreach \y in {0,1,...,4}
        {
            \draw (\x*11,0) +(0,-\y*2) node[fullset,anchor=west] {};
            \draw (\x*11,0) +(\x*5+\y,-\y*2) node[oneblock,draw,anchor=west,fill=lightgray] {};
        }
    }
    \coordinate (R) at (rightside box.west);
    \end{scope}

    % connecting arrow
    \draw[->] (B.east) -- +(2.5,0) node[below,align=center,indication] {run experiments\\using 10 different\\partitionings} |- (R);
  \end{tikzpicture}
\end{document}


text:
Q: Dash Cytoscape data from js script I'm trying to get node position data from Dash Cytoscape. I found this solution https://community.plotly.com/t/dash-cytoscape-returning-node-positions-from-layout/23818/4
but I can't get data from the browser console in python. How can I do this?

A: To get data from a js script, you could use a Clientside Callback. As documented here, a clientside callback

create(s) a callback that updates the output by calling a clientside (JavaScript) function instead of a Python function

To use it, you can for example write your JavaScript code into Python code like the following:
from dash import Dash, dcc, html, Input, Output

app = Dash(...)

# Using a Store component and a Button to trigger the callback
app.layout = html.Div(
    [
        html.Button(id="your-button"),
        dcc.Store(id="js-data")
    ]
)

app.clientside_callback(
"""
function (n_clicks) {
    // Insert your JS code here and return
    ...
    return data
}
""",
Output("js-data", "data"),
Input("your-button", "n_clicks")
)

@app.callback(
    Output("..."),  # This depends on your application
    Input("js-data", "data")
)
def work_with_js(data):
    # Do whatever you want with your data

As you can see, the example uses a Button to trigger the JavaScript code and returns some data in a dcc.Store component. This data is used in another callback afterwards and can be manipulated.


text:
Q: Why am I unable to build Up stairways in Dwarf Fort? I've accidentally trapped my mason at the bottom of my mineshaft.
The shaft is 5x5 with up/down stairways, except for at the bottom.
The bottom layer has down stairways (dug, not constructed) leading to my aqueduct.
There's plenty of Diorite on the same level as the mason, and, I have designated the construction of the Up stairways on the current Down stairways.
Right now, however, he's just sort of standing there progressively getting thirsty. Any ideas?
Edit: Here are the surrounding layers. and here is the save file.
I do have another mason with 'No job' and 2 miners with the mason skill enabled. I also ensured that nothing within range is forbidden.
The odd thing is he won't even build a floor on the same level, let alone an up/down stairways or up stairways.

A: If it are down stairs carved out using designate (This is your problem)

*

*You need to channel out the stairs. Beware that if the tile above has a up/down stairs your dwarf might fall 2 Z-levels and break his leg, or neck. Try to get the mining dwarf to the current floor first, mind you need a pickaxe for channeling.

*Now you need to construct a Up/down or up stair on that level manually. "b"-"C" and pick your stairs from the menu and place it there. Any mason will come and bring a stone or brick with him to create a stairs.
If it are constructed stairs (Just adding this since it is relevant)

*

*You can remove constructions in the designate menu "d". Not sure about the specific key but you can look it up in the designate list. I think it is "x".

*Now with the down stairs gone you can use the same method as above (2.) to construct a new stairs using construct "b"-"C".


text:
Q: How to access data in Microstrategy using a JAVA API I have Microstrategy Analytics Desktop installed on my system, and added a connection to the local Oracle connection and am able to view a oracle db on Microstrategy webapp. My goal is to access this data using Java code. I have downloaded Microstrategy SDK and can see a jar file, but couldn't find sample code or help online, to be able to connect to Microstrategy and access data.
Any help towards this is highly appreciated.

A: Did you look here ?
https://lw.microstrategy.com/msdz/MSDL/AnalyticsEnterprise/docs/DeveloperLibrary.htm#mergedProjects/genericcontent/topics/versiondiff/9.4.0_to_Analytics_Enterprise.htm

For me it was the first point when doing any MSTR SDK.
Data part:


text:
Q: SQL SERVER Case Statement for Order By Clause Following on from my earlier question of if I can bring back the highest price and also total all quantities from multiple suppliers [Select Highest Price and add Qty's for all suppliers] (SQL Server : SELECT Highest Price and add qty's from table)
I would like to put a case statement into the ORDER BY Price DESC part of the query to return the highest Price if the qty is > 10 or return the lowest if the case is not met, but I cant seem to get the query to work.  Is it possible to put a case in the same query? or is there another way to go about this?.
This works fine as it is
SELECT ManuPartNo, WebPrice, TotalQtyAdded, Supplier
FROM
(SELECT dbo.TableAllProds. *,
    ROW_NUMBER() OVER(PARTITION BY ManuPartNo ORDER BY WebPrice DESC) AS RN,
    SUM(TotalQty) OVER(PARTITION BY ManuPartNo) AS TotalQtyAdded
        FROM TableAllProds) AS t
WHERE RN = 1
ORDER BY ManuPartNo

This is what I have been trying but however I seem to write the If part it doesn't seem to like the syntax.
SELECT ProdName, ManuPartNo, Price, Qty, TotalQty, Supplier
FROM (  SELECT *,
           ROW_NUMBER() OVER(PARTITION BY ManuPartNo
               ORDER BY
                      CASE WHEN Price > '10' Price DESC
                      ELSE Price ASC END ) AS RN,
           SUM(Qty) OVER(PARTITION BY ManuPartNo) AS TotalQty,
    FROM dbo.TableAllProds) AS t
WHERE RN = 1
ORDER BY ManuPartNo;

Is it possible to write this in one query? any suggestions or pointers to other posts would be appreciated.

A: You can use the WITH TIES clause.
However, the sub-query WHERE RN=1 is a nudge more performant
Example
Select top 1 with ties *
 From  dbo.TableAllProds
 Order By row_number() over (partition by ManuPartNo Order by try_convert(money,Price) Desc)


text:
Q: Fail2Ban - Log to mysql We have a few servers with SSH public (using sFTP).
Obviously, the attacks ar too many.
We want put the banned logs into a MySQL DB for make stats and etc.
Have anyone tryied this?
Thanks

A: Fail2SQL - An SQL logger for Fail2Ban
Fail2SQL is called by Fail2Ban and logs information to a MySQL database including geographical location and total ban count. This information can then be used in reports, graphs or by third party programs to take further action such as permanent blocking, reporting to ISP etc.

A: There seems to be no direct way to do this. You will have to write a script to parse the fail2ban logfiles and insert IP's and bantimes into a mysql table. I found one here: http://blog.dp.cx/25/postfix-fail2ban-win


text:
Q: Conflicting "facts" about the likelihood employed in Bayes theorem Consider the following "facts" about Bayes theorem and likelihood:

*

*Bayes theorem, written generically as $P(A|B) = \frac{ P(B|A) P(A) }{ P(B) }$
involves conditional and marginal probabilities.  Focus on $P(B|A)$.
Wiki Bayes theorem says this is a conditional probability (or conditional probability density in the continuous case).
This seems quite clear in the alternate expression $P(B|A) P(A) = P(A|B) P(B)$.

*In the Bayes theorem, $P(B|A)$ is called the likelihood.

*The likelihood is $P(B|A)$ viewed as a function of $A$, not of $B$.
It is not a conditional probability because it does not integrate to one.
See What is the reason that a likelihood function is not a pdf? , or Bishop Pattern Recognition & Machine Learing book p.22,
"Note that the likelihood is not a probability distribution over w, and its integral with respect to w does not (necessarily) equal one."
There is a problem here, one of these three facts must be wrong, or else I do not understand something.
How can the likelihood in the Bayes theorem be a conditional probability, and also not a conditional probability?
I am not sure (since I do not understand!), but perhaps an answer would be to explain how to view the Bayes equation in terms of what is variable and what is fixed, and how probabilities (and non-probabilities -- the likelihood) can combine in a "type consistent" way.  For example, is it accurate to say that in the Bayes equation $P(A|B) = \cdots$ we should regard $B$ as fixed and $A$ as variable?
And if $P(B|A)$, the likelihood, is not a conditional probability, then the form of Bayes is
$$
    \text{conditional probability} = \frac{ \text{other} \cdot \text{probability}  }{ \text{probability}  }
$$
(or if dealing with continuous variables,
$$
    \text{conditional probability density} = \frac{ \text{other} \cdot \text{probability density} }{ \text{probability density} }
$$
) where "other" is the type of the likelihood (not a conditional probability density).
Is there a rule that
$$
   \text{other} \cdot \text{probability} = \text{probability}
$$
?  To me this seems wrong:  multiplying a probability by a thing (likelihood) with arbitrarily large values will cause the result to not integrate to 1.
Aside, I have tried to asked this question [recently], but it was closed as a duplicate. However, I think the people deciding it was a duplicate did not understand the question, which is specifically about the likelihood appearing in Bayes theorem.  I hope this version is more clear!  Please read the whole question before marking it as a duplicate, thank you!


text:
Q: array_diff_assoc() is considering 1 === "1" I am running this code from php.net example
<?php
$array1 = array(0, 1, 2);
$array2 = array("00", "01", "2");
$result = array_diff_assoc($array1, $array2);
print_r($result);
?>

Output of which I am getting :
Array
(
    [0] => 0
    [1] => 1
)

php.net says : Two values from key => value pairs are considered equal only if (string) $elem1 === (string) $elem2 .
whereas in the example it considers 2 === "2".
How is this happening ? Please Explain ?
Might be the case
If $ele1 is casting integer into string i.e. 2 to "2", then why it is comparing with === operator. There might be 2 == "2" better option and we don't need to cast it into string. Please correct me, if I am wrong ?

A: If $ele1 is casting integer into string i.e. 2 to "2", then why it is comparing with === operator. There might be 2 == "2" better option and we don't need to cast it into string. Please correct me, if I am wrong ?It's just the way it is implemented.
If you want another comparision function use array_diff_uassoc()


text:
Q: Getting the value of range_field_tag I'm trying to get the value of the range_field_tag and display it in the page, modifying the number as it moves along. (So it starts at value 1 and displays 1, move the slider up to 3 and the displayed value changes to 3).
<%= range_field_tag 'ranger', in: 1...10, step: 1 %>

Do I have to extract the value of this in the controller or is there a way to get that working in erb? Or will that require Javascript?

A: You should be using JavaScript to display
<% # your erb %>
<%= range_field_tag 'ranger', in: 1...10, step: 1 %>

#JavaScript using JQuery & coffee - works in Chrome
$('#ranger').on 'input', ->
  $('#target').text($('#ranger').val())


text:
Q: Will Google Play Store accept self signed certificate apps? I am a newbie developing an Android app. It implements a socket connection and has to bypass or allow all host for it to work with our self-signed certificate installed on a server.
I heard that google play store doesn't accept this kind of connection in the published app. Is it true? Or there is another way to do it?
Thank you.

A:
and had to bypass or allow all host in order to work with our self-signed certificate installed on server

That was not a particularly good move, from the standpoint of security.

I heard that google play store doesnt accept this kind of connection in the published app

The Play Store has implemented a ban on apps that bypass SSL validity checking and blindly accept all incoming SSL certificates.

Or there is another way to do it ?

Android 7.0+ has support for self-signed certificates. I backported that code to work on Android 4.2+. There are other libraries that offer self-signed certificate support, such as this one. There have been articles written on using self-signed certificates.


text:
Q: A card grouping game: find the expected number of groups Suppose that I have a deck of $n$ cards numbered $1$ to $n$. I randomly draw the cards from the deck one by one and put them in piles according to the following rule:

*

*The first drawn card forms the first pile.

*For each subsequent card drawn, if the number on it is just smaller than the smallest number on cards in an existing pile by one, or just larger than the largest number on cards in an existing pile by one, then I will put this card on that pile.

*If a newly drawn card cannot be put in any existing piles according to rule 2, then start a new pile with this card.
For example, if $n=6$ and the order of the cards drawn is $(2,5,1,3,6,4)$, then the piles of cards will be (step by step)
$(2)$
$(2), (5)$
$(12), (5)$
$(123), (5)$
$(123), (56)$
$(123), (456)$ or $(1234), (56)$
and I will have 2 piles.
My question is how to find the expected number of piles, $k$, I will get. My guess is $E[k] = (n+1)/3$.

A: We can calculate the expected number of new piles formed, starting with the available run $1\ldots n$, with three slightly different initial conditions:

*

*No initial piles (call the expected number of piles $A_n$);

*An initial pile at $0$ (call the expected number of new piles $B_n$);

*Initial piles at $0$ and $n+1$ (call the expected number of new piles $C_n$).

Clearly $A_1=A_2=1$ and $B_1=C_1=C_2=0$ and $B_2=1/2$.  Beyond this, we can calculate each sequence recursively by considering how the first card can be drawn and what available runs are formed thereby.  Newly formed available runs will evolve independently.  With no initial piles, the result is a newly created pile and either a shortened run with one neighboring pile (if the drawn card is $1$ or $n$) or two runs with one neighboring pile:
$$
A_n=1 + \frac{2}{n}B_{n-1}+\sum_{k=1}^{n-2}\frac{1}{n}\left(B_{k}+B_{n-1-k}\right)=1+\frac{2}{n}\sum_{k=1}^{n-1}B_k.
$$
With an initial pile at $0$, the result is either a shortened run with one neighboring pile (if the drawn card is $1$), or a new pile and a shortened run with two neighboring piles (if the drawn card is $n$), or a new pile and a run with two neighboring piles and a run with one neighboring pile:
$$
B_n=\frac{1}{n}B_{n-1}+\sum_{k=1}^{n-2}\frac{1}{n}\left(1+C_{k}+B_{n-1}\right)+\frac{1}{n}\left(1+C_{n-1}\right)=1-\frac{1}{n}+\frac{1}{n}\sum_{k=1}^{n-1}B_k+\frac{1}{n}\sum_{k=1}^{n-1}C_k.
$$
Finally, with initial piles at $0$ and $n+1$, the result is either a shortened run with two neighboring piles (if the drawn card is $1$ or $n$), or a new pile and two runs with two neighboring piles:
$$
C_n=\frac{2}{n}C_{n-1}+\sum_{k=1}^{n-2}\frac{1}{n}\left(1+C_{k}+C_{n-1-k}\right)=1-\frac{2}{n}+\frac{2}{n}\sum_{k=1}^{n-1}C_k.
$$
We know that $C_2=0$; let's assume, as an inductive hypothesis, that $C_k=a(k-2)$ for $2 \le k < n$ (for some fixed $n > 2$, and with the value of $a$ to be chosen later).  Then
$$
C_n=1-\frac{2}{n}+\frac{2}{n}\sum_{k=3}^{n-1}a(k-2)=1-\frac{2}{n}+\frac{2}{n}\left(\frac{1}{2}a(n-2)(n-3)\right)=\frac{(a(n-3)+1)(n-2)}{n}.
$$
The choice $a=1/3$ gives the self-consistent result $C_n=\frac{1}{3}(n-2)$.  We conclude by induction that $C_n=\frac{1}{3}(n-2)$ for all $n\ge 2$.  In an exactly analogous way, we can prove by induction that $B_n=\frac{1}{2}+\frac{1}{3}(n-2)$ and (OP's result) that $$A_n=1+\frac{1}{3}(n-2)=\frac{1}{3}(n+1) \qquad {\text{for }} n\ge 2.$$

A: This is not (yet) a solution, so please don't grade this, but I need more space than is available in a comment to provide some insights:
A simple lemma: The smallest number of possible final piles is $k=1$--reached many ways, but for instance by $(1,2,3,4,\ldots,n)$. The largest number of piles is $k=n/2$--reached many ways, but for instance by ($1,3,5,7,\ldots)$.
Given a deck of $n$ cards (where $n$ is large), the number of ways to get a single final pile is bounded by $\approx n 2^{n-1}$.  There are $n$ places for the first card, thereby defining the pile.  Given a pile, there are only two "available" numbers that can ensure a new pile is not formed:  the maximum in the pile +1 and the minimum in the pile -1.  Note that this is in the large-$n$ limit, where end effects (temporary piles having a card value $1$ or having card value $n$ mean that only one slot is available).  After all, once either the $1$ card or the $n$ card is drawn in this scenario, there is but a single sequence (leading sequentially from the current "open" boundary of the pile to either $1$ or $n$) that will preserve a single pile.
The number of ways to get the maximum $n/2$ piles is bounded by $\approx n (n/2-1)(n/2-2)\ldots 1 \cdot (n/2)!$.  There are $n$ slots for the first card.  Suppose the first card happens to be odd valued.  Then the only slots available (in this case) are the remaining odd values.  There are approximately $n/2-1$ of them.  Once the next card is chosen (and must be odd), there are are $(n/2-2)$ available slots.  And so on until all the odd slots are filled.  Then there are the remaining $n/2$ even cards which can be placed in the remaining unused $n/2$ even places in $(n/2)!$ ways.
Of course, the total number of ways in which to draw cards is $n!$.


text:
Q: Is the following set closed in $\ell_{p}$ for $1\le p$?
Let $S=\left\{ \left\{a_n\right\}_{n=1}^\infty\in\ell_{p}\mid
 \sum_{n=1}^\infty {a_n}=1, a_n\ge0 \ \forall \ n\in\Bbb N \right\}$
Is the set $S$ closed in the normed space
  $\left(\ell_{p},\|\cdot\|_{p}\right)$ for $1\le p$ ?

I was able to conclude that S is actually closed in $\left(\ell_{1},\|\cdot\|_{1}\right)$ by proceeding the following way:
Let $\left\{y_{n}\right\}_{n=1}^\infty$ be a sequence (of sequences) such that $y_n=\left\{y_{k}^{n}\right\}_{k=1}^\infty\in S\ \forall \ n\in\Bbb N$ and $y_{n}\rightarrow x$ as $n\rightarrow\infty$, where $x=\left\{x_k\right\}_{k=1}^\infty\in \ell_{1}$
If we prove that $x\in S$, then S would be closed. Given any fixed $k\in\Bbb N$, we can deduce from the convergence of $y_{n}$ to $x$ as $n\rightarrow\infty$ that $y_{k}^{n}\rightarrow x_k$ as $n\rightarrow\infty$. Since $y_{k}^{n}\ge0\  \forall \ k\in\Bbb N$ then $x_k\ge0$.
Therefore $x_k\ge0\ \forall \ k\in\Bbb N$.
Now, since $y_n\rightarrow x$ as $n\rightarrow\infty$ and $\|y_n\|_{1}=1\ \forall \ n\in\Bbb N$, by continuity of the norm we obtain that $1=\|y_n\|_{1}\rightarrow \|x\|_{1}$ as $n\rightarrow\infty$. Then, $\|x\|_{1}=1$, which implies that $\|x\|_{1}=\sum_{k=1}^\infty {|x_k|}=\sum_{k=1}^\infty {x_k}=1$.
Therefore $x\in S$.
However, I haven't been able to prove or disprove the closedness of $S$ for the case in which $p\gt1$. I was trying to follow the same proof, but I can't conclude that $\sum_{k=1}^\infty {x_k}=1$ (at most I can conclude that $\sum_{k=1}^\infty {x_k^{p}}=1$ by continuity of the norm in $\ell_{p}$). Since the proof failed I started to think that the set might not be closed for the case in which $p\gt1$, but I haven't been to prove that it isn't closed either.
Any hints or ideas would be highly appreciated.

A: For $p>1$, the set is not closed. To see this, note that
$$
x_n = (1/n, \dots ,1/n,0\dots)
$$
is an element of $S$ (the number $1/n$ appears $n$ times).
Now, we have
$$
\Vert x_n \Vert_{\ell^p} = 1/n \cdot n^{1/p} = n ^{1/p -1}\to 0,
$$
for $p>1$. But $0$ is not an element of the set.
EDIT: Here is more on the general principle involved: Your set is defined using the linear functional
$$
\Phi : (x_n)\mapsto \sum x_n =\sum 1\cdot x_n.
$$
Then, it is not hard to see that this functional is bounded (continuous) on $\ell^1$, but not on $\ell^p$ (one way to see this is that the constant sequence $(1,\dots)$ is in $\ell^\infty$, but in no other $\ell^q$ space). In fact, $\Phi$ is not even well defined on $\ell^p$ for $p>1$.
Now it is generally true that if you have a continuous function $f$, then the set $f^{-1}(A)$ is closed if $A$ is closed itself. For linear functionals on Banach spaces, most of the time the converse is also True, i.e. a set defined through "closed conditions" on a linear functional will most of the time not be closed if the functional is not continuous. Of course, this is only a heuristic, but the proof above shows that this heuristic is correct in this case.


text:
Q: How to import modules in Paver? I am using Paver for the first time and I can't import in my pavement.py a module I created in the same directory. The module was working when imported in a standalone script in the same directory. I guess paver is running from somewhere else, not the same directory.
Any suggestion?

A: After a bit of investigation I found a solution...
import sys
sys.path.append( os.path.abspath('.') )
import mymodule.myscript as myscript


text:
Q: Have Spring Data JPA lookup matching entities for cascading How can I use Spring Data JPA with Hibernate 5.0.12 as vendor to match existing database entries onto unmanaged entities for cascading?
Say I have entities like these:
@Entity
public class Person {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;

    private String name;

    @ManyToOne(cascade = CascadeType.ALL)
    private Address address;
}

@Entity
public class Address {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;

    @Column(unique = true)
    private Integer zip;
    private String city;
}

@Repository
public interface PersonRepository extends JpaRepository<Person, Integer> {
    // implementation provided by Spring Data JPA
}

The instances originate from a JAXB unmarshaller, for our purposes let's assume:
public Person data(String name, Integer zip, String city) {
    Person person = new Person();
    person.setName(name);

    Address address = new Address();
    address.setZip(zip);
    address.setCity(city);

    person.setAddress(address);

    return person;
}

Now I'd like this code to work as described above:
Person p1 = data("Alice", 12345, "Berlin");
Person p2 = data("Bob", 12345, "Berlin");

// create a row in person table and create a row in address table
personRepository.save(p1);

// this should only create a row in person
// and assign existing address entity reference to it
personRepository.save(p2);

Naturally the code fails due to a unique constraint violation so I'm wondering if there's some way I can specify business keys for JPA to match my entities to existing rows in the database (e.g. the zip).


text:
Q: How can I make a div auto-adjust its height between two divs, according to window height using CSS/Javascript? I have a div positioned at the top of the body and another div positioned at the bottom of the body
Now I want to place a div between those two divs and have its height take the max space available between those two divs.
The vertical space between those two divs is not fixed, meaning that when the user decreases/increases the height of the window, I want the middle div to readjust its height accordingly.
More specifically :

So basically imagine a green rectangular fixed at the top left of the page, a blue one fixed at the bottom left of the page and a red column between them readjusting its height according to the height of the window.
How can I achieve this?
Setting its height at 100% simply makes the middle div expand its height to the bottom of the window which is not what I want. I need it to stop where the blue div starts. Also, making its height e.g. 73% doesn't make it auto-adjust itself correctly when the window height is changed either.

A: Assuming you are doing this because you want a footer that is flushed to the bottom of the page, then this will achieve a similar effect: http://matthewjamestaylor.com/blog/keeping-footers-at-the-bottom-of-the-page
However solution does not resize the middle div but merely positions the footer over it and then use padding to prevent the contents of the middle div from going onto the footer.
If you want to actually change the size of the middle div, here's the JavaScript for it using jQuery: http://jsfiddle.net/BnJxE/
JavaScript
var minHeight = 30; // Define a minimum height for the middle div

var resizeMiddle = function() {
    var h = $('body').height() - $('#header').height() - $('#footer').height();
    h = h > minHeight ? h : minHeight;
    $('#body').height(h);
}

$(document).ready(resizeMiddle);
$(window).resize(resizeMiddle);

HTML

CSS
html,
body {
   margin:0;
   padding:0;
   height: 100%;
}

#header {
   background:#ff0;
   height: 100px;
}
#body {
   background: #aaa;
}
#footer {
   height: 60px;
   background:#6cf;
}

A: The correct way of ending
 tag is by using
.
Try this code-

A: HTML:

...

...

            content

            content

CSS:
html, body {
    height:100%;
}
#wrapper {
    position:relative;
    height:100%;
}
#div3 {
    background:pink;
    bottom:0;
    position:absolute;
    width:100%;
}

jsfiddle: http://jsfiddle.net/BnJxE/

A: You can use paddings the same height of your top and bottom elements and set box-sizing to border-box. By setting the height to 100% it will cover the entire height minus the paddings.
JSFiddle with scrollable content

#container {
  position: fixed;
  top: 0px;
  left: 0px;
  width: 200px;
  height: 100%;
}
#top {
  float: left;
  height: 50px;
  width: 200px;
  background-color: green;
  position: fixed;
  top: 0;
}
#middle {
  float: left;
  height: 100%;
  width: 200px;
  background-color: red;
  box-sizing: border-box;
  padding-bottom: 50px;
  padding-top: 50px;
}
#bottom {
  float: left;
  height: 50px;
  width: 200px;
  background-color: blue;
  position: fixed;
  bottom: 0;
}


text:
Q: Make a J2EE application avoid updating the DB I have a JBoss 6 application running both EJB and Spring code (some legacy involved in this decision). It should communicate to Oracle and PostgreSQL databases, on demand.
JPA is the way DB operations are done, no direct JDBC is involved.
I would like to do the following: without altering the business logic, to be able to "silence" database updates/deletes from my application, without breaking the flow with any exceptions.
My current thoughts are:

*

*Set the JDBC driver as read-only from the deployment descriptor - this works only with PostgreSQL (Oracle driver does not support this)

*Make a read-only user on the RDBMS level - it might fill me up with errors

*Make all transactions rollback instead of committing - is this possible?

*Make entity manager never persist anything - set the FlushMode to MANUAL and make sure flush() never gets called - but commit() still flushes everything.

Is there any other concise approach to this?

A: If you want to make sure the application works as on production, work on a replica of the Database. Use a scheduler every night that overwrites the replica DB.

A: My request also includes the need for this behavior to be activated or deactivated at runtime.
The solution I found (currently for a proof-of-concept) is:

*

*create a new user, grant him rights on the default schema's tables;

*with this user create views for each of the tables, with the same name (without the schema prefix);

*create a trigger for each view that does nothing on insert, update, or delete, using INSTEAD OF;

*create a data source and persistence unit for this user;

*inject two entity managers at runtime, use the one that is needed;

Thanks for your help!


text:
Q: Getting permission denied while using virtual env I'm trying to install Open CV 2 on a shared hosting inside a virtualenv.
I already got numpy and all those stuff downloaded using Pip. I'm just having a bit of trouble with OpenCV2
I run this command in the ssh session
(penv)[dire]$ cmake -D MAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=$VIRTUAL_ENV/local/ -D PYTHON_EXECTUABLE=$PYTHONPATH/python2.7 -D PYTHON_PACKAGES_PATH=$VIRTUAL_ENV/lib/python2.7/site-packages -D INSTALL_PYTHON_EXAMPLES=ON ..

and the error I get is
Traceback (most recent call last):
  File "/home/bashtroubles/website.com/public/NNPics/penv/bin/cmake", line 11, in <module>
    sys.exit(cmake())
  File "/home/bashtroubles/website.com/public/NNPics/penv/local/lib/python2.7/site-packages/cmake/__init__.py", line 33, in cmake
    raise SystemExit(_program('cmake', sys.argv[1:]))
  File "/home/bashtroubles/website.com/public/NNPics/penv/local/lib/python2.7/site-packages/cmake/__init__.py", line 29, in _program
    return subprocess.call([os.path.join(CMAKE_BIN_DIR, name)] + args)
  File "/usr/lib/python2.7/subprocess.py", line 493, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
    raise child_exception
OSError: [Errno 13] Permission denied
(penv)[dire]$

This is also my .bashrc if it matters
# ~/.bashrc: executed by bash(1) for non-login shells.
# Load pythonbrew
alias pb='pythonbrew'
export PYTHONPATH=~/.pythonbrew/pythons/Python-2.7.3/lib
[[ -s /home/bashtroubles/.pythonbrew/etc/bashrc ]] && source /home/bashtroubles/.python$

# Load custom python installation
export PATH=~/opt/python-2.7.3/bin:${PATH}
export PYTHONPATH=~/opt/python-2.7.3/lib

The specific version is opencv-2.4.13 and the python version is 2.7.3
I believe the issue is because it's using the python2.7 from
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
    raise child_exception

Any ideas on how to get this going without a permission denied issue?

A: I ran into this problem. It looks like the binary it's trying to call isn't marked as an executable. I ran this to change the permissions
sudo chmod +x -R /usr/local/lib/python2.7/dist-packages/cmake-3.13.3-py2.7-linux-x86_64.egg/cmake/data/bin