Erro "No match for operator <<" em C++

Question: Eu fiz esse codigo porém não faço a minima ideia porque esta dando esse erro : "No match for 'operator <<' Na parte em que exibo a resposta do usuário... (Lembrando que NomePessoa é uma classe e a Data tambem...)
class Filme
   {
   private:
    string titulo;
    NomePessoa Diretor;
    NomePessoa Personagem;
    Data Lancamento;

   public:

     void getInfo(string t, string d, string p, int dia, int m, int a)
        {
            titulo = t;
            Diretor.Grava(d);
            Personagem.Grava(p);
            Lancamento.getData(dia,m,a);
        };

    void imprime()
        {
            cout << "Titulo: " << titulo << endl ;
            cout << "Nome do Diretor: " << Diretor.Imprime() << endl;
            cout << "Nome do Personagem Principal: " << Personagem.Imprime() << endl;
            cout << "Data do Lançamento: " << Lancamento.sendData() << endl;
        };

Comment: Você provavelmente precisa implementar o operador `<<` nas classes `NomePessoa` e `Data`, porque elas não devem saber o que fazer quando o operador `<<` é usado, veja aqui: https://stackoverflow.com/a/22588202/8133067
Answer: Esse erro significa que o compilador não sabe como escrever o objeto File na stream indicada. Isso acontece porque algures tem no seu código tem algo como:
Filme f;
cout << f;

Como não implementou o operador << para Filme o compilador não consegue resolver essa instrução, pois não sabe como escrever um Filme no cout.
No entanto você já tem o código que mostra um Filme no método imprime e por isso basta implementar o operador << utilizando essa lógica já feita:
class Filme
{
   private:
    //...

   public:

     void getInfo(string t, string d, string p, int dia, int m, int a)
     {
         titulo = t;
         Diretor.Grava(d);
         Personagem.Grava(p);
         Lancamento.getData(dia,m,a);
     };

     //aqui implementação do operador <<
     friend ostream& operator << (ostream& os, const Filme& f)
     {
         //O acesso ao Filme é feito pelo segundo parametro que chamei de f
         os << "Titulo: " << f.titulo << endl ;
         os << "Nome do Diretor: " << f.Diretor.Imprime() << endl;
         os << "Nome do Personagem Principal: " << f.Personagem.Imprime() << endl;
         os << "Data do Lançamento: " << f.Lancamento.sendData() << endl;
         return os ;
     }

Erro "No match for operator <<" em C++


How to interpret direction of relationship between continuous predictor and outcome variable in linear mixed model?

Question: Sorry if this is a very simple question. I have run the following mixed model, which tests for the effect of two fixed effects (group and IQ) and participant as an random effect on an outcome (s). Here is the model specification:
m1 <- lmer(s ~ group + IQ + (1|ID), data=data)

Group is a categorical variable, IQ is continuous. Here is the output:

Linear mixed model fit by REML. t-tests use Satterthwaite's method ['lmerModLmerTest']
Formula: s ~ group + IQ + (1 | ID)
   Data: mat

REML criterion at convergence: 229.4

Scaled residuals:
    Min      1Q  Median      3Q     Max
-2.6797 -0.5677 -0.1657  0.5448  3.0798

Random effects:
 Groups   Name        Variance Std.Dev.
 ID       (Intercept) 0.05597  0.2366
 Residual             0.06271  0.2504
Number of obs: 499, groups:  ID, 108

Fixed effects:
              Estimate Std. Error         df t value Pr(>|t|)
(Intercept)   0.794787   0.227007 103.852255   3.501 0.000684 ***
group2       -0.056301   0.062010 103.876806  -0.908 0.366017
group3       -0.023709   0.062622 104.590355  -0.379 0.705750
IQ           -0.004828   0.002463 103.531586  -1.960 0.052664 .
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Correlation of Fixed Effects:
            (Intr) gCP/LC gCP/HC
group2      -0.225
group3      -0.322  0.424
IQ          -0.985  0.117  0.216

And here is the output of an Anova:
Analysis of Deviance Table (Type II Wald chisquare tests)

Response: s
       Chisq Df Pr(>Chisq)
group 0.8244  2    0.66220
IQ    3.8422  1    0.04998 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

My question is how I can interpret/write up the relationship between IQ and s?
I plotted the relationship, which indicates that as IQ goes up, s goes down. But I'm not sure how I would write this up in a report.
effects_IQ <- effects::effect(term= "IQ", mod= m1)
summary(effects_IQ) #output of what the values are
x_IQ <- as.data.frame(effects_IQ)

IQ_plot <- ggplot() +
  #2
geom_point(data=subset(mat), aes(IQ, s)) +
  #3
  geom_point(data=x_WASI, aes(x=IQ, y=fit), color="blue") +
  #4
  geom_line(data=x_WASI, aes(x=IQ*, y=fit), color="blue") +
  #5
  geom_ribbon(data= x_WASI, aes(x=IQ, ymin=lower, ymax=upper), alpha= 0.3, fill="blue") +
  #6
  labs(x="IQ(centered & scaled)", y="S")

IQ_plot

Here is the plot:
https://i.stack.imgur.com/zsGOi.png
I'd really welcome any advice anyone has, and will happily provide any more information if this is not clear. Thank you!
Answer: Your IQ parameter estimate is $-0.004828$, which means that for every unit increase in IQ, the dependent variable $s$ goes down by $0.004828$. (Incidentally, your plot appears to show the standard scaling of IQ to a mean of 100 and a standard deviation of 15, so I would not call it "centered and scaled", which usually refers to a linear transformation to a mean of 0 and a standard deviation of 1.)
Similarly, membership in group 2 is associated with an $s$ that is $0.056301$ smaller, and in group 3 with an $s$ that is $0.023709$ smaller than for membership in group 1 (the baseline).
Comment: Thank you very much for such a clear explanation - and for picking up my error on the graph labelling. Your help is much appreciated!


How should I use the fact that F(x) can be bounded on part b) of this question?

Question:
I understood part A) and about defining ø(0) and ø(1) so that the function to integrate is uniformly continuous on [0,1], but I cannot comprehend how to compute $\lim_{x->0^+} F(x)$ for part B). A hint my professor gave is to bound F(x), but how does that help when I don't even understand how that will allow me to compute the exact value?
Answer: For $x >0$ we have $|\frac {y^{x}-1} {\log y}|=\frac {1-e^{-x|\log y|}} {|\log y|}\leq \frac {x|\log y|} {|\log y|} =x$ so $F(x) \to 0$ as $x \to 0+$.
Comment: How did you think of the property 1-e^-x <= x for all real number x? Is it from past experience? Thank you though!
Comment: Yes, when you are trying to find  a bound for $|y^{x}-1|$ you think of the well known inequality $1-e^{-t}\leq t$ for $t \geq 0$. I could think of it  immediately because I have already used  it hundreds of times! @LHC2012


Run Sql file in MYSQL PHPMyadmin

Question: I have written the SQL file with on excecuting it is throwing the error as
mysql> @"C:\Documents and Settings\Hemant\Desktop\create_tables.sql";
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '@"C:\
Documents and Settings\Hemant\Desktop\create_tables.sql"' at line 1
on line 1 code is
CREATE DATABASE IF NOT EXISTS test;
  DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE test;
please let me know is i am missing something
Answer: Correct me if I'm wrong, but isn't there a table test by default when you setup PHPMyAdmin?
Answer: You have an extra semi column after test.
Try removing it and see if that fixes the issue.
Comment: i have updated this to now CREATE DATABASE IF NOT EXISTS `test`;

USE test;
Comment: Did it work? `CREATE DATABASE IF NOT EXISTS test DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci; USE test;` should have worked, too (and might be required). Also... there's a http://stackoverflow.com/faq that will explain what is supposed to be your next action...

Run Sql file in MYSQL PHPMyadmin


In acute angle triangle, prove that $\cos (A-B) \cos (B-C) \cos (C-A)\ge 8\cos A \cos B \cos C$

Question:
In acute angle triangle, prove that
  $$\cos (A-B) \cos (B-C) \cos (C-A)\ge 8\cos A \cos B \cos C$$

My progress:
$$\cos(A-B)=2\cos A\cos B+\cos C\ge 2\sqrt{2\cos A\cos B\cos C}$$
$$\implies \prod\cos(A-B)\ge 8\left (2\prod \cos A\right )^{\frac 32}$$
Comment: Your inequality is true for all reals $A,$ $B$ and $C$ such that $A+B+C=\pi$.
Comment: Dear Rosenberg please share your solution
Comment: Open please a new topic and I'll show my solution.
Answer: $$2\sin A\cos(B-C)=\sin2B+\sin2C\ge2\sqrt{\sin2B\sin2C}=4\sqrt{\sin B\cos B\sin C\cos C}$$
As $A,B,C$ are acute, all the trigonometric ratios are $>0$
$$\implies\cos(B-C)\ge?$$
Similarly for $\cos(C-A),\cos(A-B)$


Bootstrap Cards carousel with php

Question: I'm trying to get the custom posts image gallery images into bootstrap cards with carousel and so far I'm able to get the images but they are displaying one by one underneath each instead of a carousel please correct me what am I doing wrong here.
<?php
    $model_images = get_field('gallery');
    $image_size = 'full';

    if( $model_images ): ?>

                <?php foreach( $model_images as $image_id ):?>

                        <img class="card-img-top" src="<?php echo wp_get_attachment_image( $image_id, $image_size ); ?>" alt="Card image cap"/>

<?php the_title();?>

Some quick example text to build on the card title and make up the bulk of the card's content.

                <?php endforeach; ?>

        <?php endif;?>

Comment: Did you [include the Bootstrap files](https://getbootstrap.com/docs/4.6/getting-started/introduction/)? Sorry if this is a stupid question, but it isn't obvious from your question.
Comment: Oh! I have only included the "link" tag in the header
Comment: Ah, you forgot the Javascript? That would explain it.
Comment: Just Added the JS bundles but still it's the same it didn't changed to carousel
Comment: Well, it's an essential part, but clearly there's still another problem.
Comment: Have a look at the HTML code that is produced by your script. Check for errors in your console. See: [Developer tools](https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_are_browser_developer_tools).
Comment: Console: Failed to load resource: the server responded with a status of 521 ()
Comment: Ah, but which resource is that?
Comment: It's favicon.ico written on the right side of the failed to load warning
Comment: Oh, well, that's not important.
Comment: OK, I see a problem in your PHP script. You create one carousel item, and you put all the cards, with the images in them, in that single carousel item. You need to put one card, with one image, in one carousel item, and have multiple carousel items.
Comment: Yes I've tried to loop it by foreach loop not sure where exactly I'm wrong with the script do I have to create multiple cards? I just want a single item to auto-scroll each time
Comment: I know. I'll try and provide a solution in an answer.
Comment: I've cleaned up your posted code and the markup is all wrong, your divs dont close properly is respect to the php statements... make sure all divs open and close and no stray html tags are present
Answer: Here's my solution. I cannot guarantee it will work, because I cannot run the code:
<?php
 $model_images = get_field('gallery');
 $image_size = 'full';

 if ($model_images) { ?>

     <?php foreach ($model_images as $key => $image_id) {
       echo '
'; ?>

         <img class="card-img-top" src="<?php echo wp_get_attachment_image($image_id, $image_size); ?>" alt="Card image cap">

<?php the_title(); ?>

Some quick example text to build on the card title and make up the bulk of the card's content.

   <?php } ?>

 <?php } ?>

I used a more modern PHP syntax, and I moved the
 inside your images loop.
Comment: It didn't worked! `` this is breaking the whole layout but without `` it's displaying cards underneath each card
Comment: Yes, stupid. There can only be one active carousel item. I'll see what I can do.
Comment: @ImranIrshad: I changed my answer. It relies on the keys of `$model_images` to be numeric and start at zero.
Comment: still the same it didn't worked, I have tried change your modern syntax to my previous one but still the same
Comment: @ImranIrshad: I don't have any futher suggestions, but I am sure you can eventually work it out. Start simple, for instance with 2 images and no loop. If that works then add the loop.
Answer: This is how I solved this carousel issue:

/* Checking to see if the post item has a featured image or not if it has the image already I'm requesting to show the featured image in card view aswell*/

<?php $featured_image = wp_get_attachment_url( get_post_thumbnail_id(get_the_ID()), 'model-featured-image' );
    if($featured_image == ''){
        $featured_image = '';
        } ?>

    <img class="card-img-top" src="<?php echo $featured_image; ?>" alt="Card image cap">

<?php the_title();?>

Some quick example text to build on the card title and make up the bulk of the card's content.

    /* This is important where I'm calling the gallery field items from my custom posts types */

    <?php
    $model_images = get_field('gallery');
    $image_size = 'full';

    /* And If there are images available in the gallery loop all images individually using foreach loop and display them in cardview by ID*/
    if( $model_images ):
    foreach( $model_images as $image_id ):?>

    <img class="card-img-top" src="<?php echo wp_get_attachment_image_url( $image_id, $image_size ); ?>" alt="<?php the_title();?>">

<?php the_title();?>

Some quick example text to build on the card title and make up the bulk of the card's content.

    <?php endforeach; endif;?>

When I posted this question I was using trying to make the bootstrap carousel work but for some reason it didn't worked so I have changed it to owl carousel using the bootstrap cards same and it worked.
Also I have added comments to my code to explain how I'm requesting featured image and the other images from each post gallery field.
Answer: As per my comment, cleaned up your posted code.
This might be a start into debugging your issue. See html comments in code below for changes to your code...
<?php

$model_images = get_field('gallery');
$image_size = 'full';

if( $model_images ): ?>

        <?php foreach( $model_images as $image_id ): ?>

                <img class="card-img-top" src="<?php echo wp_get_attachment_image( $image_id, $image_size ); ?>" alt="Card image cap"/>

<?php the_title(); ?>

Some quick example text to build on the card title and make up the bulk of the card's content.

        <?php endforeach; ?>

<?php endif;?>

Make sure your html valid, semantic etc, if you are using a decent ide, it should point out these errors.
Comment: After the code clean up the front-end layout is broken might be I'm missing a closing div somewhere
Comment: @ImranIrshad try running your site url through [W3C Markup Validation Service](https://validator.w3.org/) to find out where your markup is broken
Comment: @ImranIrshad if your wordpress site is local maybe check out [HTML Validator](https://chrome.google.com/webstore/detail/html-validator/mpbelhhnfhfjnaehkcnnaknldmnocglk) chrome extension which should work on your local environment
Comment: @ImranIrshad be warned you may get a shed load of errors, but look for the unclosed element errors see [W3C HTML Error docs (Unclosed tags)](https://validator.w3.org/docs/errors.html#ve-246)

Bootstrap Cards carousel with php


Cron jobs stuck in drupal 6

Question: I am maintaining a site on drupal 6. I have installed a birthday module which can send mails to users on their bday. But it doesnt do so. None of the other cron related tasks are done, though cron runs daily, and I do get a notification on mail . I tried to install a new module called ultimate cron (6.x-1.7), this could solve my problem earlier when I last installed it. But on re-installation this also doesnt work. None of the triggered rules that should be fired on cron run are fired.
On site config -> cron it lists all the processes, but they are in starting state. And on background process page , it shows first task with 0 progress n none other are being processed.
I have tried to install latest version of ultimate cron modules, but that gives some error saying "Unknown field: start stamp".
Please help me with this.
Answer: For the latest version of Ultimate Cron, you also need the latest versions of Background Process and Progress. The versions might not match, or the database schema may not have been updated properly. Try completely uninstalling Ultimate Cron, Background Process and Progress, and then re-install them.
Answer: I'd say rtfm (that's f for 'friendly') for the birthday module. It clearly wants a CCK field which doesn't exist. Reconfigure, try again.
Answer: I've used a temporary patch to time the duration of each module's cron run.
It helps a lot to debug cron issues.
I posted a patch for D8/D7 here:
http://drupal.org/node/1143082
A code snippet for manual D6 patching can be found here:
http://drupal.org/node/23714#comment-2633550
i.e D6 common.inc drupal_cron_run

<code>// Iterate through the modules calling their cron handlers (if any):
$cron_timer = variable_get('cron_timer', '1'); // can add to settings form, defaults to on
if ($cron_timer) {
  // start timer for cron total
  timer_start('cron');
  foreach (module_implements('cron') as $module) {
    watchdog('cron', t('Starting cron for @module', array('@module' => $module)));
    $function = $module .'_cron';
    // start timer for this module, using module cron function name as id
    timer_start($function);
    // call cron hook
    $function();
    $timer = timer_stop($function);
    // get total in seconds
    $total = round($timer['time']/1000, 2);
    watchdog('cron', t('Cron time elapsed for @module is @secs seconds.'), array('@module' => $module, '@secs' => $total) );
  }
  $cron_timer = timer_stop('cron');
  $total = round($cron_timer['time']/1000, 2);
  watchdog('cron', t('Cron time total was @secs seconds.'), array('@secs' => $total) );
}else{
  // just run cron
  module_invoke_all('cron');
}
</code>
HTH

Cron jobs stuck in drupal 6


Como recuperar um soapObject de um retorno do webservice

Question: <code> androidHttpTransport.call(SOAP_ACTION4, envelope);
            SoapObject result = (SoapObject) envelope.getResponse();

            System.out.println(result.getProperty("nmConsultor"));
            return result.toString();
</code>
No caso eu gostaria de recuperar as properties contidas em meu retorno...
Alguem pode me ajudar??
Comment: Se possível, use um REST Service com JSon, já que cada envelope SOAP é muito grande e pode consumir bastante tráfego de dados no Android.
Comment: o problema é que o webservice é criado de fora da empresa... aí não tenho como opinar =/
Comment: eu entendo, de qualquer forma esse seria um bom argumento.
Answer: Utilizando a biblioteca do ksoap2 v2.5.8, faço dessa forma:
<code>public static String conectWs(String URL, String NAMESPACE, String METHOD_NAME, String strDataXmt, String param) throws Exception{

    HttpTransportSE androidHttpTransport = null;
    SoapObject request = new SoapObject(NAMESPACE , METHOD_NAME);

    request.addProperty(param, strDataXmt);
    //androidHttpTransport.debug = true;

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);
    envelope.dotNet = true;

    androidHttpTransport = new HttpTransportSE(URL);
    androidHttpTransport.call(NAMESPACE + METHOD_NAME, envelope);
    Object results = (Object) envelope.getResponse();

    return results.toString();
}
</code>
Depois, para ler essa String de resultado como um Xml, eu faço esse parse:
<code> DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
 DocumentBuilder builder = factory.newDocumentBuilder();
 Document doc = builder.parse(new InputSource(new StringReader(stringDeResultado)));

 doc.getDocumentElement().normalize();
 NodeList nodeList = doc.getElementsByTagName("suaTag");
</code>
Comment: Obrigado Brother, e no caso de vir um XML de resposta... eu não estou conseguindo parsear, pois esta vindo em formato String, aí não consigo recuperar as properties... Obrigado pela atenção
Comment: Editei o post, vê se é isso que você estava querendo
Comment: Eu Consegui fazer, mas esta com retornando esse erro...

Unexpected token (position:TEXT anyType{GestorWe...@1:163 in java.io.StringReader@41750d08)

o que será que pode ser? desculpe o incomodo, nunca mexi com XML e Webservice... Muito Obrigado pela ajuda
Comment: tem como você me mandar o conteúdo da String no momento do parse?
Comment: string = anyType{GestorWebServices=anyType{cdRetorno=0; dsRetorno=anyType{}; cdConsultor=7; nmConsultor=Ediana Frainer Mazotto; cdHash=010200020007008307042014205205; }; }
Comment: Rapaz, esse retorno aí não é um XML não. Por isso o erro.
Comment: no serviço ta dizendo que vem xml
http://gestorweb.guiafacil.com/gestorwebservices/GestorWebServices.asmx?op=AutenticarTablet
Comment: esse link que vc me mandou não tá abrindo, parece que por conta de timeout. Ele está em modo de debug?
Comment: tenta esse aqui

http://gestorweb.guiafacil.com/gestorwebservices/GestorWebServices.asmx
Comment: nao tá funfando essa url nao...
Comment: muito estranho to mexendo nela aqui agora e ta funfando
Comment: http://gestorweb.guiafacil.com/gestorwebservices/GestorWebServices.asmx

estranho pois aqui funfa e ja é de fora isso


Mysql - split result when camelcase is found

Question: I have my table with with one column called name, containing names of people in camelCase format, but I need to select those names separate by one space when a capital letter is found: for example, my table would be like this:
|name          |
----------------
| JosephJackson|
|AidenChase    |
|LukeBenjamin  |

but I want to get in this way:
 |name          |
 ----------------
 | Joseph Jackson|
 |Aiden Chase    |
 |Luke Benjamin  |

How do I should use my SELECT? thanks
Comment: Do you know there is always at most one interior upper case letter?
Comment: well, not allways it can contains for example simply: "Luke".
Comment: what about the fun names? `O'Hara`
Comment: mmmm. which are fun names?
Comment: you may visit this link http://stackoverflow.com/questions/23470794/split-words-with-a-capital-letter-in-sql may it help you
Answer:

BEGIN
SET @text = word;
SET @result = "";
SET @i = 1;
WHILE @i <= LENGTH(@text) DO
SET @t = SUBSTRING(@text, @i, 1);
IF @i > 1 AND ASCII(SUBSTRING(@text, @i, 1)) BETWEEN 65 AND 90  OR @t ='_' OR @t = '-' THEN
IF @t <> '_' AND @t <> '-' THEN
SET @result = CONCAT(@result,' ');
END IF;
END IF;
IF @t <> '_' AND @t <> '-' THEN
SET @result = CONCAT(@result , @t);
end IF;
SET @i = @i + 1;
END WHILE;
RETURN @result;
END

The above sql function will split your text from the camel case and also from special characters like underscore(_) and dash(-) if they are used in that text.
Answer: I adapted @Mahesh's answer for what I was trying to accomplish (personal preferences):

make the first character uppercase
make the - and _ characters spaces
handle abbreviations
replace minor words with lowercase

Here's a comparison of the two.
Mine:
SELECT camelCaseToSpaced('iWasUsingThisForSetting-name-conversionForTheACMECo_project');

outputs...
I Was Using This for Setting name conversion for the ACME Co project

Mahesh's version
SELECT camelCaseToSpacedMahesh('iWasUsingThisForSetting-name-conversionForTheACMECo_project');

outputs...
i Was Using This For Settingnameconversion For The A C M E Coproject

So here's my code:
CREATE FUNCTION camelCaseToSpaced(string VARCHAR(100)) RETURNS VARCHAR(255)
  BEGIN
    SET @text = string;
    SET @result = "";
    SET @i = 1;
    SET @caps = 0;

    WHILE @i <= LENGTH(@text) DO
      SET @t = SUBSTRING(@text, @i, 1);
      SET @lastCaps = @caps;
      SET @caps = 0;
      -- uppers or _ or -
      IF @i > 1 AND ASCII(SUBSTRING(@text, @i, 1)) BETWEEN 65 AND 90 OR @t ='_' OR @t = '-' THEN
        IF NOT (@t ='_' OR @t = '-') THEN
          set @caps = 1;
        ELSE
          set @caps = 0;
        END IF;
        IF @i < LENGTH(@text) THEN
          set @nextAscii = ASCII(SUBSTRING(@text, @i+1, 1));
        END IF;
        SET @sep = ' ';
        -- to not have no space separator we need:
        -- 1. previous char is cap
        -- 2. next ascii is cap
        IF (@lastCaps = 1 AND @nextAscii BETWEEN 65 AND 90) THEN
          SET @sep = '';
        END IF;
        SET @result = CONCAT(@result, @sep);
      END IF;
      -- all characters except _ and -
      IF @t <> '_' AND @t <> '-' THEN
        -- make first character uppercase
        IF @i = 1 THEN
          SET @t = UPPER(@t);
        END IF;
        SET @result = CONCAT(@result , @t);
      end IF;
      SET @i = @i + 1;
    END WHILE;

    SET @result = replace(@result, ' The ', ' the ');
    SET @result = replace(@result, ' As ', ' as ');
    SET @result = replace(@result, ' In ', ' in ');
    SET @result = replace(@result, ' To ', ' to ');
    SET @result = replace(@result, ' On ', ' on ');
    SET @result = replace(@result, ' Of ', ' of ');
    SET @result = replace(@result, ' For ', ' for ');

    RETURN @result;
  END;

Answer: I had improved @MaheshYadav code. This will change any string into proper case.
DELIMITER @@
DROP FUNCTION IF EXISTS change_case@@
CREATE FUNCTION change_case (word VARCHAR(15000)) RETURNS VARCHAR(15000)
COMMENT 'Change the case to Proper Case, A-Z (65-90 decimal|ASCII) ,
  but if first char in between a-z (97-122) than change case to upper' DETERMINISTIC
BEGIN
  SET @text = word; -- input str
  SET @result = ""; -- modified str
  SET @i = 2;       -- counter
  -- if first char is in between a-z than change to upper
  IF ASCII(SUBSTRING(@text, 1, 1)) BETWEEN 97 AND 122 THEN
    SET @text = CONCAT(UPPER(SUBSTRING(@text, 1, 1)), SUBSTRING(@text, 2));
  END IF;
  SET @result = UPPER(SUBSTRING(@text, 1, 1));
  WHILE @i <= LENGTH(@text) DO
    SET @t = SUBSTRING(@text, @i, 1);
    SET @p = SUBSTRING(@text, @i-1, 1);
    -- if curr_char is upper and pre_char is lower then insert space and the char       eg coName   > co Name
    IF ASCII(@t) BETWEEN 65 AND 90 AND ASCII(@p) BETWEEN 97 AND 122 THEN
    -- eg SomeCO   > Some CO
        SET @result = CONCAT(@result,' ', @t);
    -- pre_char is space & curr_char is lower
    ELSEIF (ASCII(@p) = 32 OR @p = '_' OR @p = '-') AND ASCII(@t) BETWEEN 97 AND 122 THEN
    -- eg some cO  > some CO
      SET @result = CONCAT(@result,' ', UPPER(@t));
    ELSEIF @t = '_' OR @t = '-' THEN
    -- Replace _ OR - > space
      SET @result = CONCAT(@result,' ');
    -- for lower case
    ELSE
    -- someco        > someco
      SET @result = CONCAT(@result, @t);
    END IF;
    SET @i = @i + 1;
  END WHILE;
  SET @result = REGEXP_REPLACE(@result, '[ ]+', ' ');
  RETURN @result;
END @@

DELIMITER ;

Example use:
SET @val = 'someVillage';
SELECT @val, change_case(@val) `mod`;

SET @val = 'some village';
SELECT @val, change_case(@val) `mod`;

SET @val = 'some_village';
SELECT @val, change_case(@val) `mod`;


Server 2008 freezes and forces reboot

Question: We have had a client of ours move over to server 2008. The transition went smoothly(this is a domain controller) and we had no issues. However, it seems that after about a week the operating system hangs.
The mouse and keyboard stop responding and a remote connection into the
system is not allowed.
The only way to correct the issue is to hard reboot the system.
I have not seen any events logged in the event viewer that provides any
relevant information.
Our antivirus is vipre enterprise but other than that we have pretty much standard installs other then our monitoring software which allows us to track the servers status at all times. The thing is, the server shows online and responds to pings but nothing else can connect.
Any ideas?
<code>OS Name:                   Microsoft Windows Server 2008 Standard
OS Version:                6.0.6001 Service Pack 1 Build 6001
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Primary Domain Controller
OS Build Type:             Multiprocessor Free
Original Install Date:     9/29/2008, 3:55:54 AM
System Boot Time:          9/12/2010, 3:02:35 AM
System Manufacturer:       HP
System Model:              ProLiant DL380 G5
System Type:               x64-based PC
Processor(s):              2 Processor(s) Installed.
                           [01]: Intel64 Family 6 Model 23 Stepping 10 GenuineIn
tel ~2833 Mhz
                           [02]: Intel64 Family 6 Model 23 Stepping 10 GenuineIn
tel ~2833 Mhz
BIOS Version:              HP P56, 9/29/2008

Total Physical Memory:     12,285 MB
Available Physical Memory: 7,984 MB
Page File: Max Size:       30,359 MB
Page File: Available:      25,868 MB
Page File: In Use:         4,491 MB
Page File Location(s):     D:\pagefile.sys
Network Card(s):           1 NIC(s) Installed.
                           [01]: HP NC373i Multifunction Gigabit Server Adapter
                                 Connection Name: Local Area Connection 2
                                 DHCP Enabled:    No
</code>
Comment: Update all the drivers from HP yet?
Comment: I would add to Chris's question with the fact that there is a new BIOS firmware update 2010.04.26 (A), 17 Aug 2010.  I would start with updating drivers and firmware first.
Comment: emm that's a good point, I will roll out an update time.
Answer: I've had symantec antivirus give me the same thing about once per month on a 2k8 server, shares all die and it's only pingable. Basically I think it killed all RPC and the server service.  They released a fix - you may wanna try your AV support and see if they've released a patch or are aware of it for their version.  Anyway, symantec was the only 3rd party software on the box and before I got the symantec patch I removed the AV and the system was flawless.
Comment: I've tried support and they claim it has nothing to do with their software. I suspected the active protection of VIPRE myself but hangs are so hard since they don't generate any kind of information relating to it.
Comment: Then, like our fine members above have recommended - I'd start updating drivers.  Locking up the mouse and keyboard is generally a world that bad drivers (especially video) play in from my experience.
Comment: I updated the drivers to max and it hasn't crashed yet,
Thanks

Server 2008 freezes and forces reboot


Can't set a second network interface on a second ethernet port Debian 3.16

Question: My goal is to set two ethernet interfaces on two different ports and with two differents static IP on the same network. The matter is that one port will become reachable by the two IPs, the other won't. I proceed with the /etc/network/interfaces file and /etc/init.d/networking restart call. I also tried with ifupdown calls. Here is how I proceed:
I've just installed my Debian 3.16 OS without any network configuration.My device has two Ethernet ports.
ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 00:30:18:cd:49:77 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000
    link/ether 00:30:18:cd:49:76 brd ff:ff:ff:ff:ff:ff
4: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether bc:30:7e:c0:e6:ba brd ff:ff:ff:ff:ff:ff

ifconfig
lo        Link encap:Boucle locale
          inet adr:127.0.0.1  Masque:255.0.0.0
          adr inet6: ::1/128 Scope:Hôte
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:31 errors:0 dropped:0 overruns:0 frame:0
          TX packets:31 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 lg file transmission:0
          RX bytes:3172 (3.0 KiB)  TX bytes:3172 (3.0 KiB)

cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

Everything seems fine.
I want to add a new ethernet interface to connect on my network, so I modify the /etc/network/interfaces file this way:
cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.160
netmask 255.255.255.0
gateway 192.168.1.1

My device is now reachable on ethernet port let's say A with the IP 192.168.1.160, ifconfig is fine too.
Then I add the new interface and modify /etc/network/interfaces this way:
cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.1.160
netmask 255.255.255.0
gateway 192.168.1.1

auto eth1
iface eth1 inet static
address 192.168.1.161
netmask 255.255.255.0
gateway 192.168.1.1

ifconfig
eth0      Link encap:Ethernet  HWaddr 00:30:18:cd:49:77
          inet adr:192.168.1.160  Bcast:192.168.1.255  Masque:255.255.255.0
          adr inet6: fe80::230:18ff:fecd:4977/64 Scope:Lien
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6550 errors:0 dropped:8 overruns:0 frame:0
          TX packets:819 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 lg file transmission:1000
          RX bytes:584489 (570.7 KiB)  TX bytes:106896 (104.3 KiB)
          Interruption:18 Mémoire:d0700000-d0720000

eth1      Link encap:Ethernet  HWaddr 00:30:18:cd:49:76
          inet adr:192.168.1.161  Bcast:192.168.1.255  Masque:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:222 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 lg file transmission:1000
          RX bytes:20241 (19.7 KiB)  TX bytes:1500 (1.4 KiB)
          Interruption:19 Mémoire:d0600000-d0620000

lo        Link encap:Boucle locale
          inet adr:127.0.0.1  Masque:255.0.0.0
          adr inet6: ::1/128 Scope:Hôte
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:31 errors:0 dropped:0 overruns:0 frame:0
          TX packets:31 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 lg file transmission:0
          RX bytes:3172 (3.0 KiB)  TX bytes:3172 (3.0 KiB)

I expect to reach my device on port A with .160 and on port B with .161.
But I actually reach my device on port A with both .160 and .161, and none on port B.
EDIT:
If I plug the Ethernet cable on the physical port A, I want to be able to join (ping or ssh connexion) my device with IP 192.168.1.160.
If I plug the Ethernet cable on the physical port B, I want to be able to join (ping or ssh connexion) my device with IP 192.168.1.161.
(network is 192.168.1.0/24)
My questions are:

What I am doing wrong? Are those file and calls aim to work together or are they non-compatible in their network management?
What are the tools commonly used to configure a network interface on Debian 3.16 if not those one?
Is there a link I've missed between network interfaces and the hardware?

Of course:

I've spent lot of time looking for some answers and build my method with thoses answers, plus the network configuration for Debian documentation.
I've tried to restart network interfaces with both /etc/init.d/networking restart and ifup/ifdown eth0
Finally I've re-installed my Debian for that, so I also tried to reboot.
Answer: In your question terms are not clear, what you mean by
"I expect to reach my device on port A with .160 and on port B with .161. But I actually reach my device on port A with both .160 and .161, and none on port B."
If this will clear than might be we can provide you how exactly proceed.
Please have a look for policy-based routing in linux. May be below can help you:  https://www.novell.com/support/kb/doc.php?id=7008874
http://blog.scottlowe.org/2013/05/29/a-quick-introduction-to-linux-policy-routing/
As you said you have tried with single gateway on active interface only, so that should worked. Problem here is with network, which is same for both interface.
Can try with this example:
ifconfig eth0 192.168.1.161/24 up
route add default gw 192.168.1.1 dev eth0
ifconfig eth1 192.168.1.162/24  up

And test with ifconfig down eth0 and eth1 one by one
also can plug lan on both interface and try with ping or ssh.
Comment: I've edited to clarify:
If I plug the Ethernet cable on the physical port A, I want to be able to join (ping or ssh connexion) my device with IP 192.168.1.160. If I plug the Ethernet cable on the physical port B, I want to be able to join (ping or ssh connexion) my device with IP 192.168.1.161. (network is 192.168.1.0/24)
Comment: So you mean at the same time you dont want to use both interface ?
Comment: Yes I do, simply I'm making test with only one Ethernet cable that I switch.
Comment: I have updated my answer, please try that one.
Comment: I've tried, same problem remains: one physical port owns the two IP addresses while the other none.
It seems not possible to give two different IPs on two physical ethernet ports in the same network.
Comment: Have you try by changing the subnet mask, eg: eth1 with /16 and eth2 /24 ...?
Answer: Basically, I suspect this is about routing.
Unless you are on the same LAN segment (i.e. broadcast domain) as the two IPs you mention, then your traffic needs to be routed.
The short version is that you have set both ports to have a default gateway.
That is something you can do (but AFAIK requires you to specify a cost for one of your NICs), but this would still more than likely cause the same thing to happen
In your config, eth0 is configured first.
I suspect this means it is the one announcing that it has a default gateway, which in turns means eth1's gateway is ignored.
You can check this with ip r.
More generally, in a routed network (again, if you are in the same broadcast domain, it is a different matter, because you are then going by physical address/MAC, not network address/IP), there is always a preferred path, and your traffic is simply using that preferred path.
In effect, all you are seeing is that your eth0 is providing access to eth0 and eth1's IP address, because it knows a route to both, and back to your IP.
So there is nothing wrong here - at least not that I can tell.
If you were doing all this for availability reasons, then you might consider bonding your NICs instead, and having a single IP, because that setup has less variables.
Comment: I want my two physical ports to be independent. In the given example I want to set them in the same network (192.168.1.0/24), but they would probably be set on two different networks.
I've found that the gateway must be provided only once /etc/network/interfaces file, so I've tried to set it only once, but the problem remains.
Comment: Yup - the only way to have more than one default gateway is to set them up with cost metrics - e.g. `ip r add default via IP weight 80`. Even then, I don't think this would fix your issue. What might, though, is to have eth0 as your public port (with a default gateway), and eth1 as a management port, with only the routes it needs to reach certain specific subnets. In other words, remove the `gateway 192.168.1.1` from the config for eth1, and for what traffic _must_ go over eth1, create the required routes, using for example `up route add 10.0.0.0/8 gw 10.0.1.1`


Simple question about equivalence of two forms of PCA as trace maximization over an implicit distribution

Question: This may be a soft question of sorts.
One formulation of principal component analysis is trace maximization: $$\arg\max_U \mathbb{E}_x \ [tr(U^Txx^TU)],$$
for $U^TU\le I$ and we assume that there is some underlying distribution.
My question is that I have also seen this written with the quantity inside the trace as $$\arg\max_P \mathbb{E}_x \ [tr(Pxx^T)],$$
where $P$ is an orthogonal projector.
These are the same, right? Any orthogonal projector $P$ is of the form $U^tU$ and the trace is invariant under cyclic permutations, giving the equivalence. Is that right?
Answer: (Presumably $P$ and $U$ are also subject to the constraint that $\operatorname{rank}(P)\le k$ and $\operatorname{rank}(U)\le k$ for some $k$.)
Not exactly. Your argument does not justify that
$$
\max_{P^2=P=P^T} \mathbb{E}_x \ [\operatorname{tr}(Pxx^T)]
\ge \max_{U^TU\preceq I} \mathbb{E}_x \ [\operatorname{tr}(U^Txx^TU)],\tag{1}
$$
because the condition that $U^TU\preceq I$ does not imply that $UU^T$ is an orthogonal projector. (It justifies the reversed inequality, though.)
To justify $(1)$, observe that $A=\mathbb{E}_x [xx^T]$ is positive semidefinite. Therefore $A=QDQ^T$ for some real orthogonal matrix $Q$ and diagonal matrix $D$ whose diagonal entries are arranged in descending order. Consequently, under the constraints that $U^TU\preceq I$ and $\operatorname{rank}(U)\le k$, $\mathbb{E}_x \ [\operatorname{tr}(U^Txx^TU)]$ is maximised when $U=UU^T=Q(I_k\oplus0_{(n-k)\times(n-k)})Q^T$. Since $UU^T$ is an orthogonal projector, $(1)$ follows.


How to explain and visualize a Q Learning Agent?

Question: What are some common visualization approaches used in explaining the behavior of a Q-Learning agent?
Here is an excerpt of some example Q values for 5 actions serialized to json:
<code>[
  [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
  [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
  [ 0.0, 9.7180743908492411E-05, 0.0, 6.0134871150517619E-05, 0.0 ],
  [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
  [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
  [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
  [ 0.0, 2.7866205412015394E-05, 0.0, -3.5352503282357707E-05, 0.0 ],
  [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
  [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
  [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
  [ 0.0, 0.002179680102508753, 0.0, 0.0003821282886147801, 0.0 ],
  [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
  [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
  [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
  [ 0.0, 0.00044976255425384565, 0.0, 2.6171104054710165E-05, 0.0 ],
  [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
</code>
Comment: Yes, these QValues are from a working agent. In terms of the visualization, exactly this: just looking for visualization approaches that will assist in understanding the behavior that given state values in a certain range the agent has encountered a particular type of reward.
Answer: To visualise your Q values, you can you a heat map. See e.g. https://seaborn.pydata.org/generated/seaborn.heatmap.html, if you are using Python.
Comment: Thanks. How do you think I could go about decomposing the states into multi-dimensional features?


How to initiate & pick up a video call via pc by ADB command on android?

Question: Can some one tell me how i can initiate & pickup a video call using adb? I want to automate some Video Telephony Testing and want to do this using adb_scripts. Is it possible at all?
I can see the following link in stackoverflow to initiate a voice only call using adb. I just cannot correlate the same to initiate video call.
How to make a call via pc by ADB command on android?
Thanks in advance.
Answer: \\ To Initiate the Video call
adb shell am start -a android.intent.action.CALL -d tel:xxx-xxx-xxxx --ei android.telecom.extra.START_CALL_WITH_VIDEO_STATE 3**

\\ To auto answer on far end
adb shell setprop persist.sys.tel.autoanswer.ms 2000

Comment: Thanks Alexan,  `adb shell am start -a android.intent.action.CALL -d tel:xxx-xxx-xxxx --ei android.telecom.extra.START_CALL_WITH_VIDEO_STATE 3` work (not include **)
Answer: Have you tried this for setting up a call:
adb shell am start -a android.intent.action.CALL -d tel:+1-xxx-xxx-xxxx

This ends a call:
adb shell input keyevent 6

I have not tried this but it might answer a call:
adb shell input keyevent 5


Jquery não exclui linhas da tabela

Question: Tenho o formulário abaixo do qual quando clico em Adicionar mais Pet, ele adiciona mais um panel normalmente:

Porém quando clico em Remover, ele remove apenas os botões e os panels continuam. Vejam o código:

                     DADOS DO PET

                          Espécie:
                          <select name="Especie" class="form-control">
                            <option value="Canino">Canino</option>
                            <option value="Felino">Felino</option>
                          </select>

                         Nome do Pet:
                         <input type="text" name="NomePet" class="form-control" required="required">

                         Aniversário do Pet:
                         <input type="date" name="AniversarioPet" class="form-control" data-inputmask="'alias': '99/99/9999'" required="required">

                        Gênero:

                           <input type="radio" name="SexoPet" value="Macho" checked> Macho
                           <input type="radio" name="SexoPet" value="Fêmea"> Fêmea

                       Idade:
                       <select name="IdadePet" class="form-control">
                         <option value="Antes dos 11 meses">Antes dos 11 meses</option>
                         <option value="Entre 1 e 8 anos">Entre 1 e 8 anos</option>
                       </select>

        <button type="button" class="adicionarCampo btn btn-primary" title="Adicionar item"> Adicionar mais Pet</button>
        <button type="button" class="removerCampo btn btn-danger" title="Remover linha"> Remover</button>

JQUERY

O que acho estranho, é quando coloco a linha abaixo dentro de um TD como uma outra coluna onde está o panel, funciona:
<button type="button" class="removerCampo btn btn-danger" title="Remover linha"> Remover</button>

Como posso resolver isso?
Comment: Fox coloca o CSS? também para eu montar o fiddle? bem melhor mano. Valeu
Comment: De boa, foi mais uma mania minha de deixar o fiddle bonitinho kkk, resolvi o problema só estou explicando o porque estava se comportando daquele jeito 1min.
Comment: Olá Leonardo. Na verdade estou usando o Bootstrap. Não tenho um CSS específico para ele. São só esses códigos que compõe a dúvida mesmo.
Answer: Você estava usando $(this).parent().parent().remove(); ou seja, de baixo para cima os elementos eram: button > td > tr você estava removendo o tr que compõe os dois botões e não o tr que compõe os campos do formulário.
A solução foi: $("tr.linhas:last").remove(); do mesmo jeito que você usou novoCampo.insertAfter("tr.linhas:last"); eu utilizei para remover o ultimo elemento adicionado.
OBS: acredito que o que você está fazendo na lógica de remover o PET, fere os conceitos de UX, porque digamos que você tenha colocado 300 PETS, e resolve remover o segundo dessa lista, você terá que remover 298 para chegar no segundo. Tenta adicionar botões independentes. ;)

$("#remove").click(function() {
  if ($("tr.linhas").length > 1) {
    $("tr.linhas:last").remove();
  };
});

$(".adicionarCampo").click(function() {
  novoCampo = $("tr.linhas:first").clone();
  novoCampo.find('input[type="text"]').val("");
  novoCampo.find('select').val("");
  novoCampo.insertAfter("tr.linhas:last");
});

           DADOS DO PET

              Espécie:
              <select name="Especie" class="form-control">
                            <option value="Canino">Canino</option>
                            <option value="Felino">Felino</option>
                          </select>

              Nome do Pet:
              <input type="text" name="NomePet" class="form-control" required="required">

              Aniversário do Pet:
              <input type="date" name="AniversarioPet" class="form-control" data-inputmask="'alias': '99/99/9999'" required="required">

              Gênero:

                <input type="radio" name="SexoPet" value="Macho" checked> Macho
                <input type="radio" name="SexoPet" value="Fêmea"> Fêmea

              Idade:
              <select name="IdadePet" class="form-control">
                         <option value="Antes dos 11 meses">Antes dos 11 meses</option>
                         <option value="Entre 1 e 8 anos">Entre 1 e 8 anos</option>
                       </select>

      <button type="button" class="adicionarCampo btn btn-primary" title="Adicionar item"> Adicionar mais Pet</button>
      <button type="button" id="remove" class="removerCampo btn btn-danger" title="Remover linha"> Remover</button>

Comment: You're welcome !
Comment: Perfeito Leonardo. Funcionou! Na verdade irei limitar apenas 10 Pets. Muito obrigado pela ajuda.
Answer: A lógica de formatação não está legal, utilize
 apenas para dados tabulares, mas se ainda sim quiser usar
, deixe os botões de adicionar e remover fora da tabela.
Exemplo simples usando jQuery:

$(function(){
  var pets = $('.pets');
  var maximo_de_pets = 10;
  $('.add').click(function(){
    if (pets.find('tr').length < maximo_de_pets){
      var novo_pet = pets.find('tr').first().clone();
      novo_pet.find('input[type="text"]').val("");
      novo_pet.find('select').val("");
      pets.append(novo_pet);
    }
    else{
     alert('maximo ' + maximo_de_pets + ' pets')
    }
  });
  $('.conteudo').on('click', '.remover', function(){
    if(pets.find('tr').length > 1){
      if ($(this).hasClass('ultimo')){
        pets.find('tr').last().remove();
      }
      else{
        $(this).closest('tr').remove();
      }
    }
    else{
      alert('minimo 1 pet');
    }
  });

});

blabla <button class='remover'>remover</button>

  <button class="add">Adicionar</button>
  <button class="remover ultimo">Remover ultimo</button>

Jquery não exclui linhas da tabela


Error while adding Check boxes to Navigation Drawer ListView

Question: I'm trying to add a customized navigation drawer to my android application. What i need is to add a list view containing icon, name and a check box.
Currently, i was able to add an icon and name.
This is my onCreateView in NavigationDrawerFragment.java
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        mDrawerListView = (ListView) inflater.inflate(
                R.layout.fragment_navigation_drawer, container, false);
        mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                selectItem(position);
            }
        });

        final TypedArray typedArray = getResources().obtainTypedArray(R.array.sections_icons);
        mDrawerListView.setAdapter(new ArrayAdapter<String>(
                getActionBar().getThemedContext(),
                android.R.layout.simple_list_item_activated_1,
                android.R.id.text1,
                getResources().getStringArray(R.array.sections)
        ) {
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                View v = super.getView(position, convertView, parent);
                int resourceId = typedArray.getResourceId(position, 0);
                Drawable drawable = getResources().getDrawable(resourceId);
                ((TextView) v).setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
                return v;
            }
        });

        mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
        return mDrawerListView;
    }

But, I couldn't add check box to my navigation drawer.
So, I followed this and I tried to add check box by adding mDrawerList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
This gives me the following error.
05-05 11:24:49.537    3640-3640/com.myayubo E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.myayubo, PID: 3640
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myayubo/com.myayubo.MainActivity}: java.lang.NullPointerException
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
            at android.app.ActivityThread.access$800(ActivityThread.java:151)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
            at android.os.Handler.dispatchMessage(Handler.java:110)
            at android.os.Looper.loop(Looper.java:193)
            at android.app.ActivityThread.main(ActivityThread.java:5299)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NullPointerException
            at com.myayubo.MainActivity.onCreate(MainActivity.java:67)
            at android.app.Activity.performCreate(Activity.java:5264)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
            at android.app.ActivityThread.access$800(ActivityThread.java:151)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
            at android.os.Handler.dispatchMessage(Handler.java:110)
            at android.os.Looper.loop(Looper.java:193)
            at android.app.ActivityThread.main(ActivityThread.java:5299)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
            at dalvik.system.NativeStart.main(Native Method)

Someone please tell me how to add check boxes to my code.
Thanks in advance. :)
Answer: You should do this way:
@Override
 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   View rootView = inflater.inflate(R.layout.fragment_navigation_drawer, container, false);

   ListView mDrawerListView = (ListView) rootView.findViewById(R.id.listView);
   mDrawerList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    // Other stuff
   return rootView;
 }

Edit 1:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
         View rootView = inflater.inflate(R.layout.fragment_navigation_drawer, container, false);

   ListView mDrawerListView = (ListView) rootView.findViewById(R.id.listView);
   mDrawerList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

        mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                selectItem(position);
            }
        });

        final TypedArray typedArray = getResources().obtainTypedArray(R.array.sections_icons);
        mDrawerListView.setAdapter(new ArrayAdapter<String>(
                getActionBar().getThemedContext(),
                android.R.layout.simple_list_item_activated_1,
                android.R.id.text1,
                getResources().getStringArray(R.array.sections)
        ) {
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                View v = super.getView(position, convertView, parent);
                int resourceId = typedArray.getResourceId(position, 0);
                Drawable drawable = getResources().getDrawable(resourceId);
                ((TextView) v).setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
                return v;
            }
        });

        mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
        return rootView;
    }

You are doing wrong with Binding of ListView.
Hope this will make sense.
Comment: You mean I need to remove other code inside onCreateView and add this?
Comment: @QualityProducts, you should bind listview like my code
Comment: I'm really sorry for ask this question. I don't understand it since I'm new to android. Can u be more descriptive? Can u get my answer and edit it? Thanks. :)
Comment: @QualityProducts, I have edited my answer with Edit 1.
Comment: Hi, added ur code and then it gives an error saying cannot find symbol isDrawerOpen()
Comment: @QualityProducts, make sure mDrawerListView object must not null
Comment: Hi, Sry DrawerListView object must not null error came because of my fault. Now, code is running. But, I don't get text boxes in my drawer yet. :(
Comment: It gives the same error in the line mDrawerList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); :(
Comment: Added the mDrawerList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);  to NavigationDrawerFragment not to the MainActivity. Problem solved. :)


Why fsck without umount results in filesystem corruption?

Question: Everyone says that you shouldn't do fsck to a disk without umount, because it will result in filesystem corruption.Actually I tried to fsck a mounted disk and the filesystem is corrupted.
That's few years ago when I didn't know much about Linux. But after all these years I still don't know what happened when doing fsck, and why this operation will corrupt the filesystem with disk mounted.
Waiting for a in-depth explanation :-)
Answer: fsck programming design makes an assumption that the program is the only thing accessing the file system.  When the filesystem is mounted, it is being no doubt constantly changing thus violating the fsck design assumptions.
fsck does its work in several passes, fsck will have to read and correlate a lot of material concering filesystem structural integrity, if the filesystem is changing, the structural data is changing and fsck is not dynamic and will not track these changes.  It will make "suggestions" as to what to fix based on its analysis at that pass not knowing that the structural data has changed.  These changes could be just plain wrong!  Fsck will then generate a corrupted filesystem.


A word problem involving induction

Question: The P & W Manufacturing Company makes bubblegum dispensers, and their machines dispense bubblegum balls in pairs (that is, for a nickel, each customer gets two bubblegum balls). The machines are of different sizes and capacities, so the number of bubblegum balls in a given machine is not known. However, it is known that each machine contains an odd number of green bubblegum balls and an odd number of red bubblegum balls.
QUESTION:
Prove by induction that before a dispenser is empty, at least one pair will be dispensed that consists of one green bubblegum ball and one red bubblegum ball.
Comment: What is the question?
Comment: I have just edited the question. Thanks
Answer: I'd rather say that the problem is solved using an invariant, which says:
"As long as no mixed pair has been dispensed, the number of green and red are both odd".
This is obvious as taking out a pair of the same color does not change the parities. Then if no mixed pair is taken earlier, the last pair will be mixed.
Answer: I'm not sure why you would use induction on this.  If there are an odd number, 2n+ 1, of red gumballs there exist at most n red pairs with one left over.  If there are an odd number, 2m+ 1, of green gumballs there exist at most m green pairs with one left over.  Those two left over gumballs must come out together.
Answer: We prove the following statement by induction on $n$:

For any $n\ge 1$, any gum machine with $2n$ total gumballs, an odd number which are red and an odd number which are green, will at some point output a red and green ball when it is used $n$ times.

Base case: When $n=1$, we have a machine with $1$ red and $1$ green gumball. Obviously, it will dispense a red and green ball when it is used.
Inductive step: Assume that the given statement is true when $n$ is set to $k$. Given a machine with $2(k+1)$ gumballs satisfying the conditions, consider what happens when two gumballs are dispensed. There are three cases...

One gumballs is red and the other is green. In this case, we are done, because what we wanted to prove will happen has happened.
Both gumballs are green. We now are left with a machine with $2k$ gumballs. Furthermore, this machine still has an odd number of red and green gumballs (place more justification here if necessary). Therefore, by the inductive hypothesis, when we use this machine $k$ times, it will at some point dispense one gumball in each color, as desired.
Both gumballs are red. This case is similar to the previous.

A word problem involving induction


How to populate dropdown menu based on rails database values

Question: I have a scaffolded project in ruby on rails in which I populated a players and scores. I would like to have a dropdown menu that is populated by the players dropdown menu.
The process is, first a player is made on the players page, then I go to the scores page, fill a new score, and then the dropdown menu will have a ll the players signed up already, input the score, then create a new player with the score associated with it.
(bonus, I would like to integrate these functions (combine player and score information into one form)
Form for scores:
<%= form_for(@score) do |f| %>
  <% if @score.errors.any? %>

<%= pluralize(@score.errors.count, "error") %> prohibited this score from being saved:

      <% @score.errors.full_messages.each do |message| %>

<%= message %>

      <% end %>

  <% end %>

    <%= f.label :lowest_time %>

    <%= f.number_field :lowest_time %>

    <%= f.label :player_id %>

    <%= f.text_field :player_id %>
    <%= @score.player %>

    <%= f.submit %>

<% end %>

Form for players
<%= form_for(@player) do |f| %>
  <% if @player.errors.any? %>

<%= pluralize(@player.errors.count, "error") %> prohibited this player from being saved:

      <% @player.errors.full_messages.each do |message| %>

<%= message %>

      <% end %>

  <% end %>

    <%= f.label :name %>

    <%= f.text_field :name %>

    <%= f.submit %>

<% end %>

I do have a players model with has_many :scores and a scores model with belongs_to :player
The way I have it now is that the player id is showing, but that is not practical in terms of the user would have to input the id_number of the player...
Any help would be appreciated! If there are is any needed additional code to show what my problem is, let me know.
Comment: You need to use `accepts_nested_attributes_for :score` in the player model. Here's more info: http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html .. https://github.com/nathanvda/cocoon .. http://railscasts.com/episodes/196-nested-model-form-part-1
Answer: In your scores form, instead of inputting the player id, use the Rails select helper:

  <%= f.label :player_id %>

  <%= f.select(:player_id, Player.all.pluck(:name, :id), @score.player_id %>

Check out the Rails docs for more info.


How to transform my sparse count data into normal distribution?

Question: I am running glm on beetle counts data. My predictors are environmental variables and my response variable is the number of beetles.
I ran three glms:

The response variable $Y_1$ is the total number of beetles.
The response is a subset of $Y_1$ ($Y_2$).
The response is also a subset of $Y_1$ ($Y_3=Y_1-Y_2$). In this $Y_3$, there are many zeros in my distribution, so the residual distribution is very far from normal.

How can I transform $Y_3$ to meet the assumption of normality?
Does anyone have an equivalent robust non-parametric test?
Comment: If your outcome is a count is there any reason why you are avoiding Poisson regression?
Comment: Or negative binomial regression, etc...
Comment: thanks for your answers. I log-transformed to normalize my response variable and diagnosed the model by checking for residuals normality... what is wrong. I will do a simple one glm(Y~X, family=poisson) and check for the goodness-of-fit the model.
Answer: You should use a Poisson regression (or in case of overdispersion, maybe negative binomial or quasi-Poisson regression). There is no assumption of normality in those models, so no need for transformations. See Normality requirements for GLM and GEE models


Taxonomy terms with conditional field

Question: 50 terms and each term needs to have radiobuttons or "other".
Food - o in price - o extra price
Drinks - o in price - o extra price
WiFi - o in price - o extra price
So "in price" and "extra price" are radiobuttons. User clicks "extra price" and he gets conditional text field (integer) where he can write the extra price. Result after choosing "extra price" should look like this:
Food - o in price - o extra price - _________ €.
There are 2 things that come to my mind. Making separate vocabulary out of each term, each containing terms "in price" and "extra price", make separate integer field in content type and use conditional field module.
But that would mean i would have to create 50 vocabularies and 50 integer fields for 1 content type and its possible that there will be more terms in the future.
2nd option would be creating 50 fields instead of using taxonomy and use Select or other module but that also seems to be overdoing it to have 1 content type with over 50 fields just becouse of this option
Comment: is drupal_add_js('...',inline) and handle displaying the radios by adding / removing a class with 'display:none' an option?
Comment: Unfortunately i only know how to use modules.
Answer: With a module, creating a form and using the drupal ajax function to switch the input field on/off might be a solution.
check out this example from deckfifty: form api using ajax example
partial code:
function deckfifty_example_form($form, &$form_state) {
  $form['fox_color'] = array(
    '#title' => t('Specify the color of the fox:'),
    '#type' => 'select',
    '#options' => drupal_map_assoc(array('', 'brown', 'black', 'white')),
    '#ajax' => array(
     'callback' => 'deckfifty_fox_ajax_callback',
     'wrapper' => 'deckfifty_fox_ajax_wrapper',
   ),
 );
 $form['fox_wrapper'] = array(
    '#type' => 'markup',
     '#prefix' => '
',
    '#suffix' => '
',
 );

 $form['submit'] = array(
   '#type' => 'submit',
   '#value' => t('Save'),
);

 return $form;
}

Comment: Link is not working, get 404 error. But anyway i do not have any skills in creating modules.

Taxonomy terms with conditional field


Find the CDF and use it to find all the medians

Question: Show that for every $p$, $0\leq p\leq 1$, the function $f(x)$ = $p\sin(x) +(1-p)\cos(x)$, $0\leq x \leq \pi/2 $, and $f(x)=0$ otherwise, is a density function. Find its CDF and use it to find all the medians.
I was able to prove it a density function and also was able to get the CDF which is
$(p +\sin(x) -p(\sin(x) + \cos(x))$ ; $0\leq x \leq \pi/2$ and $1$ for $ x\geq \pi/2$ and $zero$ elsewhere.
(I hope I am correct)
I don't understand the last part. What do they mean by finding all the medians?
I tried putting the CDF equal to $0.5$. I still can't figure it out. I have an equation with two variable $p$ and $x$. How can I solve this?
Comment: Cross-posted at https://stats.stackexchange.com/questions/444383/find-the-cdf-and-use-it-to-find-all-the-medians.
Comment: Your CDF is fine. Setting the CDF to $1/2$ is the right approach. Maybe make the substitution $t = \sin x$ and $\sqrt{1-t^2} = \cos x$, and solve for $t$ (with $p$ fixed), which amounts to solving a quadratic equation. You will get a different median for each value of $p$ (that is, the solution will be in terms of $p$).
Comment: Thank you. I got it now.
Comment: I still can't solve it bu even using the substitution. I am not getting a quadratic equation.
Answer: Using Mathematica, I found the solutions to $p + \sin x - p(\sin x+\cos x)=\frac12$ to be
$$
\tan ^{-1}\left(\frac{2 p \left(\sqrt{p^2 (4 (p-1) p+3)}+2 (p-1) p\right)-\sqrt{p^2 (4 (p-1) p+3)}}{p (4 p-3)}\right)
$$
and
$$
\tan ^{-1}\left(\frac{\sqrt{p^2 (4 (p-1) p+3)}-2 p \left(\sqrt{p^2 (4 (p-1) p+3)}-2 (p-1) p\right)}{p (4 p-3)}\right).
$$


bloco de spans não que se ajustar ao tamanho!

Question: Tenho o seguinte código:

   $(document).ready(function(){
    function animaTextos(){
     var interval;
     var contador = 1;
     var funcao = function() {
      var corrente = $('div.slider ul.slide li').length;
      if(corrente == contador) {
       $('div.slider ul.slide li.tituloAtivo').removeClass('tituloAtivo');
       $('div.slider ul.slide li').first().addClass('tituloAtivo');
       contador = 1;
      } else {
       contador++;
       $('div.slider ul.slide li.tituloAtivo').removeClass('tituloAtivo').next().addClass('tituloAtivo');

      }
     };
     interval = setInterval(funcao, 1000);
    }

    animaTextos();
   });

      window.onload = function() {

         var indexAtiva = 0;

         const lis = document.getElementsByClassName('slider').item(0).getElementsByTagName('li');

         function slider(s) {

            for (i = 0; i < lis.length; i++) {
               lis[i].classList.remove('ativa');
            }

            // aqui irá tratar o clique no "Anterior".
            // É preciso tratar de 3 formas diferentes
            // dependendo do valor de indexAtiva.
            // Veja que o valor de indexAtiva, em cada caso,
            // irá receber o valor do índice ativado
            if(s){
               // significa que o próximo a mostrar será o
               // slide de índice 1, então está sendo exibido o 0.
               // neste caso eu ativo o último da array
               if(indexAtiva == 1){
                  lis[lis.length-1].className = 'ativa';
                  indexAtiva = lis.length-1;

               // aqui diz que está exibindo o último,
               // logo próximo será o primeiro (índice 0).
               // Então eu ativo o antepenúltimo da array
               }else if(indexAtiva == 0){
                  lis[lis.length-2].className = 'ativa';
                  indexAtiva = lis.length-2;

                // aqui é quando não for nenhum dos casos anteriores.
                // Eu diminuo 2 índices porque mais a frente será
                // incrementado com +1
               }else{
                  lis[indexAtiva-2].className = 'ativa';
                  indexAtiva -= 2;
               }
            }else{
               // aqui é quando for clicado o botão "próximo"
               // ou quando nenhum botão for clicado
               lis[indexAtiva].className = 'ativa';
            }

            indexAtiva = indexAtiva + 1 == lis.length ? 0 : indexAtiva+=1;

            tempo = setTimeout(slider, 3000);
         }

         slider();

         var slider1 = document.getElementsByClassName('slider')[0]
         var nav = slider1.getElementsByTagName('nav')[0]
         var anterior = nav.getElementsByClassName('anterior')[0]
         var proximo = nav.getElementsByClassName('proximo')[0]

         anterior.onclick = function(){
            clearTimeout(tempo);
            slider(true);
         }

         proximo.onclick = function(){
            clearTimeout(tempo);
            slider();
         }

      }
      * {
          margin: 0;
          padding: 0;
          border: none;
          outline: 0;
      }
      body {
          width: 100vw;
      }
      ul {
          list-style: none;
      }
   .setaDireita {
    background-image:url(_img/_bannerImgs/direita.png);
    background-repeat:no-repeat;
    background-position: center center;
   }
   .setaEsquerda {
    background-image:url(_img/_bannerImgs/esquerda.png);
    background-repeat:no-repeat;
    background-position: center center;
   }
      .fade {
          -webkit-animation-name: fade;
          -webkit-animation-duration: 1.5s;
          animation-name: fade;
          animation-duration: 1.5s;
      }
       @-webkit-keyframes fade {
       from {
       opacity: .4
      }
       to {
       opacity: 1
      }
      }
       @keyframes fade {
       from {
       opacity: .4
      }
       to {
       opacity: 1
      }
      }
      @keyframes slider {
       0% {
       transform: scale(1);
      }
       100% {
       transform: scale(1.1);
      }
      }
      div.slider {
          position: relative;
          width: 100%;
          overflow: hidden;
      }
      div.slider ul.slide {
      }
      div.slider ul.slide li {
          display: none;
      }
      .ativa {
          display: block !important;
      }
      div.slider ul.slide li img {
          position: relative;
          width: 100%;
          animation: slider 1s linear, fade 1s linear;
          animation-fill-mode: forwards;
      }
      div.slider ul.slide li span {
          position: absolute;
          width: 200px;
          left: calc(50% - 100px);
          line-height: 40px;
          bottom: 0;
          text-align: center;
          color: rgb(255,255,255);
          z-index: 2;

    opacity                            : 0;
    top                                : 85px;
    -webkit-transition                 : all 0.5s ease-in-out;
    -moz-transition                    : all 0.5s ease-in-out;
    -o-transition                      : all 0.5s ease-in-out;
    transition                         : all 0.5s ease-in-out;
    transition-timing-function         : ease;
    -webkit-transition-timing-function : ease; /* Safari and Chrome */
      }

   div.slider ul.slide li.tituloAtivo span {
    font-size:30px;
    opacity                            : 1;
    top                                : 0;
    -webkit-transition                 : all 1s ease-in-out;
    -moz-transition                    : all 1s ease-in-out;
    -o-transition                      : all 1s ease-in-out;
    transition                         : all 1s ease-in-out;
    transition-timing-function         : ease;
    -webkit-transition-timing-function : ease; /* Safari and Chrome */
   }

      div.slider nav {
          position: absolute;
          width: 100%;
          height: 40px;
          bottom: 0;
          background-color: rgba(0,0,0,.5);
          z-index: 1;
      }
      div.slider nav button {
          position: absolute;
          width: 40px;
          height: 40px;
          cursor: pointer;
      }
      div.slider nav button.anterior {
          left: 10%;
      }
      div.slider nav button.proximo {
          right: 10%;
      }

           Este é 1

           Este é 2

           Este é 3

        <button class="anterior setaEsquerda"></button>
        <button class="proximo setaDireita"></button>

O objetivo é fazer como que os textos que estão aparecendo apareça sobre a barra de navegação. Isto é, em cima dela porém com a mesma altura e que também o efeito de subir e descer do texto ocorra levemente dentro dessa altura.
Onde estou errando?
Answer: Utilize breakpoints para ajustar a cada resolução de tela.

$(document).ready(function(){
    function animaTextos(){
     var interval;
     var contador = 1;
     var funcao = function() {
      var corrente = $('div.slider ul.slide li').length;
      if(corrente == contador) {
       $('div.slider ul.slide li.tituloAtivo').removeClass('tituloAtivo');
       $('div.slider ul.slide li').first().addClass('tituloAtivo');
       contador = 1;
      } else {
       contador++;
       $('div.slider ul.slide li.tituloAtivo').removeClass('tituloAtivo').next().addClass('tituloAtivo');

      }
     };
     interval = setInterval(funcao, 1000);
    }

    animaTextos();
   });

      window.onload = function() {

         var indexAtiva = 0;

         const lis = document.getElementsByClassName('slider').item(0).getElementsByTagName('li');

         function slider(s) {

            for (i = 0; i < lis.length; i++) {
               lis[i].classList.remove('ativa');
            }

            // aqui irá tratar o clique no "Anterior".
            // É preciso tratar de 3 formas diferentes
            // dependendo do valor de indexAtiva.
            // Veja que o valor de indexAtiva, em cada caso,
            // irá receber o valor do índice ativado
            if(s){
               // significa que o próximo a mostrar será o
               // slide de índice 1, então está sendo exibido o 0.
               // neste caso eu ativo o último da array
               if(indexAtiva == 1){
                  lis[lis.length-1].className = 'ativa';
                  indexAtiva = lis.length-1;

               // aqui diz que está exibindo o último,
               // logo próximo será o primeiro (índice 0).
               // Então eu ativo o antepenúltimo da array
               }else if(indexAtiva == 0){
                  lis[lis.length-2].className = 'ativa';
                  indexAtiva = lis.length-2;

                // aqui é quando não for nenhum dos casos anteriores.
                // Eu diminuo 2 índices porque mais a frente será
                // incrementado com +1
               }else{
                  lis[indexAtiva-2].className = 'ativa';
                  indexAtiva -= 2;
               }
            }else{
               // aqui é quando for clicado o botão "próximo"
               // ou quando nenhum botão for clicado
               lis[indexAtiva].className = 'ativa';
            }

            indexAtiva = indexAtiva + 1 == lis.length ? 0 : indexAtiva+=1;

            tempo = setTimeout(slider, 3000);
         }

         slider();

         var slider1 = document.getElementsByClassName('slider')[0]
         var nav = slider1.getElementsByTagName('nav')[0]
         var anterior = nav.getElementsByClassName('anterior')[0]
         var proximo = nav.getElementsByClassName('proximo')[0]

         anterior.onclick = function(){
            clearTimeout(tempo);
            slider(true);
         }

         proximo.onclick = function(){
            clearTimeout(tempo);
            slider();
         }

      }
* {
          margin: 0;
          padding: 0;
          border: none;
          outline: 0;
      }
      body {
          width: 100vw;
      }
      ul {
          list-style: none;
      }
   .setaDireita {
    background-image:url(_img/_bannerImgs/direita.png);
    background-repeat:no-repeat;
    background-position: center center;
   }
   .setaEsquerda {
    background-image:url(_img/_bannerImgs/esquerda.png);
    background-repeat:no-repeat;
    background-position: center center;
   }
      .fade {
          -webkit-animation-name: fade;
          -webkit-animation-duration: 1.5s;
          animation-name: fade;
          animation-duration: 1.5s;
      }
       @-webkit-keyframes fade {
       from {
       opacity: .4
      }
       to {
       opacity: 1
      }
      }
       @keyframes fade {
       from {
       opacity: .4
      }
       to {
       opacity: 1
      }
      }
      @keyframes slider {
       0% {
       transform: scale(1);
      }
       100% {
       transform: scale(1.1);
      }
      }
      div.slider {
          position: relative;
          width: 100%;
          overflow: hidden;
      }
      div.slider ul.slide {
      }
      div.slider ul.slide li {
          display: none;
      }
      .ativa {
          display: block !important;
      }
      div.slider ul.slide li img {
          position: relative;
          width: 100%;
          animation: slider 1s linear, fade 1s linear;
          animation-fill-mode: forwards;
      }
      div.slider ul.slide li span {
          position: absolute;
          width: 200px;
          left: calc(50% - 100px);
          line-height: 40px;
          margin-top: 29%;
          text-align: center;
          color: rgb(255,255,255);
          z-index: 2;

    opacity                            : 0;
    top                                : 5px;
    -webkit-transition                 : all 0.5s ease-in-out;
    -moz-transition                    : all 0.5s ease-in-out;
    -o-transition                      : all 0.5s ease-in-out;
    transition                         : all 0.5s ease-in-out;
    transition-timing-function         : ease;
    -webkit-transition-timing-function : ease; /* Safari and Chrome */
      }

   div.slider ul.slide li.tituloAtivo span {
    font-size:30px;
    opacity                            : 1;
    top                                : 0;
    -webkit-transition                 : all 1s ease-in-out;
    -moz-transition                    : all 1s ease-in-out;
    -o-transition                      : all 1s ease-in-out;
    transition                         : all 1s ease-in-out;
    transition-timing-function         : ease;
    -webkit-transition-timing-function : ease; /* Safari and Chrome */
   }

      div.slider nav {
          position: absolute;
          width: 100%;
          height: 40px;
          bottom: 0;
          background-color: rgba(0,0,0,.5);
          z-index: 1;
      }
      div.slider nav button {
          position: absolute;
          width: 40px;
          height: 40px;
          cursor: pointer;
      }
      div.slider nav button.anterior {
          left: 10%;
      }
      div.slider nav button.proximo {
          right: 10%;
      }

           Este é 1

           Este é 2

           Este é 3

        <button class="anterior setaEsquerda"></button>
        <button class="proximo setaDireita"></button>

Answer: Primeiro você deve fazer com que os spans tenha a mesma altura da nav, que é fixa em 40px. Depois ajustar o bottom inicial para -40px e quando receber a classe que faz a animação, para 0.
Veja os comentários no CSS para ver o que foi alterado e ajustado:

$(document).ready(function(){
    function animaTextos(){
     var interval;
     var contador = 1;
     var funcao = function() {
      var corrente = $('div.slider ul.slide li').length;
      if(corrente == contador) {
       $('div.slider ul.slide li.tituloAtivo').removeClass('tituloAtivo');
       $('div.slider ul.slide li').first().addClass('tituloAtivo');
       contador = 1;
      } else {
       contador++;
       $('div.slider ul.slide li.tituloAtivo').removeClass('tituloAtivo').next().addClass('tituloAtivo');

      }
     };
     interval = setInterval(funcao, 1000);
    }

    animaTextos();
   });

      window.onload = function() {

         var indexAtiva = 0;

         const lis = document.getElementsByClassName('slider').item(0).getElementsByTagName('li');

         function slider(s) {

            for (i = 0; i < lis.length; i++) {
               lis[i].classList.remove('ativa');
            }

            // aqui irá tratar o clique no "Anterior".
            // É preciso tratar de 3 formas diferentes
            // dependendo do valor de indexAtiva.
            // Veja que o valor de indexAtiva, em cada caso,
            // irá receber o valor do índice ativado
            if(s){
               // significa que o próximo a mostrar será o
               // slide de índice 1, então está sendo exibido o 0.
               // neste caso eu ativo o último da array
               if(indexAtiva == 1){
                  lis[lis.length-1].className = 'ativa';
                  indexAtiva = lis.length-1;

               // aqui diz que está exibindo o último,
               // logo próximo será o primeiro (índice 0).
               // Então eu ativo o antepenúltimo da array
               }else if(indexAtiva == 0){
                  lis[lis.length-2].className = 'ativa';
                  indexAtiva = lis.length-2;

                // aqui é quando não for nenhum dos casos anteriores.
                // Eu diminuo 2 índices porque mais a frente será
                // incrementado com +1
               }else{
                  lis[indexAtiva-2].className = 'ativa';
                  indexAtiva -= 2;
               }
            }else{
               // aqui é quando for clicado o botão "próximo"
               // ou quando nenhum botão for clicado
               lis[indexAtiva].className = 'ativa';
            }

            indexAtiva = indexAtiva + 1 == lis.length ? 0 : indexAtiva+=1;

            tempo = setTimeout(slider, 3000);
         }

         slider();

         var slider1 = document.getElementsByClassName('slider')[0]
         var nav = slider1.getElementsByTagName('nav')[0]
         var anterior = nav.getElementsByClassName('anterior')[0]
         var proximo = nav.getElementsByClassName('proximo')[0]

         anterior.onclick = function(){
            clearTimeout(tempo);
            slider(true);
         }

         proximo.onclick = function(){
            clearTimeout(tempo);
            slider();
         }

      }
* {
          margin: 0;
          padding: 0;
          border: none;
          outline: 0;
      }
      body {
          width: 100vw;
      }
      ul {
          list-style: none;
      }
   .setaDireita {
    background-image:url(_img/_bannerImgs/direita.png);
    background-repeat:no-repeat;
    background-position: center center;
   }
   .setaEsquerda {
    background-image:url(_img/_bannerImgs/esquerda.png);
    background-repeat:no-repeat;
    background-position: center center;
   }
      .fade {
          -webkit-animation-name: fade;
          -webkit-animation-duration: 1.5s;
          animation-name: fade;
          animation-duration: 1.5s;
      }
       @-webkit-keyframes fade {
       from {
       opacity: .4
      }
       to {
       opacity: 1
      }
      }
       @keyframes fade {
       from {
       opacity: .4
      }
       to {
       opacity: 1
      }
      }
      @keyframes slider {
       0% {
       transform: scale(1);
      }
       100% {
       transform: scale(1.1);
      }
      }
      div.slider {
          position: relative;
          width: 100%;
          overflow: hidden;
      }
      div.slider ul.slide {
      }
      div.slider ul.slide li {
          display: none;
      }
      .ativa {
          display: block !important;
      }
      div.slider ul.slide li img {
          position: relative;
          width: 100%;
          animation: slider 1s linear, fade 1s linear;
          animation-fill-mode: forwards;
      }
      div.slider ul.slide li span {
         height: 40px; /* adicionado */
          position: absolute;
          width: 200px;
          left: calc(50% - 100px);
          line-height: 40px;
          bottom: -40px !important; /* ajustado */
          text-align: center;
          color: rgb(255,255,255);
          z-index: 2;

    opacity                            : 1;
    /* top                                : 85px; removido */
    -webkit-transition                 : all 0.5s ease-in-out;
    -moz-transition                    : all 0.5s ease-in-out;
    -o-transition                      : all 0.5s ease-in-out;
    transition                         : all 0.5s ease-in-out;
    transition-timing-function         : ease;
    -webkit-transition-timing-function : ease; /* Safari and Chrome */
      }

   div.slider ul.slide li.tituloAtivo span {
    font-size:30px;
    opacity                            : 1;
    /*top                                : 0; removido */
        bottom: 0 !important;/* adicionado */
    -webkit-transition                 : all 1s ease-in-out;
    -moz-transition                    : all 1s ease-in-out;
    -o-transition                      : all 1s ease-in-out;
    transition                         : all 1s ease-in-out;
    transition-timing-function         : ease;
    -webkit-transition-timing-function : ease; /* Safari and Chrome */
   }

      div.slider nav {
          position: absolute;
          width: 100%;
          height: 40px;
          bottom: 0;
          background-color: rgba(0,0,0,.5);
          z-index: 1;
      }
      div.slider nav button {
          position: absolute;
          width: 40px;
          height: 40px;
          cursor: pointer;
      }
      div.slider nav button.anterior {
          left: 10%;
      }
      div.slider nav button.proximo {
          right: 10%;
      }

           Este é 1

           Este é 2

           Este é 3

        <button class="anterior setaEsquerda"></button>
        <button class="proximo setaDireita"></button>

Comment: Desta forma não dá porque se o usuário clicar nas setas, para direita e para a esquerda, o texto não vai mais condizer com a imagem. No caso, o texto é uma descrição da imagem entende?
Comment: Mas a função que anima o texto é independente da que muda os slides. Teria que fazer uma chamada para a função do texto quando um botão for clicado. Nem no seu código original isso está funcionando direito. Apenas propus o que pediu a pergunta, que é ajustar os spans dentro da nav.
Comment: Pronto, não mexi em nada do JS, apenas no CSS.
Answer: Bom, vou dar a minha resposta.
Também pode ser visualizada online em Aqui
Resolvi deixar dentro do bloco com a imagem mesmo e fazer uma animação mais alta;
Mas ainda preciso de ajuda com 2 coisas:
1) Notem que, quando aparece o efeito faide, parece que o texto some (tem que olhar com atenção pois não é sempre que ocorre).
2) Não estou conseguindo compatibilizar os tempos das 3 animações para rodarem ao mesmo tempo.
Segue a resposta:

   $(document).ready(function(){
    function animaTextos(){
     var interval;
     var contador = 1;
     var funcao = function() {
      var corrente = $('div.slider ul.slide li').length;
      if(corrente == contador) {
       $('div.slider ul.slide li.tituloAtivo').removeClass('tituloAtivo');
       $('div.slider ul.slide li').first().addClass('tituloAtivo');
       contador = 1;
      } else {
       contador++;
       $('div.slider ul.slide li.tituloAtivo').removeClass('tituloAtivo').next().addClass('tituloAtivo');

      }
     };
     interval = setInterval(funcao, 1000);
    }

    animaTextos();
   });

      window.onload = function() {

         var indexAtiva = 0;

         const lis = document.getElementsByClassName('slider').item(0).getElementsByTagName('li');

         function slider(s) {

            for (i = 0; i < lis.length; i++) {
               lis[i].classList.remove('ativa');
            }

            // aqui irá tratar o clique no "Anterior".
            // É preciso tratar de 3 formas diferentes
            // dependendo do valor de indexAtiva.
            // Veja que o valor de indexAtiva, em cada caso,
            // irá receber o valor do índice ativado
            if(s){
               // significa que o próximo a mostrar será o
               // slide de índice 1, então está sendo exibido o 0.
               // neste caso eu ativo o último da array
               if(indexAtiva == 1){
                  lis[lis.length-1].className = 'ativa';
                  indexAtiva = lis.length-1;

               // aqui diz que está exibindo o último,
               // logo próximo será o primeiro (índice 0).
               // Então eu ativo o antepenúltimo da array
               }else if(indexAtiva == 0){
                  lis[lis.length-2].className = 'ativa';
                  indexAtiva = lis.length-2;

                // aqui é quando não for nenhum dos casos anteriores.
                // Eu diminuo 2 índices porque mais a frente será
                // incrementado com +1
               }else{
                  lis[indexAtiva-2].className = 'ativa';
                  indexAtiva -= 2;
               }
            }else{
               // aqui é quando for clicado o botão "próximo"
               // ou quando nenhum botão for clicado
               lis[indexAtiva].className = 'ativa';
            }

            indexAtiva = indexAtiva + 1 == lis.length ? 0 : indexAtiva+=1;

            tempo = setTimeout(slider, 4000);
         }

         slider();

         var slider1 = document.getElementsByClassName('slider')[0]
         var nav = slider1.getElementsByTagName('nav')[0]
         var anterior = nav.getElementsByClassName('anterior')[0]
         var proximo = nav.getElementsByClassName('proximo')[0]

         anterior.onclick = function(){
            clearTimeout(tempo);
            slider(true);
         }

         proximo.onclick = function(){
            clearTimeout(tempo);
            slider();
         }

      }
      * {
          margin: 0;
          padding: 0;
          border: none;
          outline: 0;
      }
      body {
          width: 100vw;
      }
      ul {
          list-style: none;
      }
   .setaDireita {
    background-image:url(_img/_bannerImgs/direita.png);
    background-repeat:no-repeat;
    background-position: center center;
   }
   .setaEsquerda {
    background-image:url(_img/_bannerImgs/esquerda.png);
    background-repeat:no-repeat;
    background-position: center center;
   }
      .fade {
          -webkit-animation-name: fade;
          -webkit-animation-duration: 1.5s;
          animation-name: fade;
          animation-duration: 1.5s;
      }
       @-webkit-keyframes fade {
       from {
       opacity: .4
      }
       to {
       opacity: 1
      }
      }
       @keyframes fade {
       from {
       opacity: .4
      }
       to {
       opacity: 1
      }
      }
      @keyframes slider {
       0% {
       transform: scale(1);
      }
       100% {
       transform: scale(1.1);
      }
      }
      div.slider {
          position: relative;
          width: 100%;
          overflow: hidden;
      }
      div.slider ul.slide {
      }
      div.slider ul.slide li {
          display: none;
      }
      .ativa {
          display: block !important;
      }
      div.slider ul.slide li img {
          position: relative;
          width: 100%;
          animation: slider 1.5s linear, fade 1.5s linear;
          animation-fill-mode: forwards;
      }
      div.slider ul.slide li span {
          position: absolute;
          width: 500px;
          left: calc(50% - 250px);

    font-family: 'Lato', sans-serif;
    letter-spacing: 5px;
    text-transform: uppercase;
          text-align: center;
          color: rgb(255,255,255);

    opacity : 0;
    top : 60%;
    font-size : 4vw;
    -webkit-transition : all 1s ease-in-out;
    -moz-transition : all 1s ease-in-out;
    -o-transition : all 1s ease-in-out;
    transition : all 1s ease-in-out;

          z-index: 2;
      }

   div.slider ul.slide li.tituloAtivo span {
    text-decoration : none;
    opacity : 1;
    top : 20%;
    -webkit-transition : all 1.5s ease-in-out;
    -moz-transition : all 1.5s ease-in-out;
    -o-transition : all 1.5s ease-in-out;
    transition : all 1.5s ease-in-out;
   }

      div.slider nav {
          position: absolute;
          width: 100%;
          height: 40px;
          bottom: 0;
          background-color: rgba(0,0,0,.5);
          z-index: 1;
      }
      div.slider nav button {
          position: absolute;
          width: 40px;
          height: 40px;
          cursor: pointer;
      }
      div.slider nav button.anterior {
          left: 10%;
      }
      div.slider nav button.proximo {
          right: 10%;
      }

           Este é 1

           Este é 2

           Este é 3

        <button class="anterior setaEsquerda"></button>
        <button class="proximo setaDireita"></button>


Do these two random variables have the same asymptotic distribution?

Question: Let $\{X_k\}$ be a sequence of dependent random variables with mean 0. Define $\bar{Y}_k = \frac{1}{\sqrt k}\sum_{i=1}^k X_i$.
Let $\{W_k\}$ be a sequence of i.i.d. random variables with mean 1 and variance 1. Define $\bar{Z}_k = \frac{1}{\sqrt k}\sum_{i=1}^k W_i X_i$.
It is known that $\bar{Y}_k \implies \mathcal{N}(0,V)$, where $\implies$ denotes convergence in distribution, and $V$ is some covariance matrix.
Can we also say that $\bar{Z}_k$ converges to the same distribution? How would one prove this rigorously? And does this imply that $\bar{Y}_k$ and $\bar{Z}_k$ are asymptotically equivalent, in some sense?'
The main problem I see here is the dependence in the sequence $\{X_k\}$. If they were i.i.d., then the variance of the sum becomes the sum of variances, and the proof becomes straightforward.
Comment: It is not generally true that the standardized average of dependent random variables converge to a normal. Furthermore, $V$ is not a covariance matrix. It is just a value.
Answer: In general, no.
For example, suppose $A_k$ are iid $N(0,1)$ and $B_k$ are also iid $N(0,1)$ and $X_{2k}=A_k+B_k$, $X_{2k+1}= A_k-B_k$.  Then the $B_k$ all cancel and
$$\bar Y_{2k}= \frac{2}{\sqrt{2k}}\sum_k A_k\sim N(0, 2)$$
Suppose $W_k$ is binary with values 0 and 2. Instead of the $B_k$  all cancelling, about half of them will be present once, and the variance of $\bar Z$ will be larger than that of $\bar Y$.
Update: more generally, the $W_kX_k$ are uncorrelated,
$$\mathrm{var}[\bar Z_k] = \frac{1}{k}\sum_k \mathrm{var}[W_kX_k]=\frac{1}{k}\sum_k \mathrm{var}[X_k]$$
Independence (or at least exchangeability) actually matters for these multiplier results; it's not just a technical convenience.
Comment: Are you sure about the assertion you make in the "Update" section? It appears that what you write would be correct if $E(W) = 0$. But the OP assumes that $E(W)=1$.
Answer: Assume that the $X_k$'s are jointly independent and identically distributed (with zero mean), so are the $W_k$'s (with mean equal to unity and variance equal to unity as are the premises), and they are also jointly independent in between them.
Then
$${\rm var}[\bar{Z}_k] = {\rm var}\left[\frac{1}{\sqrt k}\sum_{i=1}^k W_i X_i\right] = \frac1 k \sum_{i=1}^k {\rm var}[W_i X_i] = {\rm var}[WX]. $$
Now,
$${\rm var}[WX] = E\left[WX\right]^2 - \left(E[WX]\right)^2 = E\left[W^2X^2\right] - \left(E[WX]\right)^2.$$
Due to full independence we can separate expected values,
$$E\left[W^2X^2\right] = E\left[W^2\right] E\left[X^2\right], \; {\rm and}\; E[WX] = E[W]E[X].$$
By the premises, $E[X] =0$, so the second component vanishes. Also, because again $E[X] = 0$, we have that ${\rm var}[X] = E[X^2]$. So we arrive at
$${\rm var}[WX] = E[W^2] {\rm var}[X].$$
Now, and since $E[W]=1$,
$${\rm var}[W] \equiv E[W^2] - \left(E[W]\right)^2 = E[W^2] - 1 \implies E[W^2] = 1 + {\rm var}[W].$$
So we obtain
$${\rm var}[WX] = \left(1+{\rm var}[W]\right) \cdot {\rm var}[X] \neq {\rm var}[X].$$
For ${\rm var}[W]=1$ we get
$${\rm var}[\bar{Z}_k] = {\rm var}[WX] = 2{\rm var}[X].$$
So, the side answer is "no, even if we had full independence, $\bar{Z}_k$ does not have the same variance as $\bar{Y}_k$" (the latter's variance being just ${\rm var}[X]$).