text:
Q: Jquery Toggle Loop I'm using this particular script for specific expand/collapse items and have decided i'd like to be able to toggle multiple objects on the same page but im not sure exactly how do make that happen. Can anybody provide any insight?
$('#faq_info_header').click(function() {
    $('#faq_info_exp').toggle();
    var arrow = $('#faq_info_header').find('.fa');
    if (arrow.hasClass('fa-arrow-right')) {
        arrow.removeClass('fa-arrow-right');
        arrow.addClass('fa-arrow-down');
    } else if (arrow.hasClass('fa-arrow-down')) {
        arrow.removeClass('fa-arrow-down');
        arrow.addClass('fa-arrow-right');
    }
    return false;
});

HTML as requested:
This is the question?

This is the hidden content

A: You can use toggleClass (more here http://api.jquery.com/toggleClass/) by replacing your entire if statement with:
arrow.toggleClass('fa-arrow-right fa-arrow-down');

Okay, now I think I understand the question.  Here is a fiddle
HTML:

This is the question 1?

This is the hidden content 1

This is the question 2?

This is the hidden content 2

This is the question 3?

This is the hidden content 3

JS:
$('.faqs').on('click', '.faq_item', function () {
    $(this).children('.faq_info_exp').toggle();
    $(this).find('i').toggleClass('fa-arrow-right fa-arrow-down');
});

CSS:
.faq_info_exp {
    display: none;
}

Basically what I did was:

*

*I created a couple of more question & answer pairs for demonstration.

*I surrounded all of them with a div and added a class to it called "faqs". This way we can use event delegation and have only one event handler being created versus lots of them.

*I wrapped each of the questions and corresponding answer in a div and gave it a class of "faq-item".  Now we can use that in our handler and determine which div dispatched the event and use $(this) to refer to it easily.

*Then $(this).children('.faq_info_exp').toggle(); finds the direct child element with the class faq_info_exp and toggles it.

*Finally, $(this).find('i').toggleClass('fa-arrow-right fa-arrow-down'); finds the descendant element  and toggles the class.


text:
Q: sql server 2008 R2 cannot change default datetime format My OS windows 10 home single language. The date format is dd-MM-yyyy While i am installing SQL Server 2008 R2 from my Laptop.
After that I have changed into mdy format by using the following command
DBCC useroptions
set language 'english'
Set DATEFORMAT mdy
But the datetime format error from my application  while insert data.
the conversion of varchar datatype to a datetime data type resulted in an out-of-range value

I have convert date format like as below
  DateTime dt = DateTime.ParseExact(datetime, "dd-MM-yyyy", null);
        dt = Convert.ToDateTime(dt.ToString("MM-dd-yyyy"));

How to solved it

redpajama_set_name: RedPajamaStackExchange


text:
Q: Android development, Source file organization/notation best practices? Android lists coding standards but does not seem to go into how source (Activity's, etc) files should be organized. As my project grows im wondering how I should be breaking up the classes or if I just just leave a mess of 20 files in the src folder. It does not seem like there is any sort of notation (like Hungarian) nor an way to id whats an activity, or other helper class. Are there any docs on these sorts of best practices?

A: If you look at the apps that come with the android source, like gallery, launcher ect. you will notice that those guys pretty much kept everything in one folder...
Quite a mess if you ask me.
I usually have a folder "widget" for all my views, one for activities, one for providers one for utilities whatever.
Browsing throug open source projects alot, i dont think there is any common standart for doing this. Use what works best for you.

A: We already had a little discussion about it here:
Android separate packages
Besides that, I think following the (pure) Java coding standards is a good practice.

A: Do you really have everything in your base src folder?  A good start would be to put your classes into packages.  After that, you could create a "util" package for your helper classes and name them as such (ie. MainActivityUitl.java).


text:
Q: Pasar de filas a columnas en Postgresql Tengo una tabla muy parecida a esta (la id no es clave primaria):
    id    nombre producto    atributo
    1     Camiseta           Color: Negro
    1     Camiseta           Tam: XL

Me gustaría saber como puedo pasar de la tabla anterior a una así:
    id    nombre producto    atributos
    1     Camiseta           Color: Negro, Tam: XL

También me gustaría saber si es posible llegar a esto:
    id    nombre producto    atributo1       atributo2
    1     Camiseta           Color: Negro    Tam: XL

Una cosa a tener en cuenta es que no todos los productos tienen atributo, unos pueden tener un atributo, dos, o quince.
Lo he intentado con crosstab pero no sé utilizar la función. Un saludo y gracias.

A: select string_agg(col,',') from my_table

Ejemplo:
select id, nombre_producto, string_agg(atributo,',')
from productos where nombre_producto='Camiseta'

te daría:
id  nombre_producto string_agg
1   Camiseta        Color: Negro, Tam: XL


text:
Q: how can i get email notification on salesforce from my customers? ןs it possible to synchronize between my email and salesforce  so that I can send emails to my customers and receive an alert when they reply to the email?
If so I would love to know how to do it :)

A: Quick&dirty way - configure Email-to-Case and you could be forwarding certain emails (manually? with some automated rule?)
Read up about InboundEmailHandler and you could have it bit smarter, piece of code that could find previous messages, reopen cases, link them to right contact...
Bit more involved would be proper Gmail / Office 365 /... mail sync. It used to be called "Lightning Sync" but looks like they're phasing it out. Try https://help.salesforce.com/articleView?id=sf.einstein_sales_aac.htm&type=5


text:
Q: Vue.js - can not add date/timepicker to the html element rendered by vue.js I have a Vue.js component where there are groups of text fields ( group of a text field labelled "Start" and another text field labelled "To") bound to a Vue array ( s.timespans) .
What I want is, when I add another group of text field by adding element to the ( s.timespans ) array, all the textfields get date/timepicker. But unfortunately, now only the first group of field gets the date/timepicker and the other groups don't. What is the right way of doing this?
Thanks in advance.
<template id="settings">

                <?php _e( 'From', 'smps' ); ?>
                <input type="text" class="datepicker form-control" v-model="slot.from">

                <?php _e( 'To', 'smps' ); ?>
                <input type="text" class="datepicker form-control" v-model="slot.to">

<template>

The Vue js code
Vue.component( 'settings', {
        template : '#settings',
        data : function () {
            return {
                s : {
                    timespans : [
                        {from : '', to : ''}
                    ]
                }
            }
        },
        methods : {
            add_timeslot : function () {
                Vue.set(this.s.timespans,this.s.timespans.length,{from:'',to:''});
                $('.datepicker').datetimepicker();
            },
            remove_timeslot : function (k) {
                this.s.timespans.splice(k,1);
            },

        },

    });

A: Try this then the DOM will be finished rendering, not before nextTick:
        add_timeslot : function () {
            Vue.set(this.s.timespans,this.s.timespans.length,{from:'',to:''});
            this.$nextTick(function () {
              $('.datepicker').datetimepicker();
            });
        },

when the function in nextTick is executed, the DOM Element will be rendered.


text: Q: Proper way to document that a class implements a collections interface? Assuming I have a class that implements the Sequence interface, i.e. has __len__ and __getitem__ methods, what is the recommended way to document this? Is an informal description in the classes docstring enough, should I subclass collections.abc.Sequence or do something else entirely?


text: Q: Exported Video in Pinnacle Studio 23 dosnt save full sound In Pinnacle Studio 23, during edit their is audio, but in the exported file, the audio in some areas is muted while others it plays. the audio is not fully exported. I have rendered fully and tried almost 5 times with same results


text:
Q: Can't define friend functions without namespace conflict I have created a class (MyNodeClass) and now want to add serialization capabilities.  I declare (in mynodeclass.h) my serialization methods as follows:
#ifndef MYNODECLASS_H
#define MYNODECLASS_H

#include <QString>
#include <QVariant>
#include <QDataStream>
#include <QReadWriteLock>

namespace NS { class MyNodeClass; }
QDataStream& operator<<(QDataStream &out, const MyNodeClass &node);
QDataStream& operator>>(QDataStream &in, MyNodeClass &node);

namespace NS {

class MyNodeClass
{
public:
    MyNodeClass(quint64 parent, QString name, MyNodeClass::MyEnum type);
    friend QDataStream& operator<<(QDataStream &out, const MyNodeClass &node);
    friend QDataStream& operator>>(QDataStream &in, MyNodeClass &node);

private:
    quint64 m_parent;
    QString m_name;
    int m_type;
    QVariant m_content;
    QReadWriteLock m_lock;
};
}

#endif // MYNODECLASS_H

My definitions (in mynodeclass.cpp) are:
 #include "mynodeclass.h"

QDataStream& operator<<(QDataStream &out, const NS::MyNodeClass &node) {
    out
            << node.m_name
            << node.m_type
            << node.m_parent
            << node.m_content;
    return out;
}

QDataStream& operator>>(QDataStream &in, NS::MyNodeClass &node) {
    QString name;
    int type;
    quint64 parent;
    QVariant contents;

    in
            >> name
            >> type
            >> parent
            >> contents;
    node = NS::MyNodeClass(parent,name,type);

    return in;
}

using namespace NS;

MyNodeClass::MyNodeClass(quint64 parent, QString name, MyNodeClass::MyEnum type) {}

The compiler complains that my operator<< cannot access private members of NS::MyNodeClass.  That means the signatures aren't lining up.  I've tried every combination of namespace related changes but can't figure it out.  I've modelled my code after this post
How should the friend functions be defined so that there is no complaint about namespace or access to private members?  (Please note that all examples I could find use a single file, so splitting into .h and .cpp is part of what needs to be addressed)

A: You declare 2 operator >> in different namespace, only the one in namespace NS is friend.
get rid of your "forward declarations":
// Remove that
namespace NS { class MyNodeClass; }
QDataStream& operator<<(QDataStream &out, const MyNodeClass &node);
QDataStream& operator>>(QDataStream &in, MyNodeClass &node);

and implement NS::operator<<:
namespace NS {

QDataStream& operator<<(QDataStream &out, const NS::MyNodeClass &node) {
    return out << node.m_name
               << node.m_type
               << node.m_parent
               << node.m_content;
}

QDataStream& operator>>(QDataStream &in, NS::MyNodeClass &node) {
    QString name;
    int type;
    quint64 parent;
    QVariant contents;

    in >> name
       >> type
       >> parent
       >> contents;
    node = NS::MyNodeClass(parent, name, type);

    return in;
}

MyNodeClass::MyNodeClass(quint64 parent, QString name, MyNodeClass::MyEnum type) {}


text:
Q: CommonsMail JavaMail - Falha ao enviar e-mail Estou tentando enviar e-mail utilizando smtp da google com a lib CommonsMail, em uma aplicação web, porem sempre esta gerando uma falha.
Fiz uma app a parte e testei diversas configurações, na qual fui vendo em diversos outros tópicos. Utilizando porta 465 e 587 com e sem SSL e TLS, com SessionEmail do Glassfish 5, com o firewall do win10 desativado e ativado, em versões diferentes do commons mail, porem nada esta funcionando.
 Obs: Marquei para Permitir aplicativos menos seguros acessar o gmail que criei pra teste.
Alguém poderia me ajudar com esse problema, seria muito grato, já não me restaram mais ideias.
Repositório Maven do Commons Mail
 <dependency>
     <groupId>org.apache.commons</groupId>
     <artifactId>commons-email</artifactId>
     <version>1.5</version>
 </dependency>

Código;

    public void enviarEmail() throws EmailException {
            Email email = new SimpleEmail();
            email.setDebug(true);
            email.setHostName("smtp.googlemail.com");
            email.setStartTLSRequired(true);
            email.setSmtpPort(465);
            email.setAuthenticator(new DefaultAuthenticator("teste@gmail.com","teste123"));
            email.setSSLOnConnect(true);
            email.setSslSmtpPort("587");
            email.setFrom("teste@gmail.com");
            email.setStartTLSRequired(true);
            email.setSSLCheckServerIdentity(true);
            email.addTo("destino@gmail.com");
            email.send();
    }

Erro

Warning:   org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.googlemail.com:587
javax.el.ELException: org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.googlemail.com:587
    at com.sun.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:187)
    at com.sun.el.parser.AstValue.invoke(AstValue.java:289)
    at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
    at org.jboss.weld.module.web.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
    at org.jboss.weld.module.web.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
    at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:150)
    at javax.faces.event.ActionEvent.processListener(ActionEvent.java:96)
    at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:839)
    at javax.faces.component.UICommand.broadcast(UICommand.java:315)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:870)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1418)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:201)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:670)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1580)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:258)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:652)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:591)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:371)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:238)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:463)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:168)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:242)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:539)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:593)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:573)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.googlemail.com:587
    at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1410)
    at org.apache.commons.mail.Email.send(Email.java:1437)
    at br.com.mail.mail.teste.EmailController.enviarEmail(EmailController.java:42)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.sun.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:181)
    ... 42 more
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtp.googlemail.com, port: 587;
  nested exception is:
    javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2196)

A: Você nao esta setando corretamente o host para gmail.
Exemplo:
email.setHostName("smtp.gmail.com");

Possiveis soluçoes
1- Verifique se você está importando todos os jars corretamente:
dsn.jar, imap.jar, mailapi.jar, pop3.jar, smtp.jar.
2 - Verifique se o seu email está configurado para poder enviar emails:
Minha Conta > Login e Segurança > lá embaixo procure por "Permitir aplicativos menos seguros:" caso esteja desativado, é só ativar.
E aqui exemplos de como enviar utilizando a porta 465 e 587:
SSL/TLS (Port 465) -> email.setSSLOnConnect(true);
Email email = new SimpleEmail();
email.setHostName("smtp.gmail.com");
email.setSmtpPort(465);
email.setAuthenticator(new DefaultAuthenticator("username", "password"));
email.setSSLOnConnect(true);
email.setFrom("user@gmail.com");
email.setSubject("TestMail");
email.setMsg("This is a test mail ... :-)");
email.addTo("foo@bar.com");
email.send();

STARTTLS (Port 587) -> email.setStartTLSEnabled(true);
Email email = new SimpleEmail();
email.setHostName("smtp.gmail.com");
email.setSmtpPort(587);
email.setAuthenticator(new DefaultAuthenticator("username", "password"));
email.setStartTLSEnabled(true);
email.setFrom("user@gmail.com");
email.setSubject("TestMail");
email.setMsg("This is a test mail ... :-)");
email.addTo("foo@bar.com");
email.send();


text:
Q: FlipClock.js display an image when the countdown is over I'm using FlipClock 1.1a and I want to set an image when the countdown is over and hide the counter. Currently, the counter goes in - time (-1 hour, -12 minutes) when the time is up. How can I do this? The site has very few callback and its not helping.

A: They have provided different example in their code base which do include counter stop event. So, you need to use stop callback of FlipClock performing the required operation,
 var clock;
    $(document).ready(function() {
        clock = $('.clock').FlipClock(10, {
            clockFace: 'MinuteCounter',
            countdown: true,
            callbacks: {
                stop: function() {
                    // Do whatever you want to do here,
                    // that may include hiding the clock
                    // or displaying the image you mentioned
                    $('.message').html('The clock has stopped!');
                }
            }
        });
    });

P.S
If you have downloaded their whole source file you can check out the demo itself /FlipClock-master/examples/countdown-stop-callback.html


text:
Q: How to fix this after command sudo apt-get upgrade uugana@Hunnu:~$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up icedtea-netx:i386 (1.5.1-1ubuntu1) ...
update-alternatives: warning: forcing reinstallation of alternative /usr/lib/jvm/java-6-openjdk-i386/jre/bin/itweb-settings because link group itweb-settings is broken
update-alternatives: warning: not replacing /usr/share/man/man1/itweb-settings.1.gz with a link
update-alternatives: error: alternative path /usr/lib/jvm/java-7-openjdk-i386/jre/bin/itweb-settings doesn't exist
dpkg: error processing package icedtea-netx:i386 (--configure):
 subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of icedtea-7-plugin:i386:
 icedtea-7-plugin:i386 depends on icedtea-netx (= 1.5.1-1ubuntu1); however:
  Package icedtea-netx:i386 is not configured yet.

dpkg: error processing package icedtea-7-plugin:i386 (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                Errors were encountered while processing:
 icedtea-netx:i386
 icedtea-7-plugin:i386
E: Sub-process /usr/bin/dpkg returned an error code (1)

A: Try sudo apt-get upgrade --fix-broken --fix-missing


text:
Q: What does the p value mean for Cox hazard ratio? I am puzzled about the interpretation of P value in the Cox hazard ratio analysis. I read from literature that the P value is to "reject the null hypothesis that HR=1". However, in many cases, we have tested multiple variables in the cox analysis, and therefore have multiple P values. For example
X = cbind(lcx,lvef)
call:
coxph(formula = Surv(time_to_therapy, therapy) ~ X)

  n= 174, number of events= 54

           coef exp(coef)  se(coef)      z Pr(>|z|)
Xlcx   1.218259  3.381297  0.324619  3.753 0.000175 ***
Xlvef -0.004575  0.995436  0.016626 -0.275 0.783187
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

      exp(coef) exp(-coef) lower .95 upper .95
Xlcx     3.3813     0.2957    1.7896     6.389
Xlvef    0.9954     1.0046    0.9635     1.028

Here X is a 2-column variable with first column a binary vector named lcx, and the second column a continuous vector named lvef.
How can I interpret the two p values (0.000175 and 0.783187)? In my idea, it should be related to the predictive value of two variables (lcx and lvef)?

A: Just as in a linear regression model, where a model coefficient represents a slope parameter, a model coefficient in a Cox model represents a "hazard ratio". Recall the Cox proportional hazards model accounts for an arbitrary hazard function, which represents an undulating, inestimable instantaneous risk for a failure/death at any point in time. The assumption we make is that the risk for the event of interest is continually proportional to this function according to groups defined by your exposures (such as a one-unit higher (1 mL/s) left ventricular ejection fraction... ).
The p-value comes from testing the null hypothesis that this hazard ratio is 1, or that there is no difference in the relative risk of the event comparing individuals with varying levels of LVEF.
When you control for multiple covariates at the same time, the interpretation of the hazard ratio changes somewhat. The p-value for left circumflex (which is significant) comes from testing the hazard ratio for LCX controlling additionally for LVEF. Here, the hazard ratio interpretation is the relative risk comparing individuals differing by 1 unit in left circumflex who have the same LVEF. So think of it as conditioning upon the effect of LVEF by comparing groups with varying LCX and similar LVEF.
Just the same, the $p$-value from LVEF comes from the test of relative risk for groups differing by one unit in LVEF having the same LCX.
As a point, I would consider adjusting for at least sex and age.


text:
Q: Unable to execute commands with Jsch shell channel I have a test case which connects to my app server using Jsch shell channel. I am able to execute commands using Jsch if I run my test case from test vm. But there is some situation that the test case will run in the app server and do ssh to itself with same credentials. My problem is here. In this case the commands are not executed by Jsch.
Code:
import com.google.common.io.Files;
import com.jcraft.jsch.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.*;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Properties;

/**
 * Created by prasantabiswas on 17/03/17.
 */
public class SSHManager
{
    private static Session session;
    private static Channel channel;
    private static ChannelSftp channelSftp;
    private static Logger log= LogManager.getLogger(SSHManager.class);
    private static HelperClass helperClass=HelperClass.getInstance();

    enum ChannelType
    {
        SHELL,
        SFTP
    }

    public static void openConnection(String remoteHost) throws JSchException,SecurityException
    {
        if(session == null || !session.isConnected())
        {
            String userName=helperClass.getSshUser();
            log.debug("Remote host: "+remoteHost);
            log.debug("SSH user: "+userName);
            if(helperClass.getSshAuthMode().equalsIgnoreCase("key"))
            {
                String key=helperClass.getSshKey();
                log.debug("SSH key: "+key);
                session=connectWithKey(remoteHost,userName,key);
            }
            else if(helperClass.getSshAuthMode().equalsIgnoreCase("password"))
            {
                String password=helperClass.getSshPassword();
                log.debug("SSH password: "+password);
                session=connectWithPassword(remoteHost,userName,password);
            }
            else
            {
                String password=helperClass.getSshPassword();
                log.warn("No SSH authentication mode provided. It will try with the default mode that is with password: "+password);
                session=connectWithPassword(remoteHost,userName,password);
            }
        }
        else
            log.warn("Session already connected. Disconnect first for new session.");
    }

    private static Session connectWithPassword(String hostname,String username,String password) throws JSchException,SecurityException
    {
        JSch jSch = new JSch();
        Session _session = jSch.getSession(username, hostname, 22);
        Properties config = new Properties();
        config.put("StrictHostKeyChecking", "no");
        config.put("PreferredAuthentications","publickey,keyboard-interactive,password");
        _session.setConfig(config);
        _session.setPassword(password);

        log.info("Connecting SSH to " + hostname + " - Please wait for few seconds... ");
        _session.connect();
        log.info("Connected!");
        return _session;

    }

    private static Session connectWithKey(String hostname,String username,String key) throws JSchException,SecurityException
    {
        JSch jSch = new JSch();
        log.debug("Key file path: "+key);
        jSch.addIdentity(key);
        Session _session = jSch.getSession(username, hostname, 22);
        Properties config = new Properties();
        config.put("StrictHostKeyChecking", "no");
        config.put("PreferredAuthentications","publickey,keyboard-interactive,password");
        _session.setConfig(config);

        log.info("Connecting SSH to " + hostname + " - Please wait for few seconds... ");
        _session.connect();
        log.info("Connected!");
        return _session;
    }

    private static void createChannel(ChannelType channelType)
    {
        if(channel == null || !channel.isConnected()){
            try
            {
                if(channelType==ChannelType.SHELL)
                {
                    channel = session.openChannel("shell");
                    log.info("Shell channel created!");
                }
                else if(channelType==ChannelType.SFTP)
                {
                    channel = session.openChannel("sftp");
                    log.info("SFTP channel created!");
                }
                else
                    throw new JSchException("Invalid channel type");
                channel.connect();

            }
            catch(JSchException e)
            {
                log.error("Error while opening channel: "+ e);
            }
        }
    }

    public static String executeCommand(List<String> commands,String remoteHost) throws JSchException,IOException
    {

        log.info("Opening SSH session...");
        openConnection(remoteHost);
        log.info("Creating shell channel...");
        createChannel(ChannelType.SHELL);

        log.info("Sending commands...");
        PrintStream out = new PrintStream(channel.getOutputStream());

        out.println("#!/bin/bash");
        for(String command : commands){
            out.println(command);
        }
        out.println("exit");
        out.flush();
        String output=getChannelOutput(channel);
        log.info("Finished sending commands!");
        log.info("Closing session...");
        close();
        log.info("Returning execution output...");
        return output;
    }

    public static void copyFileToRemoteHost(String sourcePath,String destinationPath,String remoteHost) throws SftpException, IOException, JSchException
    {
        log.info("Opening SSH session...");
        openConnection(remoteHost);
        log.info("Creating SFTP channel...");
        createChannel(ChannelType.SFTP);
        log.info("Copying file to remote host: "+remoteHost+" from "+sourcePath+" to "+destinationPath);
        channelSftp = (ChannelSftp) channel;
        channelSftp.cd(destinationPath);
        File sourceFile = new File(sourcePath);
        channelSftp.put(new FileInputStream(sourceFile), sourceFile.getName(),channelSftp.OVERWRITE);
        log.info("File transfer complete.");
        log.info("Closing session...");
        close();
    }

    public static void removeFileFromRemoteHost(String targetPath,String remoteHost) throws JSchException, SftpException, IOException
    {
        log.info("Opening SSH session...");
        openConnection(remoteHost);
        log.info("Creating SFTP channel...");
        createChannel(ChannelType.SFTP);
        log.info("Removing file from remote host: "+remoteHost+" at "+targetPath);
        channelSftp = (ChannelSftp) channel;
        channelSftp.rm(targetPath);
        log.info("File removed");
        log.info("Closing session...");
        close();
    }

    private static String getChannelOutput(Channel channel) throws IOException
    {
        byte[] buffer = new byte[1024];
        InputStream in = channel.getInputStream();
        String line = "";
        Calendar calendar= Calendar.getInstance();
        calendar.setTime(new Date());
        int minuteBefore=calendar.get(Calendar.MINUTE);
        int minuteAfter=0;
        while (true)
        {
            while (in.available() > 0)
            {
                int i = in.read(buffer, 0, 1024);
                if (i < 0)
                {
                    break;
                }
                line += "\n" + new String(buffer, 0, i);
            }

            if(line.contains("logout"))
            {
                break;
            }

            if (channel.isClosed())
            {
                break;
            }
            calendar.setTime(new Date());
            minuteAfter=calendar.get(Calendar.MINUTE);
            if(minuteAfter-minuteBefore>=3)
                break;

            try
            {
                Thread.sleep(1000);
            } catch (Exception e)
            {

            }
        }
        return line;
    }

    public static void close()
    {
        channel.disconnect();
        session.disconnect();
        log.info("Disconnected channel and session");
    }

}

I am using the above class to execute commands on remote host. This is working fine but when I am running it in my local machine with the remoteHost parameter being the localhost, the commands are not getting executed. However it successfully logs in which I can see in the log but cannot execute the commands which are sent throug print stream. It is stuck for sometime after "Sending commands..." and then return the log which only shows the command prompt not all the commands.
Suppose my ssh username is root and I am sending two commands : su - admin, txe restart and the remote host and the host I am running the test is same that is my localhost. I should get output like
#!/bin/bash
su - admin
txe restart
exit
Last login: Thu Apr 13 23:17:10 2017 from 10.10.4.46
[root@platform15 ~]# #!/bin/bash
[root@platform15 ~]# su - admin
id: cannot find name for group ID 491000000
admin@platform15(ERS):~> txe restart

Stopping txe...
.
.
OK

Starting txe...OK (PID: 13083)
admin@platform15(ERS):~> exit
logout

But I get this
Last login: Thu Apr 13 23:34:42 2017 from 10.10.4.27
[root@platform15 ~]#

This is only happening when I am running the test in localhost with remoteHost set to localhost. Otherwise it is working fine is remoteHost is set to some other host.
Any suggestion on this?


text:
Q: Proportional height value is taken from the xib file not from the device It's the first time that I face this stranger problem. I have an UIViewController that I create with it's XIB file. The screen has two views viewA and viewB. The viewA has those values top = 0, leading = 0, trailing = 0. The viewA.height = safeArea.height/2. The viewB constraints are top = 0, leading = 0, trailing = 0, bottom = 0. Inside the viewA I have a view named viewAbackground having top = 0, leading = 0, trailing = 0, bottom = 0 constraints to its container (viewA) and I have also some labels in the viewA. I use this viewAbackground to add a gradient because If I add it directly to viewA it comes in front of the labels. This is how I add the gradient:
func createGradientLayer(theView: UIView) {
    let gradientLayer = CAGradientLayer()
    gradientLayer.frame = theView.frame
    gradientLayer.startPoint = CGPoint(x: 0.5, y: 1.0)
    gradientLayer.endPoint = CGPoint(x: 0.5, y: 0.0)
    gradientLayer.colors = [UIColor(hexString: Colors.startColor)?.cgColor, UIColor(hexString: Colors.endColor)?.cgColor]
    //add the gradient to the view
    theView.layer.addSublayer(gradientLayer)
}

Then in the viewDidLoad I call createGradientLayer(theView: viewA)
The gradient is added but the problem is that it hasn't the same size than the viewA. After many hours trying to understand what is wrong, I found that the applied size values are the same as what device I'm choosing in the interface Builder in the view as and not the values of my device screen. For example: if in the xib I have in the view as iPhone SE, when I run in the iPhone 6 I'm getting the gradient with the size of the viewA in the iPhone SE.
I have Xcode 9.2 and I'm using Swift 4
Can anyone explain me why I'm having this size problem?
Edit for more informations: This is the hierarchy of for the views. ScrollView <- MainView <- viewA and viewB. The mainView height is equal to the safeArea height. The utility of the scrollView is for the small devices such as the iPhone 4. In this case, I give to the mainView a defined height value in order to get the scroll effect.

A: This issue connected with misunderstanding of UIViewController lifecycle.
ViewDidLoad - Called when you create the class and load from xib. All views will have size you set in xib.
ViewWillAppear - Called right before your view appears. At this point all your views will have correct sizes, so you can use their size and position.
Also, CALayer doesn't support autoresizing, so, possible you will need to update it's size in didLayoutSubviews.

A: When your view loads from a xib or storyboard the layout will match what was loaded. As you've noticed, that isn't necessarily going to be the same as the device that it's running on.
So in viewDidLoad you will have the size loaded from the data.
In the first call to viewWillAppear you see the same sizes.
viewDidLayoutSubviews is called each time the view's bounds change. And this will be the first opportunity to get the views laid out as you would expect for the device that you are running.
Be careful though because you don't want to add your gradient everytime this method is called. However, you may want to update it if the size may change due to device rotation for example.
Update
Because you are using a scroll view, viewDidLayoutSubviews may not report the correct values. Possibly a bug in the SDK. You can try getting the correct values from viewDidAppear or if that's too late try the solution below.
override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    scrollView.setNeedsLayout()
    scrollView.layoutIfNeeded()
    createGradientLayer(theView: viewA)
}


text:
Q: How to write ut for a complex algorithm I thought of writing ut for a complex algorithm, which consits of many steps. For example, the algorithm class like below. And I want to test every step. But it's obvious that i can process the private function.
I am using the google gtest.
How shall I design the UT?
Class Algorithm
{private:
    PreProcess();
    Process();
    PostProcess();
}

A: There is a specific section in the Google Test documentation dealing with testing private code.
Short version is, try to avoid testing non-public functions.  If you have to, then you can either change your class design, or your test can be made a friend of the class.
GTest provides a helper macro for this last option: FRIEND_TEST, but beware of namespace issues with this.  Your test needs to be defined in the same namespace as the class being tested for this macro to work.
So something like:
#include <iostream>
#include "gtest/gtest.h"

class Algorithm {
 private:
  bool PreProcess() { std::cout << "Pre\n"; return true; }
  bool Process() { std::cout << "Process\n"; return true; }
  bool PostProcess() { std::cout << "Post\n"; return true; }
  FRIEND_TEST(AlgorithmPrivateTest, PreProcess);
  FRIEND_TEST(AlgorithmPrivateTest, Process);
  FRIEND_TEST(AlgorithmPrivateTest, PostProcess);
};

class AlgorithmPrivateTest : public testing::Test {
 protected:
  AlgorithmPrivateTest() : algorithm_() {}
  Algorithm algorithm_;
};

TEST_F(AlgorithmPrivateTest, PreProcess) {
  EXPECT_TRUE(algorithm_.PreProcess());
}

TEST_F(AlgorithmPrivateTest, Process) {
  EXPECT_TRUE(algorithm_.Process());
}

TEST_F(AlgorithmPrivateTest, PostProcess) {
  EXPECT_TRUE(algorithm_.PostProcess());
}

int main(int argc, char **argv) {
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}


text:
Q: What is the relation between number "41794" and todays date(i.e 04/06/2014)? I am trying to extract the id 41794 from a website. But the said number depends on the start date(today's date). See snippet below from the site,

'index.cfm?fuseaction=c_availabilityGrid.displayAvailabilityGrid&startDate=41794&timeSpan=ww,2&showBeds=1&showMlos=0&showprice=1'

I am interested to know how the value 41794 is obtained from today's date so that i can put that logic in my code.
Is there any function in java which takes input as date and returns the number as mentioned above?
Any help in this matter would be greatly appreciated.

A: It looks like the number of days since 1 Jan 1900, possibly with a leap year screwup or two.
Take a look at http://www.timeanddate.com/countdown/to?p0=198&year=1900&month=1&day=1&hour=0&min=0&sec=0
Microsoft Excel uses a system like this. Google "Excel serial date".

A: The answer by NPE is correct. Using the modern date-time API*, it can be confirmed as shown below:
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Month;

public class Main {
    public static void main(String[] args) {
        LocalDateTime ref = LocalDate.of(1900, Month.JANUARY, 1).atStartOfDay();
        LocalDateTime result = ref.plus(Duration.ofDays(41794));
        System.out.println(result);
    }
}

Output:
2014-06-06T00:00

Learn more about the the modern date-time API* from Trail: Date Time.

* For any reason, if you have to stick to Java 6 or Java 7, you can use ThreeTen-Backport which backports most of the java.time functionality to Java 6 & 7. If you are working for an Android project and your Android API level is still not compliant with Java-8, check Java 8+ APIs available through desugaring and How to use ThreeTenABP in Android Project.


text:
Q: PHP determine age of customer Im trying to make sure that my customrs are over  the age of 18. So far i have done this by taking the date of birth and the current data and finding the difference between the two.
$diff=date_diff(date_create($DOB),date_create(date("Y-m-d")));
echo $diff->format("%R%a days");
if ($diff<6574){
    $D_error="You must be ages 18+ to make a booking";
}

The difference found is correct ( the correct value is shown) but an error occurs when it tries to see if $diff<6574.
The error is : Notice: Object of class DateInterval could not be converted to int
I assume this has something to so with the fact that $diff is a time interval and therefore cannot be compared to an integer. How would i get past this problem?
And is the whole thing:
if (empty($_POST["DOB"])){
    $D_error="DOB is required";
}elseif (!preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/",$DOB)){
    $D_error="DOB must be given in the form yyyy-mm-dd";
}else{
$diff=date_diff(date_create($DOB),date_create(date("Y-m-d")));
echo $diff->format("%R%a days");
if ($diff->days < 6574){{
    $D_error="You must be ages 18+ to make a booking";
}

}

But with this i get an unexpected end to file.

A: $diff is an object, and you can't compare an object to an integer.
What you are looking for is the days property of the object.
Your comparison should look like this:
if($diff->days < 6574)
    //...

As a sidenote, the object also has other interesting properties, for example y, which is the number of years. So you could also simply use the following comparison:
if($diff->y < 18)
    //...

A: The problem lies in your if statement. Date_diff function returns instance of DateInterval object (http://php.net/manual/en/class.dateinterval.php), so you can't compare it to the integer. Use any property of DateInterval object, such as $days, or even $y (years), so something like:
if ($diff->y < 18)

A: date_diff returns DateInterval which has a public property days. So try this
if ($diff->days < 6574){
    $D_error="You must be ages 18+ to make a booking";
}


text:
Q: Argument of type 'unknown' is not assignable to parameter of type 'string'." When I try to parse a stringified array Sorry if this is a duplicate. I'm looking for the best way to convert an array into a key I can use for a set in JavaScript.
const set = new Set()
const arr = [1,0,-1]
const arr2 = [1,0,-1]
set.add(arr)
set.add(arr2)

This should work because both arr and arr2 are different objects and the set recognizes their references as unique. What's the best way I can convert arr and arr2 into keys so the set recognizes them as unique?
I tried doing JSON.stringify(arr), but I had difficulty converting them back into number[].
Any help is appreciated!
Here is the full version of the code I'm trying:
function twoSum(nums: number[], excludeIndex: number, target: number)
{
    let startPointer = 0;
    let endPointer = nums.length - 1;
    while(startPointer < endPointer)
    {
        if(startPointer === excludeIndex)
        {
            startPointer++;
        }
        if(endPointer === excludeIndex)
        {
            endPointer--;
        }
        if(nums[startPointer] + nums[endPointer] === target)
        {
            return [startPointer, endPointer]
        }
        if(nums[startPointer] + nums[endPointer] > target)
        {
            endPointer--;
        }
        else{
            startPointer++;
        }
    }
    return undefined
}

function threeSum(nums: number[]): number[][] {
    if(nums.length < 3)
    {
        return []
    }
    nums.sort((a,b) => a - b);
    let index = 0;
    const uniqueTriplets = new Set()
    while(index < nums.length)
    {
        const num = nums[index]
        const twoSumResult = twoSum(nums, index, (num * -1))
        if(twoSumResult !== undefined)
        {
            const triplet = [num, nums[twoSumResult[0]], nums[twoSumResult[1]]]
            triplet.sort((a,b) => a - b)
            uniqueTriplets.add(JSON.stringify(triplet))
        }
        index++;
    }

    return Array.from(uniqueTriplets.keys()).map(k => JSON.parse(k))
}

On the last return statement I get an error saying:
"Argument of type 'unknown' is not assignable to parameter of type 'string'."
When I add the JSON.parse(k)


text:
Q: Invalid command for interaction application I register an SlashCommand... but it answered "Invalid command for interaction application" Can somebody help...
 @Override
    public void onSlashCommand(SlashCommandEvent event) {

        if (event.getName().equals("login")) {

            EmbedBuilder buil = new EmbedBuilder();
            buil.setColor(Color.RED);
            buil.appendDescription("Du hast deinen DiscordAccount noch nicht mit dem TurnierSystem verknüpft... Benutze ?connect um die Accounts zu verknüpfen.");
            buil.setAuthor("TurnierSystem");
            buil.setTitle("Discord Login (Fehler)");

           event.replyEmbeds(buil.build()).queue();

        }

A: This response means that the Discord client tried to use an old version of the command that it had cached. If you simply retype the command, it should use the updated command instead.
The cause of this behavior is from calling upsertCommand when you start your bot. This will replace the existing command and make the client cache invalid.
You can use updateCommands().addCommands(allOfYourCommands).queue() instead, to prevent this from happening. However, keep in mind you need to put all your commands in addCommands(...), not just one at a time!


text:
Q: Changing DataTemplate during Runtime I use a ResourceProvider as global management for my ResourceDictionaries. I register new ResourceDictionaries to the ResourceProvider and raise a event for each affected FrameworkElement. The FrameworkElement then updates its resources with the following method: (I tried several ways to fix this and at the End i tried to change the DataTemplate with its Uri)
public void UpdateResources(FrameworkElement elementToUpdate)
    {
        foreach(var controlDict in _registeredResources.Where(a => a.ControlType == elementToUpdate.GetType()))
        {
            //elementToUpdate.Resources.MergedDictionaries.Clear();
            //elementToUpdate.Resources.MergedDictionaries.Add(controlDict);
            //elementToUpdate.Resources = controlDict;

            ResourceDictionary dict =new ResourceDictionary() { Source = new Uri("pack://application:,,,/ApplicationCore.UITest;component/NewDataTemplate.xaml") };
            elementToUpdate.Resources = dict;
            //elementToUpdate.Resources.MergedDictionaries.Clear();
            //elementToUpdate.Resources.MergedDictionaries.Add(controlDict);
        }
    }

Right now when i press my Button to Change the DataTemplate the ui doesn't refresh with the new template. I have to mention that I'm not changing the object itself.
                 <ctrl:TreeViewControl DataContext="{Binding}">
                    <ctrl:TreeViewControl.Resources>
                        <ResourceDictionary Source="pack://application:,,,/OldDataTemplate.xaml"/>
                    </ctrl:TreeViewControl.Resources>
                </ctrl:TreeViewControl>

My Question:
Is it possible to change a DataTemplate during Runtime and refresh the UI without changing the bound object itself?
EDIT: I continued testing: The ResourceDictionary (with its Template) is changed. A new added item (after the Template change) uses the new Template. But the old items are not updated.

A: 1) You could do it even with StaticResources if you reapply the template manually:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:local="clr-namespace:MyProject">
<DataTemplate DataType="{x:Type local:MyContentClass1}">
    <Border Background="Green" >
        <TextBlock Text="{Binding MyContent}"/>
    </Border>
</DataTemplate>
</ResourceDictionary>

<TreeView Name="my_trv" DataContext="{Binding}">
     <TreeView.Resources>
         <ResourceDictionary Source="pack://application:,,,/OldDataTemplate.xaml"/>
     </TreeView.Resources>
</TreeView>

But you'll have to touch the TreeView here:
FrameworkElement elementToUpdate = my_trv;
ResourceDictionary dict = new ResourceDictionary() { Source = new Uri("pack://application:,,,/NewDataTemplate.xaml") };
elementToUpdate.Resources = dict;

var dataTemplateKey = new DataTemplateKey(typeof(MyContentClass1));
var dataTemplate = (DataTemplate)dict[dataTemplateKey];
my_trv.ItemTemplate = dataTemplate;

2) If you do not want to search your resources for a specific one, you could use DynamicResources. If there could only be one type of data in your Items, then it is relatively easy, you only have to name your template:
<DataTemplate DataType="{x:Type local:MyContentClass1}" x:Key="MyTemplate1">
    <Border Background="LightCoral" >
        <TextBlock Text="{Binding MyContent}"/>
    </Border>
</DataTemplate>

<TreeView DataContext="{Binding}" ItemTemplate="{DynamicResource MyTemplate1}">
                <TreeView.Resources>
                    <ResourceDictionary Source="pack://application:,,,/OldDataTemplate.xaml"/>
                </TreeView.Resources>
</TreeView>

This way you do not have to touch your control explicitly in the codebehind:
ResourceDictionary dict = new ResourceDictionary() { Source = new Uri("pack://application:,,,/NewDataTemplate.xaml") };
elementToUpdate.Resources = dict;

3) If you have more than one type of data with different templates, then a bit of a trick is necessary.
First, you name your templates:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:local="clr-namespace:MyProject">

<DataTemplate DataType="{x:Type local:MyContentClass1}" x:Key="MyTemplate1">
    <Border Background="Green">
        <TextBlock Text="{Binding MyContent}"/>
    </Border>
</DataTemplate>

<DataTemplate DataType="{x:Type local:MyContentClass2}" x:Key="MyTemplate2">
    <Border Background="Blue">
        <TextBlock Text="{Binding MyContent}"/>
    </Border>
</DataTemplate>
</ResourceDictionary>

Then, in xaml, you'll have to use MergedDictionaries instead of putting your ResourceDictionary directly in the Resources node.
Then, there is the trick. You put ContentPresenter inside DataTemplate set to DynamicResources with the correct name:
<TreeView DataContext="{Binding}">
    <TreeView.Resources>
         <ResourceDictionary>
             <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/OldDataTemplate.xaml"/>
             </ResourceDictionary.MergedDictionaries>
             <DataTemplate DataType="{x:Type local:MyContentClass1}" >
                 <ContentPresenter Content="{Binding}"
                     ContentTemplate="{DynamicResource MyTemplate1}" />
             </DataTemplate>
             <DataTemplate DataType="{x:Type local:MyContentClass2}" >
                 <ContentPresenter Content="{Binding}"
                      ContentTemplate="{DynamicResource MyTemplate2}" />
             </DataTemplate>
         </ResourceDictionary>
    </TreeView.Resources>
</TreeView>

The code-behind will change a bit:
elementToUpdate.Resources.MergedDictionaries.Clear();
elementToUpdate.Resources.MergedDictionaries.Add(dict);


text:
Q: Is the Wolfram Server disabling Desktop Mathematica? Earlier I got this in response to 2+2

I had to terminate it with task manager. Right now I'm trying to access FinancialData. In response to FinancialData["CAT"], the kernel has been running for 15 minutes -- still no response.
I'm on the current 11.1.1.0 and Win 7 x64.
Does anyone have an answer to this?


text:
Q: SQL select statement with increment Currently I'm using a for statement in PHP to get all the months for this SQL statement, but would like to know if I can do it all with SQL.
Basically I have to get the average listing price, and the average selling price for each month going back 1 year where the sellingdate = the month.
simple with PHP, but that creates 12 database hits.
I'm trying the sql statment below, but it returns listings totally out of order

SELECT
avg(ListingPrice),
avg(SellingPrice),
count(ListingDate),
DATE(SellingDate) as date,
MONTH(SellingDate) as month,
YEAR(SellingDate) as year
FROM `rets_property_resi`
WHERE Area = '5030'
AND Status = 'S'
AND SellingDate "less then" = 'NOW()'
GROUP BY month
ORDER BY month desc
LIMIT 0,12

the "less then" is getting stripped from the statment, so please replace "less then" with the proper code
Output:

867507.142857   877632.492063   63  1996-12-24  12  1996
971355.833333   981533.333333   60  1997-11-18  11  1997
949334.328358   985453.731343   67  1997-10-23  10  1997
794150.000000   806642.857143   70  1996-09-20  9   1996
968371.621622   988074.702703   74  1997-08-21  8   1997
1033413.366337  1053018.534653  101 1997-07-30  7   1997
936115.054795   962787.671233   73  1996-06-07  6   1996
875378.735632   906921.839080   87  1996-05-16  5   1996
926635.616438   958561.643836   73  2010-04-13  4   2010
1030224.472222  1046332.291667  72  2010-03-31  3   2010
921711.458333   924177.083333   48  1997-02-28  2   1997
799484.615385   791551.282051   39  1997-01-15  1   1997

As you can see, it pulls from random dates, I need to to pull from 2010-03, 2010-02, 2010-01, etc...
any help is appreciated!

A: Try this:
SELECT
    avg(ListingPrice),
    avg(SellingPrice),
    count(ListingDate),
    MONTH(SellingDate) as month,
    YEAR(SellingDate) as year
FROM `rets_property_resi`
WHERE Area = '5030'
    AND Status = 'S'
    AND SellingDate <= NOW()
GROUP BY year, month
ORDER BY year desc, month desc
LIMIT 0,12


text:
Q: subscript operator overload returning pointer and assigning value to it I got a situation where I have a class B having a protected array of A*. I have an another function A* func() which returns pointers to A objects stored in some other container. (for example std::map<int,A*> or A* arr[]).
For example the following implementation:
#include <iostream>
using namespace std;
class A {
public:
    A(int _x): x(_x){};
    int x;
};
class B{
public:
    B() {
        this->arr[0] = new A(1);
        this->arr[1] = new A(2);
    }
    // use idx to index in to the internal array and return A*
    A*& operator[](int idx); // return reference to pointer to avoid not a lvalue error
private:
    // class B has this private array of A*
    A* arr[2];
};

A*& B::operator[](int idx) {
    return this->arr[idx]; // 0<=idx<=1
}

A* arr[2];
A* func(int x) {
    return arr[x]; // 0<=idx<=1
}

int main() {
    arr[0] = new A(12);
    arr[1] = new A(14);

    B b;

    b[1] = func(1); // assign a new value

    cout << b[1]->x << endl; // prints 14
}
// memory leaks of this program can be removed using `std::shared_ptr<A>` in the place of `A*`.

In this example, operator[]() returns a reference to a pointer, because returning pointer becomes rvalue and I will not be able to assign value to it (i.e. b[1] = func(1)).
My question is, is this reference to pointer returning recommended (other ways to achieve this )? or is this perfectly fine with raw pointers as well as with shared_ptr?
Thank You!


text:
Q: Converting the data to numeric from the pulled data from a website's table with BeautifulSoup My friends,
I'm working on the pulling dataset from a website with BeautifulSoup in python. I guess that the some of html codes in website have been written wrong. Although I can pull the data, I can't see some of them due to they are coded differently.. I tried to convert it but I couldn't handle. The problem is;
You can check the html codes preesing F12 and go to find 4,5,6 - 10,11,12 etc. (every 3 rows) =>  the website link
The codes I've wrotten the codes which pull the data from website's table;
    # Pulling and creating rows of the table
    rows = [row.text for row in table.tr]

    texts = []
    for table in soup.find_all("table", {"class": "medias mensuales numspan"}):
        for tbody in table:
            for tr in tbody:
                te = tr.get_text()
                texts.append(te)

You can observe that, it can successfully pull the data but every 3 rows were missed. (I guess it is because of website's design) Some of the rows are coded like;

I observed that every class corresponds a number. I don't know which language it is. If you know please let me know. I can code them.
My question: I have to convert these datas to numeric to avoid the missed data. Is there any way to fix/convert/pull via class name/ it?
If you need any details, feel free to contact me.
Thanks.

A: Yes, the page is using CSS style to inject numbers to table. You can use this script to reinject the numbers back using BeautifulSoup:
import re
import requests
from bs4 import BeautifulSoup

url = 'https://en.tutiempo.net/climate/08-2020/ws-170600.html'
soup = BeautifulSoup(requests.get(url).content, 'html.parser')

# replace all  with their number form:
style = soup.select_one('.medias').find_previous('style').string
mapper = dict(re.findall(r'([^.]+?)::after{content:"(.*?)"', style))
for span in soup.find_all('span', class_=lambda cl: cl in mapper):
    span.replace_with(mapper[span['class'][0]])

# print table to screen:
for row in soup.select('.medias tr'):
    tds = [td.text for td in row.select('td') if td.text.strip()]
    print(tds)

Prints:
['1', '26.5', '32', '21.8', '-', '70', '0', '10', '15.2', '29.4', '46.5']
['2', '26.2', '31', '22.8', '-', '56', '0', '10', '21.7', '31.7', '44.3']
['3', '25.4', '29', '22.4', '-', '57', '0', '10.5', '20.7', '33.5', '48.2']
['4', '25.4', '29', '22.7', '-', '64', '0', '10', '19.6', '31.7', '48.2']
['5', '25.8', '30', '22.7', '-', '58', '0', '10', '19.8', '33.5', '46.5']
['6', '26.2', '30', '23', '-', '68', '0', '10', '19.8', '33.5', '44.3']
['7', '27', '32', '23.9', '-', '68', '0', '10', '19.6', '33.5', '42.4']
['8', '27.2', '30', '24.6', '-', '70', '0', '10', '20.7', '35.2', '51.9']
['9', '26.8', '30.1', '25', '-', '71', '0', '10.5', '27.4', '44.6', '59.4']
['10', '26.9', '31', '23.9', '-', '59', '0', '10', '20.9', '33.5', '48.2']
['11', '26.9', '31', '21.3', '-', '57', '0', '10', '16.5', '27.8', '42.4']
['12', '27.9', '32', '23.3', '-', '48', '0', '10.3', '17.8', '27.8', '40.7']
['13', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-']
['14', '25.5', '29', '22.9', '-', '53', '0', '10', '19.4', '29.4', '42.4']
['15', '25.4', '30', '22', '-', '54', '0', '10', '19.8', '31.7', '44.3']
['16', '24.8', '28', '22.5', '-', '55', '0', '10', '22.6', '33.5', '50']
['17', '24.8', '28', '22', '-', '50', '0', '10', '22', '31.7', '51.9']
['18', '24.5', '28', '21.2', '-', '62', '0', '10', '17.2', '25.9', '38.9']
['19', '25', '30', '19.7', '-', '62', '0', '10', '13.1', '22.2', '31.3']
['20', '22.7', '25.2', '19', '-', '74', '2.03', '10', '10.9', '29.4', '40.7', 'o']
['21', '24.7', '29', '20', '-', '72', '-', '10', '16.1', '27.8', '38.9', 'o']
['22', '25.2', '32', '19.3', '-', '70', '0', '10.1', '11.7', '24.1', '33.5']
['23', '25.7', '30', '21.3', '-', '64', '0', '10', '18', '31.7', '46.5']
['24', '25.8', '30', '22.8', '-', '67', '0', '10', '19.1', '31.7', '46.5']
['25', '25.7', '30.4', '22', '-', '61', '0', '10', '15.2', '25.9', '37']
['26', '24.7', '28', '20.8', '-', '71', '0', '10', '14.6', '29.4', '42.4']
['27', '24.5', '29', '19', '-', '68', '0', '10', '10.6', '20.6', '25.9']
['28', '26', '33', '18', '-', '50', '0', '10', '14.3', '25.9', '42.4']
['29', '27', '32', '22.8', '-', '55', '0', '10', '21.1', '31.7', '44.3']
['30', '26.4', '31', '23', '-', '68', '0', '10', '17', '29.4', '40.7']
['31', '25.3', '29', '22.6', '-', '69', '0', '10', '14.6', '25.9', '40.7']
[]
['25.7', '30', '21.9', '-', '62.4', '2.03', '10', '17.9', '30.1', '2', '0', '0', '0']

A: A different way to undo the double coding of the values in some (but not all) the rows in the table. This uses css selectors, pandas and string manipulation, but not regex:
import pandas as pd
#first, explicity undo the encoding:

    styles= soup.select_one('h3 + style')
    code_dict = {}
    for s in styles:
        for i in s.split('.numspan')[1:]:
            code = i.split('span.')[1].split('::')
            code_val = code[1].split(':"')[1].split('"')[0]
            code_dict[code[0]] = code_val

Now that we have a dictionary of codes and code values, we can use that for the coded rows, or use the plain text for the uncoded ones:
rows = []
columns = []
for tr in table:
    for t in tr.select('th'):
        columns.append(t.text)
table = soup.find("table", {"class": "medias mensuales numspan"})
for tr in table:
        row = []
        for t in tr.select('td'):
            if len(t.select('span'))>1: #these are the coded rows
                hidden = [] #create a list to house the encrypted codes
                for s in t.select('span'):
                    hidden.append(s['class'][0])
                item = '' #now use the dictionary to convert them and create the actual value
                for h in hidden:
                    item +=(code_dict[h])
                row.append(item)
            else:
                row.append(t.text)
        rows.append(row)
pd.DataFrame(rows[1:-2],columns=columns[:-1])

Output (pardon the formatting):
    Day     T   TM  Tm  SLP     H   PP  VV  V   VM  VG  RA  SN  TS  FG
0   1   26.5    32  21.8    -   70  0   10  15.2    29.4    46.5
1   2   26.2    31  22.8    -   56  0   10  21.7    31.7    44.3
2   3   25.4    29  22.4    -   57  0   10.5    20.7    33.5    48.2
3   4   25.4    29  22.7        64      10  19.6    31.7    48.2
4   5   25.8    30  22.7        58      10  19.8    33.5    46.5
5   6   26.2    30  23      68      10  19.8    33.5    44.3
6   7   27  32  23.9    -   68  0   10  19.6    33.5    42.4

etc.


text:
Q: Call a Vue.js component method from outside the component Let's say I have a main Vue instance that has child components. Is there a way of calling a method belonging to one of these components from outside the Vue instance entirely?
Here is an example:

var vm = new Vue({
  el: '#app',
  components: {
    'my-component': {
      template: '#my-template',
      data: function() {
        return {
          count: 1,
        };
      },
      methods: {
        increaseCount: function() {
          this.count++;
        }
      }
    },
  }
});

$('#external-button').click(function()
{
  vm['my-component'].increaseCount(); // This doesn't work
});

  <my-component></my-component>

  <button id="external-button">External Button</button>

<template id="my-template">

A counter: {{ count }}

  <button @click="increaseCount">Internal Button</button>

</template>

So when I click the internal button, the increaseCount() method is bound to its click event so it gets called. There is no way to bind the event to the external button, whose click event I am listening for with jQuery, so I'll need some other way to call increaseCount.
EDIT
It seems this works:
vm.$children[0].increaseCount();

However, this is not a good solution because I am referencing the component by its index in the children array, and with many components this is unlikely to stay constant and the code is less readable.

A: This is a simple way to access a component's methods from other component
// This is external shared (reusable) component, so you can call its methods from other components

export default {
   name: 'SharedBase',
   methods: {
      fetchLocalData: function(module, page){
          // .....fetches some data
          return { jsonData }
      }
   }
}

// This is your component where you can call SharedBased component's method(s)
import SharedBase from '[your path to component]';
var sections = [];

export default {
   name: 'History',
   created: function(){
       this.sections = SharedBase.methods['fetchLocalData']('intro', 'history');
   }
}

A: You can set ref for child components then in parent can call via $refs:
Add ref to child component:
<my-component ref="childref"></my-component>

Add click event to parent:
<button id="external-button" @click="$refs.childref.increaseCount()">External Button</button>

var vm = new Vue({
  el: '#app',
  components: {
    'my-component': {
      template: '#my-template',
      data: function() {
        return {
          count: 1,
        };
      },
      methods: {
        increaseCount: function() {
          this.count++;
        }
      }
    },
  }
});

  <my-component ref="childref"></my-component>
  <button id="external-button" @click="$refs.childref.increaseCount()">External Button</button>

<template id="my-template">

A counter: {{ count }}

    <button @click="increaseCount">Internal Button</button>

</template>

A: For Vue2 this applies:
var bus = new Vue()

// in component A's method
bus.$emit('id-selected', 1)

// in component B's created hook
bus.$on('id-selected', function (id) {

  // ...
})

See here for the Vue docs.
And here is more detail on how to set up this event bus exactly.
If you'd like more info on when to use properties, events and/ or centralized state management see this article.
See below comment of Thomas regarding Vue 3.

A: Using Vue 3:
const app = createApp({})

// register an options object
app.component('my-component', {
  /* ... */
})

....

// retrieve a registered component
const MyComponent = app.component('my-component')

MyComponent.methods.greet();

https://v3.vuejs.org/api/application-api.html#component

A: In the end I opted for using Vue's ref directive. This allows a component to be referenced from the parent for direct access.
E.g.
Have a component registered on my parent instance:
var vm = new Vue({
    el: '#app',
    components: { 'my-component': myComponent }
});

Render the component in template/html with a reference:
<my-component ref="foo"></my-component>

Now, elsewhere I can access the component externally

See this fiddle for an example: https://jsfiddle.net/0zefx8o6/
(old example using Vue 1: https://jsfiddle.net/6v7y6msr/)
Edit for Vue3 - Composition API
The child-component has to return the function in setup you want to use in the parent-component otherwise the function is not available to the parent.

Note: <sript setup> doc is not affacted, because it provides all the functions and variables to the template by default.

A: You can use Vue event system
vm.$broadcast('event-name', args)

and
 vm.$on('event-name', function())

Here is the fiddle:
http://jsfiddle.net/hfalucas/wc1gg5v4/59/

A: A slightly different (simpler) version of the accepted answer:
Have a component registered on the parent instance:
export default {
    components: { 'my-component': myComponent }
}

Render the component in template/html with a reference:
<my-component ref="foo"></my-component>

Access the component method:

A: Here is a simple one
this.$children[indexOfComponent].childsMethodName();

A: I am not sure is it the right way but this one works for me.
First import the component which contains the method you want to call in your component
import myComponent from './MyComponent'

and then call any method of MyCompenent
myComponent.methods.doSomething()

A: Declare your function in a component like this:
export default {
  mounted () {
    this.$root.$on('component1', () => {
      // do your logic here :D
    });
  }
};

and call it from any page like this:
this.$root.$emit("component1");

A: If you're using Vue 3 with

Since

Components using  are closed by default

A: Say you have a child_method() in the child component:
export default {
    methods: {
        child_method () {
            console.log('I got clicked')
        }
    }
}

Now you want to execute the child_method from parent component:
<template>

        <button @click="exec">Execute child component</button>
        <child-cmp ref="child"></child_cmp>

</template>

export default {
    methods: {
        exec () { //accessing the child component instance through $refs
            this.$refs.child.child_method() //execute the method belongs to the child component
        }
    }
}

If you want to execute a parent component method from child component:
this.$parent.name_of_method()
NOTE: It is not recommended to access the child and parent component like this.
Instead as best practice use Props & Events for parent-child communication.
If you want communication between components surely use vuex or event bus
Please read this very helpful article

A: Sometimes you want to keep these things contained within your component. Depending on DOM state (the elements you're listening on must exist in DOM when your Vue component is instantiated), you can listen to events on elements outside of your component from within your Vue component. Let's say there is an element outside of your component, and when the user clicks it, you want your component to respond.
In html you have:
Launch the component
...
<my-component></my-component>

In your Vue component:
    methods() {
      doSomething() {
        // do something
      }
    },
    created() {
       document.getElementById('outsideLink').addEventListener('click', evt =>
       {
          this.doSomething();
       });
    }

A: I have used a very simple solution. I have included a HTML element, that calls the method, in my Vue Component that I select, using Vanilla JS, and I trigger click!
In the Vue Component, I have included something like the following:

That I use using Vanilla JS:
const btnReload = document.querySelector('[data-id="btnReload"]');
btnReload.click();


text:
Q: Graphviz - how to space out the ports With many edges on a node, the 'ports' (the place where an edge connect with a node) are clustered too close together and are overlapping.
There is space to spread the ports out. Is there a way to 'justify' the spacing out of the ports?

I have read the docs but not found anything. I was hoping to either increase the number of ports, or find another solution. I already increased the margin to increase the node size and give more space for the edges:
B [label=B margin=1.6]

Example code:
digraph {
    B [label=B margin=1.6]
    C [label=C margin=1.6]
    D [label=D margin=1.6]
    F [label=F margin=1.6]
    G [label=G margin=1.6]
    H [label=H margin=1.6]
    J [label=J margin=1.6]
    K [label=K margin=1.6]
    L [label=L margin=1.6]
    M [label=M margin=1.6]
    N [label=N margin=1.6]
    P [label=P margin=1.6]
    Q [label=Q margin=1.6]
    R [label=R margin=1.6]
    S [label=S margin=1.6]
    T [label=T margin=1.6]
    V [label=V margin=1.6]
    W [label=W margin=1.6]
    X [label=X margin=1.6]
    Y [label=Y margin=1.6]
    Z [label=Z margin=1.6]
    B -> C [arrowhead=invdot arrowtail=dot dir=both]
    B -> D [arrowhead=normal arrowtail=odot dir=both]
    F -> B [arrowhead=empty arrowtail=odot dir=both]
    G -> B [arrowhead=invdot arrowtail=odot dir=both]
    B -> H [arrowhead=empty arrowtail=odot dir=both]
    J -> B [arrowhead=normal arrowtail=dot dir=both]
    B -> K [arrowhead=normal arrowtail=dot dir=both]
    L -> B [arrowhead=invodot arrowtail=dot dir=both]
    M -> B [arrowhead=empty arrowtail=dot dir=both]
    B -> N [arrowhead=invdot arrowtail=odot dir=both]
    P -> B [arrowhead=invdot arrowtail=odot dir=both]
    B -> Q [arrowhead=empty arrowtail=dot dir=both]
    B -> R [arrowhead=invdot arrowtail=dot dir=both]
    S -> B [arrowhead=invodot arrowtail=dot dir=both]
    B -> T [arrowhead=invdot arrowtail=odot dir=both]
    B -> V [arrowhead=normal arrowtail=dot dir=both]
    B -> W [arrowhead=invodot arrowtail=odot dir=both]
    B -> X [arrowhead=invdot arrowtail=dot dir=both]
    B -> Y [arrowhead=invodot arrowtail=odot dir=both]
    B -> Z [arrowhead=invdot arrowtail=odot dir=both]
    C -> B [arrowhead=normal arrowtail=dot dir=both]
    D -> C [arrowhead=invdot arrowtail=odot dir=both]
    F -> C [arrowhead=invodot arrowtail=odot dir=both]
    C -> G [arrowhead=invodot arrowtail=dot dir=both]
    H -> C [arrowhead=invdot arrowtail=dot dir=both]
    C -> J [arrowhead=invdot arrowtail=odot dir=both]
    C -> K [arrowhead=invodot arrowtail=odot dir=both]
    C -> L [arrowhead=invodot arrowtail=dot dir=both]
    M -> C [arrowhead=invdot arrowtail=dot dir=both]
    N -> C [arrowhead=invodot arrowtail=dot dir=both]
    P -> C [arrowhead=empty arrowtail=dot dir=both]
    Q -> C [arrowhead=invodot arrowtail=odot dir=both]
    R -> C [arrowhead=normal arrowtail=dot dir=both]
    C -> S [arrowhead=invodot arrowtail=dot dir=both]
    T -> C [arrowhead=invodot arrowtail=dot dir=both]
    C -> V [arrowhead=invodot arrowtail=odot dir=both]
    C -> W [arrowhead=normal arrowtail=odot dir=both]
    X -> C [arrowhead=normal arrowtail=dot dir=both]
    Y -> C [arrowhead=normal arrowtail=odot dir=both]
    C -> Z [arrowhead=normal arrowtail=odot dir=both]
    D -> B [arrowhead=invdot arrowtail=dot dir=both]
    D -> C [arrowhead=normal arrowtail=odot dir=both]
    D -> F [arrowhead=normal arrowtail=odot dir=both]
    D -> G [arrowhead=normal arrowtail=dot dir=both]
    D -> H [arrowhead=invodot arrowtail=odot dir=both]
    J -> D [arrowhead=invdot arrowtail=dot dir=both]
    K -> D [arrowhead=normal arrowtail=odot dir=both]
    D -> L [arrowhead=empty arrowtail=odot dir=both]
    D -> M [arrowhead=invdot arrowtail=dot dir=both]
    D -> N [arrowhead=normal arrowtail=dot dir=both]
    D -> P [arrowhead=invdot arrowtail=odot dir=both]
    D -> Q [arrowhead=empty arrowtail=odot dir=both]
    R -> D [arrowhead=invodot arrowtail=odot dir=both]
    S -> D [arrowhead=empty arrowtail=dot dir=both]
    D -> T [arrowhead=empty arrowtail=dot dir=both]
    V -> D [arrowhead=empty arrowtail=odot dir=both]
    W -> D [arrowhead=empty arrowtail=dot dir=both]
    D -> X [arrowhead=empty arrowtail=dot dir=both]
    Y -> D [arrowhead=invodot arrowtail=dot dir=both]
    D -> Z [arrowhead=empty arrowtail=odot dir=both]
    F -> B [arrowhead=normal arrowtail=dot dir=both]
    C -> F [arrowhead=invodot arrowtail=odot dir=both]
    F -> D [arrowhead=normal arrowtail=dot dir=both]
    G -> F [arrowhead=normal arrowtail=odot dir=both]
    F -> H [arrowhead=empty arrowtail=odot dir=both]
    J -> F [arrowhead=empty arrowtail=dot dir=both]
    K -> F [arrowhead=invodot arrowtail=odot dir=both]
    F -> L [arrowhead=invodot arrowtail=odot dir=both]
    F -> M [arrowhead=empty arrowtail=odot dir=both]
    F -> N [arrowhead=invdot arrowtail=odot dir=both]
    P -> F [arrowhead=empty arrowtail=odot dir=both]
    F -> Q [arrowhead=empty arrowtail=odot dir=both]
    F -> R [arrowhead=invdot arrowtail=odot dir=both]
    F -> S [arrowhead=empty arrowtail=dot dir=both]
    T -> F [arrowhead=normal arrowtail=odot dir=both]
    V -> F [arrowhead=empty arrowtail=dot dir=both]
    W -> F [arrowhead=empty arrowtail=odot dir=both]
    F -> X [arrowhead=normal arrowtail=odot dir=both]
    Y -> F [arrowhead=invodot arrowtail=dot dir=both]
    Z -> F [arrowhead=invodot arrowtail=odot dir=both]
    G -> B [arrowhead=empty arrowtail=dot dir=both]
    C -> G [arrowhead=empty arrowtail=odot dir=both]
    G -> D [arrowhead=empty arrowtail=odot dir=both]
    F -> G [arrowhead=empty arrowtail=odot dir=both]
    H -> G [arrowhead=invodot arrowtail=odot dir=both]
    G -> J [arrowhead=invodot arrowtail=odot dir=both]
    G -> K [arrowhead=empty arrowtail=odot dir=both]
    G -> L [arrowhead=invdot arrowtail=dot dir=both]
    G -> M [arrowhead=empty arrowtail=dot dir=both]
    G -> N [arrowhead=empty arrowtail=odot dir=both]
    G -> P [arrowhead=invdot arrowtail=odot dir=both]
    Q -> G [arrowhead=invdot arrowtail=dot dir=both]
    R -> G [arrowhead=invdot arrowtail=dot dir=both]
    G -> S [arrowhead=invdot arrowtail=odot dir=both]
    G -> T [arrowhead=empty arrowtail=dot dir=both]
    V -> G [arrowhead=normal arrowtail=dot dir=both]
    W -> G [arrowhead=empty arrowtail=dot dir=both]
    G -> X [arrowhead=empty arrowtail=odot dir=both]
    Y -> G [arrowhead=empty arrowtail=dot dir=both]
    G -> Z [arrowhead=empty arrowtail=dot dir=both]
    B -> H [arrowhead=invodot arrowtail=dot dir=both]
    C -> H [arrowhead=invodot arrowtail=odot dir=both]
    D -> H [arrowhead=invodot arrowtail=odot dir=both]
    F -> H [arrowhead=invdot arrowtail=dot dir=both]
    G -> H [arrowhead=normal arrowtail=dot dir=both]
    J -> H [arrowhead=invdot arrowtail=odot dir=both]
    K -> H [arrowhead=invdot arrowtail=dot dir=both]
    L -> H [arrowhead=empty arrowtail=odot dir=both]
    H -> M [arrowhead=empty arrowtail=odot dir=both]
    H -> N [arrowhead=invodot arrowtail=dot dir=both]
    P -> H [arrowhead=normal arrowtail=dot dir=both]
    H -> Q [arrowhead=normal arrowtail=odot dir=both]
    R -> H [arrowhead=empty arrowtail=odot dir=both]
    S -> H [arrowhead=normal arrowtail=odot dir=both]
    T -> H [arrowhead=empty arrowtail=dot dir=both]
    V -> H [arrowhead=invodot arrowtail=dot dir=both]
    W -> H [arrowhead=invdot arrowtail=dot dir=both]
    X -> H [arrowhead=invodot arrowtail=dot dir=both]
    H -> Y [arrowhead=invdot arrowtail=dot dir=both]
    H -> Z [arrowhead=normal arrowtail=dot dir=both]
    J -> B [arrowhead=invdot arrowtail=dot dir=both]
    J -> C [arrowhead=normal arrowtail=dot dir=both]
    D -> J [arrowhead=invodot arrowtail=dot dir=both]
    J -> F [arrowhead=empty arrowtail=dot dir=both]
    J -> G [arrowhead=normal arrowtail=dot dir=both]
    J -> H [arrowhead=invdot arrowtail=odot dir=both]
    J -> K [arrowhead=invdot arrowtail=odot dir=both]
    L -> J [arrowhead=invdot arrowtail=dot dir=both]
    J -> M [arrowhead=empty arrowtail=odot dir=both]
    N -> J [arrowhead=invodot arrowtail=dot dir=both]
    P -> J [arrowhead=empty arrowtail=dot dir=both]
    J -> Q [arrowhead=invdot arrowtail=odot dir=both]
    J -> R [arrowhead=empty arrowtail=dot dir=both]
    S -> J [arrowhead=normal arrowtail=dot dir=both]
    J -> T [arrowhead=invodot arrowtail=dot dir=both]
    V -> J [arrowhead=normal arrowtail=dot dir=both]
    W -> J [arrowhead=invdot arrowtail=odot dir=both]
    J -> X [arrowhead=invdot arrowtail=odot dir=both]
    Y -> J [arrowhead=empty arrowtail=odot dir=both]
    J -> Z [arrowhead=normal arrowtail=dot dir=both]
    B -> K [arrowhead=invdot arrowtail=odot dir=both]
    C -> K [arrowhead=invdot arrowtail=dot dir=both]
    K -> D [arrowhead=invodot arrowtail=dot dir=both]
    F -> K [arrowhead=empty arrowtail=odot dir=both]
    K -> G [arrowhead=invodot arrowtail=dot dir=both]
    K -> H [arrowhead=empty arrowtail=dot dir=both]
    K -> J [arrowhead=invdot arrowtail=dot dir=both]
    L -> K [arrowhead=invdot arrowtail=odot dir=both]
    M -> K [arrowhead=empty arrowtail=dot dir=both]
    K -> N [arrowhead=invdot arrowtail=odot dir=both]
    P -> K [arrowhead=normal arrowtail=dot dir=both]
    Q -> K [arrowhead=normal arrowtail=odot dir=both]
    R -> K [arrowhead=normal arrowtail=odot dir=both]
    K -> S [arrowhead=empty arrowtail=dot dir=both]
    K -> T [arrowhead=invdot arrowtail=odot dir=both]
    K -> V [arrowhead=invodot arrowtail=odot dir=both]
    W -> K [arrowhead=empty arrowtail=dot dir=both]
    X -> K [arrowhead=invdot arrowtail=odot dir=both]
    K -> Y [arrowhead=normal arrowtail=odot dir=both]
    K -> Z [arrowhead=invdot arrowtail=odot dir=both]
    L -> B [arrowhead=invodot arrowtail=odot dir=both]
    C -> L [arrowhead=invdot arrowtail=dot dir=both]
    D -> L [arrowhead=invdot arrowtail=dot dir=both]
    F -> L [arrowhead=invdot arrowtail=odot dir=both]
    G -> L [arrowhead=normal arrowtail=odot dir=both]
    H -> L [arrowhead=invdot arrowtail=odot dir=both]
    J -> L [arrowhead=normal arrowtail=dot dir=both]
    K -> L [arrowhead=empty arrowtail=odot dir=both]
    M -> L [arrowhead=normal arrowtail=odot dir=both]
    N -> L [arrowhead=normal arrowtail=dot dir=both]
    L -> P [arrowhead=normal arrowtail=odot dir=both]
    Q -> L [arrowhead=invodot arrowtail=odot dir=both]
    L -> R [arrowhead=invodot arrowtail=odot dir=both]
    L -> S [arrowhead=empty arrowtail=dot dir=both]
    L -> T [arrowhead=empty arrowtail=odot dir=both]
    L -> V [arrowhead=invdot arrowtail=odot dir=both]
    L -> W [arrowhead=normal arrowtail=odot dir=both]
    L -> X [arrowhead=invdot arrowtail=dot dir=both]
    L -> Y [arrowhead=empty arrowtail=odot dir=both]
    Z -> L [arrowhead=empty arrowtail=dot dir=both]
    M -> B [arrowhead=invdot arrowtail=dot dir=both]
    M -> C [arrowhead=invdot arrowtail=dot dir=both]
    M -> D [arrowhead=invdot arrowtail=dot dir=both]
    F -> M [arrowhead=normal arrowtail=odot dir=both]
    M -> G [arrowhead=empty arrowtail=dot dir=both]
    M -> H [arrowhead=normal arrowtail=odot dir=both]
    J -> M [arrowhead=invdot arrowtail=dot dir=both]
    M -> K [arrowhead=invdot arrowtail=odot dir=both]
    M -> L [arrowhead=invodot arrowtail=dot dir=both]
    N -> M [arrowhead=invdot arrowtail=odot dir=both]
    P -> M [arrowhead=invodot arrowtail=odot dir=both]
    Q -> M [arrowhead=invodot arrowtail=odot dir=both]
    R -> M [arrowhead=normal arrowtail=odot dir=both]
    M -> S [arrowhead=invodot arrowtail=dot dir=both]
    M -> T [arrowhead=normal arrowtail=dot dir=both]
    V -> M [arrowhead=invdot arrowtail=odot dir=both]
    W -> M [arrowhead=normal arrowtail=dot dir=both]
    X -> M [arrowhead=invodot arrowtail=dot dir=both]
    M -> Y [arrowhead=invdot arrowtail=dot dir=both]
    M -> Z [arrowhead=invodot arrowtail=odot dir=both]
    N -> B [arrowhead=normal arrowtail=dot dir=both]
    C -> N [arrowhead=normal arrowtail=dot dir=both]
    N -> D [arrowhead=invdot arrowtail=dot dir=both]
    F -> N [arrowhead=invodot arrowtail=odot dir=both]
    N -> G [arrowhead=invodot arrowtail=dot dir=both]
    H -> N [arrowhead=invodot arrowtail=odot dir=both]
    N -> J [arrowhead=empty arrowtail=odot dir=both]
    N -> K [arrowhead=invodot arrowtail=odot dir=both]
    L -> N [arrowhead=invdot arrowtail=dot dir=both]
    M -> N [arrowhead=invodot arrowtail=odot dir=both]
    P -> N [arrowhead=invdot arrowtail=dot dir=both]
    Q -> N [arrowhead=invdot arrowtail=odot dir=both]
    R -> N [arrowhead=empty arrowtail=dot dir=both]
    S -> N [arrowhead=invodot arrowtail=dot dir=both]
    N -> T [arrowhead=normal arrowtail=dot dir=both]
    N -> V [arrowhead=normal arrowtail=odot dir=both]
    W -> N [arrowhead=normal arrowtail=dot dir=both]
    X -> N [arrowhead=invodot arrowtail=dot dir=both]
    N -> Y [arrowhead=invodot arrowtail=odot dir=both]
    Z -> N [arrowhead=empty arrowtail=odot dir=both]
    B -> P [arrowhead=invdot arrowtail=odot dir=both]
    C -> P [arrowhead=invdot arrowtail=dot dir=both]
    D -> P [arrowhead=empty arrowtail=dot dir=both]
    F -> P [arrowhead=invodot arrowtail=odot dir=both]
    P -> G [arrowhead=invdot arrowtail=odot dir=both]
    H -> P [arrowhead=invodot arrowtail=odot dir=both]
    P -> J [arrowhead=invdot arrowtail=odot dir=both]
    K -> P [arrowhead=invodot arrowtail=dot dir=both]
    P -> L [arrowhead=invodot arrowtail=odot dir=both]
    P -> M [arrowhead=invdot arrowtail=odot dir=both]
    N -> P [arrowhead=invdot arrowtail=dot dir=both]
    P -> Q [arrowhead=invdot arrowtail=dot dir=both]
    R -> P [arrowhead=invdot arrowtail=odot dir=both]
    S -> P [arrowhead=invodot arrowtail=dot dir=both]
    P -> T [arrowhead=normal arrowtail=odot dir=both]
    P -> V [arrowhead=normal arrowtail=odot dir=both]
    W -> P [arrowhead=invdot arrowtail=dot dir=both]
    X -> P [arrowhead=empty arrowtail=odot dir=both]
    Y -> P [arrowhead=normal arrowtail=odot dir=both]
    Z -> P [arrowhead=invdot arrowtail=odot dir=both]
    B -> Q [arrowhead=invodot arrowtail=odot dir=both]
    Q -> C [arrowhead=normal arrowtail=odot dir=both]
    D -> Q [arrowhead=invodot arrowtail=dot dir=both]
    Q -> F [arrowhead=normal arrowtail=odot dir=both]
    G -> Q [arrowhead=invodot arrowtail=odot dir=both]
    Q -> H [arrowhead=invdot arrowtail=odot dir=both]
    J -> Q [arrowhead=empty arrowtail=dot dir=both]
    Q -> K [arrowhead=invodot arrowtail=odot dir=both]
    Q -> L [arrowhead=normal arrowtail=dot dir=both]
    Q -> M [arrowhead=empty arrowtail=odot dir=both]
    N -> Q [arrowhead=normal arrowtail=dot dir=both]
    P -> Q [arrowhead=normal arrowtail=odot dir=both]
    Q -> R [arrowhead=empty arrowtail=dot dir=both]
    Q -> S [arrowhead=invdot arrowtail=dot dir=both]
    T -> Q [arrowhead=normal arrowtail=dot dir=both]
    V -> Q [arrowhead=empty arrowtail=dot dir=both]
    W -> Q [arrowhead=empty arrowtail=odot dir=both]
    X -> Q [arrowhead=invdot arrowtail=odot dir=both]
    Q -> Y [arrowhead=invdot arrowtail=odot dir=both]
    Z -> Q [arrowhead=invdot arrowtail=odot dir=both]
    B -> R [arrowhead=normal arrowtail=dot dir=both]
    C -> R [arrowhead=empty arrowtail=odot dir=both]
    R -> D [arrowhead=normal arrowtail=odot dir=both]
    R -> F [arrowhead=empty arrowtail=odot dir=both]
    G -> R [arrowhead=empty arrowtail=dot dir=both]
    R -> H [arrowhead=invodot arrowtail=odot dir=both]
    J -> R [arrowhead=empty arrowtail=odot dir=both]
    R -> K [arrowhead=invodot arrowtail=odot dir=both]
    R -> L [arrowhead=invdot arrowtail=dot dir=both]
    M -> R [arrowhead=empty arrowtail=odot dir=both]
    N -> R [arrowhead=invdot arrowtail=dot dir=both]
    P -> R [arrowhead=empty arrowtail=dot dir=both]
    R -> Q [arrowhead=normal arrowtail=odot dir=both]
    R -> S [arrowhead=empty arrowtail=dot dir=both]
    R -> T [arrowhead=invdot arrowtail=dot dir=both]
    R -> V [arrowhead=normal arrowtail=odot dir=both]
    W -> R [arrowhead=invodot arrowtail=odot dir=both]
    X -> R [arrowhead=normal arrowtail=odot dir=both]
    R -> Y [arrowhead=invodot arrowtail=odot dir=both]
    R -> Z [arrowhead=invdot arrowtail=odot dir=both]
    S -> B [arrowhead=invodot arrowtail=dot dir=both]
    C -> S [arrowhead=invodot arrowtail=dot dir=both]
    D -> S [arrowhead=empty arrowtail=odot dir=both]
    S -> F [arrowhead=empty arrowtail=dot dir=both]
    S -> G [arrowhead=empty arrowtail=odot dir=both]
    H -> S [arrowhead=invodot arrowtail=odot dir=both]
    S -> J [arrowhead=invodot arrowtail=odot dir=both]
    S -> K [arrowhead=empty arrowtail=odot dir=both]
    S -> L [arrowhead=normal arrowtail=odot dir=both]
    M -> S [arrowhead=invodot arrowtail=odot dir=both]
    S -> N [arrowhead=invdot arrowtail=dot dir=both]
    P -> S [arrowhead=invdot arrowtail=dot dir=both]
    S -> Q [arrowhead=normal arrowtail=odot dir=both]
    S -> R [arrowhead=empty arrowtail=dot dir=both]
    T -> S [arrowhead=normal arrowtail=dot dir=both]
    S -> V [arrowhead=invodot arrowtail=odot dir=both]
    S -> W [arrowhead=empty arrowtail=odot dir=both]
    X -> S [arrowhead=invdot arrowtail=dot dir=both]
    S -> Y [arrowhead=invodot arrowtail=odot dir=both]
    Z -> S [arrowhead=empty arrowtail=dot dir=both]
    B -> T [arrowhead=normal arrowtail=dot dir=both]
    C -> T [arrowhead=empty arrowtail=odot dir=both]
    T -> D [arrowhead=invdot arrowtail=dot dir=both]
    T -> F [arrowhead=invodot arrowtail=odot dir=both]
    T -> G [arrowhead=invodot arrowtail=odot dir=both]
    H -> T [arrowhead=normal arrowtail=odot dir=both]
    T -> J [arrowhead=empty arrowtail=dot dir=both]
    K -> T [arrowhead=normal arrowtail=odot dir=both]
    T -> L [arrowhead=normal arrowtail=dot dir=both]
    T -> M [arrowhead=invdot arrowtail=odot dir=both]
    N -> T [arrowhead=empty arrowtail=dot dir=both]
    P -> T [arrowhead=normal arrowtail=dot dir=both]
    T -> Q [arrowhead=invdot arrowtail=odot dir=both]
    R -> T [arrowhead=normal arrowtail=dot dir=both]
    T -> S [arrowhead=invdot arrowtail=dot dir=both]
    V -> T [arrowhead=normal arrowtail=odot dir=both]
    W -> T [arrowhead=normal arrowtail=dot dir=both]
    T -> X [arrowhead=invdot arrowtail=odot dir=both]
    Y -> T [arrowhead=invodot arrowtail=odot dir=both]
    Z -> T [arrowhead=normal arrowtail=dot dir=both]
    V -> B [arrowhead=invodot arrowtail=dot dir=both]
    V -> C [arrowhead=invdot arrowtail=dot dir=both]
    V -> D [arrowhead=empty arrowtail=dot dir=both]
    V -> F [arrowhead=invdot arrowtail=odot dir=both]
    G -> V [arrowhead=invdot arrowtail=dot dir=both]
    V -> H [arrowhead=invdot arrowtail=odot dir=both]
    J -> V [arrowhead=invodot arrowtail=odot dir=both]
    K -> V [arrowhead=invdot arrowtail=odot dir=both]
    V -> L [arrowhead=empty arrowtail=dot dir=both]
    M -> V [arrowhead=invodot arrowtail=dot dir=both]
    N -> V [arrowhead=empty arrowtail=dot dir=both]
    P -> V [arrowhead=normal arrowtail=dot dir=both]
    Q -> V [arrowhead=empty arrowtail=dot dir=both]
    V -> R [arrowhead=normal arrowtail=odot dir=both]
    V -> S [arrowhead=invodot arrowtail=odot dir=both]
    V -> T [arrowhead=invodot arrowtail=odot dir=both]
    W -> V [arrowhead=empty arrowtail=dot dir=both]
    V -> X [arrowhead=invdot arrowtail=odot dir=both]
    V -> Y [arrowhead=invodot arrowtail=odot dir=both]
    Z -> V [arrowhead=normal arrowtail=odot dir=both]
    W -> B [arrowhead=normal arrowtail=odot dir=both]
    C -> W [arrowhead=invdot arrowtail=odot dir=both]
    D -> W [arrowhead=invdot arrowtail=dot dir=both]
    F -> W [arrowhead=normal arrowtail=dot dir=both]
    W -> G [arrowhead=invdot arrowtail=odot dir=both]
    H -> W [arrowhead=normal arrowtail=odot dir=both]
    W -> J [arrowhead=normal arrowtail=dot dir=both]
    W -> K [arrowhead=normal arrowtail=odot dir=both]
    W -> L [arrowhead=invdot arrowtail=odot dir=both]
    M -> W [arrowhead=normal arrowtail=odot dir=both]
    N -> W [arrowhead=normal arrowtail=odot dir=both]
    W -> P [arrowhead=normal arrowtail=odot dir=both]
    Q -> W [arrowhead=normal arrowtail=odot dir=both]
    R -> W [arrowhead=invdot arrowtail=dot dir=both]
    W -> S [arrowhead=empty arrowtail=odot dir=both]
    T -> W [arrowhead=invdot arrowtail=dot dir=both]
    W -> V [arrowhead=invodot arrowtail=dot dir=both]
    W -> X [arrowhead=invodot arrowtail=odot dir=both]
    Y -> W [arrowhead=invdot arrowtail=dot dir=both]
    W -> Z [arrowhead=invdot arrowtail=dot dir=both]
    X -> B [arrowhead=normal arrowtail=dot dir=both]
    C -> X [arrowhead=empty arrowtail=odot dir=both]
    X -> D [arrowhead=normal arrowtail=dot dir=both]
    X -> F [arrowhead=empty arrowtail=dot dir=both]
    X -> G [arrowhead=invdot arrowtail=odot dir=both]
    H -> X [arrowhead=invodot arrowtail=odot dir=both]
    J -> X [arrowhead=normal arrowtail=odot dir=both]
    K -> X [arrowhead=empty arrowtail=dot dir=both]
    X -> L [arrowhead=invdot arrowtail=dot dir=both]
    M -> X [arrowhead=invdot arrowtail=odot dir=both]
    X -> N [arrowhead=empty arrowtail=odot dir=both]
    X -> P [arrowhead=invodot arrowtail=dot dir=both]
    Q -> X [arrowhead=normal arrowtail=odot dir=both]
    R -> X [arrowhead=empty arrowtail=dot dir=both]
    X -> S [arrowhead=invodot arrowtail=dot dir=both]
    X -> T [arrowhead=invodot arrowtail=dot dir=both]
    X -> V [arrowhead=invodot arrowtail=dot dir=both]
    X -> W [arrowhead=invdot arrowtail=odot dir=both]
    Y -> X [arrowhead=normal arrowtail=dot dir=both]
    X -> Z [arrowhead=invdot arrowtail=dot dir=both]
    Y -> B [arrowhead=normal arrowtail=odot dir=both]
    Y -> C [arrowhead=invodot arrowtail=odot dir=both]
    D -> Y [arrowhead=empty arrowtail=odot dir=both]
    F -> Y [arrowhead=normal arrowtail=dot dir=both]
    Y -> G [arrowhead=empty arrowtail=odot dir=both]
    Y -> H [arrowhead=invodot arrowtail=dot dir=both]
    Y -> J [arrowhead=invodot arrowtail=dot dir=both]
    Y -> K [arrowhead=invdot arrowtail=odot dir=both]
    L -> Y [arrowhead=invdot arrowtail=dot dir=both]
    M -> Y [arrowhead=empty arrowtail=odot dir=both]
    N -> Y [arrowhead=invdot arrowtail=dot dir=both]
    Y -> P [arrowhead=invodot arrowtail=dot dir=both]
    Q -> Y [arrowhead=invodot arrowtail=dot dir=both]
    R -> Y [arrowhead=invodot arrowtail=dot dir=both]
    S -> Y [arrowhead=invodot arrowtail=odot dir=both]
    T -> Y [arrowhead=empty arrowtail=dot dir=both]
    Y -> V [arrowhead=invodot arrowtail=dot dir=both]
    W -> Y [arrowhead=invdot arrowtail=dot dir=both]
    X -> Y [arrowhead=normal arrowtail=dot dir=both]
    Y -> Z [arrowhead=invdot arrowtail=dot dir=both]
    Z -> B [arrowhead=normal arrowtail=dot dir=both]
    C -> Z [arrowhead=empty arrowtail=dot dir=both]
    D -> Z [arrowhead=normal arrowtail=odot dir=both]
    Z -> F [arrowhead=invdot arrowtail=dot dir=both]
    G -> Z [arrowhead=empty arrowtail=dot dir=both]
    H -> Z [arrowhead=invodot arrowtail=odot dir=both]
    Z -> J [arrowhead=empty arrowtail=odot dir=both]
    Z -> K [arrowhead=invdot arrowtail=odot dir=both]
    Z -> L [arrowhead=invodot arrowtail=dot dir=both]
    M -> Z [arrowhead=normal arrowtail=odot dir=both]
    Z -> N [arrowhead=invdot arrowtail=odot dir=both]
    P -> Z [arrowhead=normal arrowtail=dot dir=both]
    Q -> Z [arrowhead=empty arrowtail=odot dir=both]
    R -> Z [arrowhead=normal arrowtail=odot dir=both]
    S -> Z [arrowhead=invdot arrowtail=dot dir=both]
    T -> Z [arrowhead=invodot arrowtail=odot dir=both]
    Z -> V [arrowhead=normal arrowtail=dot dir=both]
    Z -> W [arrowhead=empty arrowtail=odot dir=both]
    Z -> X [arrowhead=empty arrowtail=odot dir=both]
    Y -> Z [arrowhead=normal arrowtail=odot dir=both]
}

A: Graphviz defines 8 port locations on a node, based on points on a compass (n,s,e,w,ne,se,sw,nw) (https://graphviz.org/docs/attr-types/portPos/).  This helps, but your nodes seem to "need" more than 8 positions.

*

*e.g. B:ne -> D [arrowhead=normal arrowtail=odot dir=both]
Maybe you could try a mixture of explicit ports and implicit ports


text:
Q: ASP.NET LINQ Error Cannot create a query result of type 'System.Collections.Generic.List`1[System.Int32]' I am trying to create a Dictionary<string, List<int>> through a Linq statement
It gives me the following error: Cannot create a query result of type 'System.Collections.Generic.List`1[System.Int32]'
        var output = (
                    from e in EDC.Energideklarationer_As
                    where MunicipalityName.Contains(e.Municipality)
                    group e by e.Municipality into g
                    select new
                    {
                        Municipality = g.Key,

                        listan = new List<int>()
                        {
                        g.Count(e => e.H== "El"),
                        g.Count(e => e.H== "Eldningsolja"),
                        g.Count(e => e.H== "Flis"),
                        g.Count(e => e.H== "Markvarmepump"),
                        g.Count(e => e.H== "Ved")
                        }
                    }
            ).ToDictionary(x => x.Municipality, x=> x.listan);

A: I guess you're using some kind of ORM library and the EDC.Energideklarationer_As object is an IQueryable implemented in that ORM. What happens is that this library is trying to generate a query (maybe SQL query, depending on what library you're using) to the underlying data source from your LINQ query.
Some expressions are not supported in some ORMs - for example Entity Framework won't handle select new int[] { ... }, but will handle select new List<int> { ... }. It seems that the library you're using does not support creating new List in a query. And the exception is thrown in ToDictionary, because that's where the result is instantiated and LINQ gets translated.
Try replacing the list:
                listan = new List<int>()
                {
                    g.Count(e => e.H== "El"),
                    g.Count(e => e.H== "Eldningsolja"),
                    g.Count(e => e.H== "Flis"),
                    g.Count(e => e.H== "Markvarmepump"),
                    g.Count(e => e.H== "Ved")
                }

with another anonymous type:
                listan = new
                {
                    El = g.Count(e => e.H== "El"),
                    Eldningsolja = g.Count(e => e.H== "Eldningsolja"),
                    Flis = g.Count(e => e.H== "Flis"),
                    Markvarmepump = g.Count(e => e.H== "Markvarmepump"),
                    Ved = g.Count(e => e.H== "Ved")
                }


text:
Q: Zend framework query, add to string let's say that I have:
$query = $this->select()
              ->where('name LIKE ?','%something%');
              ->where('section LIKE ?','%something%');
              ->where('cars LIKE ?','%something%');
              ............
              ............

You get the point!
But I want to add the where() clause to the query only let's say if..$x = 0; something like this:
$select = $this->select();
if($x == 0):
//add to the $this->select(); so it will be $this->select()->where('section LIKE   ?','%something%');
 $select->where('section LIKE ?','%something%');
endif;

if($x == 0):
/*add to the $this->select(); so it will be
$this->select()->where('section LIKE  ?','%something%')
->where('cars LIKE ?','%something%');
*/
 $select->where('cars LIKE ?','%something%');
endif;

Of course, this thing doesn't work but I guess you have understood what I want to make!
Best Regards,

A: Have you considered building the SQL query string manualy beforehand and then just calling fetchAll() on your $db reference?
$SQL = 'SELECT * from blah, ';
if($x == 0):
    //add to the $this->select(); so it will be $this->select()->where('section LIKE   ?','%something%');
    $SQL = $SQL . "WHERE blah");
endif;

if($x == 1):
    $SQL = $SQL . "WHERE blah");
endif;

$db = Zend_Db_Table::getDefaultAdapter();
$this->view->leaguetable = $db->fetchAll($SQL);

The Zend_DB.select() returns a sql query statement
$select = $this->select();

but you can't conditionally control the addition of where clauses to the object after the select() method has finished. It's not an append operation.
$select = $this->select();
if($x == 0):
 $select->where('section LIKE ?','%something%');
endif;

A: Problem appears to be your if clause, instead of
$x = 0

you want
$x == 0

The former is assigning 0 to $x in the if clause, which is almost never what you want.