Calculate Database Field Value and Send to Views as New Field

Question: I have a database field which stores a timestamp. This timestamp is sent to a custom views provider via hook_views_data(). This timestamp field is created as a date field to utilize the date format options from views.
$data['module']['timestamp'] = [
  'title' => t('Timestamp'),
  'help' => t('Timestamp from module'),
  'field' => [
    'id' => 'date',
  ],
  'sort' => [
    'id' => 'date',
  ],
  'filter' => [
    'id' => 'date',
  ],
];

In another views field (but with the same DB field), I would like to get the raw field value and run it through something like:
if (field_value > (time() - 800))

This is a custom module and would prefer not to have any more dependencies. Can this be achieved with hook_views_data() or hook_views_pre_render() or such?
I know there is a contributed module https://www.drupal.org/project/computed_field, but again hoping there is a way in those hooks, or in the view...
The DB table is created with hook_install() and the desired timestamp field output after check would be markup. Happy if it is just sent as markup to the views field.

I've figured how to access the field values with hook_views_pre_render() as such:
function hook_views_pre_render(&$view) {
  $result = $view->result;
  foreach ($result as $key => $row) {
    kpr($result[$key]->field_name);
    if ($result[$key]->timestamp > (time() - 800)) {
      // Can I do anything here?
    }
    else {
      //
    }
  }
}

Unfortunately, that is not the most important piece of the puzzle. And it is not possible to just add $data['module']['key'] to my hook_views_data() as this requires the unique DB field to exist.
In my use case, I'd be happy if I could rewrite the original timestamp field and append this markup to it.
Comment: If I do `$result[$key]->timestamp = $result[$key]->timestamp . $myAddedData;` inside my `if` statement, it does indeed rewrite the value (though doesn't seem the right way), but I'm hoping I can have this as a field in views.
Answer: Take a look at this, it shows how you can create custom fields that you can use within views https://www.webomelette.com/creating-custom-views-field-drupal-8
I've followed this recently and seems to work well
Comment: This has worked well. Having the `public function query()` empty was the trick so that views ignored there is no DB field. Maybe add that to your answer? Just a note, to kpr() in `public function render(ResultRow $values)` I had to `return kpr($values);` to have my kpr() sent to display. This seems like a valid approach to me.


borel measurable functions and measurable functions

Question: Say you are given the Lebesgue measure on the real line and a Lebesgue measurable function $f$. Here Lebesgue measure is a complete measure (defined for some non-Borel set). And note that in the case of real line, the borel sets are just the sets that are in the sigma-algebra generated by the open sets.
I remember seeing something like: we can change $f$ on a set of measure $0$, and turn $f$ into a Borel measurable function.
Now I don't quite know how I can prove it or if it is even true.
I think if it is indeed true, the same proof should work for any metric space and for any measure that satisfies:

$\mu(A)=\inf_{O\supset A} \mu(A)$ for all measurable $A$, where the infimum is taken over all such open sets $O$.
$\mu(A)=\sup_{K\subset A} \mu(A)$ for all measurable $A$, where the infimum is taken over all such compact sets $K$.

Can anybody give me any hint how one might prove this? Or if it's incorrect.
Comment: This (http://math.stackexchange.com/questions/1199650/completion-and-function/1200239#1200239) should be helpful.
Comment: @PhoemueX Thanks, that solves the problem!
Answer: For every rational $r$ let $A_r = \{x: f(x) \le r\}$.  There is a $G_\delta$ set
$B_r$ such that $A_r \subseteq B_r$ and $m(B_r \backslash A_r) = 0$.
Define $g(x) = \inf \{r \in \mathbb Q: x \in B_r\}$.
Comment: Thanks! Very neat construction!


Toric Varieties Exercise 1.1.1

Question: I've began working through some of Toric Varieties by Cox, Little, and Schneck, and need some basic help with this inclusion in problem 1.1.1.
Let $I = \langle x_ix_{j+1} - x_{i+1}x_j | 0 \leq i < j \leq d \rangle \subseteq \mathbb{C}[x_0,...,x_d]$
and let $\hat{C}_d$ be the surface paramaterized by
$$\phi(s,t) = (s^d,s^{d-1}t,...,st^{d-1},t^d) \in \mathbb{C}^{d+1}.$$
I just need to show that $V(I) = \phi(\mathbb{C}^2) \subseteq \mathbb{C}^{d+1}$.
Clearly $I = \langle x_0x_2 + x_1^2 \rangle$ and $\phi(\mathbb{C}^2) = (s^2,st,t^2)$, which makes the $\phi(\mathbb{C}^2) \subseteq V(I)$ inclusion very easy as
$$s^2t^2 -(st)^2 \implies s^2t^2 - s^2t^2 = 0.$$
The reverse inclusion eludes me somewhat embarrassingly. I know I can show this very easily using Grobner Bases and the Elimination/Extension Theorem but I would prefer a method that does not rely on computer algebra.
Answer: The observation is that, the generators of $I$ are related to the following matrix
$$A(x)=\begin{pmatrix} x_0&x_1&\cdots&x_{d-2}&x_{d-1}\\x_1&x_2&\cdots&x_{d-1}&x_d\end{pmatrix}.$$
In fact, the shown generators of $I$ are exactly the maximal minors by $i$-th and $j$-th columns of $A$, so we have the following interpretation.
$$x=(x_0,\dots,x_d)\in V(I) \Longleftrightarrow \text{all max. minors of $A(x)$ vanish} \Longleftrightarrow \mathrm{rank }\ A(x)\leq 1.$$
Now, to see $V(I)\subset\phi(\mathbb{C}^2)$ is not difficult: if $x\in V(I)$ then $\mathrm{rank }\ A(x)\leq 1$ and so we have for some $(q,p)\neq (0,0)$,
$$qA(x)^{(1)}-pA(x)^{(2)}=0, \text{ i.e., }qx_i=px_{i+1}\ (0\leq i\leq d-1)$$
where $A(x)^{(i)}$ denotes the $i$-th row of $A(x)\ (i=1,2)$.
When $p=0$, we have $A(x)^{(1)}=0$ and
$x$ is the image of $(0,\sqrt[d]{x_d})\in\mathbb{C}^2$. When $p\neq 0$, we have from the equations $$x=(x_0,(q/p)x_0,\dots,(q/p)^dx_0),$$
so letting $s=\sqrt[d]{x_0}$ and $t=sq/p$ gives the desired form
$$x=(s^d,ts^{d-1},\dots,t^d).$$
The other inclusion will be more obvious.
Notes: This map $\phi$ is a form of famous one, called the Veronese embedding of $\mathbb{P}^1$. The observation above is based on that its image is a determinantal variety.
Comment: Please use markdown to format text, i.e. `*italics*` for *italics*, instead of \textit. I've made the change for you this time.
Comment: Ah good, this is exactly what I was looking for. I know I can also show this using Grobner Basis Calculations and Elimination Theory but I was looking for a more instructive approach rather than relying on computer algebra.
Comment: Thank you for pointing it out, @KReiser. I never knew it.
Comment: I'm happy to be of your help. @CookieBouquets

Toric Varieties Exercise 1.1.1


Is it possible to display a non-existent url using an htacess file

Question: Not sure if this is possible.  I have a .html file in a sub-directory. I want to find a way to set it up, using HTACCESS I imagine, to display an alternate URL when that file/directory is accessed.
So, if the inbound URL is something like http://example.com/target-directory/file.html how can I use HTACCESS to force the browser to display http://renamedURL.com/ instead.
Possible? Or am I just a crazy-coo-coo dreamer?
Thanks!
Answer: Yes. You can
RewriteEngine on
RewriteRule ^target-directory/file.html$ http://renamedURL.com/ [L]

Answer: You can use:
RewriteEngine on

RewriteCond %{THE_REQUEST} \s/+target-directory/file\.html[?\s] [NC]
RewriteRule ^ http://renamedURL.com/ [R=302,L,NE]

RewriteRule ^/?$ /target-directory/file.html [L]


How does explaining away cause problems for learning?

Question: In one of his lectures Geoff Hinton explains that a big problem of sigmoid belief nets is the explaining away phenomenon. I didn't fully understand this. I see that the induced width of the graph representing Variable Elimination might increase due to the fill-in edges being introduced at the V structures. But is there a more intuition-based way to see this, rather than an appeal to the rigor of the induced graph?
Consider a simple example where the RVs are: did an earthquake occur, did a burglary occur, and did an alarm trigger. The graph is a V structure with the Earthquake and the Burglary as the parents and the Alarm as the child. If a human being were to try and reason about the true $P(Alarm|Earthquake)$ or $P(Alarm|Burglary)$ what sort of difficulty would this V-structured relationship cause?
Comment: What is the data/information that is being used to make the inference?
Comment: lets say we can collect with regularity data-vectors of the form: was there an earthquake in the last T hours?,was there a burglary in the last T hours?, did the alarm ring in in the last T hours?
Comment: Well, if that is your data - then any inference is difficult (sample size is 1).  You have also incorporated the notion of time into your data, but not into your model.
Comment: There is no need of any notion of time, Its just an example of how you would actually, physically go about collecting such data. Thus there is the usual assumption of stationarity (though we don't need to analyse that dimension of the problem ). Also, as mentioned in the previous comment, we "collect with regularity", so you don't have any dearth of data.
Comment: Although I don't have an answer to this, as I too am looking for the answer, here are two links which might be helpful: https://www.quora.com/Why-does-the-phenomenon-of-explaining-away-make-inference-difficult-in-directed-belief-nets, https://www.quora.com/What-is-an-intuitive-explanation-of-the-explaining-away-problem-in-directed-graphical-models.
Answer: The only problem I can see from such a "V structure" is that you have two "causes" - this means that there may be difficulty untangling the effect of each "parent".  In terms of your example, it could be the case that you observe "earthquake" and "burglary" together (both "on" or both "off").  So you would get a good estimate for the value $ P (alarm|earthquake \cup burglary) $ but not the marginal effects.  This is the equivalent of multicolinearity in linear regression.  If you are using the vector $ (e_i, b_i, a_i) $ (e for earthquake, etc) and assuming a binomial model your probability for the ith data point is $ p_i=e_i\theta_e + b_i\theta_b $.  The probabilities in question are $ Pr (alarm|earthquake)=\theta_e + Pr (burglary|earthquake)\theta_b $ and then $ Pr (alarm|burglary)=\theta_b + Pr (earthquake|burglary) \theta_e $
If you only observe them together $ (e_i=1, b_i=1) $ or $(e_i=0, b_i=0) $, then both probabilities are $\theta_b + \theta_e $.  This means that the data is unhelpful in choosing which variable to keep.


Deploying and starting a webdriver test program on a remote windows vm from jenkins server

Question: I have a test program in Java for testing a web app using webdriver. It builds and runs in my local machine just fine.
Now, I need to build it in jenkins, then deploy and run it on a VM running on Windows (e.g. server 2008 R2).
Obviously, the test program doesn't work on jenkins as it needs to open a browser. This cannot be done under system account in Jenkins server. So I need to deploy it to a remote machine and somehow start the test.
I've heard this can be done using ssh for a linux box, but don't know how to do it for a windows VM.
Any idea?
Answer: If you have installed jenkins as service then you need to create a JNLP node in order to run your webdriver tests.
Follow the post for creating JNLP node and running your tests on that.
http://qtp-help.blogspot.in/2013/09/setup-webdriver-maven-project-on-jenkins.html


How to find the basis for eigenspace in $\mathbb{C}^2$

Question: Can someone explain to me what is going on here?  I am following exercise where it says

find the basis for  eigenspace in $\mathbb{C}^2$ where the matrix is $\begin{bmatrix}1&5\\-2&3\end{bmatrix}$

I got the eigenvalue $ 2\pm3i$ and then did $A - \lambda_1I = 0$ (where $\lambda = 2 + 3)$ to get $\begin{bmatrix}-1-3i&5\\-2&1-3i\end{bmatrix}$
but then the author says the basis vector for the eigen space is
$v_1 = \begin{bmatrix}1-3i\\2\end{bmatrix}$.. How do they get there?
I put the matrix in RREF to get
$R_2 = R_2/-2$
$R_2 = R_1 + (1+3i)R_2$
$R_2 = \frac{R_2}{5+\frac{(i-3i)^2}{-2}}$
$R_1 = -5R_2 + R_1$
$\begin{bmatrix}-1-3i&0\\0&1\end{bmatrix}$
Comment: Remember that $$\begin{bmatrix}-1-3i&5\\0&0\end{bmatrix}$$ really means $$\left[\begin{array}{cc|c} -1-3i&5 &0\\0&0 &0\end{array}\right] \iff\begin{cases}(-1-3i)x_1+5x_2=0 \\ 0 = 0\end{cases}$$  Let $x_2 = t$, then $x_1 = \frac{-5}{-1-3i}t$.  So your eigenvectors will be of the form $$t\begin{bmatrix} \frac{-5}{-1-3i} \\ 1\end{bmatrix}$$ for all $t\in \Bbb C$.  To find *representative* eigenvectors, just choose your favorite $t$.  The author of your book takes $t=2$ (and then simplifies the first entry of the vector).
Comment: I feel confident you can figure that out for yourself.  Hint: A vector $v$ is an eigenvector of a matrix $A$ if $Av=\lambda v$ for some $\lambda\in\Bbb C$.
Comment: The first entry in $A-\lambda_1I$ should be $-1-3i$.
Comment: Typo @Moo , but I am still getting the same $rref(A)$ :(
Comment: @Yusha After your second step I get $\begin{bmatrix} -1-3i & 5 \\ 0 & 0\end{bmatrix}$ which is already in REF.
Comment: You don't even need use the matrix calculator: your first two steps are correct (except that you really should have separated your second step into two separate ones).  Go back through your calculations.
Comment: Oh I see now... now that I have $\begin{bmatrix}-1-3i&5\\0&0\end{bmatrix}$ how can I find the eigenvectors? It's confusing. would I just do $\begin{bmatrix}(-1-3i)\\0\end{bmatrix}$ and $\begin{bmatrix}-1+3i\\0\end{bmatrix}$?
Comment: Oh wait $x_2$ is free so it can be *any* number right?
Comment: so It would be like $\begin{bmatrix}1+3i\\1\end{bmatrix}$ and $\begin{bmatrix}1-3i\\1\end{bmatrix}$ right?
Comment: would the other vector then be $t \begin{bmatrix}\frac{-5}{-1+3i}\\1\end{bmatrix}$?
Answer: The characteric polynomial of
$
A=
\left[\begin{array}{rr}
1 & 5 \\
-2 & 3
\end{array}\right]
$
is
$$
\chi_A(t)=t^{2} - 4 t + 13
$$
The eigenvalues of $A$ are thus
$$
\frac{4\pm\sqrt{4^2-4(1)(13)}}{2}=2\pm3\,i
$$
Now, to compute a basis for the eigenspace $E_{2+3\,i}$, note that
$$
E_{2+3\,i}=\DeclareMathOperator{Null}{Null}\Null\bigl((2+3\,i)I-A\bigr)=\Null\left[\begin{array}{rr}
3 i + 1 & -5 \\
2 & 3 i - 1
\end{array}\right]
$$
We can row-reduce in two steps

scale row 1 by $-3/10\,i + 1/10$
add $-2$ times row 1 to row 2

This gives
$$
\DeclareMathOperator{rref}{rref}\rref\left[\begin{array}{rr}
3 i + 1 & -5 \\
2 & 3 i - 1
\end{array}\right]=
\left[\begin{array}{rr}
1 & \frac{3}{2} i - \frac{1}{2} \\
0 & 0
\end{array}\right]
$$
Hence
$$
E_{2+3\,i}=\DeclareMathOperator{Span}{Span}
\Span\{\langle -1+3\,i,2\rangle\}
$$
This also implies
$$
E_{2-3\,i}=\Span\{\langle-1-3\,i,2\rangle\}
$$


When does the core search module become worth using?

Question: I mean, is there any approximate number of nodes or just website pages (or any other measures of website size) when the out of the box Drupal search module is still worth using? I understand that much depends on webserver, but there should be some general guidelines. E.g., should I use the core search module if I have a Drupal website with 5K nodes?
Comment: It's not size of database but the type of queries that should primarily determine the choice of search solution. If your content is in a narrow field in which the search terms are likely to be predictable and well-matched to title and body content, then core search will probably be fine. But that's the exception in my experience.
Comment: Related: [Search API vs Apache Solr Search Integration in Drupal 7?](https://drupal.stackexchange.com/q/15508/1908)
Answer: It really depends on your situation.
You should use Drupal search core module only when you don't have any performance issues (as it's using database backend), your site is not so complex (in terms of search functionality) or you're not advanced user and you are not looking to make make your site more complex than already is.
Please note that high traffic sites running search queries against the database can affect overall performance especially when the database becomes the bottleneck. Secondly Drupal core search doesn't scale much.
Therefore using Search module from Drupal core it's not adequate when you have thousands of nodes on site. In this case you should use either Search API (with solr backend) or Apache Solr Search modules. Using Apache Solr provides advanced and accelerated search platform which features faceted search (Facet API), searching multiple sites, real-time indexing, dynamic clustering, NoSQL features, indexing attachments and many more. It's a great way to have fast access to big data on a budget. Basically Solr solutions are designed for searching the same way as Search API is designed to replace the core "Search" module.
It's also worth to mention about Elasticsearch as alternative for Solr, but it's topic for another discussion. The decision to choose whether Elasticsearch or Solr really depends on the project requirements and the decision needs to be made by experienced Drupal developer or solution architect.
In overall, Databases and Solr have complementary strengths and weaknesses, so you've to investigate these further depending on your project. However core search has a very limited functionality.
Please find the following chart which shows Drupal core's search performance vs. Solr based on its execution time.

The results are pretty clear: Drupal core's search takes longer as you put more words in the query. This may seem fair enough, as it makes the searching more complex. But when using Solr you can't barely see any difference at all. It doesn't really matter if you search for 1 or 6 keywords. The response time for a page is almost the same.
DISCLAIMER: This is not a valid test, and the result is only used here to give a glimpse of what the difference might look like. The results will most likely look different on your environment. You can see the shell scripts I used to perform the test in the document folder I pointed out earlier. All tests were performed on a system where content was using cache.

Please find the following table which is comparison Solr v.s. Relational Database:

See also:

Search API vs Apache Solr Search Integration in Drupal 7?
What are the advantages of using Apache Solr over the core search module?
Solr or database? at stackoverflow SE
Search API documentation at Drupal.org
Why use Solr? at Solr Wiki
Solr's features at Solr
Enlightening - The Dark Art of Solr Search with Drupal at annertech
Answer: Simpler Answer
The previous answer provide you the details explanation so you can determinate your own conclusion.
My personal opinion that is not worth to used the core Search. Here are my scenarios base of what you need.

If you need a very complex search (Autocomplete, Facets ) you would need Search Api.

If you can afford Solr Server go with a Search Api Solr otherwise go to Search Api Db

If you need a better way to search but not complex your website. I would recommend you to used Google CSE module . Google would craw your content and would show you better results Drupal Search Core would.


Formulário Complexo Bootstrap

Question: Estou criando um formulário de cadastro de cliente. Estou usando o framework Bootstrap v:3.3.7
meu fomulário de cadastro de cliente, vai abrir em um novo pop-up: width=1300, height=630.
Quando meu formulário está nesse tamanho, ele fica tudo no lugar, como na imagem abaixo:

O problema é quando eu reduzo um pouco ele. ele acaba se destorcendo de tal maneira que fica muito estranho:

Alguém saberia me informar como eu poderia trabalhar com as propriedades bootstrap, para que eu não perdesse as proporções dessa maneira??

@model Smc.Dominio.Model.EntidadeJuridicas.ClienteEmpresa
@{
    <link href="~/Template/SmcLayout/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href=https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet" />
    <link href="~/Content/Site.css" rel="stylesheet" />
    <link href="~/Template/Css/smc_ligth.css" rel="stylesheet" />
    <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />

}

Consulta

Cadastrar

        @*Tab Suporte Técnico*@

2

        @*Tab Principal*@

                                    Código
                                    <input class="form-control-sm" type="text" style="padding:0; border-radius:1px; width:52px" />

                                    Status Cliente
                                    <select class="form-control-sm" style="padding:0; width:134px">
                                        <option>Pré-Cadastro</option>
                                        <option>Ativo</option>
                                        <option>Bloqueado</option>
                                        <option>Cancelado</option>
                                        <option>Inativo</option>

                                    </select>

                                        Cadastro
                                        <input class="form-control-sm" type="text" style="padding:0; width:78px;" />

                                    usuário
                                    <input class="form-control-sm" type="text" style="padding:0;width:139px" />

                                    <input type="checkbox" class="form-control-label" /> Produtor Rural

                                    <input type="checkbox" class="form-control-label" /> Consumidor Final

                                <fieldset style="border:1px solid #ddd">

                                            Razão Social | Nome:

                                                <input type="text" class="form-control-sm" style="min-width:100%" />

                                            Nome Fantasia:

                                                <input type="text" class="form-control-sm" style="min-width:100%" />

                                            CNPJ | CPF:

                                                <input type="text" class="form-control-sm" style="min-width:100px" />

                                            Insc. Estadual | RG:

                                                <input type="text" class="form-control-sm" style="min-width:100px" />

                                            Suframa:

                                                <input type="text" class="form-control-sm" style="min-width:100px" />

                                            Incrição Municipal:

                                                <input type="text" class="form-control-sm" style="min-width:100px" />

                                            Sub. Trib IE:

                                                <input type="text" class="form-control-sm" style="min-width:100px" />

                                            Cane:

                                                <input type="text" class="form-control-sm" style="min-width:100px" />

                                            Ramo De Atividade:

                                                <input type="text" class="form-control-sm" style="min-width:100px" />

                                            Vendedor:

                                                <input type="text" class="form-control-sm" style="min-width:100px" />

                                            Tabela Preço:

                                                <input type="text" class="form-control-sm" style="min-width:100px" />

                                            @*Complemento P.Física:*@

                                                <button style="width:212px; height:24px; padding-top:2px" class="btn btn-info">Complemento P.Física</button>
                                                @*<input type="text" class="form-control-sm" style="min-width:100px" />*@

                                            Situação Financeira:

                                                <input type="text" class="form-control-sm" style="min-width:100px" />

                                            Limite De Créditos:

                                                <input type="text" class="form-control-sm" style="min-width:100px" />

                                </fieldset>

                                <fieldset style="border:1px solid #ddd">

                                            Rua | Avenida:

                                                <input type="text" class="form-control-sm" style="min-width:100%" />

                                        @*

                Nome Fantasia:

                    <input type="text" class="form-control-sm" style="min-width:100%" />

*@

                                            Número:

                                                <input type="text" class="form-control-sm" style="width:53px" />

                                            Bairro:

                                                <input type="text" class="form-control-sm" style="min-width:100%" />

                                            Complemento:

                                                <input type="text" class="form-control-sm" style="min-width:100%" />

                                            Região:

                                                <select class="form-control-sm" style="height: 20px;padding: 0;width: 156px">
                                                    <option>01</option>
                                                    <option>02</option>
                                                </select>

                                            Zona:

                                                <select class="form-control-sm" style="height: 20px;padding: 0;width: 156px">
                                                    <option>01</option>
                                                    <option>02</option>
                                                </select>

                                            Município:

                                                <input type="text" class="form-control-sm" style="width:218px" />

                                            Cód:

                                                <input type="text" class="form-control-sm" style="width:79px" />

                                            UF:

                                                <input type="text" class="form-control-sm" style="width:36px" />

                                            Cód:

                                                <input type="text" class="form-control-sm" style="width:36px" />

                                            CEP:

                                                <input type="text" class="form-control-sm" style="width:86px" />

                                            País:

                                                <input type="text" class="form-control-sm" style="width:185px" />

                                            Cód Pais:

                                                <input type="text" class="form-control-sm" style="width: 46px;margin-left: -10px;" />

                                </fieldset>

Mundo

Bot

Comment: Não se ofenda, mas o seu form é um dos piores que já vi! Vc destruiu o Bootstrap colocando esse monte de style="" nas tags. O seu principal ponto de início é apagar todos os styles, só isso já vai melhorar 90% o seu código.
Comment: Você tá setando muitos atributos de forma "errada" por exemplo, você tá dando margens fixadas para os inputs e alguns labels acabam ficando por cima de algum outro componente, porque você colocar as margens e alguns outros atributos que ficam bons apenas no tamanho da Tela X que eu presumo ser a sua. Então você pode melhorar isso lendo [aqui](https://v4-alpha.getbootstrap.com/components/forms/).
Também te recomendo [isso aqui](https://getbootstrap.com.br/docs/3.3/css/) e [aqui](https://getbootstrap.com.br/docs/4.1/components/forms/). Creio que será muito útil não apenas agora, mas em trabalhos
Comment: Sem problemas, justamente por eu saber que está ruim, foi que eu vim pedir ajuda. pesquisei bastante antes de vir aqui, porém não consigo compreender algumas coisas, por exemplo, quando se trabalha com a classe `.col-md-` ou `col-lg`, ou qualquer uma dessa, fica complicado, pq ou da um tamanho maior que eu preciso, ou meno, nunca consigo fazer com que se alinhe. ou fique do tamanho que eu preciso
Answer: Você precisa apenas formatar melhor seu código. Vamos lá, eu percebi que você tem um formulário bastante extenso, nesse caso, você pode utilizar diferentes estilos de acordo com os inputs.
Vou tentar exemplificar e explicar o comportamento das tags.

Primeiramente o col

Utilizando o col-sm-* ele vai escalar a partir da tela de dispositivos pequenos, posicionando os itens um embaixo do outro até dispositivos maiores onde ele se ajustará ao tamanho da página.
Se vc quiser migrar para o Bootstrap 4 tem um novo recurso que seria apenas o col. Ele vai criar colunas iguais em todos os tamanhos de tela e adaptar automaticamente pra você.
Exemplo:

.col

.col

.col

Eu também notei que você criou um grid utilizando as tags row e col em quase todo o formulário, o que não é necessário, na primeira linha por exemplo, para mostrar os itens um ao lado do outro bastava utilizar o form-inline.
Veja o exemplo:
<form class="form-inline" action="/action_page.php">

    Email address:
    <input type="email" class="form-control" id="email">

    Password:
    <input type="password" class="form-control" id="pwd">

    <input type="checkbox"> Remember me

  <button type="submit" class="btn btn-default">Submit</button>
</form>

Esse link tem alguns tutoriais de passo a passo que podem te ajudar a entender melhor o Bootstrap https://www.w3schools.com/bootstrap/bootstrap_grid_basic.asp
Comment: A classe `col` não exite no Bootstrap 3. E a forma como esta o form a responsividade vai fazer isso com ele http://prntscr.com/o3m7s2
Comment: @Geremias sim, eu sei. Na minha resposta deixo uma dica para o usuário usar o Bootstrap 4, que já existe essa tag. O form-inline é perfeito para o que ele precisa. Pois deixará os itens alinhados por padrão e ajustará automaticamente nas telas menores, como ele destaca que seu formulário fica estranho ao reduzir a tela, esse seria o objetivo. O código não está errado, apenas mal formatado. Só estudar um pouquinho a formatação do Bootstrap que encontra o caminho.

Formulário Complexo Bootstrap


What is the difference between linearly dependent and linearly correlated?

Question: Please explain what is the difference between if two variables are linearly dependent or linearly correlated.
I looked up the wikipedia article but didn't get a proper example.  Please explain it with example.
Comment: what does linear mean here? In pure maths usually it means something like this $T(x+y) = T(x) + T(y)$ or at least intuitively a line/matrix e.g. $y = ax $. Is it what it means here and if yes in what formal sense is it "linear"?
Answer: Two variables are linearly dependent if one can be written as a linear function of the other.  If two variable are linearly dependent the correlation between them is 1 or -1.  Linearly correlated just means that two variables have a non-zero correlation but not necessarily having an exact linear relationship.  Correlation is sometimes called linear correlation because the Pearson product moment correlation coefficient is a measure of the strength of the linearity in the relationship between the variables.
Comment: +1. Though, I'd rather say the Pearson coef. "is a measure of strength of linear relationship" instead of `is a measure of the degree of linearity in [= of?] the relationship`
Comment: @ttnphns Okay that sounds more appropriate.
Comment: Perhaps $\rho^2$ rather than $\rho$ would be a better measure since we don't need to hassle with $\rho$ close to $-1$ meaning a strong linear relationship (albeit with negative slope). Also, consider how much variance is explained versus non-explained, and that $\rho = 0.51$ does not provoke the statistician into turning cartwheels and doing handstands in celebration whereas $\rho^2 > 1/\sqrt{2} \approx 70\%$ is much better evidence of a positive (read, publishable) result.
Comment: what does linear mean here? In pure maths usually it means something like this $T(x+y) = T(x) + T(y)$ or at least intuitively a line/matrix e.g. $y = ax $. Is it what it means here and if yes in what formal sense is it "linear"?
Answer: In $\mathbf{R}^2$ linear dependence implies that one vector is a linear function of the other:
$$
\textbf{v}_{1}=a\textbf{v}_2.
$$
It's clear from this definition that the two variables would move in lock-step, implying a correlation of $1$ or $-1$ depending on the value of $a$. To more fully understand the differences and connections between the concepts, however, I think it's beneficial to consider the geometry involved.
The graph below shows an example of the formula for linear dependence. You can see that the vectors are linearly dependent because one is simply a multiple of the other.

This is in contrast to linear independence, which in $\mathbf{R}^2$ is described by:
$$
\textbf{v}_{1}\neq a\textbf{v}_2
$$
for vectors $\textbf{v}_1, \textbf{v}_2 \neq \textbf{0}.$ An example of linear independence can be seen in the graphic below.

The most extreme version of linear independence is orthogonality, defined for vectors $\textbf{v}_1, \textbf{v}_2$ as:
$$
\textbf{v}_{1}^T \textbf{v}_{2} = 0.
$$
When graphed in $\mathbf{R}^2$, orthogonality corresponds to the vectors $\textbf{v}_{1}$ and $\textbf{v}_2$ being perpendicular to one another:

Now, consider Pearson's correlation coefficient:
$$
\rho_{\textbf{v}_{1}\textbf{v}_{2}} = \frac{(\textbf{v}_{1}-\bar{v}_{1}\textbf{1})^T(\textbf{v}_{2}-\bar{v}_{2}\textbf{1})}{\sigma_{\textbf{v}_{1}}\sigma_{\textbf{v}_{2}}}.
$$
Note that if the vectors $(\textbf{v}_{1}-\bar{v}_{1}\textbf{1})$ and $(\textbf{v}_{2}-\bar{v}_{2}\textbf{1})$ are orthogonal then the numerator of Pearson's coefficient is zero, implying that the variables $\textbf{v}_{1}$ and $\textbf{v}_{2}$ are uncorrelated. This illustrates an interesting connection between linear independence and correlation: linear dependence between the centered versions of the variables $\textbf{v}_{1}$ and $\textbf{v}_{2}$ corresponds to a correlation of $1$ or $-1$, non-orthogonal linear independence between the centered versions of $\textbf{v}_{1}$ and $\textbf{v}_{2}$ corresponds to a correlation between $0$ and $1$ in absolute value, and orthogonality between the centered versions of $\textbf{v}_{1}$ and $\textbf{v}_{2}$ corresponds to a correlation of $0$.
Thus, if two vectors are linearly dependent the centered versions of the vectors will also be linearly dependent, i.e. the vectors are perfectly correlated. When two linearly independent vectors (orthogonal or not) are centered the angle between the vectors may or may not change. Thus for linearly independent vectors the correlation may be positive, negative, or zero.
Comment: what does linear mean here? In pure maths usually it means something like this $T(x+y) = T(x) + T(y)$ or at least intuitively a line/matrix e.g. $y = ax $. Is it what it means here and if yes in what formal sense is it "linear"?
Answer: Let f(x) and g(x) be functions.
For f(x) and g(x) to be linearly independent we must have
a*f(x) + b*g(x) = 0 if and only if a=b=0.
In other words there is no c such that a or b is not zero but
a*f(c) + b*g(c) = 0
If there is such a c, then we say that f(x) and g(x) are linearly dependent.
e.g.
f(x) = sin(x) and g(x) = cos(x) are linearly independent
f(x) = sin(x) and g(x) = sin(2x) are not linearly dependent (Why?)
Comment: With the definition you're using there, there *can* be a $c$ such that $a f(c) + b g(c) = 0$; they're only linearly dependent if it happens for all $x$ in the considered domain; for example, consider your second example, with $c=\pi/3$. (Also, I think there's a problem with your first example)
Comment: what does linear mean here? In pure maths usually it means something like this $T(x+y) = T(x) + T(y)$ or at least intuitively a line/matrix e.g. $y = ax $. Is it what it means here and if yes in what formal sense is it "linear"?


Contextual Filters via Taxonomy

Question: I am in the process of creating a View for my Drupal site and I am attempting to add a contextual filter by Taxonomy so I've added the Content: Has Taxonomy term ID (with depth) filter and selected the Specify validation criteria option and selected the Taxonomy that I wanted to work with. I also used the filter value type of Term name converted to term ID yet when I attempt to preview the filtered elements, I get the no results behavior. What should I be typing to call the filtered elements correctly?
Atm, to provide a concrete example, I have tried my_view/mississippi-river to call all nodes tagged with the Mississippi River taxonomy term via hierarchical select. Again, this leads me to the no results behavior. Additionally, how would I call a child of the Mississippi River Taxonomy term? Any ideas?
Answer: Contextual filters are just the term. So in the contextual filter input box for the Views Admin you would put mississippi-river as an example. In addition to Term name converted to Term ID you want to be sure you check the box for convert spaces to dashes further down in the specify validation criteria or else "mississippi-river" will not be found because it's expecting a space and you're providing a dash.
For the parent/child filters you're trying to achieve look at Taxonomy Edge. The -dev release contains some contextual filters for "parents" and "children" of stuff.
Comment: also make sure that you have selected **Save term lineage**
Comment: Thank you for your feedback. I have double-checked everything yet I am still unable to get the desired result. Could it be due to the fact that I'm using the `Hierarchical select` module as a content-type? "also make sure that you have selected Save term lineage" -- where is this interface where I can select `Save term lineage`?
Comment: @user32172 Edit the field, go to `Widget Type` tab, there you will see it under `Hierarchical Select configuration`

Contextual Filters via Taxonomy


Task with Action Delegate accepting string parameter

Question: I have just started with parallel programming. I want to create an action delegate method that print a message on console. When I chenge Action<string> to Action<object> and PritMessage parameter to to object its work but with 'string compiler throws an error.

The best overloaded method match for
  'System.Threading.Tasks.Task.Task(System.Action, object)'.
  Argument 1: cannot convert from 'System.Action<string>' to
  'System.Action<object>'

static void Main(string[] args)
{
    string message = "test";
    Action<string> print = PrintMessage;
    Task task = new Task(print, message);
    task.Start();
    Console.ReadKey();
}

static void PrintMessage(string message)
{
    Console.WriteLine(message);
}

Answer: If you examine the Task constructors, you'll see that you can't create a task with Action which accepts something other than no parameters or single object parameter.
For this particular sample you can simply run the Task with lambda, like this:
Task.Run(() =>
{
    PrintMessage(message);
}

However, better approach is to change signature and cast an in-parameter:
static void Main(string[] args)
{
    var message = "test";
    Task task = new Task(PrintMessage, message);
    task.Start();
    Console.ReadKey();
}

static void PrintMessage(object messageObj)
{
    var message = messageObj as string;
    Console.WriteLine(message);
}

Or simply print the object in Console:
static void PrintMessage(object message)
{
    Console.WriteLine(message);
}


Como usar o foreach com esse tipo de JSON (PHP)

Question: Estou tentando exibir os valores de um JSON com PHP mais sem exito.
Código Usado:
JSON

{
    "friendslist": {
        "friends": [
            {
                "steamid": "76561197960265731",
                "relationship": "friend",
                "friend_since": 0
            },
            {
                "steamid": "76561197960265738",
                "relationship": "friend",
                "friend_since": 0
            },
            {
                "steamid": "76561197960265740",
                "relationship": "friend",
                "friend_since": 0
            },
            {
                "steamid": "76561197960265747",
                "relationship": "friend",
                "friend_since": 0
            }
        ]
    }
}

PHP

$steamid_player = "76561198112612121";
        $apikey = "APIKEY";
       $amg = file_get_contents("http://api.steampowered.com/ISteamUser/GetFriendList/v0001/?key=$apikey&steamid=$steamid_player&relationship=friend");
        $decode = json_decode($amg, TRUE);

        foreach ($decode["friendslist"]["friends"][0] as $valor){

            $steamid = $valor["relationship"]->steamid;

            echo $steamid;
        }

Erro retornado

Warning: Illegal string offset 'relationship' in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\leo\test.php on line 10

Notice: Trying to get property of non-object in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\leo\test.php on line 10

Warning: Illegal string offset 'relationship' in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\leo\test.php on line 10

Notice: Trying to get property of non-object in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\leo\test.php on line 10

Notice: Trying to get property of non-object in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\leo\test.php on line 10

Porem sempre é retornado um erro , e assim nenhum valor é exibido.
Aonde estou errando ?
Comment: Qual erro está gerando, em qual linha?
Comment: Eu passei por isso agorinha e acabei resolvendo. O que você tem que ter certeza em primeiro lugar é se o ***$decode*** está te retornando um ***array*** já que o `foreach` espera um ***array***.
Answer: Segue uma simplificação, e correção de sintaxe:
$decode = json_decode( $amg, TRUE );
foreach ( $decode["friendslist"]["friends"] as $valor){
    $steamid = $valor["steamid"];
    echo $steamid;
}

Veja funcionando no IDEONE.
Você estava chamando o índice [0] no foreach, sendo que ele já vai para o $valor. Além disso, estava tratando o retorno como objeto, sendo que o json_decode está retornando array associativa.
Versão com objeto
Veja a diferença de sintaxe trocando o TRUE do json_decode():
$decode = json_decode( $amg, FALSE );
foreach ( $decode->friendslist->friends as $valor){
    $steamid = $valor->steamid;
    echo $steamid;
}

Aqui também tem um demo no IDEONE.
O segundo parâmetro do json_decode justamente determina se o retorno será um objeto ou uma array associativa.
Comment: Muito bom, parabéns !!!


Flutter rounded appbar with color line

Question: i have a rounded Appbar with a color line. Here is a Screenshot.
I want the color line to follow the rounding. Is this possible, since I have not found anything about it?
This is my code so far:
class LoginPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          "Test",
          style: TextStyle(fontStyle: FontStyle.italic),
        ),
        centerTitle: true,
        elevation: 10,
        backgroundColor: Colors.cyan[900],
        bottom: PreferredSize(
            preferredSize: Size.fromHeight(4.0),
            child: SizedBox(
              height: 5,
              child: Container(
                color: Colors.orange,
              ),
            )),
        shadowColor: Colors.cyan[900],
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.vertical(
            bottom: Radius.circular(30),
          ),
        ),
      ),
    );
  }
}

Answer: you can create your own custom Appbar by implementing PreferredSizeWidget
and the curved border can be achieved through nesting two containers where the space between them (padding in this case represents the stroke width) and the color of the parent container represents the color of the border.
here is full example
class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
  const CustomAppBar({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 80.0,
      padding: EdgeInsets.only(bottom: 6.0),
      decoration: BoxDecoration(
        color: Colors.amber,
        borderRadius: BorderRadius.only(
          bottomLeft: Radius.circular(16.0),
          bottomRight: Radius.circular(16.0),
        ),
      ),
      child: Container(
        height: double.infinity,
        padding: EdgeInsets.symmetric(horizontal: 8.0),
        decoration: BoxDecoration(
            color: AppTheme.primaryColor,
            borderRadius: BorderRadius.only(
              bottomLeft: Radius.circular(16.0),
              bottomRight: Radius.circular(16.0),
            ),
            boxShadow: [BoxShadow(color: AppTheme.primaryColor.withOpacity(.4), spreadRadius: 2.0, blurRadius: 12.0)]),
        child: Center(
          child: Text("Hello Custom Appbar"),
        ),
      ),
    );
  }

  @override
  Size get preferredSize => Size(double.infinity, 150.0);
}

then use it like
Scaffold(
      appBar: CustomAppBar() ,

Comment: I know what you mean, but i still don't understand how to make a single color line in the sharped Appbar
Comment: @Flo I've edited the answer to add the border , check it.
Comment: Yes, that is exactly what I wanted! Thanks
Answer: border will cover whole appbar, is this what you want?
Scaffold(
      extendBody: true,
      appBar: AppBar(
        title: Text(
          "Test",
          style: TextStyle(fontStyle: FontStyle.italic),
        ),
        centerTitle: true,
        elevation: 10,
        backgroundColor: Colors.cyan[900],
        shadowColor: Colors.cyan[900],
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.vertical(
            bottom: Radius.circular(30),
          ),
          side: BorderSide(width: 3.0, color: Colors.orange),
        ),
      ),

Comment: This is also a good way, but the solution above fits better. Because only at the bottom of the appbar should be a line and not everywhere. But thanks

Flutter rounded appbar with color line


stagefright CameraSource::read returns small frames (20 bytes) on Samsung Galaxy S2

Question: I am trying to grab the frames captured by the camera,
encode them and finally send them using RTP/RTSP.
To do the capturing I am using the CameraSource class of stagefright.
The preview on the screen (Surface passed from Java) is great.
But when I try to extract the frames I get frames of 20 bytes.
What am I doing wrong ?
<code>Size videoSize;
videoSize.width = 352;
videoSize.height = 288;
sp<CameraSource> myCamera = CameraSource::CreateFromCamera(NULL, NULL,
                             1 /*front camera*/, videoSize, 25, mySurface, true);
myCamera->start();

//the following is from a reader thread.
status_t err = OK;
MediaBuffer* pBuffer;
while ((err = myCamera->read(&pBuffer)) == OK)
{
    // if not getting a valid buffer from source, then exit
    if (pBuffer == NULL)
    {
        return;
    }
    else
    {
        LOGD("The Size of the returned buffer is: %d", pBuffer->size() );
    }
    pBuffer->release();
    pBuffer = NULL;
}
</code>
Answer: You are doing everything correctly, but Samsung decided not to support the route you tried to implement. The only way to use CameraSource on Galaxy S2 (and many other Samsung devices) is to connect it directly to the hardware encoder.
Comment: how then does the Camera's callbacks work and provides raw frame buffers?
Answer: The 20 bytes is actually some sort of metadata used to communicate between camera and the video encoder. unless you know how to interpret this data, it is difficult to extract the video frame from this data.


Parse RSS with jQuery

Question: I want to use jQuery to parse RSS feeds. Can this be done with the base jQuery library out of the box or will I need to use a plugin?
Comment: I would go for https://github.com/sdepold/jquery-rss — it's the best option right now, multiple options available! :)
Comment: For anyone landing here from google I had to create a similar thing for a deviantART thumbnail viewer. Nice and simple and easily extendible: http://www.adamjamesnaylor.com/2012/11/05/Keratin-DeviantART-Latest-Deviation-Widget.aspx. Note it makes use of google's feed reader, but only to convert it into JSON.
Comment: https://github.com/sdepold/jquery-rss
Answer: WARNING

The Google Feed API is officially deprecated and doesn't work anymore!

No need for a whole plugin. This will return your RSS as a JSON object to a callback function:
function parseRSS(url, callback) {
  $.ajax({
    url: document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=10&callback=?&q=' + encodeURIComponent(url),
    dataType: 'json',
    success: function(data) {
      callback(data.responseData.feed);
    }
  });
}

Comment: This is not a great answer. It is dependent on a third party company [Google] maintaining their service. It does not answer the original question ("Parse RSS with jQuery") and instead advertises Google. What if Google drops or modifies their ajax API? Your website breaks.
Comment: be aware... using the google api, the feeds are cached so you wont be getting the latest and greatest feeds.
Comment: @CharlesGoodwin Google just removed this API! https://developers.google.com/feed/?hl=en
Comment: Tried jFeed and it didn't work, this works fine and doesn't require an extra library.
Comment: where is it cached? how can i remove cache?
Comment: @CharlesGoodwin, yes, this solution depends on a 3rd party-hosted service and therefore isn't ideal, but if you're hitting a cross-domain URL, you're going to need some kind of hosted service. According to Google's ToS (http://developers.google.com/feed/terms), this API will be available through April 2015. Yahoo also has a service (see https://github.com/AIRSHP/Feed-To-JSON/blob/master/jquery.feedToJSON.js), and there are plenty of XML-to-JSON projects on github if you want to host your own.
Comment: I wonder about the missing API key google asks for in all it's requests.
Comment: what value should be passed in url
Comment: @JegBagus I had the same issue and posted my solution below
Comment: How do you apply  google.feeds.Feed.MIXED_FORMAT to this example code?
Comment: "solution depends on a 3rd party-hosted service and therefore isn't ideal": Well, please consider the whole World Wide Web as 3rd party-hosted oriented architecture. BTW, if you need to fetch a **mix of RSS feeds** ordered by item date, & if you're not afraid of (historical) 3rd party: http://pipes.yahoo.com/pipes is a great solution, outputing JSON / XML.
Comment: In case someone is interested in a drop-in replacement for the former Google Feed API, you can find such here: https://github.com/sdepold/feedrapp
Answer: Use jFeed - a jQuery RSS/Atom plugin. According to the docs, it's as simple as:
jQuery.getFeed({
   url: 'rss.xml',
   success: function(feed) {
      alert(feed.title);
   }
});

Comment: Please note the latest version of this plugin is available **[on Github](https://github.com/jfhovinne/jFeed)**.
Comment: Anirudha, perhaps you can try 7-zip? It's Free, open source, and opens a variety of file types, including tar/gzip.
Comment: jFeed seems to be no longer actively maintained (the last change of note is 2 years old, and many open pull requests seem to be ignored), and does not work with recent releases of jQuery.
Comment: NOTE: the download has all kinds of great examples in it
Comment: any examples of real world usage? ie parsing and displaying rather than alert. or is it as simple as $("#results").append(feed.title)
Comment: good answer but i can't download this plugin how i can download it because tar.gz format is not supports by my winrar
Comment: It's on GitHub. Why not fork it and update it instead of complain about it? Maybe email the author and find out what's up.
Comment: I used jFeed a couple of years ago and had a great experience with it.
Answer: For those of us coming to the discussion late, starting with 1.5 jQuery has built-in xml parsing capabilities, which makes it pretty easy to do this without plugins or 3rd party services.  It has a parseXml function, and will also auto-parse xml when using the $.get function.  E.g.:
$.get(rssurl, function(data) {
    var $xml = $(data);
    $xml.find("item").each(function() {
        var $this = $(this),
            item = {
                title: $this.find("title").text(),
                link: $this.find("link").text(),
                description: $this.find("description").text(),
                pubDate: $this.find("pubDate").text(),
                author: $this.find("author").text()
        }
        //Do something with item here...
    });
});

Comment: @jackocnr, yeah that's the downside of this method.  You can't do cross-domain requests unless you have access to set the Access-Control-Allow-Origin header on the source server.  If the server supports jsonp, then that is your best bet.  Otherwise, you might use a proxy script within your domain to retrieve the xml and then call that script instead of the external server.
Comment: XmlHttpRequest error: Origin is not allowed by Access-Control-Allow-Origin
Comment: Is this really the only answer that doesn't rely on external plugins or services?
Comment: Why the `$this.find("link").text()` always returns empty string ''?
Comment: @JeffTian, hard to say without seeing your xml. The most obvious reason would be that the  element is missing or empty.
Comment: @DavidHammond, thank you for your reply. I figured out the cause is the data returned contains some leading unvisible white spaces by using $.parseXML(data). So I resolved the issue by using `$xml = $($.parseXML(data.trim()));`, and then I can get the link as expected.
Answer: jFeed doesn't work in IE.
Use zRSSFeed. Had it working in 5 minutes
Comment: BTW, zRssFeed uses internally [Google Feed RSS API](http://code.google.com/apis/feed/v1/jsondevguide.html). So if one wants to do the HTML layout itself it's easier to just look directly to that instead.
Comment: FYI anyone looking to use this plugin. The developer posted the following.

"THIS PLUGIN IS DISCONTINUED

Due to the Google Feeds API being removed from service, which the plugin replied on, it will no longer be available or supported."

Source:
http://www.zazar.net/developers/jquery/zrssfeed/
Comment: Available at http://www.zazar.net/developers/zrssfeed/
About to try it out myself to see how it goes, looks promising.
Comment: super cool... only thing is if they were providing the feed objects rather than the whole html in a callback function than that would be great...
Answer:
Update (Oct 15, 2019)

I extracted the core logic from jquery-rss to a new library called Vanilla RSS which is using the fetch API and can work without any additional dependencies:
const RSS = require('vanilla-rss');
const rss = new RSS(
    document.querySelector("#your-div"),
    "http://www.recruiter.com/feed/career.xml",
    {
      // options go here
    }
);
rss.render().then(() => {
  console.log('Everything is loaded and rendered');
});

Original

post:
You can also use jquery-rss, which comes with nice templating and is super easy to use:
$("#your-div").rss("http://www.recruiter.com/feed/career.xml", {
    limit: 3,
    layoutTemplate: '
{entries}
',
    entryTemplate: '
[{author}@{date}] {title}
{shortBodyPlain}
'
})

yields (as of Sept 18, 2013):

    <entries></entries>

[@Tue, 10 Sep 2013 22:23:51 -0700] When to Go Over a Recruiter's Head
Job seekers tend to have a certain "fear" of recruiters and hiring managers, and I mean fear in the reverence and respect ...

[@Tue, 10 Sep 2013 14:52:40 -0700] The Perfect Job
Having long ago dealt with the "perfect resume" namely God's, in a previous article of mine, it makes sense to consider the ...

[@Mon, 09 Sep 2013 12:49:17 -0700] Unemployment Benefits Applications Remain Near 5-Year Low, Decline Again
As reported by the U.S. Department of Labor, the number of workers seeking unemployment benefits continued to sit near ...

See http://jsfiddle.net/sdepold/ozq2dn9e/1/ for a working example.
Comment: Bear in mind that jquery-rss uses the Google Feed API which will cache the feed, which could present a problem.  You can trick it by adding a junk url parameter though: http://stackoverflow.com/questions/13401936/prevent-google-feed-api-from-using-cached-feed
Comment: please provide an example to format date without the use of `moment.js`
Comment: Check the following snippet https://gist.github.com/sdepold/d1e5e0e7a66fc77930fe

It will generate something like this: ", [@2015-11-18]"
Comment: Just wanted to mention that jquery-rss is NOT using the Google Feed API but a drop-in replacement called Feedr (https://github.com/sdepold/feedrapp) and respectively works fine despite the original API being turned off.
Comment: Just want to mention that jquery-rss returns an error for me utilizing Feedr: "jquery-1.6.4.min.js:4 Mixed Content: The page at 'https://blah.com/' was loaded over HTTPS, but requested an insecure script 'http://www.feedrapp.info/etcetcetc'..." I tried forcing "https:" in the script but it keeps throwing errors.
Comment: Are you willed to share more details? This should not happen if you enable the ssl option. To fully reproduce, I'd need: How do you include the script into your website, how do you use the script incl options and target RSS feed.
Answer: Using JFeed
function getFeed(sender, uri) {
    jQuery.getFeed({
        url: 'proxy.php?url=' + uri,
        success: function(feed) {
            jQuery(sender).append('
'
            + ''
            + feed.title
            + ''
            + '
');

            var html = '';

            for(var i = 0; i < feed.items.length && i < 5; i++) {

                var item = feed.items[i];

                html += '
'
                + ''
                + item.title
                + ''
                + '
';

                html += '
'
                + item.updated
                + '
';

                html += '
'
                + item.description
                + '
';
            }

            jQuery(sender).append(html);
        }
    });
}

Answer: Use Google AJAX Feed API unless your RSS data is private. It's fast, of course.
https://developers.google.com/feed/
Comment: A good idea, but doesn't work when you're inside a firewall which requires proxy authentication using a dialogue box.
Comment: the google feed is deprecated and not supported any more.
Answer:
UPDATE [4/25/2016] Now better written and fully supported version with more options and abilities hosted at GitHub.jQRSS

I saw the Selected Answer by Nathan Strutz, however, the jQuery Plugin page link is still down and the home page for that site did not seem to load. I tried a few other solutions and found most of them to be, not only out-dated, but EASY! Thus I threw my hat out there and made my own plugin, and with the dead links here, this seems like a great place to submit an answer. If you're looking for this answer in 2012 (soon to b 2013) you may notice the frustration of dead links and old advice here as I did. Below is a link to my modern plugin example as well as the code to the plugin!  Simply copy the code into a JS file & link it in your header like any other plugin. Use is EXTREMELY EZ!
jsFiddle

Plugin Code2/9/2015 - made long overdue update to check for console before sending commands to it! Should help with older IE issues.

(function($) {
    if (!$.jQRSS) {
        $.extend({
            jQRSS: function(rss, options, func) {
                if (arguments.length <= 0) return false;

                var str, obj, fun;
                for (i=0;i<arguments.length;i++) {
                    switch(typeof arguments[i]) {
                        case "string":
                            str = arguments[i];
                            break;
                        case "object":
                            obj = arguments[i];
                            break;
                        case "function":
                            fun = arguments[i];
                            break;
                    }
                }

                if (str == null || str == "") {
                    if (!obj['rss']) return false;
                    if (obj.rss == null || obj.rss == "") return false;
                }

                var o = $.extend(true, {}, $.jQRSS.defaults);

                if (typeof obj == "object") {
                    if ($.jQRSS.methods.getObjLength(obj) > 0) {
                        o = $.extend(true, o, obj);
                    }
                }

                if (str != "" && !o.rss) o.rss = str;
                o.rss = escape(o.rss);

                var gURL = $.jQRSS.props.gURL
                    + $.jQRSS.props.type
                    + "?v=" + $.jQRSS.props.ver
                    + "&q=" + o.rss
                    + "&callback=" + $.jQRSS.props.callback;

                var ajaxData = {
                        num: o.count,
                        output: o.output,
                    };

                if (o.historical) ajaxData.scoring = $.jQRSS.props.scoring;
                if (o.userip != null) ajaxData.scoring = o.userip;

                $.ajax({
                    url: gURL,
                    beforeSend: function (jqXHR, settings) { if (window['console']) { console.log(new Array(30).join('-'), "REQUESTING RSS XML", new Array(30).join('-')); console.log({ ajaxData: ajaxData, ajaxRequest: settings.url, jqXHR: jqXHR, settings: settings, options: o }); console.log(new Array(80).join('-')); } },
                    dataType: o.output != "xml" ? "json" : "xml",
                    data: ajaxData,
                    type: "GET",
                    xhrFields: { withCredentials: true },
                    error: function (jqXHR, textStatus, errorThrown) { return new Array("ERROR", { jqXHR: jqXHR, textStatus: textStatus, errorThrown: errorThrown } ); },
                    success: function (data, textStatus, jqXHR) {
                        var f = data['responseData'] ? data.responseData['feed'] ? data.responseData.feed : null : null,
                            e = data['responseData'] ? data.responseData['feed'] ? data.responseData.feed['entries'] ? data.responseData.feed.entries : null : null : null
                        if (window['console']) {
                            console.log(new Array(30).join('-'), "SUCCESS", new Array(30).join('-'));
                            console.log({ data: data, textStatus: textStatus, jqXHR: jqXHR, feed: f, entries: e });
                            console.log(new Array(70).join('-'));
                        }

                        if (fun) {
                            return fun.call(this, data['responseData'] ? data.responseData['feed'] ? data.responseData.feed : data.responseData : null);
                        }
                        else {
                            return { data: data, textStatus: textStatus, jqXHR: jqXHR, feed: f, entries: e };
                        }
                    }
                });
            }
        });
        $.jQRSS.props = {
            callback: "?",
            gURL: "http://ajax.googleapis.com/ajax/services/feed/",
            scoring: "h",
            type: "load",
            ver: "1.0"
        };
        $.jQRSS.methods = {
            getObjLength: function(obj) {
                if (typeof obj != "object") return -1;
                var objLength = 0;
                $.each(obj, function(k, v) { objLength++; })
                return objLength;
            }
        };
        $.jQRSS.defaults = {
            count: "10", // max 100, -1 defaults 100
            historical: false,
            output: "json", // json, json_xml, xml
            rss: null,  //  url OR search term like "Official Google Blog"
            userip: null
        };
    }
})(jQuery);

USE

//  Param ORDER does not matter, however, you must have a link and a callback function
//  link can be passed as "rss" in options
//  $.jQRSS(linkORsearchString, callbackFunction, { options })

$.jQRSS('someUrl.xml', function(feed) { /* do work */ })

$.jQRSS(function(feed) { /* do work */ }, 'someUrl.xml', { count: 20 })

$.jQRSS('someUrl.xml', function(feed) { /* do work */ }, { count: 20 })

$.jQRSS({ count: 20, rss: 'someLink.xml' }, function(feed) { /* do work */ })

    $.jQRSS('Search Words Here instead of a Link', function(feed) { /* do work */ })
   // TODO: Needs fixing

Options

{
    count: // default is 10; max is 100. Setting to -1 defaults to 100
    historical: // default is false; a value of true instructs the system to return any additional historical entries that it might have in its cache.
    output: // default is "json"; "json_xml" retuns json object with xmlString / "xml" returns the XML as String
    rss: // simply an alternate place to put news feed link or search terms
    userip: // as this uses Google API, I'll simply insert there comment on this:
        /*  Reference: https://developers.google.com/feed/v1/jsondevguide
            This argument supplies the IP address of the end-user on
            whose behalf the request is being made. Google is less
            likely to mistake requests for abuse when they include
            userip. In choosing to utilize this parameter, please be
            sure that you're in compliance with any local laws,
            including any laws relating to disclosure of personal
            information being sent.
        */
}

Answer: I agree with @Andrew, using Google is a solid, reusable way to do it with the huge benefit that you get JSON back instead of XML.  An added advantage of using Google as a proxy is that services that might block your direct access to their data are unlikely to stop Google.  Here is an example using ski report and conditions data.  This has all of the common real world applications: 1) Third party RSS/XML 2) JSONP 3) Cleaning strings and string to array when you can't get the data exactly the way you want it 4) on load add elements to the DOM.  Hope this helps some people!

Comment: This is not going to work because of cross-domain issues. You need JSONP.
Comment: It works for me.  Did you test it?  Pretty sure Google returns jsonp using the callback parameter not ajax dataType.
Comment: Not sure what the downvote was for. This code still works three years later. Paste it all into the console and you'll see current (XML) ski conditions added to the footer of this page.
Answer: (function(url, callback) {
    jQuery.ajax({
        url: document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=10&callback=?&q=' + encodeURIComponent(url),
        dataType: 'json',
        success: function(data) {
            callback(data.responseData.feed);
        }
    });
})('http://news.hitb.org/rss.xml', function(feed){ // Change to desired URL
    var entries = feed.entries, feedList = '';
    for (var i = 0; i < entries.length; i++) {
        feedList +='
' + entries[i].title + '
';
    }
    jQuery('.feed > ul').append(feedList);
});

Hacker News

Answer: jFeed is somewhat obsolete, working only with older versions of jQuery. It has been two years since it was updated.
zRSSFeed is perhaps a little less flexible, but it is easy to use, and it works with the current version of jQuery (currently 1.4). http://www.zazar.net/developers/zrssfeed/
Here's a quick example from the zRSSFeed docs:

Comment: Might note this only works with non-local feeds, since it uses the Google Feed API (Google must be able to load the feed xml).
Answer:

Comment: Not a bad answer, but unfortunately you didn't do the greatest job pasting the code. ;-)
Answer: I'm using jquery with yql for feed. You can retrieve twitter,rss,buzz with yql. I read from http://tutorialzine.com/2010/02/feed-widget-jquery-css-yql/ . It's very useful for me.
Answer: I advice you to use FeedEk. After Google Feed API is officially deprecated most of plugins doesn't work. But FeedEk is still working. It's very easy to use and has many options to customize.
$('#divRss').FeedEk({
   FeedUrl:'http://jquery-plugins.net/rss'
});

With options
$('#divRss').FeedEk({
  FeedUrl:'http://jquery-plugins.net/rss',
  MaxCount : 5,
  ShowDesc : true,
  ShowPubDate:true,
  DescCharacterLimit:100,
  TitleLinkTarget:'_blank',
  DateFormat: 'MM/DD/YYYY',
  DateFormatLang:'en'
});

Comment: I'm not sure if you can actually define an alternative api endpoint, but if you could, there would potentially be the possibility to replace the google feed api with feedrapp: https://github.com/sdepold/feedrapp (which is also the backbone for jquery-rss nowadays)
Comment: This does not do parsing. It uses yahooapis to do the parsing, then it just displays the content.
Answer: zRSSfeed is built on jQuery and the simple theme is awesome.
Give it a try.
Answer: Use google ajax api, cached by google and any output format you want.
Code sample;
http://code.google.com/apis/ajax/playground/#load_feed

Comment: this is a great option because it doesn't rely on jquery!
Answer: The jQuery-rss project is pretty lightweight and doesn't impose any particular styling.
The syntax can be as simple as
$("#rss-feeds").rss("http://www.recruiter.com/feed/career.xml")

See a working example at http://jsfiddle.net/jhfrench/AFHfn/
Answer: jQuery Feeds is a nice option, it has a built-in templating system and uses the Google Feed API, so it has cross-domain support.
Answer: Superfeedr has a jquery plugin which does that very well.
You won't have any Cross Origin Policy issue and the updates are propagated in realtime.
Comment: Why would this solution not have CORS issues?
Answer: jFeed is easy and has an example for you to test. But if you're parsing a feed from another server, you'll need to allow Cross Origin Resource Sharing (CORS) on the feed's server. You'll also need to check browser support.
I uploaded the sample but still did not get support from IE in any version when I changed the url in the example to something like example.com/feed.rss via the http protocol. CORS should be supported for IE 8 and above but the jFeed example did not render the feed.
Your best bet is to use Google's API:
https://developers.google.com/feed/v1/devguide
See:
https://github.com/jfhovinne/jFeed
http://en.wikipedia.org/wiki/Cross-origin_resource_sharing
http://en.wikipedia.org/wiki/Same_origin_policy
http://caniuse.com/cors

Parse RSS with jQuery


CrystalReportViewer print

Question: I would like to access the Print event of CrystalReportViewer(while I click the Print button of CrystalReportViewer) in ASP.NET C#, How ?
Comment: Nicole - Is this using WinForms or ASP.NET. What language are you using C# or VB.NET?
Answer: Something like the below should work. Hope it helps.
<code>    public Form1()
    {
        InitializeComponent();
        foreach (ToolStrip ts in crystalReportViewer1.Controls.OfType<ToolStrip>())
        {
            foreach (ToolStripButton tsb in ts.Items.OfType<ToolStripButton>())
            {
                //hacky but should work. you can probably figure out a better method
                if (tsb.ToolTipText.ToLower().Contains("print"))
                {
                    //Adding a handler for our propose
                    tsb.Click += new EventHandler(printButton_Click);
                }
            }
        }
    }

    private void printButton_Click(object sender, EventArgs e)
    {
        MessageBox.Show("Printed");
    }
</code>
Comment: This version of the hack will only work with an english version of the viewer, as the toolstrip will change with the language used in the UI. A french version of the hack would be  'tsb.ToolTipText.ToLower().Contains("imprimer")' for example.
Comment: Is there any chance that you can convert this one to `vb.net?`
Comment: Alternatively use `(tsb.AccessibleName == "Print Report")`, independently of  ui language.
Answer: Not really a new answer but here is the above in C++ using .NET framework objects etc.:
<code>    CRXViewerNetControl(void)
    {
        InitializeComponent();

        // OK, go though the CRViewer and find the Print Button in the toolbar.  When we find it,
        // attach a "Click" event handler so that we can detect the operator clicking the button to
        // print the report.
        for (Int32 i = 0; i < CRXViewer->Controls->Count; i++)
        {
            if (dynamic_cast<System::Windows::Forms::ToolStrip^>(CRXViewer->Controls[i]))
            {
                System::Windows::Forms::ToolStrip^ ctlToolStrip = dynamic_cast<System::Windows::Forms::ToolStrip^>(CRXViewer->Controls[i]);
                for (int j = 0; j < ctlToolStrip->Items->Count; j++)
                {
                    if (dynamic_cast<System::Windows::Forms::ToolStripButton^>(ctlToolStrip->Items[j]))
                    {
                        System::Windows::Forms::ToolStripButton^ ctlToolStripButton = dynamic_cast<System::Windows::Forms::ToolStripButton^>(ctlToolStrip->Items[j]);
                        if (ctlToolStripButton->ToolTipText->ToLower()->Contains("print"))
                        {
                            //Adding a handler for our propose
                            ctlToolStripButton->Click += gcnew System::EventHandler(this, &CRXViewerNetControl::printButton_Click);
                        }
                    }
                }
            }
        }

    }

private: System::Void printButton_Click(System::Object^  sender, System::EventArgs^  e)
    {
        MessageBox::Show("Printed");
    }
</code>

CrystalReportViewer print


Unclear construction in Hitchins paper on Integrable Systems

Question: In the paper Stable Bundles and Integrable Systems (1987), Hitchin shows that the cotangent bundles of moduli spaces of stable bundles can be viewed as integrable systems.
In section 4 of the paper, he constructs a mapping
$$p:H^0(M;\ \text{ad}P\otimes K)\to H^0(M;\ K^d)$$
based on an invariant homogeneous polynomial $p$ of degree $d$ on a Lie algebra $\mathfrak{g}$ (which he later uses to construct hamiltonians). He justifies this construction by stating that the vector bundle $\text{ad}P$ is a bundle of Lie algebras each isomorphic to $\mathfrak{g}$.
Here, $P$ is a stable holomorphic principal $G$-bundle over a compact Riemann surface $M$ of genus $g>1$, with $G$ a semisimple complex Lie group, and $K$ is the canonical line bundle on $M$.
I do not understand how exactly we construct a mapping $H^0(M;\ \text{ad}P\otimes K)\to H^0(M;\ K^d)$, given the polynomial $p$?
All other discussions of the Hitchin system that I have seen (that came out some years after Hitchins original paper, for example here and here) employ a notion of Higgs bundles in the construction of the Hitchin system and do not directly mention the above mapping. I would therefore be very grateful for help.
Edit: Previously, I also included the following question (resolved due to comments below):
I understand that each fibre of the associated bundle $\text{ad }P$ is a Lie algebra; however, I am not sure how to show that they are mutually isomorphic, and hence all isomorphic to a Lie algebra $\mathfrak{g}$. Furthermore, is $\mathfrak{g}$ in this case the Lie algebra associated to $G$ (I don't believe that it is for principle bundles and adjoint representations in general)?
Comment: Note "principal bundle" refers to $P$ whose fibres are isomorphic to $G$. The bundle with Lie algebra fibres is $\operatorname{ad}P$. This is an example of what is called an "associated bundle" to $P$ and has fibres isomorphic to $\mathfrak{g}$ by definition.
Comment: Thank you! I also understand why the fibres are isomorphic to $\mathfrak{g}$ (the lie algebra associated with $G$) now - I had forgotten that $G$ acts freely and transitively on the fibres of $P$. I am still unclear on the construction of $p$.
Answer: It is probably helpful to consider the case of vector bundles first, where we can replace $\text{Ad}(P)$ by $\text{End}(E)$ for a given vector bundle $E\to\Sigma$. In this case, a section of $\text{End}(E)$ can be viewed as a family of matrices which is parameterised by the base $\Sigma$. Say $\varphi\in H^{1,0}(\Sigma,\text{End}(E))\cong H^0(\Sigma,\text{End}(E)\otimes K)$ (Serre duality) and represent it by a $1$-form also denoted $\varphi$. Then we can define $\varphi\mapsto\text{tr}(\wedge^d\varphi)$ where $\wedge^d\varphi:\wedge^d E\to\wedge^d(E\otimes K)$. But now, we can use the fact that $\wedge^d(E\otimes K)=\wedge^dE\otimes K^{\otimes d}$, which is true because $K$ is a line bundle (see here for instance). So locally, we have that $\wedge^d\varphi$ can be written as $\sum A_i\otimes\eta_i$ with $A_i$ an endomorphism of $\wedge^dE$, and $\eta_i$ a section of $K^{\otimes d}$. The trace map is obtained by just taking the trace of each $A_i$. So we are left with $\sum \text{tr}(A_i)\eta_i\in H^0(U,K^{\otimes d})$, and likewise globally $\text{tr}(\wedge^d\varphi)\in H^0(\Sigma,K^{\otimes d})$.
So when $\mathfrak{g}=\text{End}(V)$ for a vector space $V$, then we have $\det(\lambda-\varphi)=\lambda^r+\sum_{k=1}^r\text{tr}(\wedge^k\varphi)\lambda^{r-k}$ and so these coefficients (which are known to be $\text{Ad}$-invariant homogeneous polynomials) are a natural choice. When we look at more general principal bundles, we have to fix some $\text{Ad}$-invariant homogeneous polynomials on the Lie algebra $\mathfrak{g}$. But besides that, the idea is exactly the same and you should be able to copy the construction I outlined above in the case of principal bundles. I'll leave that for you to write down as it's probably a useful exercise to make sure you understood the concept.
Comment: You would not use the exterior powers if you're doing the more general case of principal bundles. The traces of the exterior powers are a way to obtain invariant polynomials on $\mathfrak{gl}(V)=\text{End}(V)$. Instead, use the homogeneous invariant polynomial $p$, in the way you describe. Also, you should be aware that $\varphi_x$ is a sum of terms $\sum q_i\otimes\eta_i$, not necessarily pure. But that is not important. My $\varphi\mapsto\text{tr}(\wedge^d\varphi)$ is your $q$.
Comment: Ah, that is a good point that I forgot to mention. This boils down to the transformation rule that the section $\sum p(q_i)\otimes\eta_i$ obeys, because you have applied $p$ to the first factor. It will now transform as a section of the $d$-th symmetric product of $K$, but that is the same as the $d$-th tensor power because $K$ is a line bundle. This follows from the fact that $q$ is homogeneous of degree $d$, and again I would leave the details as an exercise (recall that a polynomial on $\mathfrak{g}$ of homogeneous degree $d$ is the same as an element of $\text{Sym}^d(\mathfrak{g}^*)$.
Comment: Thank you, I think you help me grasp the general ideas. For $\varphi\in H^0(M;\ \text{ad}P\otimes K)$ and $p\in M$, I have $\varphi(p)=q\otimes \eta$ for some $q\in \text{ad}P$ and $\eta\in K$. I understand that $q$ is in one of the fibres of $\text{ad}P$, and so I could apply the polynomial $p$ to $q$ - but instead, I want to look at $\wedge^k(q\otimes \eta)$ and use $\wedge^d(\text{ad}P\otimes K)\cong\wedge^d\ \text{ad}P\otimes\wedge^d\ K$ - but how could I apply $p$ to an element of $\wedge^d\ \text{ad}P$?
Comment: Oh, that makes sense. I see that I can map $\sum_iq_i\otimes\eta_i$ to $\sum_ip(q_i)\otimes\eta_i$ (extending $p:\mathfrak{g}\to\mathfrak{g}$ to $p:\text{ad}P\to\text{ad}P$ (a fibre-preserving map)), but then how can I get an element in $H^0(M, K^d)$?
Comment: Thank you again. I feel out of my depth when it comes to how symmetric products and tensor powers interplay in the case of a line bundle, or how $\sum_ip(q_i)\otimes\eta_i$ "transforms" as an element of a symmetric product of $K$. Can you give me a reference for these constructions (or elaborate)?
Comment: There's a book called "Integrable Systems: Twistors, Loop Groups, Riemann Surfaces" by Hitchin and others. Chapter 2 is written by Hitchin and probably contains the relevant information that you need. What I mean when I say that the section transforms as something, is that you need to look at the expression for $\sum p(q_i)\otimes \eta_i$ in a different choice of coordinates. Because you're applying $p$ to the $q_i$, you will find that the section must transform as a section of the $d$-th tensor power of $K$. It's a good exercise, the book will give you more background if necessary.


virtualbox ansible and PHP

Question: I am trying to install Centos-7 on Ubuntu vivit in Virtual Box using Ansible. I get through a large amount of configuration and set up before it fails with the message below. I have searched for various error types but haven't seen one with mine so I figured I will come here. Can anyone tell me what the errors mean? I suspect it is a failure to install PHP dependencies but I don't why they are failing and how to correct this.
Thanks
<code>PLAY [all] ********************************************************************

GATHERING FACTS ***************************************************************
ok: [default]

TASK: [common | check if EPEL is installed] ***********************************
failed: [default] => {"changed": false, "cmd": "/usr/bin/rpmquery epel-release", "delta": "0:00:00.036192", "end": "2015-09-30 19:40:02.697466", "rc": 1, "start": "2015-09-30 19:40:02.661274", "stdout_lines": ["package epel-release is not installed"]}
stdout: package epel-release is not installed
...ignoring

TASK: [common | install EPEL] *************************************************
changed: [default]

TASK: [common | clean yum metadata on first run] ******************************
changed: [default]

TASK: [common | upgrade all packages on first run] ****************************
changed: [default]

TASK: [mariadb | MariaDB Install] *********************************************
changed: [default] => (item=mariadb-server)

TASK: [mariadb | MariaDB my.cnf] **********************************************
changed: [default]

TASK: [mariadb | Starting MariaDB] ********************************************
changed: [default]

TASK: [mariadb | Enabled MariaDB Service] *************************************
changed: [default]

TASK: [mariadb | Ensure DB user exists] ***************************************
changed: [default]

TASK: [mariadb | Ensure DB exists] ********************************************
changed: [default]

TASK: [mariadb | Import ConnectDB] ********************************************
changed: [default]

TASK: [php | Install PHP Packages] ********************************************
failed: [default] => (item=php,php-devel,php-pecl-zendopcache,php-mbstring,php-xml,php-mysql,php-gd,php-pdo,php-drush-drush,php-json,libmcrypt-devel,libmcrypt,php-mcrypt) => {"failed": true, "item": "php,php-devel,php-pecl-zendopcache,php-mbstring,php-xml,php-mysql,php-gd,php-pdo,php-drush-drush,php-json,libmcrypt-devel,libmcrypt,php-mcrypt"}
msg: unsupported parameter for module: update_cache

FATAL: all hosts have already failed -- aborting

PLAY RECAP ********************************************************************
           to retry, use: --limit @/home/jcorbett/playbook.retry

default                    : ok=12   changed=10   unreachable=0    failed=1

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
</code>
Comment: What is unclear about the error message? `msg: unsupported parameter for module: update_cache`
Comment: It would really help if you could specify at least the task and module that is throwing the error.
Answer: Without see the playbook, I can only assume here. It seems like you are using a unsupported parameter as suggested here.
<code>- name: Run yum upgrade
action: command yum upgrade
</code>

virtualbox ansible and PHP


Find function which satisfies the initial value problem: $\displaystyle 6 \sec x \,\frac{dy}{dx} = e^{y + \sin x} $

Question: Find the function which satisfies the initial value problem:
$\displaystyle  6 \sec x \,\frac{dy}{dx} = e^{y + \sin x} $
$\displaystyle \;\ y(0) = -9 $
So as far as I understand it, I should move everything with y to the left, and with x to the right.
But what do I do with $e^{y + \sin(x)}$? it has both y and x
if I leave it on the right side, do I just do $u$ substitution $= y + \sin(x)$?
Answer: Hint:
$$e^{y+\sin x}=e^y\cdot e^{\sin x}\implies 6e^{-y}\frac{dy}{dx}=e^{\sin x}\cos x$$
Then, by integrating both sides, you get
$$-6e^{-y}=e^{\sin x}+C$$
Answer: Outline  :
You can separate RHS by writing $e^ye^{\sin x}$.
Now, the equation is in separable form,
$6e^{-y}dy = \cos x \times e^{sin x} dx $
LHS is easily integrable, for RHS substitute $t = \sin x$, so you will get
$-6e^{-y}  = e^{\sin x} + c$
You can get c from the initial condition
Comment: I don't see how you got rid of cosx. Derivative of e^t = e^t -> e^sinx
Comment: shouldn't I only get y on the left side in order to find C?
Comment: @jack you put t=sin x, then dt = cosx dx. That's how the cos disappears


how to edit the nlog config file programmatically

Question: i am trying to edit the logging level in the config file programmaticly.
<code> foreach (var rule in LogManager.Configuration.LoggingRules)
    {

                if (m_loginglevelcomboBox.SelectedItem.ToString() == "Debug")
                {
                    rule.EnableLoggingForLevel(LogLevel.Debug);
                }
                else
                {
                    rule.EnableLoggingForLevel(LogLevel.Info);

                }
     }

            //LogManager.ReconfigExistingLoggers();
</code>
I am not interested in calling the Reconfig,as the changes will affect the application on the fly.
I want the changes to be made when the application is restarted. so I need it to edit the config file.
i cant use xDocument ,as linq is not compatible with my .net version
so how can i edit the minlevel rule to debug/info ?
Comment: Judith, you forgot to ask a question. What's going wrong here? What can't you fix?
Comment: ok will update my question.
Comment: If you intend your program to be redistributed and installed in "program files", you'll need to copy the config to a location where standard users have write access and get nlog to read it from there. If the config simply lives next to the .exe file in "program files" you should consider it to be readonly.
Comment: well , the config file exists in a folder where the users  have the permissions  to edit the files.
Answer: i used this to edit the logging level. I hope if this would help if some one stumbles across. If some one thinks it to be a bad idea, please let me know .
<code>            string configFilename = GetConfigFilePath();

            XmlDocument doc = new XmlDocument();
            doc.Load(configFilename);

            XmlNode documentElement = doc.DocumentElement;

            foreach (XmlNode node in documentElement.ChildNodes)
            {
                if (ruleDocumentNodeName.Equals(node.Name))
                {
                    foreach (XmlNode childNode in node.ChildNodes)
                    {
                        if (loggerDocumentNodeName.Equals(childNode.Name))
                        {
                            XmlAttribute idAttribute = childNode.Attributes[minLevelAttributeName];
                            string currentValue = minLogingLevelComboBox.SelectedItem.ToString();
                            idAttribute.Value = currentValue;
                            doc.Save(configFilename);
                            MinLoggingLevelChanged = true;
                        }
                    }
                }
            }
</code>


Web form sending email to gmail-hosted domain is not delivering for 1 of 3 clustered web servers

Question: We have 3 AWS-hosted web servers all configured (as far as I can tell) identically. Each server has a copy of a web feedback form that submits to a PHP script that ultimately calls the php mail() function to send an email to us.
This works fine on 2 of the 3 web servers. On the third, the php mail() function returns 1 (indicating that the mail was sent), /etc/maillog on the web server shows the message as accepted for delivery, and then transferred-on to Google's MX which also accepts the message.
Example mail log for delivery to gmail:
Nov  7 00:40:18 ip-[redacted] sendmail[18499]: sA70eHGI018497: to=<[recipient]>, ctladdr=<apache@ip-[redacted]> (48/48), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=121194, relay=aspmx.l.google.com. [[redacted]], dsn=2.0.0, stat=Sent (OK 1415320818 q110si8698921qgd.122 - gsmtp)

That looks good to me. But the message never shows up in my inbox.
Things I've checked:

domain MX records are sane
same version of sendmail on all 3 hosts
/etc/mailname is set identically on all 3 hosts

Any suggestions?
Answer: The last part of that log excerpt confirms that the message was accepted by the recipient mail server at gmail:
relay=aspmx.l.google.com. [[redacted]], dsn=2.0.0, stat=Sent (OK 1415320818 q110si8698921qgd.122 - gsmtp)

The portion in parenthesis is part of the confirmation that the remote server gave back so if you had a support contact at google, they could presumably use that to trace what they did with the message.  Considering that it's a free mail service though, getting them to do that is unlikely.
How about checking spam/junk mail folders? Anything there?
Comment: I've checked everywhere. The same types of messages work through the two other web servers and appear where I expect them. The script that runs is identical. Perhaps I'm unlucky enough to have my EC2 instance's IP address in a blacklisted block for Google. I think I might try configuring SPF for that specific IP address and see if that helps. Thanks for confirming that Google is pretty clearly accepting the message.


History of screaming in music throughout the world

Question: Screaming is a common technique in metal and other music genres but according to Wikipedia it has also been used in blues music and very few times in more classical Western works.
Are there other early examples of music (Western or not) that make use of screaming? In particular, are there any cultures that have had a tradition of using screams in music that predate rock music?
Answer: There are a few examples of screaming in Western classical music, but only as a coloristic effect; I am not aware of any compositions where it is used on a sustained basis the way it is in heavy metal. Some of these are when the music imitates styles such as blues or rock.
Some examples:

There are some primal screams in the first movement of Orff's Catulli Carmina.
The blues singer in the finale of Tippett's Third Symphony is asked to scream several phrases at key points during the movement.
There is a moment of free improvisation at the end of the "Agnus Dei" of Bernstein's Mass where screaming could be interpolated.
The movement "London" from Bolcom's massive Songs of Innocence and of Experience is essentially a power ballad for rock tenor.
Györgi Ligeti's Aventures and Nouvelles Aventures call for shouted and screamed text by amplified singers. This might be the closest to a sustained effort of any work I am currently aware of.
Answer: This is a very late answer, but only because I'm not convinced by some of the other answers.
(And I admit I'm actually a little bothered by one answer apparently equating a scream with standard operatic/vocal technique! Hopefully I misunderstood this author's intent. Perhaps they were addressing shouting within the dialogue, but that, I think, also misses the point of the original question, which is screaming within the context of music.)
One early possibility is in Wagner's famous Die Walküre (premiered 1870, written 1856). At the end of Act II, Siegmund is killed by Hunding. In the score, Wagner writes that Sieglinde "sinkt mit einem Schrei" (falls with a Schrei, which could mean cry, scream, etc.). Not all productions ask Sieglinde to actually scream out, but some do, as in this famous 1990 Met production.
Indeed, Wagner uses it throughout his Ring cycle (I can't believe I didn't mention this earlier!). Scene 3 of Das Rheingold has a much "screamier" scream, this time from a whole cast of Nibelungs!
Answer: I think this is kind of a broad question, and when you say screams in rock music it's kind of a different definition to how it is used everywhere else.  I think of everything from Deep Purple to Iron maiden, opeth and beyond in rock, but in everything else it can have multiple meanings.
When I started searching it seemed that Bel Canto has some early screaming from Queen of the night in the 17th century, but then I found earlier examples of a similar sound in 1600.  I believe you could trace it back even further by listening to early vocal music, but there are far better hunters on this site than me for that!
Again it's down to what you define as a scream.  If it's a pure resonant tone then you can say that most vocal music was screaming at one point!
I can't give you a complete history on this one, but I can give you some examples in my mind that are outside metal/rock.  In chronological order
The List
Cruda Amarilli - Claudio Monteverdi (1600)
This may not fall into the screaming category, only I'm not sure where the line is if we say that queen of the night is screaming, because both it,this and St Matthews Passion have a similar quality
Not All My Torments - Purcell (1659 - 1695)
St Matthews Passion - Bach (1727)
Queen Of the Night - Mozart (1791)
A very large chunk of opera could be considered screaming if it's anything like the above.  in that regard screaming could be as far back as the Bel Canto technique
Dies Irae/Requiem - Verdi (1874)
I could go on for a while with that style, it's beautiful, but I'll leave bel Canto for now!
I Put a spell on you - Screamin Jay Hawkins (1956)
Eight Songs for a Mad King - Peter Maxwell Davies(1969)
This makes heavy use of extended vocal techs, especially screaming.  It also has an extremely crazy score (while still being playable)
Lovin' You - Minnie Ripperton(1975)
Phantom of he Opera - Andrew Lloyd Webber (1986)
Ok, I said no more Opera, but this one's technically a musical, totally different thing ;)
there's also a nice little compilation you might like on Youtube here
Hope that that helped to answer your question, It was a lot of fun hunting around for all the songs! Almost put Crazy Horses in there, but that was a synth of some sort :(
Comment: -1 Because most of your examples do not contain any screaming, by any definition.
Comment: @johannes That's your prerogative of course! I did say in my answer that it depends on your definition of screaming,  but which one of the examples do you consider to absolutely not contain a scream?
Comment: I would say all but the Screamin' Jay and Maxwell Davies examples.
Answer: Not quite the same, but a very unusual, guttural, vocal sound is produced by some techniques of Tuvan throat singing.
Particularly, the khoomei, and kargyraa styles.
So the quest for that harsh tone is quite universal.


dotnet publish /p:EnvironmentName=Staging not work

Question: I tried to publish my ASP.NET 5 solution via
dotnet publish -c Release -r ubuntu.18.04-x64 --self-contained false /p:DebugType=None /p:DebugSymbols=false /p:EnvironmentName=Staging

that found here.
But I still see in logs that EnvironmentName is Production. What did I do wrong?
I also tried to add
<PropertyGroup Condition=" '$(Configuration)' != '' AND '$(Configuration)' != 'Debug' ">
    <EnvironmentName>'$(Configuration)'</EnvironmentName>
  </PropertyGroup>

into WebApp .csproj, but the result is the same - nothing changes.
Answer: This approach is valid only if you deploy your application on IIS (docs).
Based on your publish command

dotnet publish -c Release -r ubuntu.18.04-x64 --self-contained false
/p:DebugType=None /p:DebugSymbols=false /p:EnvironmentName=Staging

You are building it for ubuntu.18.04-x64, therefore you will not be using IIS.
To change the EnvironmentName on Linux you will have to do one of the following:

Setup env variable ASPNETCORE_ENVIRONMENT=Staging.
Send enviroment as cli argument when you run the application :"
dotnet .\webapi.dll environment=staging
Comment: thanks for the answer! What does the first step mean, could you please say how to do it a little bit more?
Comment: its not a step (updated the answer sorry for the confusion), you can do one of the approaches. Here you have information for the first approach https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-7.0#linux


Windows Batch File - Multiple Conditions and Lines

Question: I need to extract information from a file using BATCH file. I have AWK (GNUWIN32) installed in Windows.
Text File contains -
# FOR Example Purposes  *** #
# Dated on Jan 29, 2014

TEST_tag=branch_release_v_184.108.40.206_YOU_Branch
NONE_tag=branch_release_v_184.108.40.206_ONE_Branch
DOIT_tag=branch_release_v_1.0.9_EXA_Branch

Now, I need the following output from this file (comments removed and string manipulated)-
TEST/branch_release_v_18.104.22.168_YOU_Branch
NONE/branch_release_v_126.96.36.199_ONE_Branch
DOIT/branch_release_v_1.0.9_EXA_Branch

I will prefer if it can be done using variables instead of replacing "_tag=" with "/" so, I can use the logic with other formats as well.
Here what I tried to do.
FOR /F "tokens=*" %%A IN ('awk "!/^($|#)/" test.txt') DO (
ECHO %%A | awk -F_ "{print $1}" > one.tmp
SET /P ONE=<one.tmp

ECHO %%A | awk -F= "{print $2}" > two.tmp
SET /P TWO=<two.tmp

ECHO %ONE%/%TWO%
)

It's not working and is printing the same result (last line only printed 3 times)
DOIT/branch_release_v_1.0.9_EXA_Branch
DOIT/branch_release_v_1.0.9_EXA_Branch
DOIT/branch_release_v_1.0.9_EXA_Branch

Solution (Thanks to Magoo) ---
FOR /F "tokens=*" %%A IN ('awk "!/^($|#)/" test.txt') DO (

setlocal enabledelayedexpansion

ECHO %%A | awk -F_ "{print $1}" > one.tmp
SET /P ONE=<one.tmp

ECHO %%A | awk -F= "{print $2}" > two.tmp
SET /P TWO=<two.tmp

ECHO !ONE!/!TWO!
)

Thanks again.
Answer: Within a block statement (a parenthesised series of statements), the entire block is parsed and then executed. Any %var% within the block will be replaced by that variable's value at the time the block is parsed - before the block is executed.
Hence, IF (something) else (somethingelse) will be executed using the values of %variables% at the time the IF is encountered.
Two common ways to overcome this are 1) to use setlocal enabledelayedexpansion and use !var! in place of %var% to access the changed value of var or 2) to call a subroutine to perform further processing using the changed values.