text:
Q: PHP Trying to get property of non-object - Not sure why Im trying to generate a DataTable of the list of Payables from the database using PDO and JQuery AJAX But i keep encountering this error on my PHP File. Im not sure whats wrong with my code.
The error message says:
[28-Jun-2016 16:33:12 Asia/Manila] PHP Notice:  Trying to get property of non-object in ** on line 121

Line 121 in pay_controller.php is:
if($allPayList->res == 0) { echo ""; }

This is the pay_controller.php
<?PHP
class PayController {

public function pay() {

    if (empty($_GET['sid']))
    return call('home', 'expire');

    $getSessionData = SessionData::getData($_GET['sid']);

    if($getSessionData->res = 0)
    {
        return call('home', 'expire');
    }
    date_default_timezone_set('Asia/Manila');
    $dtnow = date('Y-m-d H:i:s');
    $sexpire = date('Y-m-d H:i:s', strtotime($getSessionData->ssend));

    if($sexpire < $dtnow)
    {
        return call('home', 'expire');
    }

    $getMenu = MENU::getMenu();
    $menuid = 3;

    require_once('views/pay.php');

}

public function currentpay() {

    $curPayList = Payables::getCurrentPayable();

    echo "

                        Sequence
                        Date
                        Vendor
                        Reference No.
                        Amount
                        Action

        ";

        if($curPayList->res == 0) {
            echo "";
        }
        elseif($curPayList->res == 1) {

            echo "

                    " . $curPayList->seq . "
                    " . $curPayList->pdate . "
                    " . $curPayList->vendor . "
                    " . $curPayList->refno . "
                    " . number_format($curPayList->amount,2) . "

                        seq .")' class='btn btn-sm btn-default'>

                        VIEW DETAILS

";
        }
        elseif($curPayList->res > 1) {
            foreach($curPayList as $cPL) {
                echo "

                        " . $cPL->seq . "
                        " . $cPL->pdate . "
                        " . $cPL->vendor . "
                        " . $cPL->refno . "
                        " . number_format($cPL->amount,2) . "

                            seq .")' class='btn btn-sm btn-default'>

                            VIEW DETAILS

";
            }
        }

            echo "

        ";
}

public function allpay() {

    $allPayListing = Payables::getAllPurchase();

    echo "

                        Sequence
                        Date
                        Vendor
                        Reference No.
                        Amount
                        Action

        ";

        if($allPayListing->res == 0) {

            echo "";

        }
        elseif($allPayListing->res == 1) {
            echo "

                    " . $allPayList->seq . "
                    " . $allPayList->pdate . "
                    " . $allPayList->vendor . "
                    " . $allPayList->refno . "
                    " . number_format($allPayList->amount,2) . "

                        seq .")' class='btn btn-sm btn-default'>

                        VIEW DETAILS

";
        }
        elseif($allPayListing->res > 1) {
            foreach($allPayListing as $aPL) {
                echo "

                        " . $aPL->seq . "
                        " . $aPL->pdate . "
                        " . $aPL->vendor . "
                        " . $aPL->refno . "
                        " . number_format($aPL->amount,2) . "

                            seq .")' class='btn btn-sm btn-default'>

                            VIEW DETAILS

";
            }
        }

    echo "

        ";
}

public function error() {

    require_once('404.php');

}

public function expire(){

    require_once('expire.php');
 }
}
?>

And this is the mod_pay.php
<?PHP
class Payables {

public $seq;
public $pdate;
public $vendor;
public $refno;
public $amount;
public $res;

public function __construct($seq, $pdate, $vendor, $refno, $amount, $res) {
    $this ->seq         = $seq;
    $this ->pdate       = $pdate;
    $this ->vendor      = $vendor;
    $this ->refno       = $refno;
    $this ->amount      = $amount;
    $this ->res         = $res;
}

public static function getCurrentPayable() {

    $db = Db::getInstance();

    $currentPay = $db->prepare('SELECT
                                payables.seq AS seq,
                                payables.purdate AS pdate,
                                companies.compname AS vendor,
                                payables.refno AS refno,
                                payables.balance AS amount
                            FROM
                                payables
                            LEFT JOIN
                                companies
                            ON
                                companies.seq = payables.vendor
                            WHERE
                                payables.paidstatus = 0
                            ');

    switch($currentPay->execute())
    {
        case True:

            $currentPayResCount = $currentPay->rowCount();

            if($currentPayResCount == 0) {

                $currentPayList = new Payables(NULL,NULL,NULL,NULL,NULL,0);

            }
            elseif($currentPayResCount == 1) {

                $currentPayRes = $currentPay->fetch();
                $currentPayList = new Payables($currentPayRes['seq'], $currentPayRes['pdate'], $currentPayRes['vendor'], $currentPayRes['refno'], $currentPayRes['amount'], $currentPayResCount);

            }
            elseif($currentPayResCount > 1) {

                $currentPayRes = $currentPay->fetchAll();
                foreach($currentPayRes as $cPR) {
                    $currentPayList[] = new Payables($cPR['seq'], $cPR['pdate'], $cPR['vendor'], $cPR['refno'], $cPR['amount'], $currentPayResCount);
                }

            }
            return $currentPayList;
            break;

        case False:
            $currentPayList = new Payables(NULL,NULL,NULL,NULL,NULL,0);
            return $currentPayList;
            break;
    }
}

public static function getAllPurchase() {

    $db = Db::getInstance();

    $allPayables = $db->prepare('SELECT
                                payables.seq AS seq,
                                payables.purdate AS pdate,
                                companies.compname AS vendor,
                                payables.refno AS refno,
                                payables.balance AS amount
                            FROM
                                payables
                            LEFT JOIN
                                companies
                            ON
                                companies.seq = payables.vendor
                            ');

    switch($allPayables->execute())
    {
        case True:

            $allPayResCount = $allPayables->rowCount();

            if($allPayResCount == 0) {

                $allPayList = new Payables(NULL,NULL,NULL,NULL,NULL,0);

            }
            elseif($allPayResCount == 1) {

                $allPayRes = $allPayables->fetch();

                $allPayList = new Payables($allPayRes['seq'], $allPayRes['pdate'], $allPayRes['vendor'], $allPayRes['refno'], $allPayRes['amount'], $allPayResCount);

            }
            elseif($allPayResCount > 1) {

                $allPayRes = $allPayables->fetchAll();

                foreach($allPayRes as $aPR) {
                    $allPayList[] = new Payables($aPR['seq'], $aPR['pdate'], $aPR['vendor'], $aPR['refno'], $aPR['amount'], $allPayResCount);
                }

            }
            return $allPayList;
            break;

        case False:
            $allPayList = new Payables(NULL,NULL,NULL,NULL,NULL,0);
            return $allPayList;
            break;
    }
  }
}
?>

Note: I'm duplicating the getCurrentPayable() function which does not return an error. It returns 1 result. getAllPurchase() should return 2.
Edit: I included the entire file.
Edit: I edited it to reflect the recent changes I've made and it still showing the same error.

A: So for those wondering, the correct answer to this question and the solution to the problem was that one of the multiple conditions being used within the 'mod_pay.php' file to initialise the object in question was actually returning an array of these objects and so could not be directly accessed as an object using if($allPayList->res == 0) { echo ""; }.
Without knowing more about the intention of the system, I can't really offer the most suitable method for dealing with multiple records being returned from the database.

A: Possibly, the data you are fetching does not exist into the join table. Be sure to skip that data from fetching or else add "ON DELETE CASCADE" or "ON UPDATE SET NULL" option while applying reference key in your data table.

A: As @arkascha asks, we need to see the function getAllPurchase() which I'm guessing can return null or some other non-object result in some circumstances. Because it's not returning an object, you cannot call any properties or methods on anything returned from this method, stored in your case in $allPayList and is why PHP tells you so in its error message.
The easy "fix" is to test $allPayList->res using isset($allPayList->res) or !empty($allPayList->res), if either of these return true, only then can you actually call $allPayList->res.
The better fix, is to ensure you do a better job of returning something meaningful in getAllPurchase() i.e. an empty instance of a return object so that there is always a res property available and it's that that might be true, false or possibly null

A: $allPayList is an ARRAY and u use it as a object.
First check all variables inside the $allPayList with print_r() method.
Then u will easily find out the hierarchy of the array.

A: Try to use a proper approach to return value from the Payables class getAllPurchase() method.
In your code, static method getAllPurchase() in some case returns Object (instance) of Payables class & in other case it returns Array of Objects of Payables class.
So, use an approach to check for returned value in $allPayListing variable is an array of objects or an object of Payables class:
Use below code to by-pass the error occured at line 121:
    if(!is_array($allPayListing))
    {
        if(isset($allPayListing->res) && $allPayListing->res == 0) {
            echo "";
        }
    }

A: I finally solved it. Thanks to all of your help.
It turns out, since the getAllPurchase() function is returning 2 records, the condition creates an array of objects. Since it is an array, It cannot be read as object.
The first function getCurrentPayable() function only returns 1 record thus the condition creates an object.
Here is the updated working code.
public function allpay() {

    $allPayListing = Payables::getAllPurchase();

    echo "

                        Sequence
                        Date
                        Vendor
                        Reference No.
                        Amount
                        Action

        ";

        if(!is_array($allPayListing)) {
            if(isset($allPayListing->res) && $allPayListing->res == 0) {
                echo "";
            }
            else {

                echo "

                        " . $allPayList->seq . "
                        " . $allPayList->pdate . "
                        " . $allPayList->vendor . "
                        " . $allPayList->refno . "
                        " . number_format($allPayList->amount,2) . "

                            seq .")' class='btn btn-sm btn-default'>

                            VIEW DETAILS

";
            }
        }
        else {

            foreach($allPayListing as $aPL) {
                echo "

                        " . $aPL->seq . "
                        " . $aPL->pdate . "
                        " . $aPL->vendor . "
                        " . $aPL->refno . "
                        " . number_format($aPL->amount,2) . "

                            seq .")' class='btn btn-sm btn-default'>

                            VIEW DETAILS

";
            }

        }

    echo "

        ";
}

I first counted the contents of $allPayListing then throw the condition that if it is more than 0 or 1 then it means its an array. I have to loop through the array first to access the objects.


text:
Q: Tello Video Stream API for Android I have looked around and I have been unable to find any support for capturing the video feed coming from a Ryze Tello drone. The official DJI sample does not include support for Tello. I have a hunch that the solution involves native calls to FFMPEG but I have been unable to pinpoint all the details of the video protocol.
Has anyone looked into this or found useful libraries that support this behavior?

A: Here is the sample code that receives and decodes the h264 video stream provided by Tello SDK team, you can use the "streamon" command: https://github.com/dji-sdk/Tello-Python.
Please refer to doc/reademe.pdf and the source code under the path of h264 decoder for the specific processing method of the received video stream data.
Before you run the sample code, you should install some dependencies by using the install script.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Call Microservice from another Microservice within Docker I created several Microservices in C# that are running on docker in windows, I need to call Microservice from another Microservice so I used this way to call:
    [HttpGet("GetOrder/{Object_ID}")]
    public Order GetOrder (int id)
    {
        string Baseurl = "http://189.29.0.100/";
        …..

        using (var client = new HttpClient())
        {
            //Passing service base url
            client.BaseAddress = new Uri(Baseurl);

            client.DefaultRequestHeaders.Clear();
            //Define request data format
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            //Sending request to find web api REST service resource GetAllEmployees using HttpClient
            borrowerData = await client.GetStringAsync("api/order/" + Id.ToString());

        }

       …
    }

I used the fix IP in Composed file as follows:
 orderservice:
    environment:
     - ASPNETCORE_ENVIRONMENT=Development
   ports:
  - "80"
networks:
  default:
    ipv4_address: 189.29.0.100

The problem is when we deploy this project in VM, how to make it work with these Ips?

A: Docker compose create a virtual network on you host and the services are not routable from outside of docker with those IPs. But inside the virtual network all services can access to each other with their names (http://otherservice/).
If you want to access to all deployed microservices on VM you will need a reverse proxy inside your docker compose. For example an nginx service that dispatch request to other services.

A: I agree with @Bardia that using a docker-compose file is the easiest way to let microservices know the location of each other! Personally, I also use one compose file for all my microservices.
So if you name the service service-a in your docker-compose.yml file, you will be able to find it by http://service-a:{port}/path. This has a huge advantage: you can use the same port on every microservice without worrying about port collision (since DNS is used to resolve the path), this is also crucial for enabling horizontal scaling!
Going one step further, like @Bardia said, add a reverse-proxy instead of starting real chaos with ports on the host machine... I personally like Traefik, you can configure it by using labels in your service descriptions of the compose file. This also has the advantages for your UI application (if you have one) to access the microservice APIs via relative paths. Thus, you can deploy it anywhere without the necessity to change paths.


text:
Q: Left Multiplication Ring Homomorphism
Assume we have a non-commutative unital ring $R$ and an element $r$ not in the center. Define a map $$\phi_r:R\rightarrow R$$ $$x\mapsto rx$$ Can this ever be a ring homomorphism?

If it can be then $r$ has to be idempotent, and the kernel (the set of $r$'s zero divisors with $0$) must be an ideal.  I'm pretty sure that this can't be a homomorphism, but I can't prove it.  Although I can't promise that I just haven't been clever enough to think of an example where this works.  Some simple proof showing that $r$ has to be in the center is what I've striven for, but alas...
Edit:  Suppose I should add that I'm adopting the definition of a ring homomorphism that isn't necessarily (multiplicative) identity invariant.

A: Let $R$ be the ring of $2\times 2$ upper triangular matrices with coefficients in some field, and let $r=\begin{pmatrix}0&0\\0&1\end{pmatrix}$.

A: It is certainly possible to concoct an artificial example where $x\mapsto rx$ is a homomorphism but $r$ does not commute with everything.
The elements shall be non-commutative polynomials in two variables, say $x$ and $y$, such that no term of the polynomial contains more than one occurrence of $x$. Addition is ordinary polynomial addition. For multiplication, multiply the polynomials as usual and then delete from each term the second occurrence of $x$, if there is one.
For example:
$\begin{array}{rcl}(2y^2xy + x + 2y)(xy+yx)&=&2y^2xyxy + x^2y + 2yxy + 2y^2xy^2x + xyx + 2y^2x \\&=& 2y^2xy^2 + xy + 2yxy + 2y^2xy^2 + xy + 2y^2x \\&=& 4y^2xy^2 + 2xy + 2yxy + 2y^2x\end{array}$
In other words, this is the free ring on $x$ and $y$ quotiented by the relations $xab=xaxb$ for all $a$ and $b$.
Clearly $x$ does not commute with $y$, so is not in the center, and yet $xab=(xa)(xb)$ for all $a$ and $b$.

A: Let's assume that $x\mapsto ex$ is a ring homomorphism. Then of course the image $eR$ is a ring with identity $e$, and so (as you observed) it will be idempotent and central in the ring $eR$. Those are certainly necessary conditions, so it's natural to ask if they're sufficient also.
Suppose that $e^2=e$ and $e$ commutes with everything in $eR$. Then $x\mapsto ex$ is obviously an additive homomorphism from $R$ to $eR$, and additionally $(ex)(ey)=(exe)y=(eex)y=exy$, so it's a multiplicative homomorphism as well. Thus $eR$ is a ring with identity $e$, and the multiplication map is a ring homomorphism.
So we have the answer:

The map $x\mapsto ex$ from $R\to R$ using the element $e\in R$ is a ring homomorphism iff $e$ is an idempotent of $R$ commuting with each element of $eR$.

In particular, any idempotent that's in the center of $R$ will create the ring $eRe=eR$ inside of $R$. Mariano's example shows us a noncentral idempotent satisfying the condition highlighted above. If you look at the same idempotent in the full ring of $2\times 2 $ matrices, you'll find it fails to commute with $eR$. (Just check its product with $\begin{bmatrix}0&0\\1&1\end{bmatrix}$ on both sides, for example.)


text:
Q: Use Java class file in IDEA Is it possible to use a class from a .class file in IDEA? For example, if I have a directory with two files Ball.java and DemoBall.class, how would I use DemoBall in Ball? It says it cannot find symbol when compiling. I just want to tell IDEA that there is a compiled Java class in the directory and to recognize that, I don't want to decompile it.

A: EDIT:

*

*Open IntelliJIDEA. Now Press CTL + Shift + ALT + S. This will open Project Structure.

*Now Select Module from Project Settings (left hand side). And Dependencies tab from the right hand side.

*Now Click on the + on the extreme right hand side toolbar. Select Jars or Directories. A new Window, Attack File or Directories will pop up.

*Now browse to the location, where DemoBall.class is located. Click OK.

*Select the CheckBox under Export against the location just selected. Click OK on the main Project Structure window. You are done.

Original(This one it seems is not the right way):

*

*Open IntelliJDEA. Create a Project, with simple Java Class named Ball.java
inside it, having one main method(empty body).

*Run this class, so as to create one out folder.

*Copy DemoBall.class. Now through Windows Explorer/File System, go to out folder and paste DemoBall.class inside out\production\ProjectName folder.

*Now simply write the code that uses this DemoBall class, inside the main method of Ball.java class.

Previously, I was wondering, as to why the red lines are coming still, even though, the program is running fine. But once, I restart, IntelliJIDEA, everythingy works fine, without showing any errors.


text:
Q: Why does log likelihood function for a model use SSE/n and not SSE/df? I'm trying to find out how log-likelihood function works for linear regression. I found the formula here and here. Making some experiments with it (see code below), I was quite surprised that the likelihood uses SSE/n instead of MSE (SSE/df). MSE was used everywhere up to now! I thought MSE is much better estimator of $\sigma^2$ mentioned in the formula in the 1st resource (page 6) - the actual residual variance. But the 2nd resource and my experiment clearly states that $\sigma^2$ is defined as SSE/n (where n is length of the outcome variable vector).
Here is the code to play with:
set.seed(128)
y = c(rnorm(200, 20, 4), rnorm(300, 30, 4), rnorm(400, 40, 4), rnorm(500, 50, 4))
cat1 = as.factor(c(rep(1, 200), rep(2, 300), rep(3, 400), rep(4, 500)))
rand_order = sample(1:length(cat1))
cat2 = cat1[rand_order]
cat2y = c(rep(1, 200), rep(-2, 300), rep(3, 400), rep(-4, 500))
y = y + cat2y[rand_order]
m1 = lm(y ~ 0 + cat1 + cat2)

# logLik using residual degrees of freedom (-3941.94):
-length(m1$model$y)/2*log(2*pi) - length(m1$model$y)/2*log(sum((m1$residual)^2)/m1$df.residual) - 1/2*m1$df.residual

# logLik using N (-3941.931)
-length(m1$model$y)/2*log(2*pi) - length(m1$model$y)/2*log(sum((m1$residual)^2)/length(m1$model$y)) - 1/2*length(m1$model$y)

# real logLik (-3941.931)
logLik(m1)

A: The same situation happens in the simplest Normal means model: $Y=\mu + \epsilon$, with $\epsilon$ ~ N(0,$\sigma^2$).
The MLE of $\sigma^2$ is the sum of squares about the mean divided by n: $$S^2=\sum \frac{(Y_i-\bar{Y})^2}{n}$$.
However, this quantity is a biased estimator: $E(S^2) \neq \sigma^2$. Dividing the sum of squares by $n-1$ instead of $n$ gives an unbiased estimator of the variance.
Furthermore, $\sum \frac{(Y_i-\bar{Y})^2}{\sigma^2(n-1)}$ has a $\chi^2$ distribution with $n-1$ degrees of freedom. And ratios of independent mean squares will have the F distribution.
Statistical inference offers several criteria for "bestness" in estimators: these include unbiasedness, minimum variance, minimizer of a loss function and (increasingly) predictive accuracy. Being the maximum likelihood estimator is also considered desirable, because the likelihood (supposedly) contains all relevant information about the model (this is debatable and has been debated). The MLE usually manages to be asymptotically unbiased and efficient. What this means for a finite sample depends on the model.
Linear regression with Normal errors works much like the simple normal means model that I gave here: the unbiased estimator for the variance is not the MLE.
The unbiased estimator is preferred because of its nice distributional properties. Geometrically, you are partitioning $R^n$ into two linear subspaces: one to contain the model and one to contain the residuals. The dimension of the residual space is the degrees of freedom.

A: To expand on a very good answer that Placidia gave:

*

*Unbiasedness is not necessarily the best possible property for an estimator. Shrinkage estimators applied in situations of multiple collinearity or with many possible regressors (lasso) are intentionally biased, and this is done to improve their other properties (easier interpretation of the results). Any Bayesian posterior mean or posterior mode estimator with an informative prior is biased; it does not mean that we want to dismiss this whole area of statistics.

*As far as other criteria of performance of a statistical estimator go, the mean squared error (MSE) is a popular criterion: by how far the estimator is off, on average, disregarding whether it is biased or not. The best estimator of the population $\sigma^2$ is then the one that has not $n-1$, not $n$, but $n+1$ in the denominator. So if your inferential target is the population variance, you might want to use the estimator that divides the sum of squared errors by $n+1$.

*The observation that the MLE $S^2$ does not appear to make much sense in regression context has been made earlier, of course, and corrections have been proposed to force it to use the "right" degrees of freedom. This is the idea of restricted maximum likelihood (REML), where the estimators are defined conditioning on the residual subspace that has the "right" dimension.

*Yet another useful property of the ML is transformation invariance. If $S^2$ is the MLE of $\sigma^2$, then automatically $S$ is the MLE of $\sigma$, and $\ln S$ is the estimator of $\ln(\sigma)$. This comes handy in software code: maximizing with respect to $S$ or $S^2$ is being complicated by the quantity being non-negative, while maximizing with respect to $\ln S$ does not involve any constraints. (You'd observe that by Jensen's inequality, unbiasedness of an estimator $$s^2 = \frac1{n-1} \sum (Y_i - \bar Y)^2$$ is easily destroyed by any transformation: $s$ is not an unbiased estimate of $\sigma$. In fact, the unbiased estimator of $\sigma$ is pretty difficult to construct, and I won't be too much ashamed to admit that I don't know one off the top of my head.)


text:
Q: confidence interval on expected number of cases in a set given a model I have a set of units, where unit $i$ has:

*

*a binary outcome $y_i$ ("case" or "non-case")

*a binary vector of treatments $\mathbf{t_i}$, where $t_{i,j}=1$ if unit $i$ received treatment $j$.

*several hundred confounding covariates $\mathbf{x_i}$, some real-valued and some binary.

I expect that most treatments have no association with the outcome.  I am trying to spot the outlier treatments that do have an effect, and estimate how many cases that effect was responsible for. For each treatment, I'd like to say something like:

Supposing there were no association between this treatment and the outcome, here is the number of cases (and a confidence interval) we would have expected to see for this treatment, predicted based on the covariates for the set of units that received that treatment.

Is there a standard way for doing this?
I fit a logistic regression model $m(\mathbf{x})$ that gives $E[Y]$ for a given $\mathbf{x_i}$. That is, it predicts the outcome given the covariates.
Then I can look at:
$$c_j=\text{actual number cases with treatment $j$} = \sum_i{t_{i,j} y_i}$$
 $$h_j=\text{predicted number of cases with treatment $j$} = \sum_i{t_{i,j} m(\mathbf{x_i})}$$
and compare the two.
These quantities are easily calculable, but I'm unsure how to test significance of the difference (call it $q_k$, where $k$ is the number of units with the treatment), since I don't know what distribution $Q_k$ is drawn from under the null hypothesis.
I want $Q_k$ to be the distribution one would get by doing the following: sample $k$ many $(\mathbf{x_i}, y_i)$ pairs according to the process that generated my data (or uniformly from the data itself), and compute the difference between the predicted and actual number of cases. Intuitively, this distribution should get tighter as $k$ increases and also as the model gets more accurate. That is, I don't want to just assume that my model is accurate (and model $Q_k$ as something like a poisson binomial), but rather I want the distribution of $Q$ to take into account how well my model fits the data.
Any pointers or ideas would be very appreciated!
EDIT
Thanks @Bill for the link! My understanding of that standardization approach is that their confidence interval takes into account the variance of the model (i.e. the uncertainty in the logistic regression coefficients), but not the performance of the model. They suggest separately testing the goodness of fit of the model. I am hoping to find something that takes directly into account the performance of the model in the confidence interval. Does that make sense?
EDIT 2
By "performance", I mean how well my model fits the data (perhaps something involving the AUC or the $R^2$).
Here's the sort of thing I'm imagining.
Let $Y=y(x)$ be my outcome and $V=m(x)$ be the logistic regression model's predicted probability for a data point $x$ drawn at random. Suppose I draw $k$ points, so I have $Y_1, ... Y_k$ and $V_1, ... V_k$. Define:
$$ M = \sum_{i=0}^k V_i = \text{sum of model estimates} $$
$$ Z = \sum_{i=0}^k Y_i = \text{sum of actual outcomes} $$
$$ Q = M - Z $$
I want to ideally know the distribution of $Q$, or at least know its first two moments. Trying to work those out:
$$ E[Q] = E[M] - E[Z] $$
$$ E[M] = k E[V] = k\bar{v} $$
$$ E[Z] = k\bar{y} $$
where $\bar{v}$ and $\bar{y}$ come from my data and are the average model prediction and the average outcome, respectively. (I would expect $E[Q]$ to usually be close to $0$.) For the variance:
$$ Var[Q] = E[Q^2] - E[Q]^2 $$
$$ E[Q^2] = E[(M-Z)^2] = E[M^2] - 2E[MZ] - E[Z^2] $$
$$ E[M^2] = E[(V_1 + ... + V_k)^2] = k E[V^2] = k \bar{v^2} $$
$$ E[Z^2] = E[(Y_1 + ... + Y_k)^2] = k E[Y^2] = k E[Y] = k \bar{y} $$
$$ E[MZ] = E[(V_1 + ... V_k)(Y_1 + ... + Y_k)] = k E[VY] = k (\Pr[Y=1] E[VY \vert Y=1] + \Pr[Y=0] E[VY \vert Y=0] = k\Pr[Y=1]E[V \vert Y=1] = k\bar{y} E[V \vert Y=1] = 2k\bar{y}\bar{v}_{Y=1}$$
where in all of these, I've assumed independence between each of my $k$ draws. The $\bar{v}_{Y=1} = E[V \vert Y=1]$ is related to the accuracy of my model, and is the average model prediction across all the positive cases. Putting this together, if the algebra is right:
$$ E[Q] = k\bar{v} - k\bar{y} $$
$$ Var[Q] = k \bar{v^2} - 2k\bar{y}\bar{v}_{Y=1} - k \bar{y} - (k\bar{v} - k\bar{y})^2 $$
I'm interested if this makes sense, and if there's a standard technique that does this (or if perhaps the technique @Bill mentioned is already doing this, but I'm just not understanding).

A: This is similar to a standard problem in epidemiology.  You want to read about direct and indirect standardization and about standardization using logistic regression.  Here is an article to get you started, but the keywords you want to search on are "standardization, indirect, direct, logistic regression."


text:
Q: define an indicator when number of duplicate rows -1 is equal one of the column I have some duplicate rows whose are the same in some columns, I want to define indicator if the number of duplicate rows -1 are equal the number of one of the column .
example
        SAMPN       PERNO       ARR_HR      HHMEM
          1           1           2           1
          1           2           2           1
          2           1           3           2
          2           3           3           2
          3           1           4           2
          3           2           4           2
          3           3           4           2

rows are duplicate if they are the same in first ,second and third columns. I want the indicator to be 1   if number of duplicate rows -1 is equal HHMEM  .
for example 2 first rows are duplicate so 2-1=1=HHMEM so indicator is 1.
out put
       SAMPN       PERNO       ARR_HR      HHMEM        indicator
          1           1           2           1              1
          1           2           2           1              1
          2           1           3           2              0
          2           3           3           2              0
          3           1           4           2              1
          3           2           4           2              1
          3           3           4           2              1

A: After grouping by 'SAMPN' and other grouping variables (from OP's comments) create the 'indicator' by coercing the logical vector ((n()- 1) == HHMEM) into binary with as.integer
library(dplyr)
df1 %>%
      group_by(SAMPN, ARR_HR, HHMEM) %>%
      mutate(indicator = as.integer((n()-1) == HHMEM))
# A tibble: 7 x 5
# Groups:   SAMPN [3]
#  SAMPN PERNO ARR_HR HHMEM indicator
#  <int> <int>  <int> <int>     <int>
#1     1     1      2     1         1
#2     1     2      2     1         1
#3     2     1      3     2         0
#4     2     3      3     2         0
#5     3     1      4     2         1
#6     3     2      4     2         1
#7     3     3      4     2         1

NOTE: We don't need to create any additional column and then remove it later

Or the same logic in base R with ave
df1$indicator <- +(with(df1, HHMEM == ave(HHMEM, HHMEM, SAMPN,
                 ARR_HR, FUN = length)-1))

Or using duplicated with table
i1 <- table(cumsum(!duplicated(df1[c(1, 3, 4)])))
as.integer(rep(i1, i1) - 1 ==  df1$HHMEM)

data
df1 <- structure(list(SAMPN = c(1L, 1L, 2L, 2L, 3L, 3L, 3L), PERNO = c(1L,
2L, 1L, 3L, 1L, 2L, 3L), ARR_HR = c(2L, 2L, 3L, 3L, 4L, 4L, 4L
), HHMEM = c(1L, 1L, 2L, 2L, 2L, 2L, 2L)), class = "data.frame",
row.names = c(NA,
-7L))

A: We can use add_count to get count and compare it with HHMEM.
library(dplyr)

df %>%
 add_count(SAMPN, ARR_HR, HHMEM) %>%
 mutate(indicator = as.integer(n - 1 == HHMEM)) %>%
 select(-n)

#  SAMPN PERNO ARR_HR HHMEM indicator
#  <int> <int>  <int> <int>     <int>
#1     1     1      2     1         1
#2     1     2      2     1         1
#3     2     1      3     2         0
#4     2     3      3     2         0
#5     3     1      4     2         1
#6     3     2      4     2         1
#7     3     3      4     2         1


text:
Q: How to try to convert this API query parameter that maybe contains some strange code? I am working on a WordPress website (but I think that the problem is not strictly related to WordPress but to some string encoding problem).
Basically I have two post in a specific post type named "Notary districts". This post type have a custom field named wpcf-idnotary-district containing a string value representing the ID of an object.
Ok then I have two different POST having different format for the value of this wpcf-idnotary-district field.
I have the following situation:
POST 1: the value of wpcf-idnotary-district field is 123456
POST 2: the value of wpcf-idnotary-district field is CG7drXn9fvA%253D
Then I have an WordPress API retrieving post from this post type by this wpcf-idnotary-district ID value.
Getting the previous POST 1 from my post type using the first value it is not a problem, infact calling my API passing this ID paramether, something like this:
https://www.MYPORTAL.it/wp-json/filter/notary-district?wpcf-idnotary-district=123456

I am obtaining the expected response:
[
    {
        "post_type": "notary-district",
        "ID": 39244,
        "wpcf-idnotary-district": "123456",
        "post_title": "DISTRICT NAME TEST"
    }
]

the problem happen getting the previous POST 2 using this ID, infact calling:
https://www.MYPORTAL.it/wp-json/filter/notary-district?wpcf-idnotary-district=CG7drXn9fvA253D

in this case the JSON response is an empty array:
[]

But, as you can see here it exist a post with this wpcf-idnotary-district field having CG7drXn9fvA%253D as value:

Trying to get this post calling my API give me this issue (an empty list, it doesn't find the post) both calling my API via Postman and by a Java batch application that I am developing.
I suppose that the problem is the % character into the CG7drXn9fvA%253D value, infact if I try to replace this post ID with this CG7drXn9fvA253D value (the previous one without the % character), then trying to search to this new value it works fine. So the problem is this % character.
I suspect that it is converting it in some way. Maybe I can try to pass the converted value as my API parameter but I have no idea about what I can try.
Some idea? How can I try to solve this problem?

A: CG7drXn9fvA%253D is the url encoded form of CG7drXn9fvA%3D,
% = %25
you can decode this in postman itself.

Just copy the text to any part like body , url etc select the text and right click and select decode.


text:
Q: Is it possible to view where you most recently gained reputation? Is there a feature somewhere that allows users to see where they gained their most recent reputation?

A: Click on the envelope next to your name at the top of the page. Once there, you can select different time periods to view.

A: In addition to your recent activity (found by clicking on the envelope icon near your user name at the top of each page) the reputation tab on your user profile will give you what you're looking for.
Yours is here.


text:
Q: How to solve value difference between Formula Bar and Cell Value in Excel Sheet? I'm try to insert excel values into Database table using SSIS package creation
Formula Bar value = 7.96039603960396

Cell Value        = 7.96039604

In my Excel Sheet c10 cell value is 7.96039604.
If i click the A1 cell in formula bar it show me 7.96039603960396.
C1 to C9 values are empty.so I'm using IMEX=1 in Excel Connection string
In c10 cell I'm not using any Format cell its General only.
If i using IMEX=1 in excel connection string in DB Table 7.96039604 is inserted.
but i need to insert 7.96039603960396 in DB Table

A: Format the entire Excel Spreadsheet as text, then convert the text values to decimals of the required precision once the data is in SQL Server.
Excel => Temp Table or inline transformation => Destination Table.


text:
Q: Count the number of substrings between two markers in a list I want to count the number of times the name is mentioned in the following list and put the number and frequency mentioned in a dictionary.
so, for example, this is the dialogue list
dialogue = ["This is great! RT @user14: Can you believe this?",
            "That's right RT @user22: The dodgers are destined to win the west!",
            "This is about things @user14, how could you",
            "RT @user11: The season is looking great!"]

I want my output to be {user14:2, user22:1, user11:1}
I have tried to start writing the following to produce a name list and then count the name list and output to the dictionary. But not sure how to do this
user_name = [x.split('@')[1].split(':')[:-1] for x in tweets]

A: Regex is probably the best approach to account for the unknown characters after the user name:
from collections import defaultdict
import re

result = defaultdict(int)

for item in dialogue:

    user = re.search('(?<=@)[\w\s]+', item).group(0)
    result[user] += 1

print(result)

Gives:
{'user14': 2, 'user22': 1, 'user11': 1}

A: In single pass with collections.Counter object and re.findall function:
from collections import Counter
import re

...
uname_counts = Counter(re.findall(r'@(\w+)', ''.join(dialogue)))
print(dict(uname_counts))   # {'user14': 2, 'user22': 1, 'user11': 1}


text:
Q: Delete session and cookies then create new one - only takes effect at next page load I use Codeigniter (which may be the reason for my issue) and I identify users by a couple of cookies and session variables. When users want to sign up but are detected like already having an account based on their cookie (e.g someone else signed up on their computer), this is what currently happens in the controller after the signup form has been submitted:

*

*if detected user #4 already has an account but still signs up: delete
session and cookies, then create new user-identifying session and
cookie as user #5 and proceed with the DB stuff.

*else proceed with the DB stuff as user #4.

The issue: deleting the session and/or cookie only happens at next page load, which means that I sign user 4 up (overwriting the current user 4) but it becomes user 5 (who has nothing in the DB) as soon as the next page loads. The correct behaviour would be to get the deletion instant, so that when I create the new session + cookie it correctly creates the account for user #5.
How can I delete session variables + cookies instantly, not at next page load?
UPDATE:
After some testing this is what happens: cookies don't get deleted before next page load; session variables get deleted instantly but not set before next page load. So 2 different issues to fix so that they both get instantly deleted and set again.

A: detect user
delete cookies
    optionally you could create new session data right here
redirect to some page of your choosing :)

that way it will pick it up correctly (and create new data)

A: In the end I changed my script to create a new user directly and not rely on cookies or session to identify the user, which means I don't have to worry about when cookies or session variables get deleted.


text:
Q: Use MS SQL Server to convert MGRS to Lat Long Below is the SQL for converting Military Grid Reference System (MGRS) to decimal Latitude and Longitude.  It is very accurate, but not perfect.  If you can make it work 100%, it is yours, but PLEASE share the answer.  We used various spreadsheets from the internet to help us get this far and thought we had it solved.  It works perfectly for many MGRS coordinates, but some not.
The gauntlet is thrown and we have taken it a long way. I hope one of you can see our error and get it working.
Currently, we are using an open source dll for the conversion, but I really want to get it into SQL Server.
ALTER FUNCTION [dbo]. [getMGRSLat]
(
@latzone decimal(25,16),
script Date: 04/30/2012
@longzone decimal(25,16), @northing decimal(25,16), @easting decimal(25,16), @diRight decimal(25,16), @diLeft decimal(25,16)
)
RETURNS decimal (38,16)
AS
BEGIN

declare @c17 decimal(38,16), @c29 decimal(38,16), @c26 decimal (38,16) declare @latzone decimal(25,16), @longzone decimal(25,16), @northing decimal(25,16), @easting decimal(25,16), @diRight decimal(25,16), @diLeft decimal(25,16)

SET @latzone = 24
set @longzone = 42
set @northing = 56275
set @easting = 01445
set @diLeft = 19
set @diRight = 1

set @c29 =
(61+90.0*0.242541767+298.0*0.00542396+45.0*0.242541767*0.242541767-252.0*0.006739497
-3.0*0.00542396*0.00542396)*(power(-0.044123322,6.0)/720.0)
declare @c12 decimal(38,38)
set @c12 =
(l-power((1-0.081819191*0.081819191),(1.0/2.0)))/(1+power((1-0.081819191*0.081819191
), (1.0/2.0)))
declare @cl0 decimal(38,16), @cll decimal(38,16), @c16 decimal(38,16), @c15 decimal(38,38), @c14 decimal(38,16), @c13 decimal(38,16) declare @G20 int, @g25 int SET @G20 = (2000000*cast((@latzone*40000000/360)/2000000 as integer))+((@diRight-((case when 1 + @longzone % 2 = 1 then 6 else 1 end)))*100000) set @g25 CASE WHEN @G20 > 0 then @G20 else 10000000 + @G20 end set @cl0 (@g25+@northing)/0.9996 set @cll =
@c10/(6378137*(1.0-((power(0.081819191,2.0))/4.0)-((3.0*(power(0.081819191,4.0)))/64
.0)-((5.0*(power(0.081819191,6)))/256.0)))
set @c16 =
(1097.0*power(cast((1-power((1-0.081819191*0.081819191),(1.0/2.0)))/(1+power((1-0.08
1819191*0.081819191),(1.0/2.0))) as decimal(38,38)),4.0))/512.0 set @c15 = (151. 0*power(cast((1-power((1-0. 081819191*0. 081819191) , (1.0/2.0)))/(1+power((1-0.081
819191*0.081819191),(1.0/2.0))) as decimal(38,38)),3.0))/96.0 set @c14 = ((21.0*power(@c12,2))/16.0)-((55.0*power(@c12,4.0))/32.0)
set @c13 = 3.0*@c12/2-((27*(power(@c12,3.0)))/32.0)
set @c17 =
@c11+@c13*SIN(2.0*@c11)+@c14*SIN(4.0*@c11)+@c15*SIN(6.0*@c11)+@c16*SIN(8.0*@c11)
set @c26 =
(6378137.0/(power((1-power((0.081819191*SIN(@c17)),2.0)),(1.0/2.0))))*TAN(@c17)/6347
877 . 706
declare @c24 decimal(38,16), @c27 decimal(38,16), @c28 decimal(38,16), @c22
decimal(25,18)
DECLARE @G5 INT
set @c22 =
6378137.0/(power((1-power((0.081819191*SIN(@c17)),2.0)),(1.0/2.0)))
SET @G5 = 1 + @longzone % 3
set @c24 = (500000-(100000.0*(@diLeft-(CASE WHEN @G5 = 1 THEN 16 WHEN @G5
2 THEN 0 ELSE 8 END))+@easting))/(@c22*0.9996) set @c27 = (@c24*@c24/2.0) declare @c20 decimal(38,16), @c21 decimal(38,16) set @c20 = 0.006739497*power(cos(@c17),2.0) SET @c21 = power(TAN(@c17),2.0) set @c28 =
(5+3.0*@c21+10.0*@c20-4.0*@c20*@c20-9.0*0.006739497)*(power(@c24,4.0)/24.0)
select @c29, @c12,@c22
select @G20, @g25
select @c10, @c11 ,@c16 , @c15, @c14, @c13 select @g5, @c24, @c20, @c21 select @c12, @c10, @G20, @g25

return 180*(@c17-@c26*(@c27+@c28+@c29))/PI()

END

ALTER FUNCTION [dbo] . [getMGRSLong]
(
@latzone decimal(25,16),
script Date: 04/30/2012
@longzone decimal(25,16), @northing decimal(25,16), @easting decimal(25,16), @diRight decimal(25,16), @diLeft decimal(25,16)
)
RETURNS decimal(38,16)
AS
BEGIN

declare @c17 decimal(38,16), @c29 decimal(38,16), @c26 decimal (38,16) declare @latzone decimal(25,16), @longzone decimal(25,16), @northing decimal(25,16), @easting decimal(25,16), @diRight decimal(25,16), @diLeft decimal(25,16)

SET @latzone = 32
set @longzone = 42
set @northing = 56275
set @easting = 01445
set @diLeft = 19
set @diRight = 1

declare @c12 decimal(38,38), @c22 decimal(38,16) set @c12 = (1-power((1-0.081819191*0.081819191),(1.0/2.0)))/(1+power((1-0. 081819191*0. 081819191 ), (1.0/2.0)))

declare @g2 decimal(38,16), @h12 decimal(38,16), @k10 decimal(38,38) declare @c10 decimal(38,16), @c11 decimal(38,16), @c16 decimal (38,16), @c15 decimal(38,38), @c14 decimal(38,16), @c13 decimal(38,16) declare @G20 int, @g25 int SET @G20 = (2000000.0*cast((@latzone*40000000.0/360.0)/2000000.0 as integer))+((@diRight-((case when 1 + @longzone % 2 = 1 then 6 else 1 end)))*100000) set @g25 = CASE WHEN @G20 > 0 then @G20 else 10000000 + @G20 end set @c10 = (@g25+@northing)/0.9996 set @c11 =
@c10/(6378137.0*(1-((power(0.081819191,2.0))/4.0)-((3.0*(power(0.081819191,4.0)))/64
.0)-((5.0*(power(0.081819191,6.0)))/256.0)))
set @c16 =
(1097.0*power(cast((1-power((1-0.081819191*0.081819191),(1.0/2.0)))/(1+power((1-0.08
1819191*0.081819191),(1.0/2.0))) as decimal(38,38)),4.0))/512.0 set @c15 =
(151.0*power(cast((1-power((1-0.081819191*0.081819191),(1.0/2.0)))/(1+power((1-0.081
819191*0.081819191),(1.0/2.0))) as decimal(38,38)),3.0))/96.0 set @c14 = ((21.0*power(@c12,2.0))/16.0)-((55.0*power(@c12,4.0))/32.0)
set @c13 3.0*@c12/2.0-((27.0*(power(@c12,3.0)))/32.0)
set @c17
@c11+@c13*SIN(2.0*@c11)+@c14*SIN(4.0*@c11)+@c15*SIN(6.0*@c11)+@c16*SIN(8.0*@c11)

set @c22 = 6378137.0/power((1-power((0.081819191*SIN(@c17)),2.0)),(1.0/2.0))
declare @c20 decimal(38,16), @c21 decimal (38,16) set @c20 = 0.006739497*power(COS(@c17),2.0) SET @c21 = power(TAN(@c17),2.0) declare @g5 int, @c31 decimal(38,16),@c32 decimal(38,16),@c33 decimal(38,38), @c24 decimal (38,16) SET @G5 = 1 + @longzone % 3 set @c24 = (500000-(100000*(@diLeft-(CASE WHEN @G5 = 1 THEN 16 WHEN @G5 2 THEN 0 ELSE 8 END))+@easting))/(@c22*0.9996) set @c31 = @c24 set @c32 = (1+2*@c21+@c20)*power(@c24,3.0)/6.0
set @c33 =
(5.0-2.0*@c20+28*@c21-3.0*power(@c20,2.0)+8.0*0.006739497+24.0*power(@c21,2.0))*powe
r(@c24,5.0)/120.0
set @k10 = (@c31-@c32+@c33)/cos(@c17)
set @g2 = -183+6*@longzone
set @h12 = @k10*180.0/PI()

return @g2 - @h12
END


text:
Q: ERROR ==> EACCES: permission denied, scandir '/home/$User/.ssh' after install lando and star first project I get this error and I cant use sudo !!!
An error occurred while starting up your app!
Here are a few things you can try to get back into a good state:
■ Try running lando rebuild
■ Try restarting in debug mode lando restart -vvv
■ Try checking the logs with lando logs
If those fail then consult the troubleshooting materials:
Or post your issue to Slack or GitHub
ERROR ==> EACCES: permission denied, scandir '/home/baker/.ssh'

     $lando start
     Let's get this party started! Starting app hello-lando...
     ERROR ==\> EACCES: permission denied, scandir '/home/baker/.ssh' message=EACCES: permission denied, scandir '/home/baker/.ssh', stack=Error: EACCES: permission denied, scandir '/home/baker/.ssh'
     at Object.readdirSync (fs.js:1047:3)
     at Object.readdirSync (pkg/prelude/bootstrap.js:1266:35)
     at AsyncEvents.\<anonymous\> (/snapshot/cli/plugins/lando-core/app.js)
     at AsyncEvents.handle (/snapshot/cli/lib/events.js)
     at /snapshot/cli/lib/events.js
     From previous event:
     at AsyncEvents.emit (/snapshot/cli/lib/events.js)
     at /snapshot/cli/lib/app.js
      From previous event:
      at App.init (/snapshot/cli/lib/app.js)
      at initAndReport (/snapshot/cli/lib/app.js)
      at App.start (/snapshot/cli/lib/app.js)
      at Object.run (/snapshot/cli/plugins/lando-core/tasks/start.js)
      From previous event:
      at /snapshot/cli/lib/cli.js
      From previous event:
      at Object.handler (/snapshot/cli/lib/cli.js)
      at Object.runCommand (/snapshot/cli/node_modules/yargs/lib/command.js:238:44)
      at Object.parseArgs \[as \_parseArgs\] (/snapshot/cli/node_modules/yargs/yargs.js:1063:30)
      at Function.get \[as argv\] (/snapshot/cli/node_modules/yargs/yargs.js:1004:21)
      at Cli.init (/snapshot/cli/lib/cli.js)
      at Cli.run (/snapshot/cli/lib/cli.js)
      at Object.\<anonymous\> (/snapshot/cli/bin/lando.js)
      at Module.\_compile (pkg/prelude/bootstrap.js:1887:22)
      at Object.Module.\_extensions..js (internal/modules/cjs/loader.js:1114:10)
      at Module.load (internal/modules/cjs/loader.js:950:32)
      at Function.Module.\_load (internal/modules/cjs/loader.js:790:12)
      at Function.runMain (pkg/prelude/bootstrap.js:1940:12)
      at internal/main/run_main_module.js:17:47, errno=-13, syscall=scandir, code=EACCES,         path=/home/baker/.ssh, __stackCleaned__=true

     ██╗   ██╗██╗  ██╗     ██████╗ ██╗  ██╗██╗
     ██║   ██║██║  ██║    ██╔═══██╗██║  ██║██║
     ██║   ██║███████║    ██║   ██║███████║██║
     ██║   ██║██╔══██║    ██║   ██║██╔══██║╚═╝
     ╚██████╔╝██║  ██║    ╚██████╔╝██║  ██║██╗
      ╚═════╝ ╚═╝  ╚═╝     ╚═════╝ ╚═╝  ╚═╝╚═╝

    An error occurred while starting up your app!
    Here are a few things you can try to get back into a good state:

    ■ Try running lando rebuild
    ■ Try restarting in debug mode lando restart -vvv
    ■ Try checking the logs with lando logs

     If those fail then consult the troubleshooting materials:

     ■ https://docs.lando.dev/help/logs.html
     ■ https://docs.lando.dev/help/updating.html

     Or post your issue to Slack or GitHub

      ■ Slack - https://launchpass.com/devwithlando
      ■ GitHub - https://github.com/lando/lando/issues/new/choose

     ERROR ==\> EACCES: permission denied, scandir '/home/baker/.ssh'

$ lando start
ERROR ==> EACCES: permission denied

lando start = permission denied ,every time.
what is the problem?


text:
Q: how to add "Return Product" after "Product Delivery" functionality in node.js I have build a product delivery application, and un-able to implement "Return Product" after "Product Delivery" using node.js. Can someone please guide.
I set a variable associated to product_id, when it become true then the product delivery is successful and set a countdown of 7 days, within which if a user clicks on "Return Product" then it will become a return will be initiated. But it's not working.


text:
Q: What is the version of C used in gcc What is the version of C used in GCC? C99, C11 or C90? I thought was the GCC use C99 but I was mistaken:
for(int i = 0; i < 100; i++){
  ...
}

error: 'for' loop initial declarations are only allowed in C99 mode.

A: According to 2 Language Standards Supported by GCC:

The default, if no C language dialect options are given, is -std=gnu90; this is intended to change to -std=gnu11 in some future release.

A: I believe the default is -std=gnu90. You could specify -std=c99 in your compiler flag to support this.

A: By default gcc uses C90 with GNU extension, this is all covered in the gcc docs Language Standards Supported by GCC, the flag for this would be -std=gnu90:

The default, if no C language dialect options are given, is -std=gnu90; this is intended to change to -std=gnu11 in some future release.

If you want C99 support than you should use -std=c99, although this does not mean gcc will not use extensions, so if you want to receive a warning when gcc using an extension you need to add -pedantic and -pedantic-errors to turn that into an error:

to obtain all the diagnostics required by the standard, you should also specify -pedantic (or -pedantic-errors if you want them to be errors rather than warnings)

A: Use -std=99
Before C99, you had to define the local variables at the start of a block. C99 imported the C++ feature that you can intermix local variable definitions with the instructions and you can define variables in the for and while control expressions.


text:
Q: barcode on pos tilslip very new to the site
i have delphi pos
and want to add bar code to the tillslip template the bar code need to be at the bottom of the page and it will be the document ID
    the barcode need to be EAN 128

  HEADER]
    SELECT * FROM SALES_TRANSACTION_HEADER
    JOIN STORES ON (ST_ID=TH_STORE_ID)
    LEFT OUTER JOIN USERS ON (US_STORE_ID=TH_STORE_ID AND US_ID=TH_USER_ID)
    WHERE TH_ID=?DOCUMENT_ID AND TH_STORE_ID=?STORE_ID AND TH_TYPE=?DOCUMENT_TYPE

   DETAIL]
    SELECT * FROM SALES_TRANSACTION_DETAIL
    JOIN PRINTER_CATEGORY ON (PRC_STORE_ID=?THIS_STORE_ID AND PRC_WORKSTATION_ID=?THIS_WORKSTATION_ID AND PRC_PRINTER_ID=?THIS_PRINTER_ID AND PRC_CATEGORY_ID=TD_CATEGORY_ID1)
    JOIN STORES ON (ST_ID=TD_STORE_ID)
    LEFT OUTER JOIN SALES_REPS ON (SR_ID=TD_SALESREP_ID AND ((ST_GLOBAL_REPS = 0 AND SR_STORE_ID=TD_STORE_ID) OR (ST_GLOBAL_REPS  0 AND SR_STORE_ID=(SELECT ST_ID FROM STORES WHERE ST_TYPE = 2))))
    WHERE TD_DOCUMENT_ID=?DOCUMENT_ID AND TD_STORE_ID=?STORE_ID AND TD_TYPE=?DOCUMENT_TYPE

    [SQL_PAYMENT]
    SELECT * FROM SALES_TRANSACTION_PAYMENT
    LEFT OUTER JOIN TENDER_TYPES ON (TT_ID=TP_TENDER_ID)
    WHERE TP_DOCUMENT_ID=?DOCUMENT_ID AND TP_STORE_ID=?STORE_ID AND TP_TYPE=?DOCUMENT_TYPE

    [HEADER]

    +
    +[PRINTLOGO]
    +

    +   TAX INVOICE

    +
    +CASH SALE
    +Document ID: ~0ddddddd;
        !TH_ID

    @IF !TH_PRINTED_COUNT THEN
    + COPY ~D
        !TH_PRINTED_COUNT
    @ELSE
    +
    @ENDIF

    +~SSSSSSSSS                      ~SSSSSSS
    !TH_TRANSACTION_DATE,!TH_TRANSACTION_TIME
    +

    +~SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
    !ST_COMPANYNAME

    @IF !ST_PHYSICALADDR1 THEN
    +~SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
      !ST_PHYSICALADDR1
    @ENDIF

    @IF !ST_PHYSICALADDR2 THEN
    +~SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
      !ST_PHYSICALADDR2
    @ENDIF

    @IF !ST_PHYSICALADDR3 THEN
    +~SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
      !ST_PHYSICALADDR3
    @ENDIF

    @IF !ST_PHYSICALADDR4 THEN
    +~SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
      !ST_PHYSICALADDR4
    @ENDIF

    @IF !ST_PHYSICALADDR5 THEN
    +~SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
      !ST_PHYSICALADDR5
    @ENDIF

    @IF !ST_TELEPHONE1 THEN
    +
    +Telephone: ~SSSSSSSSSSSSSSSSSSS
      !ST_TELEPHONE1
    @ENDIF

    @IF !ST_FAX THEN
    +      Fax: ~SSSSSSSSSSSSSSSSSSS
      !ST_FAX
    @ENDIF

    @IF !ST_TAX_NUMBER THEN
    +VAT Reg #: ~SSSSSSSSSSSSSSSSSSSSSSS
    !ST_TAX_NUMBER
    @ENDIF

    @IF !TH_CUSTOMER_NAME THEN
    +
    +To:~SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
    !TH_CUSTOMER_NAME
    @ENDIF

    @IF !TH_ADDRESS_1 THEN
    +   ~SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
    !TH_ADDRESS_1
    @ENDIF

    @IF !TH_ADDRESS_2 THEN
    +   ~SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
    !TH_ADDRESS_2
    @ENDIF

    @IF !TH_ADDRESS_3 THEN
    +   ~SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
    !TH_ADDRESS_3
    @ENDIF

    @IF !TH_ADDRESS_4 THEN
    +   ~SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
    !TH_ADDRESS_4
    @ENDIF

    @IF !TH_ADDRESS_5 THEN
    +   ~SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
    !TH_ADDRESS_5
    @ENDIF
    @IF !TH_TELEPHONE THEN
    +Telephone: ~SSSSSSSSSSSSSSSSSSS
    !TH_TELEPHONE
    @ENDIF

    @IF !TH_ACCOUNTCODE THEN
    +Account No: ~SSSSSSSSSSSSSSSSSSS
    !TH_ACCOUNTCODE
    @ENDIF

    @IF !TH_EXEMPT_TAX_NUMBER THEN
    +Tax Number:~SSSSSSSSSSSSSSSSSSSS
    !TH_EXEMPT_TAX_NUMBER
    @ENDIF

    @IF !TH_ORDER_NUMBER THEN
    +Order Number:~SSSSSSSSSSSSSSSSSSSS
    !TH_ORDER_NUMBER
    @ENDIF

    +

    +Description        Unit
    +Item Code          Price   Qty     Nett
    +---------------------------------------

    [DETAIL]
    @IF (!TD_ITEMTYPE  3) THEN
    +~SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
    !TD_DESCRIPTION
    @ELSE
    +~SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
    !TD_DESCRIPTION
    @ENDIF
    +~SSSSSSSSSSSSSSS ~fff.ff ~ff.q ~ffff.ff;
    !TD_PRODUCTCODE,!TD_RETAIL_PRICE,!TD_QTY,!TD_LINE_VALUE

    @IF !TD_LINE_TAX_ID = 0 THEN
    +*;
    @ELSEIF !TD_LINE_TAX_ID = 2 THEN
    +#;
    @ENDIF
    +

    @IF !TD_DISCOUNT_AMOUNT  0 THEN
    + Discount on above line ~ffff.ff
      !TD_DISCOUNT_AMOUNT
    @ENDIF

    @IF (!TD_ITEMTYPE = 2) AND (!TD_COLOUR_PACK_SERIAL  '') THEN
    +Colour/Size:~SSSSSSSSSSSSSSSSSSSSSSSSS
    !TD_COLOUR_PACK_SERIAL
    @ENDIF

    @IF (!TD_ITEMTYPE = 3) AND (!TD_COLOUR_PACK_SERIAL  '') THEN
    +Serial #:~SSSSSSSSSSSSSSSSSSSSSSSSSSSS
      !TD_COLOUR_PACK_SERIAL
    @ENDIF

    $COUNT=0

    @WHILE $COUNT

    [SUMMARY]
    +---------------------------------------
    @IF !TH_TRANSACTION_TAX_TYPE THEN
    +                SUB-TOTAL: ~ffffffff.ff
    !TH_TRANSACTION_TOTAL - !TH_TRANSACTION_TAX - !TH_ADMIN_FEE + !TH_OVERALL_DISCOUNT + !TH_ROUNDING_LOSS
    @ELSEIF (!TH_ADMIN_FEE  0) OR (!TH_OVERALL_DISCOUNT  0) OR (!TH_ROUNDING_LOSS  0) THEN
    +                SUB-TOTAL: ~ffffffff.ff
    !TH_TRANSACTION_TOTAL - !TH_ADMIN_FEE + !TH_OVERALL_DISCOUNT + !TH_ROUNDING_LOSS
    @ENDIF

    @IF !TH_OVERALL_DISCOUNT THEN
    +     ~sssssssssssssssssss: ~ffffffff.ff
    'DISCOUNT (' + !TH_OVERALL_PERCENT + '%)', -!TH_OVERALL_DISCOUNT
    @ENDIF

    @IF !TH_ADMIN_FEE THEN
    +             ADMIN CHARGE: ~ffffffff.ff
    !TH_ADMIN_FEE
    @ENDIF

    @IF !TH_TRANSACTION_TAX_TYPE THEN
    +                      VAT: ~ffffffff.ff
    !TH_TRANSACTION_TAX

    @ELSE
    +             VAT INCLUDED: ~ffffffff.ff
    !TH_TRANSACTION_TAX
    @ENDIF

    @IF !TH_ROUNDING_LOSS  0 THEN
    +            ROUNDING LOSS: ~ffffffff.ff
    -!TH_ROUNDING_LOSS
    @ENDIF

    @IF (!TH_TRANSACTION_TAX_TYPE > 0) OR (!TH_ADMIN_FEE  0) OR (!TH_OVERALL_DISCOUNT  0) OR (!TH_ROUNDING_LOSS  0) THEN
    +                           ------------
    @ENDIF

    +                    TOTAL: ~ffffffff.ff
    !TH_TRANSACTION_TOTAL

    @IF !TH_DEPOSIT_AMOUNT THEN
    +             LESS DEPOSIT: ~ffffffff.ff
    -!TH_DEPOSIT_AMOUNT
    +      TOTAL AFTER DEPOSIT: ~ffffffff.ff
    !TH_TRANSACTION_TOTAL - !TH_DEPOSIT_AMOUNT
    @ENDIF
    +                           ------------

    @IF $PAYMENTCOUNT > 0 THEN
    $CHANGE = 0
    $COUNTER = 0

    &FIRSTPAYMENT

    @WHILE $COUNTER  0 THEN
    +~ssssssssssssssssssssssss: ~ffffffff.ff
    !TT_NAME + ' CHANGE', -!TP_AMOUNT
    @IF !TP_NUMBER THEN
    +~ssssssssssssssssssssssssssssssssssssss
    !TT_NAME + ' #: ' + !TP_NUMBER
    @ENDIF
    @ENDIF

    $COUNTER = $COUNTER + 1

    &NEXTPAYMENT

    @ENDWHILE

    @ENDIF

    [FOOTER]
    +---------------------------------------
    +User: ~SSSSSSSSSSSSSSSSSSSSSSS Wks: ~DD
    !US_NAME, !TH_WORKSTATION_ID
    + Rep: ~SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
    !DETAIL.SR_NAME

    @IF !TH_OUR_REFERENCE  '' THEN
    + Our Reference: ~SSSSSSSSSSSSSSSSSSSSSS
    !TH_OUR_REFERENCE
    @ENDIF
    @IF !TH_YOUR_REFERENCE  '' THEN
    +Your Reference: ~SSSSSSSSSSSSSSSSSSSSSS
    !TH_YOUR_REFERENCE
    @ENDIF

    @IF $MESSAGE1 THEN
    +~SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
    $MESSAGE1
    @ENDIF
    @IF $MESSAGE2 THEN
    +~SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
    $MESSAGE2
    @ENDIF
    @IF $MESSAGE3 THEN
    +~SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
    $MESSAGE3
    @ENDIF
    @IF $MESSAGE4 THEN
    +~SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
    $MESSAGE4
    @ENDIF
    @IF $MESSAGE5 THEN
    +~SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
    $MESSAGE5
    @ENDIF


text:
Q: Is there a way to detect which MutationObserver a callback was called from? If I have a single callback function and two MutationObservers for two different dom nodes, is there a way to tell which observer triggered the callback when it is called? The work the callback needs to perform is substantially similar, so creating one for each observer seems undesirable.

A: The specific MutationObserver is supplied as the 2nd argument to the callback.  See the MDN documentation.


text:
Q: Docker image for .net 5 Typically I use following images for .net core 3.1 and it works fine.
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build

I have for experimental reason started a new .net 5 project and created dockerfile with following
FROM mcr.microsoft.com/dotnet/core/aspnet:5.0-buster-slim AS base
FROM mcr.microsoft.com/dotnet/core/sdk:5.0-buster AS build

and have following issue:
 => ERROR [internal] load metadata for mcr.microsoft.com/dotnet/core/sdk:5.0-buster                           0.2s
 => ERROR [internal] load metadata for mcr.microsoft.com/dotnet/core/aspnet:5.0-buster-slim                   0.2s
 => CANCELED [build 1/7] FROM mcr.microsoft.com/dotnet/core/sdk:5.0-buster                                    0.0s
 => => resolve mcr.microsoft.com/dotnet/core/sdk:5.0-buster                                                   0.0s
 => [internal] load build context                                                                             0.0s
 => ERROR [base 1/2] FROM mcr.microsoft.com/dotnet/core/aspnet:5.0-buster-slim                                0.0s
 => => resolve mcr.microsoft.com/dotnet/core/aspnet:5.0-buster-slim

A: As I read here, it is changed to:
FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS base
FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build

It is also mentioned on the docker hub with more info:

As part of the .NET 5.0 release, all .NET Docker images (including
.NET Core 2.1 and 3.1) have transitioned to a new set of Docker
repositories described below. Updates will continue to be made to
supported tags in the old repository locations for backwards
compatibility. Please update any repository references to these new
names. For more information see the .NET 5.0 repository rename
announcement.

EDIT:
Image descriptions:

Image
Comments

mcr.microsoft.com/dotnet/runtime:5.0
.NET 5 multi-architecture: Supports Linux and Windows Nano Server depending on the Docker host.

mcr.microsoft.com/dotnet/aspnet:5.0
ASP.NET Core 5.0 multi-architecture: Supports Linux and Windows Nano Server depending on the Docker host. The aspnetcore image has a few optimizations for ASP.NET Core.

mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim
.NET 5 runtime-only on Linux Debian distro

mcr.microsoft.com/dotnet/aspnet:5.0-nanoserver-1809
.NET 5 runtime-only on Windows Nano Server (Windows Server version 1809)

Image description reference.

A: You do not have to write this yourself. A quick way to go about it is to use the dockerfile generator as explained by Julio Casal in this quick tutorial https://www.youtube.com/watch?v=wQSuZFd01tY.
A sample code for MyApp will look like
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

ENV ASPNETCORE_URLS=http://+:80

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["MyApp/MyApp.csproj", "MyApp/"]
RUN dotnet restore "MyApp/MyApp.csproj"
COPY . .
WORKDIR "/src/MyApp"
RUN dotnet build "MyApp.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "MyApp.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyApp.dll"]


text:
Q: Add a root element to a XML I'm quite a noob, since I don't have any previous knowledge of java programming.
Said that, I've managed to arrange some code into a working txt to xml converter.
Please take extreme consideration of the following note:
I have no clue at all about the building of the code, see it as someone who look for each piece from a different page and merge it together with, not a little, but a lot of help. Remind of that prior to report this question. Thanks
Given the following code:
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStreamWriter;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
import com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder;

public class xml{

static class Bean {
    int id;
    String firstname;
    String lastname;
    String mail;

    public Bean(int id, String firstname, String lastname, String mail) {
        super();
        this.id = id;
        this.firstname = firstname;
        this.lastname = lastname;
        this.mail = mail;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getFirstname() {
        return firstname;
    }

    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }

    public String getLastname() {
        return lastname;
    }

    public void setLastname(String lastname) {
        this.lastname = lastname;
    }

    public String getMail() {
        return mail;
    }

    public void setMail(String mail) {
        this.mail = mail;
    }
}

private XStream xstream = new XStream();

public static void main(String[] args) throws IOException {

    new xml().process();
}

private void process() throws FileNotFoundException, IOException {

    xstream.alias("item", Bean.class);
    BufferedReader br = new BufferedReader(new FileReader("\\test.txt"));
    try {
        String line = br.readLine();
        line = br.readLine();
        while (line != null) {
            String[] split = line.split("\t");
            Bean bean = new Bean(new Integer(split[0]), split[1], split[2], split[3]);
            createBeanFile(bean);
            line = br.readLine();
        }
    } finally {
        br.close();
    }

}

private void createBeanFile(Bean bean) throws IOException {

    BufferedWriter bw = new BufferedWriter
            (new OutputStreamWriter(new FileOutputStream("\\test.xml"),"UTF-8"));
    String str = xstream.toXML(bean);
    bw.write(str);
    bw.close();
    }
}

How and where can I add a root element in order to modify my current ouput from this:
<item>
  <id>56885</id>
  <firstname>LYTF</firstname>
  <lastname>LPRT</lastname>
  <mail>LYTF_LPRT@DERP.COM</mail>
</item>

To this:
<root>
    <item>
      <id>56885</id>
      <firstname>LYTF</firstname>
      <lastname>LPRT</lastname>
      <mail>LYTF_LPRT@DERP.COM</mail>
    </item>
</root>

A: I would urge you to study how the XStreams library works instead of copying existing (badly implemented code) and try to modify it to your needs.
What you could do is to add a root class, which holds collection of your items.
static class Root{

    List<Item> item = new ArrayList<Item>();

    public List<Item> getitem() {
        return item;
    }

    public void setBeans(List<Item> item) {
        this.item = item;
    }
}

in your process method, you then set the following properties to xStream.
xstream.alias("root", Root.class);
xstream.alias("item", Item.class); //I renamed the bean class to item here.
xstream.addImplicitCollection(Root.class, "item");

and in your while loop, you would then add the items to the root class and write out the XML after the loop.
while (line != null) {
            String[] split = line.split(",");
            Item item = new Item(new Integer(split[0]),split[1]);
            root.getitem().add(item);
            line = br.readLine();
        }

        createBeanFile(root);

Hopefully this will get your started.


text:
Q: How to change ruler size in vim? So I'm a noob to vim, and this is the default ruler line:
<file-name>                              line_num,col_num        %file

I am using tmux with 8 panes and the ruler doesn't fit on the smaller screens, so I was trying to make my own, like so:
:set rulerformat=%t,%l,%c

and the result is all jammed to the right and looks like
<ons.yml,314,5

How can I make it display the full filename? There's 59 cols available, but it's only using just like 10-15. I did try to RTFM but holy shit it's like they tried to make it as complicated as possible.

A: Wrap the command in
%<num>(

and
%)

such that it goes from
:set rulerformat=%t

to
:set rulerformat=%59(%t%)

replace  with desired width in character widths, in my case it was 59


text:
Q: mod_rewrite with GET requests I have mod_rewrite working on most of my site. Right now I have a search that normally would point to
search.php?keyword=KEYWORD

And I'm trying to rewrite that to
search/?keyword=KEYWORD

Just to make it a little bit cleaner. So here's my mod_rewrite. (There are other rules I'm just posting the one that isn't working.)
RewriteRule ^search/?keyword=([^/\.]+)/?$ search.php?search=$1

When I type a search in the address bar way I want it to be, I get a page telling me its a "broken link" (I'm guessing that that's Chrome's equivalent of a 404 error). So what am I doing wrong? I think that the problem is the '=' or the '?' sign in the rule (the first part) because when I take the ?keyword= part out, it works. Does that make sense?

EDIT: This is my full .htaccess code:
RewriteEngine on
RewriteRule ^$ index.php
RewriteRule ^thoughts$ archives.php
RewriteRule ^thoughts/$ archives.php
RewriteRule ^about$ about.php
RewriteRule ^about/$ about.php
RewriteRule ^search/\?keyword=([^/]+)$ search.php?search=$1
RewriteRule ^tags/([^/]+)$ tags.php?tag=$1
RewriteRule ^thoughts/([^/]+)$ post.php?title=$1 [L]

Still getting an error page...

A: If you just want to transform:
search.php?keyword=KEYWORD

into:
search/?keyword=KEYWORD

all you need to do is:
RewriteRule ^search/$ search.php [QSA]

The QSA flag means "query string append", and passes to search.php whatever you request via GET:
search/?keyword=KEYWORDD
search/?name=value&name2=value2

You may also want to check out Apache MultiViews, which sends every /foo request to any foo.* file it finds in the / directory, although they are considered bad.

A: RewriteRule ^search/\?keyword=([^/.]+)/?$ search.php?search=$1

The question mark character has special meaning in a regex. You need to escape it.
Additionally, the dot has no special meaning when inside a character class; you need not escape it (you're requiring that keyword contain no forward slashes and dots).


text:
Q: How to run test classes one by one inside  tag using maven I have below testng xml but its not working. Every time running by maven it strat execution on three browsers. I want to run all classes one by one.
<?xml version="1.0" encoding="UTF-8"?>

<parameter name="browser" value="${browser}" />
<parameter name="execution" value="${execution}" />

<test name="POC Test" preserve-order="true" thread-count="1" >
    <classes>
        <class name="com.testscript.OurPurposeTest" />
        <class name="com.testscript.ContactUsTest" />
        <!-- <class name="com.testscript.ChevronTest" /> -->
        <class name="com.testscript.SearchTest" />
        <class name="com.testscript.FinancialRegulatoryReportsTest" />
        <class name="com.testscript.CompanyHistoryTest" />
        <class name="com.testscript.HomePageTest" />
    </classes>
</test> <!-- POC Test -->

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.9</version>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>

        </plugin>


text:
Q: C++,оптимизация подобия функции strstr(const char*,const char*) Вот код:
using std::cout;
int CheckArray(const char* str, const char* str1, const size_t size_N) {
    for (int i = 0; i < size_N; i++) {
        if (str[i] == str1[i]) {
        }
        else {
            return -1;
        }
    }
    return 1;
}
int mystrstr(const char* str, const char* str1) {//хотел зделать подобие strstr(const char*,const char*) только чтоб возращало номер с какого места идёт вхождение строки str1 в str
    const size_t str_size = strlen(str);//максимальный допустимый размер проверочной строки(для цикла)
    const size_t str1_size = strlen(str1);//размер строки которая подставляеться на проверку (str) на правильность в temp(тоесть temp == str1)
    char* temp = new char[str1_size];//временный массив для копирования части целевой строки и будущей проверки
    int count_up = 0;//счетчик для вставление в temp с последующим збрасыванием для сравнения новой части строки
    int i = 0;//счетчик для копирования str в temp
    for (int limit = str1_size; limit <= str_size; limit++) {//проверяем до конца строки
    //(потому что count_up будет завершать ниже приведенный цикл и копировать только target_size символов(первую часть) в temp)
        for (;count_up < str1_size; i++, count_up++) {//если count_up достигает target_size или i доходит до  max_size значит копирование части завершено
            temp[count_up] = str[i];//копируем часть строки в временный массив для проверки
        }
        if (CheckArray(temp, str1, str1_size) == 1) { // если проверка удалась
            delete[] temp;//чистим память
            return i - str1_size;//возращаем место вхождения строки str1 в str(если отсчитывать от нуля)
        }
        count_up = 0;//сбрасывание счетчика чтобы не заходить за пределы массива
        i -= str1_size - 1;//для того чтобы проверять часть строки смещяясь не на новую строку,а на один символ(ксатате фактически это сломало мне голову)
    }
    return -1;//сравнивание не удалось
}

Это мое подобие функции strstr() только оно показует место откуда начинаеться входимая строка(если отсчитывать с нуля).
Хочу узнать почему я говнокодер и как мне бы оптимизировать мой код,чтоб он работал быстрее и эфективней.


text:
Q: SharePoint Server 2013 Search Benchmarking What are the possible benchmarks that can give an idea about search performance in SharePoint Server 2013 ?
Thanks.

A: So with Search in my opinion the Crawl Rate and Query Time are most important, as they affect the experience. The Test for 2010 can give you indication what to expect. https://technet.microsoft.com/en-us/library/ff599526(v=office.14).aspx . The scaling article will give you guidance which resources are most important. https://technet.microsoft.com/en-us/library/dn727118.aspx. Search is IOPS hungry and the faster disk you can give it the better. I have some fantastic experience with ExtremeIO (SSD storage). The values for crawl rate and queries you can find in the search report in search service administration.

A: You should download and test the SharePoint SRx Search Health Reports. These reports provide tons of deep metrics on the search service application. Pay attention to Crawler Health and Index Reports with:
$xSSA | Get-SRxIndexReports -DiskReport
Announcing the Search Health Reports SRx for SharePoint Search Diagnostics and Create a Search Service Status Dashboard


text:
Q: How to add a forced line break inside a table cell I have some text in a table and I want to add a forced line break. I want to insert a forced line break without having to specify the column width, i.e. something like the following:
\begin{tabular}{|c|c|c|}
\hline
Foo bar & Foo <forced line break here> bar & Foo bar \\
\hline
\end{tabular}

I know that \\ inserts a line break in most cases, but here it starts a new table row instead.

A similar question was asked before: How to break a line in a table

A: Here's a very simple way to do it, using Plain TeX commands within
the tabular environment:
\begin{tabular}{|c|c|c|}
\hline
here&\vtop{\hbox{\strut top line}\hbox{\strut botline}}&more\\
\hline
x&y&z\\
\hline
\end{tabular}

By using hboxes within the vtop we've stayed in vertical mode
and therefore the width of the text in the hboxes determines
the width of the vtop. This way we don't need to know the
width of the text in advance. \strut will maintain the right
space above and below the text in the hbox.

A: I don't have direct help on how to add a linebreak, but using the multirow package may provide different route to same desired end.  You can read a tutorial here:
http://andrewjpage.com/index.php?/archives/43-Multirow-and-multicolumn-spanning-with-latex-tables.html
But I have a feeling the \parbox answer in the similar question you linked is what you're looking for.  I think using a box in the cell is going to be simplest and best way, was there something about that that wasn't working for you?
If you want to use parbox without having to hardcode in a width, here's one way that works for me.  Not perfect, since it requires you to know beforehand the text of the longest line in the multi-line column, but it does work:
% define new length and set to length of longest line
\newlength{\longline}
\settowidth{\longline}{longest line in table}\\

\begin{tabular}{lll}

one line & \parbox[t]{\longline}{longest line in table \\ and another line} & more text \\
second line here& and what & more text
\end{tabular}

A: It seems there is a rather simple solution. Just wrap the text into currly braces and use \raggedright like this:
{\raggedright \bfseries WS 2016 \\(average)}

Here is a simple example:
\begin{tabularx}{\textwidth}[ht]{|X|p{1.8cm}|}
  \hline
  Some Longer Column &
  {\raggedright \bfseries Line \\Break} \\\hline
  This is a wide line with some text & Small \\\hline
\end{tabularx}

This gives:

A: It's easy peasy to write multiline cells without fixing the column width with tblr environment of the new LaTeX3 package tabularray: just enclose the cell text with braces and use \\ to break lines:
\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{tblr}{|l|c|r|}
\hline
 Left & {Center \\ Cent \\ C} & {Right \\ R} \\
\hline
 {L \\ Left} & {C \\ Cent \\ Center} & R \\
\hline
\end{tblr}
\end{document}

A: Strangely, no answer (unless I've misread them) mentions a package that is dedicated to this precise question: makecell, which allows for common formatting of certain cells, thanks to its \thead and \makecell commands, and for line breaks inside these cells. The horizontal and vertical alignments can chosen independently from those of the table they're included in. The default is cc, but you can change it globally in the preamble with
\renewcommand{\cellalign}{vh}
\renewcommand{\theadalign}{vh}

where v is one  of t, c, or b and h one of l, c, or r. Alternatively, for a single cell, you can use the \makecell or \thead commands with the optional argument [vh].
So here is a demo:
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{fourier}
\usepackage{array}
\usepackage{makecell}

\renewcommand\theadalign{bc}
\renewcommand\theadfont{\bfseries}
\renewcommand\theadgape{\Gape[4pt]}
\renewcommand\cellgape{\Gape[4pt]}

\begin{document}

  \begin{center}
    \begin{tabular}{ | c | c | c |}
      \hline
      \thead{A Head} & \thead{A Second \\ Head} & \thead{A Third \\ Head} \\
      \hline
      Some text &  \makecell{Some really \\ longer text}  & Text text text  \\
      \hline
    \end{tabular}
  \end{center}

\end{document}

A: \begin{tabular}{lll}
a&\vbox{\hbox{\strut ASDF}\hbox{\strut ASDF}\hbox{\strut This is my
really long line}}&c
\end{tabular}

The \strut is essential for spacing.

A: It's a quite old question, but I'll add my answer anyway, as the method I suggest didn't appear in the others
\begin{tabular}{|c|c|c|}
\hline
Foo bar & \begin{tabular}[x]{@{}c@{}}Foo\\bar\end{tabular} & Foo bar \\
\hline
\end{tabular}

where x is either t, c, or b to force the desired vertical alignment.
In case this is needed in more than a couple of places, it's better to define a command
\newcommand{\specialcell}[2][c]{%
  \begin{tabular}[#1]{@{}c@{}}#2\end{tabular}}

so the table line before can be one of
Foo bar & \specialcell{Foo\\bar} & Foo bar \\    % vertically centered
Foo bar & \specialcell[t]{Foo\\bar} & Foo bar \\ % aligned with top rule
Foo bar & \specialcell[b]{Foo\\bar} & Foo bar \\ % aligned with bottom rule

More variations are possible, for instance specifying also the horizontal alignment in the special cell.
Notice the @{} to suppress added space before and after the cell text.

A: You can also just fake it:
\begin{tabular}{|c|c|c|}
\hline
Foo bar & Foo & Foo bar \\
~       & bar &  ~      \\
\hline
\end{tabular}

A: You can use the minipage environment:
\begin{minipage}[t]{0.2\columnwidth}%
This is the first line
\newline
second line
\newline
...
\end{minipage}

A: When I was younger I was typesetting a tabular environment inside a tabular environment. Since we have TikZ I use the tikzpicture environment inside tabulars, or even a tikzpicture inside a tikzpicture. I prefer putting simple TikZ nodes next and below each other, but it depends on actual task. I enclose an MWE with fast text height correction.
\documentclass{article}
\usepackage{tikz}\pagestyle{empty}
\begin{document}
\tikzset{inner sep=0pt}
\begin{tabular}{|l|l|} \hline
 \begin{tikzpicture}
  \node[align=left, text height=4.5ex]{This is the\\[3pt]first cell};
\end{tikzpicture}
    & second \\ \hline
    3rd & and the last cell \\ \hline
\end{tabular}
\end{document}

![MWE][1]
[1]: http://i.stack.imgur.com/64Gjo.png

A: This approach isn't so different from some of the others already given, except that it "externalises" all of the design decisions from the table definition itself (that is, leaving it cleaner to write and read each table should you want to include multiple tables like this throughout your doc or docs).
Preliminaries (presumably in your preamble):
\usepackage{array} % needed if you're going to use \\ together with centering,
                   % raggedright, raggedleft in your column specifier (see
                   % manuals on \arraybackslash)
\newlength{\mywidestcolwidth}
\newcommand*\mycellformat{\protect\footnotesize}
\newcommand*\mytableparskip{\setlength\parskip{4pt}}
\newcommand*\setmywidestcolwidth[1]{
  \settowidth{\mywidestcolwidth}{\mycellformat #1}
}

Usage:
\setmywidestcolwidth{foo baz bar}
\begin{tabular}{|>{\mycellformat}c
                |>{\mytableparskip\mycellformat\centering\arraybackslash}p{\mywidestcolwidth}
                |>{\mycellformat}c|}
\hline
foo bar baz&
foo

foo baz bar

baz&
foo

foo baz bar

baz\\ \hline
\end{tabular}

Skip the \mycellformat and \parskip if you have no need for them (although not necessary in your case, I included \parskip since it's useful to visually distinguish paragraphs from one another since paragraph  indentation is automatically switched off in tables, and added \mycellformat to allow for uniform document-wide table design settings).

A: Personally, I prefer to use \usepackage{multirow} \multirow{"number of rows"}{"width"}{"contents"} for everything else except the information that should be on different rows.
For example:
 \begin{tabular}{p{2.5cm}@{\hskip 0mm}  p{5cm}@{\hskip 4mm} p{5cm} }
     Parameter & Description & Used by\\
     \hline
     \\[-0.1cm]
     \multirow{2}{*}{Accuracy}&1. The error rate or frequency of correctness of sensor readings.  & \\[0.3cm]
     & 2. The degree of correspondence of measured values to actual values.& \\[0.3cm]
      \hline
      \\[-0.1cm]
    \end{tabular}

A: You can use adjustbox:
\documentclass{article}

\usepackage{adjustbox}

\begin{document}

\begin{tabular}{|c|c|c|}
\hline
Foo bar & \adjustbox{stack=ll}{Foo\\bar} & Foo bar \\
\hline
\end{tabular}

\end{document}

See also this question.

A: Here I use stacks to accomplish it.  Several things are noteworthy:

*

*I demonstrate \Longstack , \Longunderstack and \Centerstack, which give three different alignments.

*In order not to squeeze against the vertical margins, a \strutlongstacks{T} declaration was issued.  Alternately, one might wrap a stack inside an \addstackgap[<gap>]{content} to add a vertical buffer above/below the stack.

*Not shown is the ability to set the horizontal alignment of the stacked content with an optional argument, or to change the EOL character (from \\ to another user-specified token)
Here is the MWE.
\documentclass{article}
\usepackage[usestackEOL]{stackengine}
\begin{document}
\strutlongstacks{T}
\begin{tabular}{|c|c|c|}
\hline
Foo bar & \Longstack{ Foo \\ bar \\ baz} & Foo bar \\
\hline
Foo bar & \Longunderstack{ Foo \\ bar \\ baz} & Foo bar \\
\hline
Foo bar & \Centerstack{ Foo \\ bar} & Foo bar \\
\hline
\end{tabular}
\end{document}

A: You can switch your cell layout to paragraph to use the \newline command.
\begin{tabular}{|p{2cm}|p{2cm}|}
\hline
Test & foo \newline bar \\
...

Edit:
Use the following commands instead of p if you want to specify the alignment as well:
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

A: You can use this:
\usepackage{pbox}

\begin{tabular}{|l|l|} \hline
    \pbox{20cm}{This is the first \\ cell} & second \\ \hline
    3rd & and the last cell \\ \hline
\end{tabular}

which looks like:

Note that the width supplied to \pbox is a maximum width. If the content is shorter the length of the longest line is taken.

A: This is a really old question, but since this was linked from a recent question on separating content and presentation, I'll add a ConTeXt answer for comparision.
In ConTeXt, \crlf adds a forced line-break, so achieving a forced line-break in a table is as simple as just adding \crlf in the appropriate place. Here is the complete example:
% Setup for rules at the top and bottom
\startsetups table:rules
  \setupTABLE[frame=off]
  \setupTABLE[row][first][topframe=on]
  \setupTABLE[row][last][bottomframe=on]
\stopsetups

% Setups for middle alignment
\startsetups table:middle
  \setupTABLE[align=middle]
\stopsetups

\starttext

\startTABLE[setups={table:rules, table:middle}]
  \NC Foo bar \NC Foo \crlf Bar \NC Foo bar \NC \NR
  \NC Foo bar \NC Foo \crlf Bar \NC Foo bar \NC \NR
\stopTABLE

\stoptext

which gives:

A: Use the tabularx environment instead of tabular, and then use \newline where you want line breaks within a cell.
\usepackage{tabularx}
\begin{tabularx}{\textwidth}{lX}
    Section:   &  This is my     \newline
                  long paragraph \\
\end{tabularx}

The tabularx environment has a special column type, X, in addition to the usual ones, and its first argument is the desired width of the table. The X column will have the necessary width in order to make the whole table the desired width.
Note: \newline will not take effect in columns of standard type.
Details on tabularx can be found here.

A: How about using \parbox in a custom command:
\documentclass{article}
\newsavebox\mybox
\newlength\mylength
\newcommand\boxup[2]{%
  \savebox\mybox{#1}%
  \setlength\mylength{\wd\mybox}%
  \parbox{\mylength}{#1 \\ #2}%
}
\begin{document}
\begin{tabular}{|c|c|c|}
Foo bar & \boxup{Foo}{bar} & Foo bar \\
\end{tabular}
\end{document}

This takes two arguments with the assumption that the first line is longer than the second. It would be possible to refine the code to work through an arbitrary number of lines and find the longest. If that's of interest I'll write something, probably using expl3 for the looping.

A: I believe I have the simplest answer here:
If you are using a paragraph column in a table, you can put text in an alignment environment and the table does not pick up the \\ as a new table row, so you can use it normally. For example:
\begin{tabular}{p{2in}p{2in}}
    \begin{flushleft}
        Some text over here \\
        newline! \\
        \bigskip all the way down
    \end{flushleft}
    &
    \begin{flushleft}
        Lorem ipsum dolor sit amet, consectetur
        adipisicing elit, sed do eiusmod
        tempor incididunt ut labore et dolore
        magna aliqua. Ut enim ad minim veniam,
        quis nostrud exercitation ullamco laboris
        nisi ut aliquip ex ea commodo\\ \bigskip
        consequat. Duis aute irure dolor in
        reprehenderit in voluptate velit esse
        cillum dolore eu fugiat nulla pariatur.
        Excepteur sint occaecat cupidatat non
        proident, sunt in culpa qui officia
        deserunt mollit anim id est laborum.\\
        \bigskip \bigskip lorem ipsum\\
    \end{flushleft}\\
\end{tabular}\

Will give you a table with line breaks using the \\ command.

A: I think multirow is a simple elegant solution, at least for simple tables.
For example, I tried a few of the suggestions above but I found this worked the best:
\usepackage{multirow}
\begin{table}[ht]
    \caption{RESTful Resources}
    \centering
    \begin{tabular}{l l l}
        \hline
        Resource & Methods & Description \\
        \hline
        \multirow{2}{*}{Resource1} & \multirow{2}{*}{POST, PUT}
            & This resource contains ...\\
          & & \emph{Media types: text/plain, application/json}\\
        \multirow{2}{*}{Resource2} & \multirow{2}{*}{POST, PUT}
            & This resource contains ...\\
          & & \emph{Media types: text/plain, application/json} \\
        \hline
    \end{tabular}
    \label{table:resources}
\end{table}

A: It's been a long time, but now you can just use Optex without any packages:
\thistable{\tabskipl=0pt plus1fil \tabskipr=\tabskipl} % center the able
\table{p{5cm\fC}c}{%\fC centers cell
\crll
Here\break we have a broken line & As we want\crll
}

\bye


text:
Q: Wordpress inner-section full width I want to have a header that will have two inner sections in it both occupying full width of the viewport. I tried many things ( adding custom css to installing many sticky-header plugins ) but nothing's helping.
What I am getting:

What I want to have:

Essentially I want my header to be sticky ( by adding all header stuffs in single section and setting the property to be sticky on top). It would be a great help if anybody can find me a way to do this. Maybe not in this procedure but any other.

A: Go to Section Settings and set Columns Gap -> No Gap

or set padding 0 from Advanced option


text:
Q: php marking grid intersections x/y coords I am trying to take an array of data containing x/y coords and directional info (across or down) and linking shared cells with a incrementing number. This is for a crossword puzzle. Here is the original array:
Array
(
[0] => Array
    (
        [id] => 1
        [puzzle_id] => 1
        [word] => hello
        [hint] =>
        [direction] => across
        [grid_x] => 3
        [grid_y] => 1
    )

[1] => Array
    (
        [id] => 2
        [puzzle_id] => 1
        [word] => loot
        [hint] =>
        [direction] => down
        [grid_x] => 5
        [grid_y] => 1
    )

[2] => Array
    (
        [id] => 3
        [puzzle_id] => 1
        [word] => hellotest
        [hint] =>
        [direction] => down
        [grid_x] => 3
        [grid_y] => 1
    )

[3] => Array
    (
        [id] => 4
        [puzzle_id] => 1
        [word] => looking
        [hint] =>
        [direction] => across
        [grid_x] => 3
        [grid_y] => 3
    )

)
I want to add a new key to each entry called "num" that will start at 1 and increment by 1 but the tricky part is I need across AND down to share the same number if they share a starting cell (share a grid_x and grid_y). This is the code I have now but it doesn't produce the correct numbers I am looking for.
$puzzle_data2 = $puzzle_data;

$across_counter = 1;
foreach($puzzle_data as $rkey=>$row)
{
    if($row['direction'] == 'across')
    {
        $puzzle_data[$rkey]['num'] = $across_counter++;

        foreach($puzzle_data2 as $rkey2=>$row2)
        {
            if($row['direction'] == 'down')
            {
                if($row['grid_x'] == $row2['grid_x'] && $row['grid_y'] == $row2['grid_y'])
                {
                    $puzzle_data[$rkey2]['num'] = $across_counter;
                    break;
                }
            }
        }
    }
}
foreach($puzzle_data as $rkey=>$row)
{
    if(!isset($row['num']))
    {
        $puzzle_data[$rkey]['num'] = $across_counter++;
    }
}

I end up getting this result:
Array
(
[0] => Array
    (
        [id] => 1
        [puzzle_id] => 1
        [word] => hello
        [hint] =>
        [direction] => across
        [grid_x] => 3
        [grid_y] => 1
        [num] => 1
    )

[1] => Array
    (
        [id] => 2
        [puzzle_id] => 1
        [word] => loot
        [hint] =>
        [direction] => down
        [grid_x] => 5
        [grid_y] => 1
        [num] => 3
    )

[2] => Array
    (
        [id] => 3
        [puzzle_id] => 1
        [word] => hellotest
        [hint] =>
        [direction] => down
        [grid_x] => 3
        [grid_y] => 1
        [num] => 4
    )

[3] => Array
    (
        [id] => 4
        [puzzle_id] => 1
        [word] => looking
        [hint] =>
        [direction] => across
        [grid_x] => 3
        [grid_y] => 3
        [num] => 2
    )

)

I am looking for ID 1 and 3 to both be "1". If you think of a crossword puzzle where a down and across share the same starting cell its labeled with the same number in the across and down key, that is what I am trying to accomplish with my data set.
Thanks for your time.

A: You should sort the data first, so that entries on the top left are first, going across the line, before moving down to the next line. IE the way we read.
We can take grid_x and grid_y and calculate which is first.
Then we can use these to sort the data.
function cmp($a, $b)
{
    $a_index=($a['grid_y']*100)+$a['grid_x'];
    $b_index=($b['grid_y']*100)+$b['grid_x'];
    if ($a_index == $b_index)
    {
        return 0;
    }
    return ($a_index < $b_index) ? -1 : 1;
}
usort($puzzle_data, "cmp");

I've used 100 here to make things easier, but you should use the width of the grid for more accuracy.
x1,y1   would give 101
x3,y1   would give 103
x1,y3   would give 301
y3,y3   would give 303
so  the order would be 101, 103, 301, 303
Then apply the numbers to the data using grid_x and grid_y to test if already done.
$number=1;
$grid_numbers=array();
foreach($puzzle_data as $rkey=>$row)
{
    if(isset($grid_numbers[$row['grid_x']][$row['grid_y']]))
    {
        $puzzle_data[$rkey]['num'] = $grid_numbers[$row['grid_x']][$row['grid_y']];
    }
    else
    {
        $grid_numbers[$row['grid_x']][$row['grid_y']]=$number;
        $puzzle_data[$rkey]['num']=$number;
        $number++;
    }
}

That should be everything


text:
Q: How can I timestamp IIS Web deployment packages made with Visual Studio 2013? Right now I can deploy  a package to a directory but we may want to have a weekly deployment package so is there some easy way to append the filename of the deployment zip file with a timestamp ?

A: You can make MSBUILD script which makes such deployment package for you:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build" ToolsVersion="4.0">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
    <BasePackageName>TestPackage</BasePackageName>
    <BuildTime>$([System.DateTime]::Now.ToString("yyyy-MM-dd-HH-mm-ss"))</BuildTime>
    <DeployDir Condition=" '$(DeployDir)' == '' ">$(MSBuildProjectDirectory)\Output</DeployDir>
    <PackageFileName Condition=" '$(PackageFileName)' == '' ">$([System.String]::Format("{0}\{1}_{2}.zip", $(DeployDir), $(BuildTime), $(BasePackageName)))</PackageFileName>
  </PropertyGroup>

  <Target Name="CheckProperties">
    <Error Condition=" '$(ProjectFile)' == '' " Text="ProjectFile is required." />
  </Target>

  <Target Name="Build" DependsOnTargets="CheckProperties">
    <!-- Deploy using windows authentication -->

    <Message Text="Creating $(PackageFileName)" />
    <MSBuild Projects="$(ProjectFile)"
        Targets="WebPublish"
        Properties="Configuration=$(Configuration); WebPublishMethod=Package; DeployOnBuild=true; PackageFileName=$(PackageFileName);"
    />
    <Message Text="$(PackageFileName) successfully created!" />
  </Target>
</Project>

It will create in deploy dir (DeployDir script parameter, with $(MSBuildProjectDirectory)\Output as default value) files:

*

*2014-06-23-17-04-21_TestPackage.zip

*2014-06-23-17-04-21_TestPackage.deploy.cmd

*2014-06-23-17-04-21_TestPackage.deploy-readme.txt

*2014-06-23-17-04-21_TestPackage.SetParameters.xml

*2014-06-23-17-04-21_TestPackage.SourceManifest.xml

This script requires ProjectFile parameter to be set.
To run this MSBUILD script you can use the following bat file (let's save MSBUILD script in the same directory with name deploy.xml) or use autobuild server.
set WORK_DIR=%~dp0
pushd %WORK_DIR%
set VSTOOLS="%VS120COMNTOOLS%"
if %VSTOOLS%=="" goto vsnotfounderror
call "%VSTOOLS:~1,-1%vsvars32.bat"
if errorlevel 1 goto end

msbuild.exe deploy.xml "/p:ProjectFile=%1"
if errorlevel 1 goto end

:vsnotfounderror
echo "Can't find Visual Studio 2013"

:end
popd
exit /b %ERRORLEVEL%

Now run this script:
deploy.bat TestSolution\TestWebApplication.csproj


text:
Q: How can I change color / backgroundColor of list item in nativescript-vue? I want to update selected item style when user taps on items. nextIndex/event.index is updated but style doesn't apply. Thanks for your help.
https://play.nativescript.org/?template=play-vue&id=ihH3iO

export default {
  name: "CustomListView",
  props: ["page", "title", "items", "selectedIndex"],
  data() {
    return {
      nextIndex: this.selectedIndex ? this.selectedIndex : undefined
    };
  },
  methods: {
    onItemTap(event) {
      this.nextIndex = event.index;
    }
  }
};
.selected {
  color: white;
  background-color: black;
}
<ListView for="(item, index) in items" @itemTap="onItemTap">
    <v-template>
    <Label :class="['list-item-label', { selected: index == nextIndex }]" :text="item" />
    </v-template>
</ListView>

A: More info about this issue.

This is expected behavior because the ListView's item template is rendered and updated by the list view when scrolling (view recycling) if you need to make sure the list view is updated when you change your property, call refresh on it.

So the solution is

<template>
    <Page class="page">
        <ActionBar title="Home" class="action-bar" />
        <ListView v-for="(item, index) in items" @itemTap="onItemTap" ref="listView">
            <v-template>
                <Label :class="[{selected: index === nextIndex}, 'list-item-label']"
                    :text="item" />
            </v-template>
        </ListView>
    </Page>
</template>

<script>
    export default {
        name: "CustomListView",
        data() {
            let selectedIndex = 2;
            return {
                items: ["Bulbasaur", "Parasect", "Venonat", "Venomoth"],
                nextIndex: selectedIndex
            };
        },
        methods: {
            onItemTap(event) {
                this.nextIndex = event.index;
                this.$refs.listView.nativeView.refresh();
            }
        }
    };
</script>

You need refresh your listView the code for that is this.$refs.listView.nativeView.refresh();
Don't forget to add the ref on the <ListView>


text:
Q: Sqoop the data from oracle using HDP 2.4 on windows environment Sqoop the data from oracle using HDP 2.4 on windows environment
Error message:

The system can not find the file specified.

sqoop import --connect jdbc:oracle:thin:hud_reader/hud_reader_n1le@huiprd_nile:1527 --username hud_reader --password hud_reader_n1le --table <DATAAGGRUN> --target-dir C:\hadoop\hdp\temp  --m 1
Help appreciated. Thank you.