Erro ao executar relatório principal - Jasper Studio

Question: Estou gerando um relatório no Jasper Studio, onde o relatório principal possui N sub relatórios, sendo que um desses relatórios possui uma conexão com um Database diferente do relatório principal.
Quando eu executo o relatório principal no Jasper Studio a primeira vez eu recebo o seguinte erro:
Caused by: java.sql.SQLException: No suitable driver found for jdbc:postgresql://192.168.1.226:5432/BancoDados
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at gerenciamentoContratosTI_Master_1527160426610_582447.evaluate
(gerenciamentoContratosTI_Master_1527160426610_582447:241)
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:250)
Porém se eu vou nesse sub relatório e executo ele sozinho (Que funciona normalmente) e depois executo novamente o relatório principal funciona normalmente, alguém sabe o que pode estar causando isso?

Outra coisa que notei é que as vezes se ocorre esse erro e eu tento executar novamente o mesmo relatório sem alterar nada o erro não ocorre novamente, porém quando estou tentando gerar o relatório fora do Jasper studio o erro sempre ocorre mesmo executando mais de uma vez.
CÓDIGO DO RELATÓRIO
<?xml version="1.0" encoding="UTF-8"?>

<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="gerenciamentoContratosTI_Master" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="31b1aa49-0fa2-4acf-9b60-510e34a327f8">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="conexaoMySQL"/>
    <property name="com.jaspersoft.studio.unit." value="pixel"/>
    <parameter name="empresaInicial" class="java.lang.String"/>
    <parameter name="dataInicial" class="java.lang.String"/>
    <parameter name="dataFinal" class="java.lang.String"/>
    <parameter name="conteudoPrincipal" class="java.lang.String">
        <defaultValueExpression><![CDATA["C:\\Users\\romualdo\\JaspersoftWorkspace\\MyReports\\RelatoriosFinal\\resumoTrimestral.jasper"]]></defaultValueExpression>
    </parameter>
    <parameter name="tempoTotal" class="java.lang.String">
        <defaultValueExpression><![CDATA["C:\\Users\\romualdo\\JaspersoftWorkspace\\MyReports\\RelatoriosFinal\\tempoTotalTrimestre.jasper"]]></defaultValueExpression>
    </parameter>
    <parameter name="cabecalho" class="java.lang.String">
        <parameterDescription><![CDATA[]]></parameterDescription>
        <defaultValueExpression><![CDATA["C:\\Users\\romualdo\\JaspersoftWorkspace\\MyReports\\RelatoriosFinal\\dadosContratosTI.jasper"]]></defaultValueExpression>
    </parameter>
    <parameter name="empresaFinal" class="java.lang.String"/>
    <parameter name="chamados" class="java.lang.String">
        <defaultValueExpression><![CDATA["C:\\Users\\romualdo\\JaspersoftWorkspace\\MyReports\\RelatoriosFinal\\Chamados.jasper"]]></defaultValueExpression>
    </parameter>
    <parameter name="resumoMensal" class="java.lang.String">
        <parameterDescription><![CDATA[]]></parameterDescription>
        <defaultValueExpression><![CDATA["C:\\Users\\romualdo\\JaspersoftWorkspace\\MyReports\\RelatoriosFinal\\resumoMensal.jasper"]]></defaultValueExpression>
    </parameter>
    <parameter name="valorTotalRequisicoes" class="java.lang.String">
        <defaultValueExpression><![CDATA["C:\\Users\\romualdo\\JaspersoftWorkspace\\MyReports\\RelatoriosFinal\\valorTotalRequisicoes.jasper"]]></defaultValueExpression>
    </parameter>
    <queryString language="SQL">
        <![CDATA[SELECT
    otrs.ticket.customer_id as EMPRESA,
    (case when day(sysdate()) < 10 then MONTHNAME(STR_TO_DATE(Month(now()) -1,'%m')) else
    MONTHNAME(STR_TO_DATE(Month(now()),'%m')) end) as mes
FROM
    otrs.ticket,
    otrs.users,
    otrs.ticket_type,
    otrs.ticket_state,
    otrs.service,
    otrs.time_accounting,
   otrs.customer_company cc2
WHERE
    cc2.valid_id = 1 and
    cc2.customer_id = otrs.ticket.customer_id and
    otrs.ticket.id = otrs.time_accounting.ticket_id and
    otrs.ticket.user_id = otrs.users.id and
    otrs.ticket.type_id = otrs.ticket_type.id and
    otrs.ticket.ticket_state_id = otrs.ticket_state.id and
    otrs.ticket.service_id = otrs.service.id and
    /*otrs.ticket.change_time between '2018-02-01' and '2018-04-30' and*/
    otrs.time_accounting.change_time between $P!{dataInicial} and $P!{dataFinal} and
    otrs.ticket.customer_id between $P{empresaInicial} and $P{empresaFinal} and
    otrs.ticket_type.name = 'Contrato PCH'
group by
    EMPRESA
order by
    EMPRESA]]>
    </queryString>
    <field name="EMPRESA" class="java.lang.String"/>
    <field name="mes" class="java.lang.String"/>
    <variable name="valorTotalRelatorio" class="java.lang.Double" resetType="Group" resetGroup="Empresa" calculation="System"/>
    <variable name="valorHoraTrimestralRelatorio" class="java.lang.Double" resetType="Group" resetGroup="Empresa" calculation="System"/>
    <variable name="multiplicadorServidorRelatorio" class="java.lang.Double" resetType="Group" resetGroup="Empresa" calculation="System"/>
    <variable name="valorHoraAdicionalRelatorio" class="java.lang.Double" resetType="Group" resetGroup="Empresa" calculation="System"/>
    <variable name="horasContratadasRelatorio" class="java.lang.Integer" resetType="Group" resetGroup="Empresa" calculation="System"/>
    <variable name="quantidadeChamados" class="java.lang.Integer" resetType="None" incrementType="Group" incrementGroup="Empresa" calculation="Count"/>
    <variable name="valorMensalRelatorio" class="java.lang.Double" resetType="Group" resetGroup="Empresa" calculation="System"/>
    <variable name="arrayChamadosRelatorio" class="java.lang.String" resetType="Group" resetGroup="Empresa" calculation="System"/>
    <variable name="valorTotalRequisicoesRelatorio" class="java.lang.Double" calculation="System"/>
    <group name="Empresa">
        <groupExpression><![CDATA[$F{EMPRESA}]]></groupExpression>
        <groupHeader>
            <band height="181">
                <property name="local_mesure_unitheight" value="pixel"/>
                <property name="com.jaspersoft.studio.unit.height" value="px"/>
                <rectangle>
                    <reportElement x="0" y="71" width="802" height="20" forecolor="#4A8FC7" backcolor="#4A8FC7" uuid="7dff156d-4f09-428e-be15-6c4df13d2f9f">
                        <property name="local_mesure_unitheight" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.height" value="px"/>
                    </reportElement>
                </rectangle>
                <subreport>
                    <reportElement x="10" y="95" width="670" height="76" uuid="75b469b7-ec70-423b-bf4e-f0b5e06284c1">
                        <property name="local_mesure_unitheight" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.height" value="px"/>
                        <property name="local_mesure_unitwidth" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    </reportElement>
                    <subreportParameter name="empresaInicial">
                        <subreportParameterExpression><![CDATA[$F{EMPRESA}]]></subreportParameterExpression>
                    </subreportParameter>
                    <subreportParameter name="dataFinal">
                        <subreportParameterExpression><![CDATA[$P{dataFinal}]]></subreportParameterExpression>
                    </subreportParameter>
                    <connectionExpression><![CDATA[java.sql.DriverManager.getConnection("jdbc:postgresql://192.168.1.226:5432/BancoDados","postgres","9ORwi%Iz4Uq9")]]></connectionExpression>
                    <returnValue subreportVariable="valorHoraTrimestralSubRelatorio" toVariable="valorHoraTrimestralRelatorio"/>
                    <returnValue subreportVariable="multiplicadorServidorSubRelatorio" toVariable="multiplicadorServidorRelatorio"/>
                    <returnValue subreportVariable="valorHoraAdicionalSubRelatorio" toVariable="valorHoraAdicionalRelatorio"/>
                    <returnValue subreportVariable="horasContratadasSubRelatorio" toVariable="horasContratadasRelatorio"/>
                    <returnValue subreportVariable="valorMensalSubRelatorio" toVariable="valorMensalRelatorio"/>
                    <subreportExpression><![CDATA[$P{cabecalho}]]></subreportExpression>
                </subreport>
                <textField>
                    <reportElement x="58" y="71" width="398" height="20" forecolor="#FFFFFF" backcolor="#FFFFFF" uuid="30790453-d6db-499c-9e64-b5c7de8e837f"/>
                    <textElement textAlignment="Left" verticalAlignment="Middle">

                    </textElement>
                    <textFieldExpression><![CDATA[$F{EMPRESA}]]></textFieldExpression>
                </textField>
                <staticText>
                    <reportElement x="1" y="71" width="55" height="20" forecolor="#FFFFFF" backcolor="#FFFFFF" uuid="f32bbd89-a209-4f81-ab82-0b7c51042316">
                        <property name="local_mesure_unitwidth" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    </reportElement>
                    <textElement textAlignment="Right" verticalAlignment="Middle">

                    </textElement>
                    <text><![CDATA[   CLIENTE:]]></text>
                </staticText>
                <image>
                    <reportElement x="10" y="13" width="121" height="37" uuid="44f92e3c-9af6-4264-bdd3-cfa1edc638f0"/>
                    <imageExpression><![CDATA["http://www.hss.com.br/images/logo_oficial.png"]]></imageExpression>
                </image>
                <staticText>
                    <reportElement x="172" y="11" width="498" height="21" uuid="1ce8eb7c-edca-40b6-bdf8-dcf0022444bf"/>
                    <textElement textAlignment="Center" verticalAlignment="Middle">

                    </textElement>
                    <text><![CDATA[RELATÓRIO DE GERENCIAMENTO DE CHAMADOS]]></text>
                </staticText>
                <textField>
                    <reportElement x="351" y="32" width="100" height="20" uuid="593ccefe-36e5-49cd-8fe4-80ac098c4bd6"/>
                    <textElement textAlignment="Center" verticalAlignment="Middle">

                    </textElement>
                    <textFieldExpression><![CDATA[$F{mes}.replace("January", "Janeiro").replace("February", "Fevereiro").replace("March", "Março").replace("April", "Abril").replace("May", "Maio").replace("June", "Junho").replace("July", "Julho").replace("August", "Agosto").replace("September", "Setembro").replace("October", "Outubro").replace("November", "Novembro").replace("December", "Dezembro")]]></textFieldExpression>
                </textField>
            </band>
        </groupHeader>
        <groupFooter>
            <band height="1">
                <break>
                    <reportElement x="0" y="0" width="99" height="1" uuid="90838081-d37e-45bd-b976-39e6c76a3dc0"/>
                </break>
            </band>
        </groupFooter>
    </group>
    <background>
        <band splitType="Stretch"/>
    </background>
    <detail>
        <band height="80">
            <property name="local_mesure_unitheight" value="pixel"/>
            <property name="com.jaspersoft.studio.unit.height" value="px"/>
            <rectangle>
                <reportElement x="7" y="10" width="384" height="15" forecolor="#4A8FC7" backcolor="#4A8FC7" uuid="77a5a131-5aa3-4094-9fa9-04f2fd2f1cd6">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
            </rectangle>
            <rectangle>
                <reportElement x="412" y="10" width="384" height="15" forecolor="#4A8FC7" backcolor="#4A8FC7" uuid="5b5c11ca-5d00-47ab-b278-3bd60489290f"/>
            </rectangle>
            <staticText>
                <reportElement x="412" y="30" width="55" height="15" uuid="714e6f4c-a47d-4916-96cb-217c63fe9fe6">
                    <property name="local_mesure_unitwidth" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <box>
                    <topPen lineWidth="0.6"/>
                    <leftPen lineWidth="0.6"/>
                    <bottomPen lineWidth="0.1"/>
                    <rightPen lineWidth="0.1"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle">

                </textElement>
                <text><![CDATA[Mês]]></text>
            </staticText>
            <staticText>
                <reportElement x="412" y="45" width="55" height="15" uuid="dbe27dfa-8a79-4f1b-abc2-1af7f31f8cd7">
                    <property name="local_mesure_unitwidth" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <box>
                    <topPen lineWidth="0.1"/>
                    <leftPen lineWidth="0.6"/>
                    <bottomPen lineWidth="0.6"/>
                    <rightPen lineWidth="0.1"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <text><![CDATA[Horas]]></text>
            </staticText>
            <subreport>
                <reportElement x="467" y="30" width="252" height="30" uuid="fbf525b1-4034-4953-b828-86c2f7c634b1">
                    <property name="local_mesure_unitwidth" value="pixel"/>
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <subreportParameter name="empresa">
                    <subreportParameterExpression><![CDATA[$F{EMPRESA}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="dataInicial">
                    <subreportParameterExpression><![CDATA[$P{dataInicial}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="dataFinal">
                    <subreportParameterExpression><![CDATA[$P{dataFinal}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="parametro">
                    <subreportParameterExpression><![CDATA[$V{multiplicadorServidorRelatorio}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA[$P{conteudoPrincipal}]]></subreportExpression>
            </subreport>
            <staticText>
                <reportElement x="719" y="30" width="77" height="15" uuid="4bd30050-0093-4014-b5f5-37a6f1a76b63">
                    <property name="local_mesure_unitwidth" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <box>
                    <topPen lineWidth="0.6"/>
                    <leftPen lineWidth="0.1"/>
                    <bottomPen lineWidth="0.1"/>
                    <rightPen lineWidth="0.6"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle">

                </textElement>
                <text><![CDATA[Tempo total]]></text>
            </staticText>
            <subreport>
                <reportElement x="719" y="45" width="77" height="15" uuid="366ce86a-3346-488f-ab79-a01b1e2ec669">
                    <property name="local_mesure_unitwidth" value="pixel"/>
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <subreportParameter name="empresa">
                    <subreportParameterExpression><![CDATA[$F{EMPRESA}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="dataInicial">
                    <subreportParameterExpression><![CDATA[$P{dataInicial}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="dataFinal">
                    <subreportParameterExpression><![CDATA[$P{dataFinal}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="parametro">
                    <subreportParameterExpression><![CDATA[$V{multiplicadorServidorRelatorio}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <returnValue subreportVariable="valorTotalSubRelatorio" toVariable="valorTotalRelatorio"/>
                <subreportExpression><![CDATA[$P{tempoTotal}]]></subreportExpression>
            </subreport>
            <staticText>
                <reportElement x="554" y="10" width="100" height="15" forecolor="#FFFFFF" backcolor="#FFFFFF" uuid="b6d363b6-05d8-450f-9c97-1ea965339239">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement textAlignment="Center" verticalAlignment="Top">

                </textElement>
                <text><![CDATA[Trimestre]]></text>
            </staticText>
            <textField pattern="">
                <reportElement x="148" y="10" width="100" height="15" forecolor="#FFFFFF" backcolor="#FFFFFF" uuid="229eebaa-f51b-4186-938a-06c341e19f40">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement textAlignment="Center" verticalAlignment="Top">

                </textElement>
                <textFieldExpression><![CDATA[$F{mes}.replace("January", "Janeiro").replace("February", "Fevereiro").replace("March", "Março").replace("April", "Abril").replace("May", "Maio").replace("June", "Junho").replace("July", "Julho").replace("August", "Agosto").replace("September", "Setembro").replace("October", "Outubro").replace("November", "Novembro").replace("December", "Dezembro")]]></textFieldExpression>
            </textField>
            <subreport>
                <reportElement x="7" y="30" width="384" height="45" uuid="7312ba1a-c833-454e-a5ed-0ac8b86a2695">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <subreportParameter name="empresa">
                    <subreportParameterExpression><![CDATA[$F{EMPRESA}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="parametro">
                    <subreportParameterExpression><![CDATA[$V{multiplicadorServidorRelatorio}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <returnValue subreportVariable="arrayChamadosSubRelatorio" toVariable="arrayChamadosRelatorio"/>
                <subreportExpression><![CDATA[$P{resumoMensal}]]></subreportExpression>
            </subreport>
            <line>
                <reportElement stretchType="RelativeToTallestObject" x="406" y="0" width="1" height="80" uuid="972f5ac6-a5e9-43a1-aa2f-50d10c2c1bfe">
                    <property name="local_mesure_unitwidth" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <graphicElement>
                    <pen lineStyle="Dashed" lineColor="#D9D9D9"/>
                </graphicElement>
            </line>
            <line>
                <reportElement stretchType="RelativeToTallestObject" x="802" y="0" width="1" height="80" uuid="9c1090f2-20de-481a-8207-6a12b06552b3">
                    <property name="local_mesure_unitwidth" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <graphicElement>
                    <pen lineStyle="Dashed" lineColor="#D9D9D9"/>
                </graphicElement>
            </line>
            <line>
                <reportElement x="406" y="0" width="397" height="1" uuid="8b17c238-66c5-4b94-8da0-0a4427b622ff">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                    <property name="local_mesure_unitwidth" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <graphicElement>
                    <pen lineStyle="Dashed" lineColor="#D9D9D9"/>
                </graphicElement>
            </line>
            <line>
                <reportElement x="0" y="0" width="397" height="1" uuid="4292612f-4f93-4931-bc0f-ba79878be37c">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                    <property name="local_mesure_unitwidth" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <graphicElement>
                    <pen lineStyle="Dashed" lineColor="#D9D9D9"/>
                </graphicElement>
            </line>
            <line>
                <reportElement stretchType="RelativeToTallestObject" x="397" y="0" width="1" height="80" uuid="096d778a-0de1-4415-b1ea-89ca9fba7688">
                    <property name="local_mesure_unitwidth" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <graphicElement>
                    <pen lineStyle="Dashed" lineColor="#D9D9D9"/>
                </graphicElement>
            </line>
            <line>
                <reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="1" height="80" uuid="0f150b56-4ef1-44d7-8776-5981c7d48c9d">
                    <property name="local_mesure_unitwidth" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <graphicElement>
                    <pen lineStyle="Dashed" lineColor="#D9D9D9"/>
                </graphicElement>
            </line>
        </band>
        <band height="272">
            <staticText>
                <reportElement x="496" y="45" width="103" height="15" uuid="9180e0f1-23b1-410e-8a94-0767ef08b84d">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <box>
                    <topPen lineWidth="0.1"/>
                    <leftPen lineWidth="0.6"/>
                    <bottomPen lineWidth="0.1"/>
                    <rightPen lineWidth="0.1"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <text><![CDATA[Valor hora adicional]]></text>
            </staticText>
            <textField>
                <reportElement x="599" y="45" width="103" height="15" uuid="f5c1b9fa-4807-4954-b63b-44cb455f9782">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                    <property name="local_mesure_unitwidth" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <box>
                    <topPen lineWidth="0.1"/>
                    <leftPen lineWidth="0.1"/>
                    <bottomPen lineWidth="0.1"/>
                    <rightPen lineWidth="0.6"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[java.text.NumberFormat.getCurrencyInstance(new Locale("pt","br")).format($V{valorHoraAdicionalRelatorio})]]></textFieldExpression>
            </textField>
            <textField pattern="#0.00">
                <reportElement x="599" y="30" width="103" height="15" uuid="90d29675-0270-401a-8c81-7aa72ffc958f">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                    <property name="local_mesure_unitwidth" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>

Comment: Vou atualizar minha pergunta com o código do relatório @Macario1983, Tive que colocar menos linhas por que atingiu o limite permitido pelo stack
Comment: Vc já "linkou" os dados do banco ao relatório? Tem como postar o código do relatório?
Comment: Cara, pq vc n faz o tratamento de sql e população fora do relatório?
Comment: @Macario1983 mas como poderia passar isso para o relatório? Pois serão sempre N registros retornados do banco
Comment: Cara vc esta usando classes model? Pq precisa passar um objeto e na hora de montar o relatório vc usaria estes campos
Comment: @Macario1983 eu não tenho muito conhecimento em Jasper assim, o que eu estou usando agora, é passar parâmetros para meus comandos SQL's tanto dentro do relatório principal quanto nos sub relatórios, o que seria essas classes model?
Comment: Vamos [continuar esta discussão no chat](https://chat.stackexchange.com/rooms/78740/discussion-between-macario1983-and-r-santos).
Answer: Esse aparenta ser um erro de classpath. O problema não acontece após a primeira execução do relatório porque, antes de executar o relatório a IDE do jasper compila os arquivos e coloca as dependências junto aos compilados.
Usa o tutorial desse link, da propria jasper soft, para reconfigurar sua conexão dentro da IDE Jasper Soft.
Para a sua aplicação, se certifica de que os jars de conexão do seu banco de dados estão no classpath de aplicação e estão acessíveis também à sua aplicação (web-inf/lib por exemplo).
Comment: Eu já adicionei os Jar's no classpath e aparentemente pelo link que você me passou eu já configurei a conexão na IDE Jasper Soft. Tanto que o erro acusa no driver do Postgresql que é algo que vem configurado de forma nativa no Jasper Studio. E eu estranhei que se eu executo o subrelatório antes do relatório principal funciona o relatório principal dai, isso já aconteceu contigo alguma vez?


how to set a node to anonymous author?

Question: Change node author works :
$node = \Drupal\node\Entity\Node::load($nid);
$node->set('uid','45');
$node->save();

But i don't know how to set it to anonymous user ? or unset it ?
 $node = \Drupal\node\Entity\Node::load($nid);
 // set uid to anonymous ?
 $node->save();

Answer: $node->set('uid', 0); $node->save should have worked. Maybe you forgot to flush caches.
To programmatically set the author to anonymous user on any entity you can call $entitiy->setOwnerId(0); and then $entity->save();, done.
$entity->setOwnerId(0);
$entity->save();

Comment: i figured out $node->set('uid', 0); $node->save worked indeed but the content was not listed on /admin/content because of the view relation with author. When opting out "Exiger cette relation" ,the content is there but the user column is empty instead of anonymous
Comment: both options work then but the content author is not set to anonymous as it is when deleting content and reassiging using the backoffice. The consequence is the /admin/content view must be modified in order to see the reassigned content with ownerId 0

how to set a node to anonymous author?


How to prepare for a music major?

Question: do you guys know how to prepare for a music major?
More specifically a composition major, in an university/faculty that emphasizes performance. (or a conservatory)
Should I be a master at my instrument?
Answer: You need to be humble, first and foremost.  Especially as an undergraduate, accept and try everything that your teachers tell you - especially if you don't agree with what they say.  Composers who believe they know best tend to learn little and their careers suffer as well.
Write as much music as humanly possible.
ALWAYS revise - especially when it's painful and you believe that you love what you have.
Write everyday; never stop, no matter how long or arduous the process may seem.
You do not need to be a master of your instrument, but you can only write music as expressively as you yourself can perform it, so think about that. Also, I would highly suggest writing for every type of instrument you can get your hands on - talk to the people who play those instruments WELL, and take notes. Do not believe for a second that writing for an orchestra makes you a respected composer.
If you're in high school and applying to some universities, I would try to get your high school band / chorus to perform / record something of yours. It wouldn't be a bad idea to write something for yourself as well.  ALWAYS try and diversify your pallet of experience: write for what you don't know. If you play brass, write for strings, woodwinds, and percussion.  Write for everything.  All the time. Always.
If you are already enrolled in the university, I would highly recommend taking the pedagogy classes that your music education classmates are taking.  Learning how to play each instrument (and the issues therein) is one of the best things you can do for yourself.
Good luck.
Comment: This is a good answer.  Basically, you need to have a primary instrument that you play well, you need to be able to pick up other instruments to check for playability and range at a basic level, and (this is something jj didn't mention) you need to be very good at analyzing music -- that means studying music theory.  You'll also need a lot of patience, or else be preparing for a day job.  Music composition will not earn you the downpayment on a house, unless you get a teaching job in a music department.  That takes time -- hence the remark about patience.
Comment: @aparente001 Yes, you're right, I forgot! Analyzing other people's music *does* take theory, but analyzing your own music (especially when composing) takes experience and an objective eye; composers must keep their idealized, mental projection of their intent in focus.
Answer: I failed an audition for DePaul's music composition program (the only school to offer a Jazz Composition degree), so I can offer a few tips.
You should be able to sight-read simple pieces on your primary instrument cold. And you will be expected to go beyond just playing correctly, but musically -- with any piece of music they put in front of you. Now of course, they're not going to hand you a Bach fugue (but if you can play one, they'll probably want to hear that, too). But you should be fluent on your primary instrument, though you don't need to be a virtuoso -- that's what the school is for.
You should bring some things that you've written, but avoid being too avant garde. That original that you scrawled on poster board with a dip pen in red and purple ink -- leave that at home. Write it out nicely, in standard notation. Even better, bring more than one copy so they can read along. Don't try to out-Schoenberg Prokofiev, because you won't do it justice.
[Hm, need to edit-out some sour grapes, there.]
Comment: Though they both lived at the same time, I do not believe Schoenberg and Prokofiev shared compositional techniques with one another. Now, Stravinksy on the other hand...
Comment: Was  the program solely on composition? Or composition and performance (or something like that)?
Comment: I auditioned on piano, which I had only played for 2 years, having played guitar for 6 years at that point (age 16). So I was told that I wasn't sufficiently competent on my chosen primary instrument: piano. This was in conjunction with an early-acceptance application, so that may have raised the bar on me. I could play every song recorded by Tori Amos (pre-1996) but I couldn't play this piece they put in front of me that was supposed to sound like a rooster crowing or something. I forget the title, or maybe I never knew it.
Comment: @jjmusicnotes I had listened to them all devoutly, but without any rigorous study or analysis of technique. So I had written a few pieces that just kinda *sounded weird* but pleasing *to me*. And they weren't impressed. I later realized that it only sounded right on *my* piano, which was an ex-player upright, not in particularly good repair. Certain combinations of notes would evoke these eerie resonances from that sorry instrument that simply couldn't be reproduced on another piano.
Answer: A good composer would still be proficient in one or more instruments. Do not stop playing your instrument just because you have decided you want to compose.
As with all music programs the more theory you know the better. That is also actually one of the better reasons why you should do theory as it educates you in how to compose.
Also I would start analysing a lot of scores. The wider your musical knowledge spans the better informed your own compositions would be.
Write a lot of melodies. They form the basis of all compositions.
Comment: Personally, I've found music history to be much for informing compositionally than theory, but that's just me.  Theory helps if you're stuck on an idea sometimes.  Also, melodies absolutely *do not* form the basis of **all** compositions.

How to prepare for a music major?


Sum of an exponential function/Mathematica

Question: I have a function that looks like following:
$$T=2\sum_{n=1}^{\infty}\frac{(-1)^{n-1}\cos(\lambda_n x)}{\lambda_n}\exp(-\lambda_n^2 t)$$
where $\lambda_n=\frac{(2n-1)\pi}{2}$. I use Mathematica to plot $T$ as a function of $x$ in the range of {x,0,1} for different $t$ values. The solution when $t=0$ and $t=\infty$ appears correctly. However, for all values $0<t<\infty$ the software keeps running. I am wondering if the exponential function has a special command to use in Mathematica or I am missing something in my code.
Here is my Mathematica syntax:
Plot[Simplify[ Abs[2 Sum[((-1)^(n - 1) Cos[((2 n - 1) [Pi])/2 x])/(((2 n - 1) [Pi])/2) Exp[-(((2 n - 1) [Pi])/2)^2 (t)], {n, 1, Infinity}]], Assumptions -> {x > 0}] // Evaluate, {x, 0, 1}, PlotRange -> All]
Any help would be highly appreciated!
Lama
Comment: You had an unescaped `<` outside of MathJax or a code markup. So the parser interpreted that as the start of a HTML tag. An invalid tag that was never closed, but HTML parsers are used to just ignore such niceties as correct syntax [the web would be less than half as large as it is if they refused incorrect syntax], and go on nevertheless. But of course tags aren't rendered.
Answer: When $\,t=0\,$:
$$ T=2\sum_{n=1}^{\infty}\frac{(-1)^{n-1}\cos\left(\lambda_n\,x\right)}{\lambda_n} = \frac{2}{\pi}\left[\arctan\left({\large e}^{-i\frac{\pi}{2}x}\right)+\arctan\left({\large e}^{+i\frac{\pi}{2}x}\right)\right] $$
And this is a famous square wave function.

When $\,x=1\,$:
$$ T=2\sum_{n=1}^{\infty}\frac{(-1)^{n-1}\cos\left(\lambda_n\right)}{\lambda_n}\,{\large e}^{-\lambda_n^2\,t} = \color{red}{0} \quad\text{for all }t\quad\left\{{\small\cos\left((2n-1)\frac{\pi}{2}\right)=0}\right\} $$

Noticing the series is rapid convergent, exploiting Mathematica defining functions capabilities,
Perhaps it will be better to define a function $\,f(x,t,l)\,$ As shown below,

And start plotting multiple graphs for different values of $\,t\,$ at the same time. Enjoy!

f[x_, t_, l_] := 2 Sum[((-1)^(n - 1)) Cos[(((2 n - 1) Pi)/2) x] Exp[-((((2 n - 1) Pi)/2)^2) t]/(((2 n - 1) Pi)/2), {n, 1, l}];
Plot[{f[x, 0/4, 100], f[x, 1/4, 100], f[x, 2/4, 100], f[x, 3/4, 100], f[x, 4/4, 100], f[x, 5/4, 100]}, {x, -1, +1}]
Comment: Now that's a beauty!! Many thanks for your help!!!


Run both sshd and httpd SSL on port 443

Question: Is it possible by anyway (maybe with inetd) to make 443 port serve both as sshd and as httpd SSL?
Perhaps by analysing the request, if request is "CONNECT", then let httpd handle the connection; if request is ssh initialization, then let sshd handle it.
Comment: Why in the world would you want to do this? The only reason I can think of for something like this would be to go around company firewall policies.
Comment: @Zypher: you are right, that's what I wanted to do
Comment: @Zypher: I do not see how this is off-topic, it may be undesirable behaviour, but it is still server software setup, it is not "off-topic".  Just unpleasant.
Comment: @Zypher: Good suggestion.
Comment: @Zypher Wow.  Responses like yours ("Why do you want to do that?") make me irrationally angry.  There are lots of places with open wifi (e.g. the local library) which for reasons *I* don't understand block ssh, which at times prevents me from doing my work which requires ssh into my various servers.
Comment: Too bad people closed the question.   The correct answer is yes.  Give [SSLH](http://www.rutschle.net/tech/sslh.shtml) a test.
Answer: No. When an SSH client connects, the server sends an announcement. When HTTP SSL connects the server waits for the client to start the SSL handshake (ClientHello). They're mutually exclusive ways to start the protocols.
Comment: You can use [SSLH](http://www.rutschle.net/tech/sslh.shtml) to accomplish this.
Answer: You could conceivably write a program to sit on the port, sniff the packets coming in and act as a proxy forward to the sshd and httpd servers.  I can not think of any existing software that would handle that directly and transparently.
Bit like those automatic fax/phone switchers.
Answer: You could write a program to do what you suggest (analyze the incoming traffic and send it to httpd or sshd), but I don't of any existing project.

Run both sshd and httpd SSL on port 443


Is it ok to keep/discard rules based on the holdout set?

Question: We have a POC project that is looking for rules that fit our data (eg "when a=1 and b=2 and c=3 then X=6" sort of thing). We split our data into 6 sets, and we use the first 5 sets as K-fold training sets where we say "only keep the rules where the accuracy of the rule on each of the 5 parts is within 5% of the accuracy of the other 4 combined". This gives us a bunch of rules. Then we validate each of these rules against the holdout set to see if it generalizes.
My view is that if the majority (over 90%) of the rules are failing on the holdout set then the way we are finding these rules is too overfitted and that the remaining 10% that pass validation are probably just passing by coincidence but won't perform well on future data. My colleague's view is that if we keep the 10% that passed then these are the ones that have shown to perform well on unseen data and we will have a good set of rules.
What is the standard accepted practice in this scenario? And are there any other tests one can do to say if our methodology is flawed or not?
Answer:
Is it ok to keep/discard rules based on the holdout set?

It would not be valid to perform model selection based on the holdout set if you're also using that set to estimate/report the generalization performance of your learning algorithm. Doing this would make the performance estimate overoptimistically biased.

What is the standard accepted practice in this scenario?

Performance should be evaluated using a separate, independent set of data that hasn't been used for training or model selection. Model selection may also use a separate subset of the data than training, depending on the model selection procedure. Using simple holdout, the data would be split into training, validation, and test sets. The validation set is used for model selection and the test set is used to estimate generalization performance. Alternatively, nested cross validation could be used.
It's possible for model selection to overfit the validation set, even though it contains data that hasn't been seen by the training procedure. For example, see Cawley and Talbot (2010) and this question. This is more likely to happen when searching over a larger set of models, or when the validation set is smaller. Nested cross validation would be preferred over simple holdout in this setting, because the training, validation, and test sets would effectively be larger. But, it still might not be enough to save things--in that case the only recourse is to gather more data or search a simpler/more restricted set of models.

are there any other tests one can do to say if our methodology is flawed or not?

You might try randomly permuting the outputs in the dataset, which destroys the information between input and output. Then, try to fit the permuted data. Any fitting here is, by construction, overfitting. You'd want to see that your model selection procedure correctly rejects overfit models.
References:
Cawley and Talbot (2010). On Over-fitting in Model Selection and Subsequent Selection Bias in Performance Evaluation.
Comment: Selection Bias is exactly what I was worrying about. So it seems (unfortunately) that you agree with my pessimistic view rather than my colleague's more optimistic view. Back to the drawing board!


Pull out a certain period of time worth of data from an API request

Question: import requests,json
from datetime import datetime

func = 'function=TIME_SERIES_DAILY'
sym = 'symbol=AAPL'
inter = 'interval=10min'
apikey = 'apikey=XXXXXXXXXXXXX'
url = XXXXXXXXXXXX

resp = requests.get(url)
data = json.loads(resp.content)
d = data['Time Series (Daily)']

maxdate = max((x for x in d.keys()), key=lambda x: datetime.strptime(x, "%Y-%m-%d"))
#pull_number = 5
print(d[maxdate])

Using the above code, i can pull out the latest stock data, i took Apple as an example, this pulls out the following data:

{'1. open': '250.7400', '2. high': '255.5200', '3. low': '249.4000', '4. close': '254.8100', '5. volume': '41863171'}

This gives me the latest data, how do i pull out data in a certain range of time, ie 1 week? Also i've put it to give me the data of each day  not hourly
Data which was pulled out:
{'Meta Data': {'1. Information': 'Daily Prices (open, high, low, close) and Volumes', '2. Symbol': 'AAPL', '3. Last Refreshed': '2020-03-30', '4. Output Size': 'Compact', '5. Time Zone': 'US/Eastern'}, 'Time Series (Daily)': {'2020-03-30': {'1. open': '250.7400', '2. high': '255.5200', '3. low': '249.4000', '4. close': '254.8100', '5. volume': '41863171'}, '2020-03-27': {'1. open': '252.7500', '2. high': '255.8700', '3. low': '247.0500', '4. close': '247.7400', '5. volume': '51054153'}, '2020-03-26': {'1. open': '246.5200', '2. high': '258.6800', '3. low': '246.3600', '4. close': '258.4400', '5. volume': '63140169'}, '2020-03-25': {'1. open': '250.7500', '2. high': '258.2500', '3. low': '244.3000', '4. close': '245.5200', '5. volume': '75900510'}, '2020-03-24': {'1. open': '236.3600', '2. high': '247.6900', '3. low': '234.3000', '4. close': '246.8800', '5. volume': '71882773'}, '2020-03-23': {'1. open': '228.0800', '2. high': '228.4997', '3. low': '212.6100', '4. close': '224.3700', '5. volume': '84188208'}, '2020-03-20': {'1. open': '247.1800', '2. high': '251.8300', '3. low': '228.0000', '4. close': '229.2400', '5. volume': '100423346'}, '2020-03-19': {'1. open': '247.3850', '2. high': '252.8400', '3. low': '242.6100', '4. close': '244.7800', '5. volume': '67964255'}, '2020-03-18': {'1. open': '239.7700', '2. high': '250.0000', '3. low': '237.1200', '4. close': '246.6700', '5. volume': '75058406'}, '2020-03-17': {'1. open': '247.5100', '2. high': '257.6100', '3. low': '238.4000', '4. close': '252.8600', '5. volume': '81013965'}, '2020-03-16': {'1. open': '241.9500', '2. high': '259.0800', '3. low': '240.0000', '4. close': '242.2100', '5. volume': '80605865'}, '2020-03-13': {'1. open': '264.8900', '2. high': '279.9200', '3. low': '252.9500', '4. close': '277.9700', '5. volume': '92683032'}, '2020-03-12': {'1. open': '255.9400', '2. high': '270.0000', '3. low': '248.0000', '4. close': '248.2300', '5. volume': '104618517'}, '2020-03-11': {'1. open': '277.3900', '2. high': '281.2200', '3. low': '271.8600', '4. close': '275.4300', '5. volume': '64094970'}, '2020-03-10': {'1. open': '277.1400', '2. high': '286.4400', '3. low': '269.3700', '4. close': '285.3400', '5. volume': '71322520'}, '2020-03-09': {'1. open': '263.7500', '2. high': '278.0900', '3. low': '263.0000', '4. close': '266.1700', '5. volume': '71686208'}, '2020-03-06': {'1. open': '282.0000', '2. high': '290.8200', '3. low': '281.2300', '4. close': '289.0300', '5. volume': '56544246'}, '2020-03-05': {'1. open': '295.5200', '2. high': '299.5500', '3. low': '291.4100', '4. close': '292.9200', '5. volume': '46893219'}, '2020-03-04': {'1. open': '296.4400', '2. high': '303.4000', '3. low': '293.1300', '4. close': '302.7400', '5. volume': '54794568'}, '2020-03-03': {'1. open': '303.6700', '2. high': '304.0000', '3. low': '285.8000', '4. close': '289.3200', '5. volume': '79868852'}, '2020-03-02': {'1. open': '282.2800', '2. high': '301.4400', '3. low': '277.7200', '4. close': '298.8100', '5. volume': '85349339'}, '2020-02-28': {'1. open': '257.2600', '2. high': '278.4100', '3. low': '256.3700', '4. close': '273.3600', '5. volume': '106721230'}, '2020-02-27': {'1. open': '281.1000', '2. high': '286.0000', '3. low': '272.9600', '4. close': '273.5200', '5. volume': '80151381'}, '2020-02-26': {'1. open': '286.5300', '2. high': '297.8800', '3. low': '286.5000', '4. close': '292.6500', '5. volume': '49678431'}, '2020-02-25': {'1. open': '300.9500', '2. high': '302.5300', '3. low': '286.1300', '4. close': '288.0800', '5. volume': '57668364'}, '2020-02-24': {'1. open': '297.2600', '2. high': '304.1800', '3. low': '289.2300', '4. close': '298.1800', '5. volume': '55548828'}, '2020-02-21': {'1. open': '318.6200', '2. high': '320.4500', '3. low': '310.5000', '4. close': '313.0500', '5. volume': '32426415'}, '2020-02-20': {'1. open': '322.6300', '2. high': '324.6500', '3. low': '318.2100', '4. close': '320.3000', '5. volume': '25141489'}, '2020-02-19': {'1. open': '320.0000', '2. high': '324.5700', '3. low': '320.0000', '4. close': '323.6200', '5. volume': '23495991'}, '2020-02-18': {'1. open': '315.3600', '2. high': '319.7500', '3. low': '314.6100', '4. close': '319.0000', '5. volume': '38190545'}, '2020-02-14': {'1. open': '324.7300', '2. high': '325.9800', '3. low': '322.8500', '4. close': '324.9500', '5. volume': '20028447'}, '2020-02-13': {'1. open': '324.1900', '2. high': '326.2200', '3. low': '323.3500', '4. close': '324.8700', '5. volume': '23686892'}, '2020-02-12': {'1. open': '321.4700', '2. high': '327.2200', '3. low': '321.4700', '4. close': '327.2000', '5. volume': '28432573'}, '2020-02-11': {'1. open': '323.6000', '2. high': '323.9000', '3. low': '318.7100', '4. close': '319.6100', '5. volume': '23580780'}, '2020-02-10': {'1. open': '314.1800', '2. high': '321.5500', '3. low': '313.8500', '4. close': '321.5500', '5. volume': '27337215'}, '2020-02-07': {'1. open': '322.3700', '2. high': '323.4000', '3. low': '318.0000', '4. close': '320.0300', '5. volume': '29421012'}, '2020-02-06': {'1. open': '322.5700', '2. high': '325.2200', '3. low': '320.2648', '4. close': '325.2100', '5. volume': '26356385'}, '2020-02-05': {'1. open': '323.5200', '2. high': '324.7600', '3. low': '318.9500', '4. close': '321.4500', '5. volume': '29706718'}, '2020-02-04': {'1. open': '315.3100', '2. high': '319.6400', '3. low': '313.6345', '4. close': '318.8500', '5. volume': '34154134'}, '2020-02-03': {'1. open': '304.3000', '2. high': '313.4900', '3. low': '302.2200', '4. close': '308.6600', '5. volume': '43496401'}, '2020-01-31': {'1. open': '320.9300', '2. high': '322.6800', '3. low': '308.2900', '4. close': '309.5100', '5. volume': '49897096'}, '2020-01-30': {'1. open': '320.5435', '2. high': '324.0900', '3. low': '318.7500', '4. close': '323.8700', '5. volume': '31685808'}, '2020-01-29': {'1. open': '324.4500', '2. high': '327.8500', '3. low': '321.3800', '4. close': '324.3400', '5. volume': '54149928'}, '2020-01-28': {'1. open': '312.6000', '2. high': '318.4000', '3. low': '312.1900', '4. close': '317.6900', '5. volume': '40558486'}, '2020-01-27': {'1. open': '310.0600', '2. high': '311.7700', '3. low': '304.8800', '4. close': '308.9500', '5. volume': '40485005'}, '2020-01-24': {'1. open': '320.2500', '2. high': '323.3300', '3. low': '317.5188', '4. close': '318.3100', '5. volume': '36634380'}, '2020-01-23': {'1. open': '317.9200', '2. high': '319.5600', '3. low': '315.6500', '4. close': '319.2300', '5. volume': '26117993'}, '2020-01-22': {'1. open': '318.5800', '2. high': '319.9900', '3. low': '317.3100', '4. close': '317.7000', '5. volume': '25458115'}, '2020-01-21': {'1. open': '317.1900', '2. high': '319.0200', '3. low': '316.0000', '4. close': '316.5700', '5. volume': '27235039'}, '2020-01-17': {'1. open': '316.2700', '2. high': '318.7400', '3. low': '315.0000', '4. close': '318.7300', '5. volume': '34454117'}, '2020-01-16': {'1. open': '313.5900', '2. high': '315.7000', '3. low': '312.0900', '4. close': '315.2400', '5. volume': '27207254'}, '2020-01-15': {'1. open': '311.8500', '2. high': '315.5000', '3. low': '309.5500', '4. close': '311.3400', '5. volume': '30480882'}, '2020-01-14': {'1. open': '316.7000', '2. high': '317.5700', '3. low': '312.1700', '4. close': '312.6800', '5. volume': '40653457'}, '2020-01-13': {'1. open': '311.6400', '2. high': '317.0700', '3. low': '311.1500', '4. close': '316.9600', '5. volume': '30028742'}, '2020-01-10': {'1. open': '310.6000', '2. high': '312.6700', '3. low': '308.2500', '4. close': '310.3300', '5. volume': '35217272'}, '2020-01-09': {'1. open': '307.2350', '2. high': '310.4300', '3. low': '306.2000', '4. close': '309.6300', '5. volume': '42621542'}, '2020-01-08': {'1. open': '297.1600', '2. high': '304.4399', '3. low': '297.1560', '4. close': '303.1900', '5. volume': '33090946'}, '2020-01-07': {'1. open': '299.8400', '2. high': '300.9000', '3. low': '297.4800', '4. close': '298.3900', '5. volume': '27877655'}, '2020-01-06': {'1. open': '293.7900', '2. high': '299.9600', '3. low': '292.7500', '4. close': '299.8000', '5. volume': '29644644'}, '2020-01-03': {'1. open': '297.1500', '2. high': '300.5800', '3. low': '296.5000', '4. close': '297.4300', '5. volume': '36633878'}, '2020-01-02': {'1. open': '296.2400', '2. high': '300.6000', '3. low': '295.1900', '4. close': '300.3500', '5. volume': '33911864'}, '2019-12-31': {'1. open': '289.9300', '2. high': '293.6800', '3. low': '289.5200', '4. close': '293.6500', '5. volume': '25247625'}, '2019-12-30': {'1. open': '289.4600', '2. high': '292.6900', '3. low': '285.2200', '4. close': '291.5200', '5. volume': '36059614'}, '2019-12-27': {'1. open': '291.1200', '2. high': '293.9700', '3. low': '288.1200', '4. close': '289.8000', '5. volume': '36592936'}, '2019-12-26': {'1. open': '284.8200', '2. high': '289.9800', '3. low': '284.7000', '4. close': '289.9100', '5. volume': '23334004'}, '2019-12-24': {'1. open': '284.6900', '2. high': '284.8900', '3. low': '282.9197', '4. close': '284.2700', '5. volume': '12119714'}, '2019-12-23': {'1. open': '280.5300', '2. high': '284.2500', '3. low': '280.3735', '4. close': '284.0000', '5. volume': '24677883'}, '2019-12-20': {'1. open': '282.2300', '2. high': '282.6500', '3. low': '278.5600', '4. close': '279.4400', '5. volume': '69032743'}, '2019-12-19': {'1. open': '279.5000', '2. high': '281.1800', '3. low': '278.9500', '4. close': '280.0200', '5. volume': '24626947'}, '2019-12-18': {'1. open': '279.8000', '2. high': '281.9000', '3. low': '279.1200', '4. close': '279.7400', '5. volume': '29024687'}, '2019-12-17': {'1. open': '279.5700', '2. high': '281.7700', '3. low': '278.8000', '4. close': '280.4100', '5. volume': '28575798'}, '2019-12-16': {'1. open': '277.0000', '2. high': '280.7900', '3. low': '276.9800', '4. close': '279.8600', '5. volume': '32081105'}, '2019-12-13': {'1. open': '271.4600', '2. high': '275.3000', '3. low': '270.9300', '4. close': '275.1500', '5. volume': '33432806'}, '2019-12-12': {'1. open': '267.7800', '2. high': '272.5599', '3. low': '267.3210', '4. close': '271.4600', '5. volume': '34437042'}, '2019-12-11': {'1. open': '268.8100', '2. high': '271.1000', '3. low': '268.5000', '4. close': '270.7700', '5. volume': '19723391'}, '2019-12-10': {'1. open': '268.6000', '2. high': '270.0700', '3. low': '265.8600', '4. close': '268.4800', '5. volume': '22632383'}, '2019-12-09': {'1. open': '270.0000', '2. high': '270.8000', '3. low': '264.9100', '4. close': '266.9200', '5. volume': '32182645'}, '2019-12-06': {'1. open': '267.4800', '2. high': '271.0000', '3. low': '267.3000', '4. close': '270.7100', '5. volume': '26547493'}, '2019-12-05': {'1. open': '263.7900', '2. high': '265.8900', '3. low': '262.7300', '4. close': '265.5800', '5. volume': '18661343'}, '2019-12-04': {'1. open': '261.0700', '2. high': '263.3100', '3. low': '260.6800', '4. close': '261.7400', '5. volume': '16810388'}, '2019-12-03': {'1. open': '258.3100', '2. high': '259.5300', '3. low': '256.2900', '4. close': '259.4500', '5. volume': '29377268'}, '2019-12-02': {'1. open': '267.2700', '2. high': '268.2500', '3. low': '263.4500', '4. close': '264.1600', '5. volume': '23693550'}, '2019-11-29': {'1. open': '266.6000', '2. high': '268.0000', '3. low': '265.9000', '4. close': '267.2500', '5. volume': '11654363'}, '2019-11-27': {'1. open': '265.5800', '2. high': '267.9800', '3. low': '265.3100', '4. close': '267.8400', '5. volume': '16386122'}, '2019-11-26': {'1. open': '266.9400', '2. high': '267.1600', '3. low': '262.5000', '4. close': '264.2900', '5. volume': '26334882'}, '2019-11-25': {'1. open': '262.7100', '2. high': '266.4400', '3. low': '262.5200', '4. close': '266.3700', '5. volume': '21029517'}, '2019-11-22': {'1. open': '262.5900', '2. high': '263.1800', '3. low': '260.8400', '4. close': '261.7800', '5. volume': '16331263'}, '2019-11-21': {'1. open': '263.6900', '2. high': '264.0050', '3. low': '261.1800', '4. close': '262.0100', '5. volume': '30348778'}, '2019-11-20': {'1. open': '265.5400', '2. high': '266.0830', '3. low': '260.4000', '4. close': '263.1900', '5. volume': '26609919'}, '2019-11-19': {'1. open': '267.9000', '2. high': '268.0000', '3. low': '265.3926', '4. close': '266.2900', '5. volume': '19069597'}, '2019-11-18': {'1. open': '265.8000', '2. high': '267.4300', '3. low': '264.2300', '4. close': '267.1000', '5. volume': '21700897'}, '2019-11-15': {'1. open': '263.6800', '2. high': '265.7800', '3. low': '263.0100', '4. close': '265.7600', '5. volume': '25093666'}, '2019-11-14': {'1. open': '263.7500', '2. high': '264.8800', '3. low': '262.1000', '4. close': '262.6400', '5. volume': '22395556'}, '2019-11-13': {'1. open': '261.1300', '2. high': '264.7800', '3. low': '261.0700', '4. close': '264.4700', '5. volume': '25817593'}, '2019-11-12': {'1. open': '261.5500', '2. high': '262.7900', '3. low': '260.9200', '4. close': '261.9600', '5. volume': '21847226'}, '2019-11-11': {'1. open': '258.3000', '2. high': '262.4700', '3. low': '258.2800', '4. close': '262.2000', '5. volume': '20507459'}, '2019-11-08': {'1. open': '258.6900', '2. high': '260.4400', '3. low': '256.8500', '4. close': '260.1400', '5. volume': '17520495'}, '2019-11-07': {'1. open': '258.7400', '2. high': '260.3500', '3. low': '258.1100', '4. close': '259.4300', '5. volume': '23735083'}, '2019-11-06': {'1. open': '256.7700', '2. high': '257.4900', '3. low': '255.3650', '4. close': '257.2400', '5. volume': '18966124'}, '2019-11-05': {'1. open': '257.0500', '2. high': '258.1900', '3. low': '256.3200', '4. close': '257.1300', '5. volume': '19974427'}}}

Also i'm a bit new to python so please excuse me from any errors, i started a year back but i left coding because of my exams. There is an unused variable called pull_number is how many days ie 5 days worth of stock api requests from today to 5 days ago.
Comment: a tip: if you're using requests, you can replace `json.loads(resp.content)` with  `resp.json()`
Comment: alright thanks ill do that, anymore ways of making it faster?
Answer: You'll notice, that when using it daily, you have dates in the format YYYY-MM-DD which is very conveniently naturally ordered. So all you have to do to take last pull_number available dates is:
d = data['Time Series (Daily)']

print([(date, d[date]) for date in sorted(d, reverse=True)[:pull_number]])

This works by sorting the dictionary keys in reversed (descending) order and then only taking the first pull_number (so they are from newest to oldest). You could also not reverse it and take the last pull_number entries with sorted(d)[-pull_number:] (but now they are from oldest to newest).
Comment: oh yeah sorry my fault on that side after a bit of reviewing i realised i had two pull_number variables, one was [1,2,3,4,5] and one was 5, sorry :P
Comment: ```print([(date, d[date]) for date in sorted(d, reverse=True)[:pull_number]])
TypeError: slice indices must be integers or None or have an __index__ method``` when using it?
Comment: what is the type of `pull_number`? I assumed `type(pull_number) == int`


How do I host multiple independent, secured SharePoint sites (WSS 3.0) without using Active Directory on the same server?

Question: I have a SharePoint site set up on one of my networks to service Active Directory users.  To be clear, this is a Windows SharePoint Services 3.0 installation running on Windows Server 2003 Standard.  It is not an option to upgrade the server or SharePoint version.
Management would like to create several new sites, one for each of a handful of clients.  These sites will be used like "dropboxes" or FTP sites so that my company can make large files available to outside contacts, and vice versa.
Here are my requirements:

I do not want to have to create Active Directory accounts for each external contact.
If possible, I would like to store the external usernames and passwords in a database that I can write a small GUI for so that management can handle adding their own external contacts.
Each client site must be sandboxed from each other and from my main company SharePoint site.
I would like to keep everything running on port 80 and be able to access the sites as either clientname.mycompany.com or www.mycompany.com/clientname

If anybody has ever done this I would really appreciate hearing about any lessons you learned and suggestions for how to set this up.
Kyle
Comment: Watch out for the licensing implications of what you're doing here. You'd either need the external connector license of have a base Windows server CAL for each of the named accounts that you allow access to these sites.
Comment: Ah, no - sorry, chris. If no AD is used, no Windows Server CAL is needed, as this is purely an application level authentication then.
Answer: You can setup sharepoint sites to use Forms Based Authentication, if you google for that exact term you'll find tons of information. As for keeping things running on port 80, since you indicate you want to use a url like clientname.mycompany.com this is no problem, as long as that DNS FQDN (clientname.mycompany.com or *.mycompany.com) is known outside your company DNS (i.e. have all request for *.mycompany.com rerouted to that server for instance) then just creating the site with the specified URL will create a site in IIS on port 80 with host header clientname.mycompany.com...
EDIT: Another idea is to use ADAM, Active Directory Application Mode, which works like regular AD, also for sharepoint auth, but is completely separate from your own company AD.
P.S. In server 2008 it is called Active Directory Lightweight Directory Services
Comment: Forms based authentication is an ASP.NET thing, not IIS related AT ALL. All users are managed through the web UI of sharepoint. As long as the web.config authentication (membership / role provider) is set to forms and a suitable provider (i.e. the default ASP.NET MEmbership and RoleProviders) is available it WILL work, on IIS6 also. Al you need is a SQL Server db to store your users and add the correct connectionstring to the aforementioned providers in the web.config.
Comment: Forms based authentication is not supported in IIS6 (Windows 2003 Standard default) or this question would not have been necessary.


The inclusion of Sobolev spaces

Question: Let $\Omega$ denote a bounded open set in $\mathbb R^n$ with sufficiently smooth boundary. If $u\in H_m^0(\Omega ) \cap H_k^{loc}(\Omega )$ with $m,k$ two positive integers, then can we conclude that $u \in H_k(\Omega )$?
Answer: Consider the function $f:[-1,1]\rightarrow\mathbb{R}$ defined by $$f(x)=\sqrt{1-x^2}$$
Note that $f\in H_1^0([-1,1])\cap H_2^{loc}([-1,1])$, but $f\notin H_2([-1,1])$.

The inclusion of Sobolev spaces


Should I stop taking lesson from a Jazz guitar player when I want to learn Classical guitar?

Question: I am currently taking Classical guitar lessons intending to take ABRSM graded exam.
The problem now is the guitar teacher doesn't seem to be well versed in Classical guitar. I have often spotted him practising jazz guitar when he has no lesson with his students. Anyway, since I paid for lessons, I continue to attend his lessons. But all I did is to follow the textbook and play according to the textbook.  I am wondering how far he can teach the Classical guitar on a syllabus level. Maybe he can't handle higher grade ABRSM syllabus. I had asked him to demonstrate a certain piece of music for me but I sensed that he turned panicky but somehow able to briefly cross over my request.
Another issue is he can't articulate well in the English language. I often can't understand what he is trying to say and have to guess what he is trying to convey.
He praised me as a student who can be 'easily taught and understand his lessons well' but that is because  I am not new to the guitar. And I have to guess what he is saying whenever he start talking to me.
I am keen to advance to higher grade in Classical guitar but not so comfortable to take lessons with a jazz guitar player who has problem communicating with his students.
Should I get another teacher ?
The reason why I am in a dilemma is because of the time/location of the lesson/school. And the cheaper than others tuition rate. There are no other slots/unsuitable timings available. which means I will have to spend time waiting for months after months to start lesson. I am a working adult btw.
Comment: You've already answered your own question, so what are you really asking? Are you looking for permission? What's stopping you from just going out and finding a teacher you feel more confident in?
Comment: The reason why I am in a dilemma is because of the time/location of the lesson/school. And the cheaper than others tuition rate. There are no other slots/unsuitable timings available. which means I will have to spend time waiting for months after months to start lesson. I am a working adult btw.
Comment: I received excellent classical guitar lessons online via zoom. So location and school affiliation do not have to be a problem if you're willing to try out online learning.
Answer: Several separate issues, it appears.
Firstly, cost. You're happy with the charge made by present teacher, but would have to pay more, maybe considerably more, for another. Your choice.
Next, availability. You already have a teacher, and are on the route to learning. Leave this one, and who knows how long till you find another - who may also turn out to be unsuitable for various reasons.
Next, language. You seem to be managing, albeit struggling, but still improving despite the problem of not understanding everything said. I'd think if you didn't understand, he'd show you.
Which brings us onto the next. Quite often (not always), jazz players have been through most other styles, before settling on jazz as their preferred. Maybe he can't play the higher grade classical well. So what? Just about every coach around can't perform as well as the folk they coach - football, tennis, boxing, and yes, playing instruments! That doesn't mean they can't teach well. I've had students who ended up far better players than I am, but it didn't stop me teaching them, or them being taught by me. That's the way it goes!
Next, distance/availability. Probably always going to be problematic, so, unless you try as Todd suggests with Zoom, you're stuck with that one. I've done lessons using Whatsapp, which I thought wouldn't be marvellous, but they worked o.k., and probably would improve if we did more.
Finally, the answer must be in your hands. All I've done is pinpoint each problem, and its possible solution. You have to weigh up the pros and cons yourself - we don't really know how good you are, how you learn, how well you learn, how you practise. But if progress has been o.k. with the present teacher, despite all odds, stick with him - the next one may turn out equally unsuitable, for a myriad of reasons. Then where are you? Starting all over again.
Answer: I agree with Tim's answer, but I am posting this to suggest a slightly different tack.

I am keen to advance to higher grade in Classical guitar but not so comfortable to take lessons with a jazz guitar player who has problem communicating with his students.

I would focus on your discomfort with this teacher.  It's entirely possible that another jazz guitar player with limited English would make a much better teacher for you.  It's possible that a native speaker of English who specializes in classical guitar would be a less effective teacher for you.  Whatever you do, don't leave this teacher because of who he is, nor even because of what he does, but because of what you are or aren't getting from the lessons.
Analyzing the reasons for your discomfort with the teacher may be helpful for any of several reasons.  It might help you find a more suitable teacher.  It also might help you approach the teacher differently.  Whatever you do, don't talk about these things with the teacher as reasons why you no longer want to study with the teacher, but give the teacher a chance to respond to them and perhaps adjust his teaching to your learning style -- or don't mention them at all.  If you haven't brought them up by the time you tell the teacher you're stopping, it's too late.
I know: I've had students who did both, and being told that you are inadequate in some way without having a chance to address it is difficult and frustrating.  A student expressing unhappiness about something in the hope that it can be improved is actually a sign of respect, and, in the end, it will either improve the experience for both of you or help the teacher understand that the relationship is not fruitful for the student.
But, in the end, you don't need a better reason for leaving your teacher than "I'm not learning enough" or even "I'm not comfortable."  A "stronger" or more specific justification than that is just an excuse, really.
All of this assumes a fair amount of good will on the teacher's part, of course, and the teacher may not be so mature and self confident.  Your mention of "turning panicky" hints at this.  If the teacher is too defensive, then it might not be worthwhile to address these issues explicitly.  If that's your sense, then just leave, and be as vague as possible about why.
If you are set on leaving, though, consider Tim's point that finding a new teacher brings its own risk.  Consider shopping for a new teacher before you leave your current one.  Maybe it will be a while before you can find someone better than your current teacher; in the interim, you can still get what you can from him.  Maybe if you approach the process of auditioning new teachers with sufficient care, you will find a better teacher at a similar rate or who is similarly convenient with regard to schedule and location.  Even if you do settle on someone who can't start teaching you for months and months, you can continue with your current teacher in the meanwhile.


Imputation of a censored variable

Question: I have a medical dataset with approx 200 variables. One of the variables is a bio-marker (concentration of a particular enzyme). It's distribution is right skew, and the problem is that values above a certain level are censored/cut off at that level. So while the mean of the variable is around 10, any values greater than 50 are recorded as 50.
I would like to impute continuous values for those censored values. I am using multiple imputation with the mice package in R at present, though other systems are available to me and I am open to other approaches. A thought I had was to recode all those censored values to be missing and then running the imputations. If any of the imputed values that were originally censored are below the cut-off, then they will then be assigned to be the cut-off value.
I'd like to know opinions about this, and/or any better methods of dealing with this.
Comment: What role will that biomarker play in subsequent analyses? E.g., will it be an explanatory variable, a covariate, or a dependent variable in a regression? It's possible you could use a method that does not require imputation of values. You should favor such methods, because otherwise you're making a WAG about the shape of the censored right tail, which--because of the skewness--could contain some influential values in the analyses.
Comment: @whuber, the biomarker is an explanatory variable. Normal practice in this field is to discretise it as 0-1, 1-10, 10+ or sometimes just 0-1 and 1+ (ie elevated or not elevated). I had the idea to include it as a continuous explanatory variable. Although the dataset has 200 variables, clinical guidance and prior experience suggests to use 10 of these in the final model, hence I was thinking of imputing the values >50 using some of the other variables.
Answer: Any method of imputation including multiple imputation is a shot in the dark if you can't take acoount of how the data above 50 are distributed.  Since you have 200 variables are any of them correlated with the biomarker? If you could fit a regression for the biomarker as a function of the covariates you could use that model to predict the values for the truncated ones.  You could apply an error to the prediction based on the residual variance in the model to generate multiple imputations that way.  It would be more sensible.  Of course this assumes you can find a valid model and that the residuals have zero mean and constant variance.  You would only fit then non-truncated biomarker values to construct the model.

Imputation of a censored variable


Can a runner run back to their original base?

Question: I have a question about baseball rules:

R1 starts on 1B and goes to 3B legally, now, until the play has finished, I mean pitcher on the mound, can R1 go back to his starting 1B first base ?
Answer: In the MLB Rules, two rules apply under 5.06:

5.06(b)(1):

(1) In advancing, a runner shall touch first, second, third and home base in order. If forced to return, he shall retouch all bases in reverse order, unless the ball is dead under any provision of Rule 5.06(c). In such cases, the runner may go directly to his original base.

5.06(a) comment:

Rule 5.06(a)/5.06(c) Comment: If a runner legally acquires title to a base, and the pitcher assumes his pitching position, the runner may not return to a previously occupied base.

As such: yes, players may return to bases previously touched (so long as they retouch them in the proper order), so long as there is not a trailing runner (in which case that runner must also cooperate), and so long as the pitcher has not assumed a pitching position.
Answer: The simple answer to all your questions is "yes" - runners can retreat if they wish, so long as they obey all the normal rules for running the bases (staying within the base paths, touching all bases, etc).
This is very rarely a good idea of course - about the only situation in which a runner might do this is if two runners end up in the vicinity of the same base, at which point one of them may attempt to retreat in order to avoid an out.


How to group DIVs to one DIV using jQuery?

Question: I have several DIVs with same class, and I need using jQuery or pure JS group it into one DIV

1

2

3

and I need it looks like:

1

2

3

I can't change HTML, only can use JS
Answer: use wrapAll method

$(".a").wrapAll("

")
.new-class {
  color: red;
}

1

2

3

Comment: Thank you! I was trying to find information for 3 hours...
Answer: $( ".inside-div-class" ).wrap('');
$("div").wrapAll('')


Trac: "opened" time display format on ticket screen

Question: Is it possible to change the way trac displays "opened" and "last modified" times on the ticket screen?
I often need to know the exact date something happened on our system. I can find the relevant ticket by searching for keywords. Then I would like to simply open the ticket and see the exact date instead of "opened 1 month ago" or similar.
Answer: Hover the mouse over the text "opened 1 month ago" and it will display the exact date in tooltip.


Interpretation of logistic regression summary

Question: I'm having trouble understanding how to interpret the results in this particular situation.
The research topic is to understand how different cat species (Cats 1-3) get infected by a specific parasite.

In the table above, the base category is Cat1. The p-value for the intercept is high, so we cannot conclude Cat1 has a high/low probability of infection. But, we can say that Cat2 has significantly lower odds of infection than Cat1 since the odds ratio is exp(3.52) = 34 (approx.). In this situation what can I say about the odds (or probability) of infection for Cat2? (Although Cat1 has higher odds than Cat2, we can't say if Cat1 has a high/low probability of infection).
This part seems confusing to me, so any help would be appreciated.
Comment: Welcome to Cross Validated! When you sau that Cat1 does not have a higher/lower odds of infection, what if your reference? Higher or lower than what?
Comment: that was a mistake, I corrected it.
Answer: You're right that there is uncertainty about whether the log-odds for $\text{Cat1}$ are greater than or less than zero, but we do have an estimate for the log-odds of $\text{Cat1}$: $-0.19$.
Then we have an estimate for the log-odds of $\text{Cat2}$, relative to $\text{Cat1}$: $-3.52$.
Consequently, the estimated log-odds for $\text{Cat2}$ are $-0.19 - 3.52 = -3.71$.
By similar logic, the log-odds for $\text{Cat3}$ are $-0.22$.
To get the odds, we can take $\exp(\text{log-odds})$.
$$
\text{Cat2 odds: }\exp(-3.71) = 0.0245\\
\text{Cat3 odds: }\exp(-0.22) = 0.803
$$
Comment: So, would the conclusion be something like "although cat1 has a low probability of infection, cat2 has an even lower probability of infection than cat1"?
Comment: $\text{Cat1}$ has an estimated probability of infection of about $45\%$. I am not sure that's a low probability of infection.


How to create a user following php script?

Question: What i am trying to do is to add a user following system (twitter like) to my script.
This is how the db structure looks like:
CREATE TABLE IF NOT EXISTS `user_follow` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `follower` int(11) NOT NULL,
  `following` int(11) NOT NULL,
  `subscribed` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `follow_unique` (`follower`,`following`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 ;

If i want create i should use this code:
mysql_query(" INSERT INTO `user_follow` (`follower`, `following`, `subscribed`) VALUES ('$follower', '$following', CURRENT_TIMESTAMP); ");

For the unsubscribe it should look like this:
mysql_query(" DELETE FROM `user_follow` WHERE `follower` = '$follower' AND `following` = '$following'; ");

.
$follower = $_SESSION[user_id]; // the user_id for the one who is currently logged id
$following = $user_id; // the user_id for the user profile where the script will be on

On the profile page i have a form like this:
<?php if (isset($_SESSION[user_id]) && $_SESSION[user_id] != $user_id) { ?>
<form action="" method="post">
<input name="action" type="hidden" value="<?php echo $subscribe_status; ?>"/>
<button name="subject" type="submit" value="<?php echo $subscribe_text.' '.$username; ?>"><?php echo $subscribe_text.' '.$username; ?></button>
</form>
<?php } ?>

What i don't know is how to link all of those codes...
EDIT:
$subscribe_status should change to follow or unfollow depending if the user is already following that user or not (by checking with a query i think).
Also $subscribe_text should be Follow or Unfollow depending if the currently logged in user ($follower) is already following that user or not.
Can anybody help me please?
EDIT 2 (based on Mihir Singh's answer)
$user_follow = dbquery(" SELECT * FROM `user_follow` WHERE `follower` = '$follower' AND `following` = '$following'; ");
$check_status = dbrows($user_follow);

$sub = false; //Boolean var which states if subscribed or not

if ( $check_status !== 0 ){ //Pseudo code
    $sub = true; //If row is found, they are subscribed, so set $sub to true
}

if($sub){
     $subscribe_status = "follow";
     $subscribe_text = "Follow";
}

else{
     $subscribe_status = "unfollow";
     $subscribe_text = "Unfollow";
}

Comment: Before anything, obligatory http://bobby-tables.com/
Comment: Okay. Now what exactly is the question? How to find out what `$subscribe_text` is, or...? I really can't tell. It seems you have all you need.
Comment: Regardless of your escaping, please stop writing new code with the ancient `mysql_*` functions. They are no longer maintained and community has begun the [deprecation process](http://goo.gl/KJveJ) . Instead you should learn about [prepared statements](http://goo.gl/vn8zQ) and use either [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli). If you cannot decide, [this article](http://goo.gl/3gqF9) will help to choose. If you care to learn, [here is a quite good PDO-related tutorial](http://goo.gl/vFWnC).
Comment: thank you. i am already know about mysql_real_escape_string and so on...
Comment: Sorry, that's my instinctive answer when I see something like `mysql_query(" DELETE FROM \`user_follow\` WHERE \`follower\` = '$follower' AND \`following\` = '$following'; ");`
Comment: it's ok but both of them are already safe (i mean `$follower` and `$following`).
Answer: Here's some code:
$sub = false; //Boolean var which states if subscribed or not

if (row in table exists --> subscribed ){ //Pseudo code
    $sub = true; //If row is found, they are subscribed, so set $sub to true

if($sub){
     $subscribe_status = "Follow";
     $subscribe_text = "Unfollow";
}

else{
     $subscribe_status = "Unfollow";
     $subscribe_text = "Follow";
}

EDIT:
So, this is the form code that you're using:
<?php if (isset($_SESSION[user_id]) && $_SESSION[user_id] != $user_id) { ?>
<form action="" method="post">
<input name="action" type="hidden" value="<?php echo $subscribe_status; ?>"/>
<button name="subject" type="submit" value="<?php echo $subscribe_text.' '.$username; ?>">
<?php echo $subscribe_text.' '.$username; ?></button>
</form>
<?php } ?>

Based on that, I would change
<form action="" method="post">

to
<form action="handler.php" method="post">

and then create a handler file with this:
<?
    if ($_POST['action'] == "Follow")
        //Perform Unfollow Query to Database
    else
        //Perform Follow Query to Database
?>

That's barebones.... but it should work out. How's that?
Comment: thank you, i used this code but how should i add the query to update (follow or unfollow) to the code?
Comment: @m3tsys I'll append it in a moment.
Comment: @m3tsys the new code has been appended. Tell me what you think.
Comment: thank you very much for your time. i had to modify the code like following because if i used your example at a simple refresh of the page a unfollow was made `if ($_POST['action'] == "follow"){/* follow query */}
elseif ($_POST['action'] == "unfollow"){/* unfollow query */}`  i basically added a else if condition. thank you again.


Braid groups and representations

Question: I was wondering if $\mathbb{Z} \wr S_n$, where $\mathbb{Z}$ is the usual group of integers, $S_n$ the symmetric group on n elements and $\wr$ the wreath product of two groups, contains the braid group $B_n$.
I was also wondering if $n+1$-dimensional matrices of the form :
$$\begin{bmatrix} 1&0&0 \\\\ 1&0&1 \\\\ 1&1&0 \end{bmatrix}$$ for B2
$$\begin{bmatrix} 1&0&0&0 \\\\ 1&0&1&0 \\\\ 1&1&0&0 \\\\ 0&0&0&1 \end{bmatrix}$$
and
$$\begin{bmatrix} 1&0&0&0 \\\\ 0&1&0&0 \\\\ 1&0&0&1 \\\\ 1&0&1&0 \end{bmatrix}$$
 for B3
and so on... form a representation of the braid group $B_n$.
Thank you for your help
A. Popoff
Comment: Your hypothesis is not correct: for n=3, your wreath product is solvable, but $B_3$ contains a non-abelian free subgroup.
Comment: Checking whether something is a braid group representation is straightforward; you just have to check the braid relations. Have you done that yet?
Comment: Perhaps it is not faithful? (In fact, it shouldn't be faithful. The linearity of the braid groups was until recently an open problem so a faithful linear representation shouldn't be easy to write down.) I guess the Burau representations aren't faithful either...
Comment: Hi... yes I checked and it works fine, but then why bothering with complicated representations like the Burau one, when this one is simpler....
Comment: I have to admit, I didn't check for faithfulness, it just arose while doing some other stuff with braid groups...
Comment: @Alexandre: as you surely expect, checking faithfulness is a difficult thing!
Comment: I'll have to ask an expert then... by the way, I was thinking that if my hypothesis concerning the wreath product is true, then Zm () Sn could be considered as "constrained" braid groups where the generators of the braid group have a limited number m of twists... does that make any sense ? Has this ever been studied ?
Comment: @Alexandre: regarding that, look at http://mathoverflow.net/questions/48849/transpositions-of-order-three: Gjergji mentions a paper which studies such things.
Comment: (By the way, I don't really see what matrices you have in mind. Your explanation that they are obtained by «swapping pairs of columns and adding» does not tell me anything... Could you write down explicitly a couple more?)
Comment: Would be :$$\begin{bmatrix} 1&0&0 \\\\ 1&0&1 \\\\ 1&1&0 \end{bmatrix}$$ for B2

$$\begin{bmatrix} 1&0&0&0 \\\\ 1&0&1&0 \\\\ 1&1&0&0 \\\\ 0&0&0&1 \end{bmatrix}$$ and $$\begin{bmatrix} 1&0&0&0 \\\\ 0&1&0&0 \\\\ 1&0&0&1 \\\\ 1&0&1&0 \end{bmatrix}$$ for B3
and so on...
Comment: @Alexandre: if you add them to the body of the question, it is much easier to find them :)
Comment: Sorry for that... I corrected it, hope it will make more sense...
Comment: @Steve ... thanks for the answer. I had found a couple of elements from the wreath product that were satisfying the braid  relations, but I wasn't looking at the big picture (this whole thing comes from rather applied stuff...)
Comment: @user8167: "but then why bothering with complicated representations like the Burau one" -- because different representations highlight different properties of the group being represented. If you were just interested in having a single representation, you could always just take the trivial one.
Answer: It is certainly not true that $\mathbb{Z}\wr S_n$ contains $B_n$, for any $n>2$.  Indeed, by definition, $\mathbb{Z}\wr S_n$ has a free abelian subgroup of finite (indeed, $n!$)  index.
On the other hand, the kernel of the natural map of pure braid groups $PB_n\to PB_{n-1}$ obtained by forgetting a strand is the free group of rank $n-1$ (this follows from the Birman Exact Sequence, I suppose), so if $n>2$, $PB_n$ (and hence $B_n$) contains a non-abelian free group.  If it were contained in $\mathbb{Z}\wr S_n$ then this non-abelian free group would have an abelian subgroup of finite index, which is absurd.
[Note: this answer is essentially the same as Steve D's comment.]
Comment: There is no question that your wreath product contains a **quotient** of the the braid group ($S_n$ for example!!).
Comment: As Steve suggests, it is in general easy to check if a given map defines a representation (you just have to check the relations), and very difficult to check whether a given representation is faithful.  Indeed, in the following paper, Bridson and I exhibit a sequence of representations with the property that no algorithm determines which are faithful: http://arxiv.org/abs/1003.5117 .
Comment: Hi... I have trouble following your proof; wouldn't it be possible that $\mathbb{Z}\wr S_n$ contains both ?

Here's what I was trying on GAP:
a:=FreeGroup("a");
b:=SymmetricGroup(3);
g:=WreathProduct(a,b);
u:=g.1*g.3*g.1;
v:=g.3*g.1*g.2*g.1*g.2;
u*v*u=v*u*v; (returns true)
Comment: Alexandre: suppose that $|G:K|=n$ and $H$ is a subgroup of $G$. It is an easy exercise to check that $|H:H\cap K|\leq n$.  So if $G$ has a subgroup of finite index that's abelian, then $H$ must also have a subgroup of finite index that's abelian.  But non-abelian free groups certainly don't have abelian finite-index subgroups, for all sorts of reasons (eg growth).

Braid groups and representations


Change UINavigationBar alpha to 0.5, then back home and return to app. the navigationBar alpha change to 1 automatic

Question: first

second

Change UINavigationBar alpha to 0.5, then back home and return to app. the navigationBar alpha change to 1 automatic  I want to Know how to do it
Comment: What do you mean by "then back home"?
Comment: Write your code in viewWillAppear method
Answer: Try this code
<code>[self.navigationController.navigationBar setTranslucent:YES];
</code>
Comment: I has set translucent = yes
Comment: but it will change to 1 automic
Comment: - (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    self.navigationController.navigationBar.translucent = YES;
    }
Comment: And  applicationWillEnterForeground   not call viewWillAppear
Answer: How did you set the navigationBar color with alpha value 0.5?
is this your code to set alpha ?
<code>
[UINavigationBar appearance].barTintColor = [UIColor colorWith RGBA]
</code>


Something not looking obvious in solving equation $x^y=y^x$ for rational $x$ and $y$.

Question: This is a very popular problem (I believe, its Question 666 by Ramanujan):
Solve in positive rational numbers  $x^y=y^x$.
There are quite a few sites and videos about solving this equation, but at any time I find something taken for granted, that doesn't look obvious to me.
Typically the solution looks like the following:
Let $x$,  $y$ be the rational numbers, satisfying the equation and $y>x$ (case $y=x$ is trivial and disregarded). Then $q=\frac{y}{x}$ is also a rational number and $q>1$.
Substituting $y=qx$ into the equation, gives:  $x^{qx}=(qx)^x$. Then we raise both sides into power $\frac{1}{x}$, solve for $x$ and get $y$ as $qx$. The result is:
$$
x=q^\frac{1}{q-1}, \qquad y=q^\frac{q}{q-1}
$$
No questions so far.
Now, assume $k=\frac{1}{q-1}$. Since $q>1$,  $k$ is positive. Also  $q=\frac{k+1}{k}$.  Now, the solution can be rewritten in terms of $k$:
$$
x=\left(\frac{k+1}{k}\right)^k, \qquad y=\left(\frac{k+1}{k}\right)^{k+1},
$$
where $k$ is an integer (???).
From where it follows, that $k$ must be an integer? Mere examples $4^\frac{1}{2}=2$,   or $\left(\frac{1}{4}\right)^\frac{1}{2}=\frac{1}{2}$   show, that $a^r$ may be rational, even if $r$ is fractional. I guess there is something to do specifically with $\left(\frac{k+1}{k}\right)^k$, however, despite my best effort, I couldn't find a way to prove that.
Comment: I don't see why $k$ has to be an integer. For example https://www.wolframalpha.com/input?i=x%5Ey-y%5Ex+where+x%3D%28%28a%2Fb%2B1%29%2F%28a%2Fb%29%29%5E%28a%2Fb%29+and+y%3D%28%28a%2Fb%2B1%29%2F%28a%2Fb%29%29%5E%28%28a%2Fb%29%2B1%29%2C+a%3D1%2C+b%3D2
Pick any values for a,b > 0.
Comment: @DavidP You may want to check my answer.
Answer: For the sake of contradiction, suppose $k>0$ is not an integer. Then $k=\frac st$, where $s$ and $t$ are positive integers, $\gcd(s, t)=1$ and $t>1$.
Let $x=\frac pq$, where $p$ and $q$ are positive integers, $\gcd(p,q)=1$.
We have
$$
\frac pq=x=\left(\frac{k+1}{k}\right)^k=\left(\frac{s+t}s\right)^{\frac st}
$$
$$
\frac {p^t}{q^t}=\frac{(s+t)^s}{s^s}
$$
Note that $\gcd(s+t,s)=\gcd(t,s)=1$.
Since the fractions on both sides are reduced fractions, we have $p^t=(s+t)^s$ and $q^t=s^s$.
Since $\gcd(s,t)=1$ and $(s+t)^s$ is a $t$-th power of an integer, $s+t$ must be a $t$-th power of an integer as well.
Since $\gcd(s,t)=1$ and $s^s$ is a $t$-th power of an integer, $s$ must be a $t$-th power of an integer as well.
However, $t=(s+t)-s$. That cannot be true since the difference between any two positive $t$-th powers of integers is greater than $t$ when integer $t>1$.
We have reached a contradiction.
Comment: The answer is wrong: $\frac{k+1}{k}=\frac{s+1}{s}$, not $\frac{s+t}{f}$.
Comment: @cyanide I have fixed my answer. Please check.
Answer: This is not exactly an answer, but relates to some related thoughts.
An implicit plot of two variable function product reveals the "factors"  just as $x^2-y^2$  displays factor graphs for $x-y,x+y.$
The plot of
$$ \frac{x^x-y^y}{x-y}$$
shows a factor $ (x-y)$ alright but shows one second "transcendental" non-polynomial factor selected by the software.
This is because it is not a single variable  to isolate  the second factor by use of L'Hospital's Rule. Depending on direction we can have any second factor, which cannot be unique.
ContourPlot[x^x-y^y==0,{x,-2,2},{y,-2,2},PlotLabel->"x power x minus y power y FACTORS ",GridLines->Automatic,AspectRatio->1,ContourStyle->{Red,Thick},PlotRange->All]
slope[u_]=u^u(1+Log[u]);
g1=ContourPlot[( slope[x]+slope[y])/2==0,{x,-2,2},{y,-2,2},PlotLabel->"FACTOR1",GridLines->Automatic,AspectRatio->1,PlotStyle->{Purple,Thick},PlotRange->All];
g2=ContourPlot[( slope[x]-slope[y])/10^-8==0,{x,-2,2},{y,-2,2},PlotLabel->"FACTOR2STRAIGHT_LINE",GridLines->Automatic,AspectRatio->1,PlotRange->All];
Show[{g1,g2},PlotRange->All]

Two cases with factor weightages $ (1+1, 1-1)$ are attempted. They give the implicit straight line factor $x-y$ and another "factor" looking like a rectangular hyperbola  bounded in range/domain $(0,\pm 2)$ that is by no means unique., i.e.,
by choosing curve direction in $x-y$ plane several "factors" can be obtained and plotted.
It is of interest to find the choice made by Mathematica.


Android - How can I achieve this type of toolbar?

Question: I notice this type of toolbar used in recent apps on PlayStore, and I need to achieve this.

I know how to create a simple toolbar in XML.
Simple Toolbar
<android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:background="@color/ColorPrimary"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin"
            android:theme="@style/about_toolbar"
            >
...

</android.support.v7.widget.Toolbar>

I seems like a toolbar with padding.
So I'm not entirely sure.
Please can someone who has done this help me out !
Comment: did you try adding a margin?
Comment: Thanks @DavidMedenjak, margin worked, but Its missing the shadow and the UI feel which is the image i posted.
Comment: Check my answer for the shadow
Comment: check this answer: http://stackoverflow.com/questions/28798699/floating-toolbar-with-appcompat/28799795#28799795
Answer: Example with cardView:
<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout  xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#bcbcbc"
        >
        <android.support.v7.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:layout_alignParentTop="true"
            android:layout_margin="20dp"
            android:background="@android:drawable/dialog_holo_light_frame"
            />
    </RelativeLayout>

Comment: It worked, Please remove the 1st example so as not to confuse people !
Comment: Done glad to help you


What is the best practice to retrieve Facebook user picture with Firebase in Swift?

Question: I have the following method in a ViewModel to handle user clicks on a Facebook login button:
import Foundation
import FirebaseAuth
import FacebookLogin

/// A view model that handles login and logout operations.
class SessionStore: ObservableObject {
    @Published var user: User?
    @Published var isAnon = false

    private var handle: AuthStateDidChangeListenerHandle?
    private let authRef = Auth.auth()

    /// A login manager for Facebook.
    private let loginManager = LoginManager()

    /// Listens to state changes made by Firebase operations.
    func listen()  {
        handle = authRef.addStateDidChangeListener {[self] (auth, user) in
            if user != nil {
                self.isAnon = false
                self.user = User(id: user!.uid, fbId: authRef.currentUser!.providerData[0].uid, name: user!.displayName!, email: user!.email!, profilePicURL: user!.photoURL)
            } else {
                self.isAnon = true
                self.user = nil
            }
        }
    }

    /// Logs the user in using `loginManager`.
    ///
    /// If successful, get the Facebook credential and sign in using `FirebaseAuth`.
    ///
    /// - SeeAlso: `loginManager`.
    func facebookLogin() {

        loginManager.logIn(permissions: [.publicProfile, .email], viewController: nil) { [self] loginResult in
            switch loginResult {
            case .failed(let error):
                print(error)
            case .cancelled:
                print("User cancelled login.")
            case .success:
                let credential = FacebookAuthProvider.credential(withAccessToken: AccessToken.current!.tokenString)
                authRef.signIn(with: credential) { (authResult, error) in
                    if let error = error {
                        print("Facebook auth with Firebase error: \(error)")
                        return
                        }
                    }
                }
            }
        }

}

In listen(), I'm trying to build my User model whenever Firebase detects state change (i.e., when a user is logged in). My User model is a simple struct like this:
/// A model for the current user.
struct User: Identifiable, Codable {
    var id: String
    var fbId: String
    var name: String
    var email: String
    var profilePicURL: URL?
}

The Problem
Right now, as you can see in my listen() method, I'm using Firebase's photoURL to get user's profile picture. However, it will only give me a low-quality thumbnail pic.
I would love to fetch normal photos from Facebook.
What I have tried
I tried, in my facebookLogin() to call GraphRequest to get the picture url. However, since my function is synchronous, I couldn't store the result to my User model.
I also tried directly using the Graph API link like "http://graph.facebook.com/user_id/picture?type=normal", but it seems like it's no longer the safe/suggested practice.
Question
Given my ViewModel structure, what is the best way to fetch and store Facebook user picture URL to my User model?
Comment: Seems like you have at least a couple of options: 1) Use the `GraphRequest` and don't set your `User` model until you get the result back. 2) Set your `User` model as you are now and then *update* it with a new URL once your `GraphRequest` comes back.
Comment: I highly recommend looking into Swift's optional binding syntax so that you can use `if let user = user` rather than `if user != nil` and then using `!` to force unwrap.
Comment: Thank you, I just found out that Firebase's `photoURL` is the default Facebook URL, to get the normal pic URL, I just need to append "?type=normal" to `photoURL`.
Answer: I found out that Firebase's photoURL is Facebook's Graph API URL: http://graph.facebook.com/user_id/picture. So, to get other sizes, all I need to do is to append a query string like ?type=normal to the photoURL.
To use GraphRequest, consider @jnpdx's suggestion:

Seems like you have at least a couple of options: 1) Use the
GraphRequest and don't set your User model until you get the result
back. 2) Set your User model as you are now and then update it with a
new URL once your GraphRequest comes back.