How to graph a curve finding the Cartesian equation

Question: I have to graph the curve
$$\gamma(t)=\left(\frac{t^3}3-t,(\ln t)^2\right)$$
with $t>0$. How can I express the curve as a function graph? Maybe I have to put $\frac{t^3}3=x$? I don't think this is the best way, but I only know this method. Can you help me?
If you want to know, the curve is simple and it is regular $\forall t\ne1$.
Comment: what base has the logarithm function?
Comment: It is the natural logarithm
Comment: you can solve $$y=(\ln(t))^2$$ for $t>0$
Comment: Why do you want a parametric curve to be necessarily the graph of a function? A circle is *not* !
Comment: @Bernard how would you graph this curve?
Comment: You have to study the variations of  $x(t)$ and $y(t)$ separately, find the critical points for each of them,   study the nature of singular points (points which are critical for both $x(t)$ and $y(t)$). Here the value $t=1$ yields a singular point. Finally you have to determine whether the curve has oblique asymptotes (when $x(t)$ and $y(t)$ both tend to $\infty$).
Answer: It's not possible to describe the curve by some expression $y=f(x)$, as we will see, but that's not really necessary. In gnuplot, you'd do something like
<code>gnuplot> set parametric

dummy variable is t for curves, u/v for surfaces
gnuplot> plot [t=0.1:2] t**3/3-t, (log(t))**2
</code>
and get a decent graph:

As you can see, the point corresponding to $t=1$, i.e. $(x,y)=(-2/3, 0)$, is not a regular one.


Why the morphisms of vector spaces, over different fields is not interesting?

Question: Suppose $V_\mathbb{F_V}$ and $W_\mathbb{F_W}$ are two vector spaces over fields $\mathbb{F}_V$ and $\mathbb{F}_W$. Then a homomorphism of these vector spaces consists of maps $f:V\rightarrow W$ and $f_\mathbb{F}:\mathbb{F}_V\rightarrow \mathbb{F}_W$ satisfying:
$$
f\left(a.v+b.u\right)= f_{\mathbb{F}}\left(a\right)f\left(v\right)+f_{\mathbb{F}}\left(b\right)f\left(u\right)
$$
for all $a,b \in \mathbb{F}_V$ and $v,u \in V$.
With such morphisms we can talk about the category of all vector spaces over arbitrary fields. But, I have never seen such examples. Why is that? Is it because the category of fields is not very  welcoming of a place.
Answer: There is indeed a category of all vector spaces with morphisms as you describe. It has many interesting properties – first of all, notice that it comes equipped with a projection to the category of all fields, $p : \textbf{Vect} \to \textbf{Fld}$. Let $\textbf{Vect}(K)$ be the non-full subcategory of $\textbf{Vect}$ of objects $V$ such that $p V = K$ and morphisms $f$ such that $p f = \textrm{id}_K$. This is easily seen to be isomorphic to the usual category of $K$-vector spaces. Given any field homomorphism $\phi : K \to L$, we get a functor $\phi^\sharp : \textbf{Vect}(L) \to \textbf{Vect}(K)$, and it is not hard to check that the operation $(-)^\sharp$ is strictly functorial. The category $\textbf{Vect}$ is then seen to be the Grothendieck construction applied to $(-)^\sharp$, and therefore $p : \textbf{Vect} \to \textbf{Fld}$ is a Grothendieck fibration.
Why is this interesting? Well, it gives us a way to consider vector spaces over all fields on equal grounds, and the universal property of some familiar constructions is best expressed in terms of this Grothendieck fibration. For example, if $W$ is a $L$-vector space, then $\phi^\sharp W$ is a $K$-vector space $V$ and a morphism $f : V \to W$ lying over $\phi : K \to L$ such that for all morphisms $h : U \to W$ in $\textbf{Vect}$ lying over $\chi : F \to L$ in $\textbf{Fld}$ and all factorisations $\chi = \phi \circ \psi$, there is a unique morphism $g : U \to W$ lying over $\psi : F \to K$ such that $h = g \circ f$. If you draw the diagram you will see this is basically the universal property of a pullback, but two different categories are involved here.
On the other hand, $\phi^\sharp : \textbf{Vect}(L) \to \textbf{Vect}(K)$ has a well-known left adjoint $\phi_\sharp : \textbf{Vect}(K) \to \textbf{Vect}(L)$, namely the tensor product $\phi_\sharp V = L \otimes_K V$. This makes $p : \textbf{Vect} \to \textbf{Fld}$ into a Grothendieck bifibration, and again this means $\phi_\sharp V$ can be described in terms of a universal property.
You are quite right that $\textbf{Fld}$ isn't a category with particularly good properties – and unfortunately that means $\textbf{Vect}$ also lacks the same properties. For example, there is no terminal object in either $\textbf{Fld}$ or $\textbf{Vect}$. In this respect, the category $\textbf{Mod}$ of all modules over all commutative rings is more well-behaved. $\textbf{Mod}$ has some remarkable properties – in addition to being a Grothendieck bifibration, it (or rather $\textbf{Mod}^\textrm{op}$) is what is known as a stack for the faithfully flat topology on $\textbf{CRing}^\textrm{op}$. This is studied at length in SGA1 and is the motivating example behind the whole theory of fibred categories in general.
Comment: I know it has been quite a while since you posted this, but would you be able to direct me towards any texts that, at least tangentially, consider the category of all modules over all commutative rings? You mentioned SGA, and that's great, but my French could do with some work
Answer: Your conditions imply that $F_V$ can be viewed as a subfield of $F_W$ and via that $W$ is a $F_V$-vector space and $f$ is $F_V$-linear.
For example nothing prevents you from considering the linear maps from the real vector space $C([0,1])$ of continuous function on the interval $[0,1]$ to the complex vector space $\mathbb C^{42}$. But what you get is the same as if you considered $\mathbb C^{42}$ just as $\mathbb R^{84}$.
Comment: While you didn't say it, to have any chance of sensible properties we should take $f_\mathbb{F}$ to be a homomorphism of fields, and all of these are injective.
Comment: It's not exactly the same – you have first choose an embedding of $\mathbb{R}$ into $\mathbb{C}$, and there might be more than one.
Comment: But, $f_F$ is not necessarily injective, why $F_V$ can be viewed as a subfield of $F_W$?
Answer: Well, you will be able to talk about morphisms between vector spaces over different fields as long as you think up a category in which those vector spaces coexist as objects :)
There is something similar (and somewhat important) for semisimple rings. I'm doing this from a memory from Jacobson's BA2 text, so I dearly hope I'm not too far off of the correct statement.
I think the question is: For finite dimensional vector spaces $V_F$ and $W_{F'}$, if $End(V_F)\cong End(W_{F'})$ as rings, what can you conclude about the relationship of $V_F$ to $W_{F'}$?
The answer is that $V$ and $W$ are semilinearly isomorphic, which is a generalization of a linear isomorphism. You might be interested in semilinear transformations :)


Algorithm Recursive Formula Calculation

Question: I have the following recursion:
T(n) = T(2*n / 3) + T(n / 3) + O(n log n)

I need to know the exact equation, I know Master theorem won't help me.
Please tell me how to do it in general for such recursions. I need complexity and to understand how to solve such problems.
Thanks in advance.
Comment: Why do you think the Master Theorem won't help you? What is your exact question? In general, the Master Theorem is the correct way to determine the asymptotic run-time for most (not all) recursive calls.
Comment: @pkacprzak T(2*n / 3) + T(n / 3) != T(n)
Comment: @MatthewHerbst The Master Theorem requires that the 2n/3 and n/3 be the same.  You can convert the n/3 to 2n/3 to get an upper bound, as AbcAeffchen did.
Comment: Do you see that you're equation is `T(n) = T(n) + O(n logn)` which is very weird?
Comment: @pkacprzak That's not at all the case.
Comment: @NiklasB. what do you mean exactly?
Answer: You could use a simplification to get an upper bound.
1. Way:
T(n) = T(2/3 ⋅ n) + T(1/3 ⋅ n) + O(n log n)
     ≤ T(2/3 ⋅ n) + T(2/3 ⋅ n) + O(n log n)
     = 2 T(2/3 ⋅ n) + O(n log n)

Now you can use the master theorem. This should give you O( n1.7095 ). Due to we  have a ≤, we do have O instead of Θ.
2. Way:
You can 'count' the nodes in the calling-tree, which is a binary tree in your case. This tree has maximum depth log3/2(n), so it has less than 2O(log n) = O(n) nodes. For each node there comes a O(n log n), so you get O(n) ⋅ O(n log n) = O(n² log n) in total.
Sure, this is very unexact. We can do better if we split the tree up into two parts:

The upper part above depth of 1/2 ⋅ log n: O(21/2 ⋅ log n ) = O( sqrt(n) ) nodes.
This nodes have a weight of O(n log n).
The lower part below depth of 1/2 ⋅ log n: O(2log n - sqrt(n) ) = O(n) nodes.
This nodes have a weight of O(sqrt(n) log n)

In total you get: T(n) = O(sqrt(n)) ⋅ O(n log n) + O(n) ⋅ O(sqrt(n) log n) = O(n1.5 log n).
I hope this helps.
EDIT: O(n1.5 log n) ⊂ O(n1.7095).
EDIT: You can write O(n1.5 log n) as O(n⋅sqrt(n)⋅log n). As @Teepeemm showed, the exact complexity is Θ(n log²(n)), which improves the upper bound I showed by replacing the factor sqrt(n) by log(n).
Comment: Replacing T (2/3 n) + T (n/3) with T (2/3 n) + T (2/3 n) totally changes the result. T (n) = c * n * log^2 n matches the recursion formula just fine.
Comment: Sure, both results are only upper bounds, but you can get them without any heavy theory but master theorem
Answer: A generalization of the Master Theorem is the Akra-Bazzi method.
Assuming that your O(n log n) is really Θ(n log n), we have g(x)=x log x, ai=1 for i=1 and i=2, b1=2/3 and b2=1/3.  Then b1p+b2p=1 when p=1, g(u)/up+1=(log u)/u has integral (log²u)/2, and T(x) is Θ(x log²x).

Algorithm Recursive Formula Calculation


Knot location using quantile knots

Question: I have implemented regression splines and penalised splines, with different algorithms to choose optimal lambda.
But I am still not satisfied with it as I am not able to choose the location of knots as required.
I have been using uniform knots till now, but some one suggested that quantile knots may work.
I tried to find, but could not find a good book for that.
Can you please suggest me some good books or articles for quantile knots.
Please also share if you have any valuable information regarding it.
Comment: Frank Harrell's book _Regression modeling strategies_ (Springer 2001, 2015) discusses this idea.
Comment: If you want to get more exotic and computationally intensive, you can employ adaptive knot spline regression. I.e., for a fixed number of knots, let an algorithm optimize the placement of the knots per some goodness criterion. I don't have a good reference for something I can quickly find on the web which is not behind a paywall.
Answer:
I am not able to choose the location of knots

For regression splines, if you want to choose the location of the knots, you can specify them anywhere you want.
If you want knots placed at some set of quantiles, calculate the quantiles you want and place knots there (you're unlikely to find more than a couple of sentences on putting knots at quantiles in a book; there's nothing to it).
For example, in R, quantile(x,ppoints(k)) :

$\hspace{1.25cm}$
(here k=10) would be one way to spread knots fairly uniformly across the points of x, but exactly what you do will depend on what you want to end up with; you may want to modify this if you place knots at the boundary points.
You can get approximately what you seek by just placing knots every n/k points; the quantile(x,ppoints... trick above does almost that, except for the first and last segment (which has slightly fewer points out the ends, though it's really only noticeable in small samples)
If you want something else than this, you're going to have to clarify the question further.

Knot location using quantile knots


How to spoof a tcp/http response in C#

Question: I have an app that makes a request to a server and gets authenticated.
I'm wondering if it is a possible to write a listener that listens for requests and if any request matches that particular request the listener sends back a message, without it actually getting to the server.
In essence I want to make the app. think it has been authenticated when it actually hasn't.
This is what the tcp stream looks like on WireShack. The highlighted response is exactly what I want my code to respond to.
Is this possible?
Answer: Yes. It's called a "proxy", and you can do that in C# by using System.Net.Sockets namespace. Or you can use Fiddler and forget about programming at all. :) (Btw - AFAIK Fiddler is written in C# too)
Comment: Thank you for your response. I have already tried fiddler, this particular http request doesn't show up in fiddler..
Comment: Thanks for the upvote, but it doesn't make me notice your plea faster. :) If it doesn't show up in Fiddler, that means that your app isn't set to connect via proxy (fiddler), but rather connects directly. Check the settings of the app, perhaps you need to specify the proxy manually; if not, then you can try first launching fiddler (that will change the settings of Wininet), and only then starting the app.
Comment: Thanks, again. The app connects directly, it doesn't have a proxy setting.. I've tried launching fiddler first but it still doesn't capture.

How to spoof a tcp/http response in C#


Problemas para converter data mon dd yyyy hh:mm

Question: Fiz um select no SQLSERVER dentro do php:
mssql_query(SELECT TOP 1 ven.DATA FROM tab_venda ven (nolock)
                         INNER JOIN dbo.tab_item_venda iven (nolock)
                                 ON iven.num_Venda = ven.NUM_VENDA
                        INNER JOIN dbo.tab_produto pro (nolock)
                                ON pro.cod_produto = iven.cod_produto
                         WHERE ven.tipo_venda <> 'X'
                              AND pro.Situacao = 1
                              AND (pro.ind_controle_periodo = 1 OR pro.Marca = 'RQ ETIQUETAS')
                              AND ven.COD_PESSOA = @cod_cliente
                              AND pro.cod_produto = @cod_produto
                         ORDER BY ven.DATA DESC)

Esse SELECT esta me retornando a data no seguinte formato: Feb 19 2013 12:00:00:000 dentro do PHP. Se caso eu fiz a mesmo select direto no SQLSERVER Management Studio ele me retorna no formato: 2013-02-19 00:00:00
A primeira questão seria: Porque dentro do PHP o formato da data esta sendo: Feb 19 2013 12:00:00:000?
Quando eu tento formatar a data usando:
date('Y-m-d', strtotime($data))

o resultado esta sendo: 1969-12-31
A segunda questão é, porque esta retornando a data 1969-12-31 em vez de 2013-02-19?
Answer: Tente utilizar a função FORMAT no SQL, como o exemplo abaixo:
SELECT FORMAT(ven.DATA, 'dd/MM/yyyy', 'en-US') AS 'data';

Ou formatar no PHP:
$parsed = date_parse_from_format('M d Y H:i:s:B', $data); // 'Feb 19 2013 12:00:00:000'
$new = mktime($parsed['hour'], $parsed['minute'], $parsed['second'], $parsed['month'], $parsed['day'], $parsed['year']);
echo date('Y-m-d', $new);
echo date('d/m/Y', $new);

Espero que ajude.
Comment: Acho que isso não responde nenhuma das duas perguntas.
Comment: É uma alternativa para tratar o retorno do SELECT dela, talvez seja útil e resolva as duas questões e talvez não seja, mas não deixa de ser uma resposta, colabore com uma sua também. Abraço @JéfersonBueno
Comment: Sim, que é uma alternativa eu sei. Mas se presares atenção verá que as perguntas são: `Porque dentro do PHP o formato da data esta sendo: Feb 19 2013 12:00:00:000?` e `Porque esta retornando a data 1969-12-31 em vez de 2013-02-19?`
Comment: Muito Obrigada pela ajuda, mesmo tentando formatar direto no SELECT o retorno continua no formato: Feb 19 2013 12:00:00:000 acredito que é algo ligado ao formato de data no Linux, eu acho né.. num sei
Comment: Editei a resposta com a opção de formatação em PHP ve se te ajuda @LaísaFerreiraCardoso
Answer: Pode usar a função Convert.
SELECT CONVERT(VARCHAR, GetDate(), 103) As Data_Hoje
Vai retornar:

24/09/2015

SELECT TOP 1 CONVERT(VARCHAR, ven.DATA, 103) as Data FROM tab_venda ven (nolock)
INNER JOIN dbo.tab_item_venda iven (nolock)
ON iven.num_Venda = ven.NUM_VENDA
INNER JOIN dbo.tab_produto pro (nolock)
ON pro.cod_produto = iven.cod_produto
WHERE ven.tipo_venda <> 'X'
AND pro.Situacao = 1
AND (pro.ind_controle_periodo = 1 OR pro.Marca = 'RQ ETIQUETAS')
AND ven.COD_PESSOA = @cod_cliente
AND pro.cod_produto = @cod_produto
ORDER BY ven.DATA DESC

Você fez isso acima e fez como no PHP ?
Quando faz isso, a data já é formatada no formato dd/mm/YYYY, não precisando assim, formatar pelo PHP usando date ou strtotime.
Comment: Então é essa a questão, mesmo eu formatando no SELECT o retorno dentro do PHP é Feb 19 2013 12:00:00:000 nesse formato.. mesmo formando. Se eu fizer essa query fora do PHP, dentro do Managent Studio por exemplo da certinho, mas quando joga dentro do PHP não formata.. por isso que eu acho que pode ser configuração do servidor.. eu acho
Comment: Muito Obrigada pela ajuda, mas mesmo eu tentando formatar a data dentro do SELECT o retorno continua no formato: Feb 19 2013 12:00:00:000. Acredito que é algo relacionado ao servidor Linux
Comment: Atualizei meu post.
Comment: Você pode por na sua pergunta como está fazendo no PHP ? Não creio que seja o servidor...


How do you bind an object returned from a factory to a method on an element?

Question: I am learning how to use angular and I decided to split some code off into its own module to keep my main javascript file cleaner. I have everything working except for the binding part. Before I split it I had an element in my html file using ngStyle and I had a variable on my scope. I would call $scope.$apply(function () { $scope.styles = { width: xxx }; }) when ever I set the variable on my scope and the element would update.
When I removed everything from my code and seperated it into a factory and directives I couldn't figure out how to do the same thing. I basically ended up with the code below and everything works except ele's style tag does not update.
I wanted to use variables to hold the values and generate the styles object so I didn't have to do extra work myself, did I handle this correctly? If so, how can I make sure the element updates when myFactory's size variable changes? If not, what would be a better way to handle this?
angular.module('test').factory('myFactory', function ($) {
    var size = 0;

    return {
        setSize: function (value) {
            size = value;
        },
        styles: {
            width: size + "px"
        }
    };
});

angular.module('test').directive('testDirective', ['myFactory', function (myFactory) {
    return {
        restrict: 'EA',
        link: function (scope, ele) {
            ele.css(myFactory.styles);
        }
    };
}]);

Answer: The link function only runs once when the directive is added to the DOM. I assume you purposefully don't want to add elements to the DOM with this directive, so I would suggest trying something like:
angular.module('test').directive('testDirective', ['myFactory', function (myFactory) {
  return {
    restrict: 'EA',
    link: function (scope, ele) {
      scope.$watch(function () {
        return myFactory.styles;
      }, function (newValue) {
        ele.css(newValue);
      }, true);
    }
  };
}]);

Comment: I didn't catch the issue with `setSize` that @charlietfl did. I think a combination of his code and the above code will allow updates to the factory to be reflected in the directive.
Comment: I had actually tried that verbatim but it didn't work either.
Answer: Check the working demo: JSFiddle (Combining the answer of charlietfl and Exo).
In the factory, change the styles to be an object:
angular.module('test', [])
    .factory('myFactory', function () {
    var styles = {
        width: 100 + 'px'
    };

    return {
        setSize: function (value) {
            styles.width = value + 'px';
            console.log(styles);
        },
        styles: styles
    };
})

Then $watch the objects in the directive link function:
scope.$watch(function () {
    return myFactory.styles;
}, function (newValue) {
    ele.css(newValue);
}, true);

Comment: The only issue with this is that I need to access the number elsewhere, I was hoping to avoid having to parse it out
Comment: At least, you need some mechanism to **inform** the users of the factory: "Hey guys, I have changed the value, please update". `$watch` is to ensure the directive gets this message. I kind of cannot think of other ways except this mechanism (or similar).
Comment: Oh, maybe you want to use `events` (pub/sub) to control. But it needs extra code as well.
Answer: Your size variable is a primitive so your width property won't update when you change it. The styles.width value will only be whatever it is when factory is initialized.
Change the setSize() function to actually update styles.width
 setSize: function (value) {
    this.styles.width = value + 'px';
  }

Now any scopes that are sharing this property will be updated also


Applying 2 PDFs - for resource demand and also duration of resource use

Question: If I have a (lets say) kayak rental business which is open 24/7 and has no hourly variation in the parameters outlined below.

The number of customers approaching the stall to rent a kayak each hour follows a Poisson distribution, say with a λ = 0.5
The duration of rental (time before the customer returns the kayak) follows a right skewed distribution of some kind - lets say log normal (working in hours as our unit of time):
μ = ln(2) and σ = ln(1.5)

What is the CDF for the number of kayaks rented out at a given moment in time? If this is not solvable, how might I approximate a solution or find an alternative approach? Thank you.
Answer: If you assume instead an exponential distribution of rental times, then there are exact solutions from the theory of the $M/M/\infty$ queue.
In your example, you might take the exponential distribution with scale parameter $\beta = \exp(\ln(2)+\ln(1.5)^2/2)$, so that the kayak rental times have the same mean as in the lognormal example. Meanwhile your Poisson distribution has $\lambda = 1/2$.
Then the probability of having $j$ kayaks rented out after $t$ hours is $e^{-u}u^j/j!$ where $u=\lambda\beta(1-e^{-t/\beta})$.


Lilypond: How to use repeat bars in markup lyrics

Question: I am using \markup after the score for several verses of lyrics, so roughly
\score { ... }
\markup {
  \column {
    \line { ... }
    ...
  }
}

How can I typeset repeat marks for a piece of lyrics that gets repeated? I tried using \bar "...", \markup { \bar "..." }, and I had a look at the various music glyph commands inside markup, but I can't see to find anything suitable.
Answer: Lyrics are text, and repeat bars in text are different from repeat bars in music.  Assuming reasonably complete text fonts, probably the simplest expedient is using what is intended for use in text:
repL = \markup \char ##X1D106
repR = \markup \char ##X1D107
\markup { \repL This cannot be repeated enough \repR }


Using Carousel without module

Question: I want to use jCarousel plugin or similar. But I do not want to use the module.
Add content will form part of and the carousel will add pictures. How can I do? Does anyone have an idea?
Comment: You're going to end up essentially writing a watered-down version of the code from the jCarousel slideshow module anyway (no way around that) so why not just use it? Also please add more information to the question about what you want to achieve, what research you've done to solve the problem yourself, and most importantly [_what you've tried_](http://mattgemmell.com/2008/12/08/what-have-you-tried/). No-one's going to write a full module for you so you'll need to do your own research, and ask for help here on _specific issues_
Comment: @Clive ok, sorry. I will try it.
Answer: You can do this on the theme level.
Your obviously going to want to setup the content using the CMS so will take the form of nodes.
You can then use a process function to determine what content type you are on for applying your script, for example...
function YOURTHEME_preprocess_node($variables) {
   if ($SOME_NODE) {
      // Add JS plugin...
   }
}

You can then create template files for node or specific fields in that node with markup that the plugin can manipulate.
node--[CONTENT_TYPE].tpl.php

To be honest, take Clives advice, use the modules, thats what makes Drupal what it is.

Using Carousel without module


K-Means clustering - upper bound for number of iterations

Question: Suppose we run the K-means clustering algorithm on a one-dimensional dataset, i.e. $p = 1$, so that each observation consists of a single real number.
We assume that these real numbers are distinct.
We need to show that the algorithm terminates in at most $n^{K-1}$ steps.
I know that I can find an upper bound for the number of steps based off of Stirling numbers, but that will be much higher than the required bound.
Any ideas on how to get the $n^{K-1}$ ?
Answer: Let us call our one-dimensional dataset $X$.
Since this is a deterministic algorithm that visits partitions of $X$ into consecutive data points, it suffices to show that there are at most $n^{K-1}$ such partitions.
How many such partitions of $X$ are there?
As many as there are ways to place $n$ indistinguishable balls into $k$ non-empty labelled boxes: \begin{equation} {{n+k-3} \choose {k-1}}. \end{equation}
The result follows from a direct evaluation for $k \leq 3$ and the well-known $$ {a \choose b} \leq \Big(\frac{ea}{b} \Big)^b $$ upper bound on binomial coefficients for $k \geq 4$.


A network-related or instance-specific error?

Question: Hi i deployed my application on clients machine an it is working fine but at first when i click on any button it gives me error present in the screen shot:
I am going round and round but not reach at exact issue ,i am using sql server 2012,can anyone explain me what is the actual reason behind this ??
Comment: http://www.sswug.org/articlesection/default.aspx?TargetID=44331
Comment: enable on server FW UDP ports 1433-1435
Answer: I had the same problem and solved as doing followings
1- Go to All Programs > Microsoft SQL Server 2012 > Configuration Tools > SQL Server Configuration Manager
2- Double click the SQL Server on the right pane
3- On the Log On page check the service status below, if it stopped then click the start.
4- Once it turns to running try to connect your database againg. I have solved it doing this just a few minutes ago.
Answer: This is only one possibility among many, but the first thing I would check given you are confident that the target database does, in fact, exist as configured is to ensure there's not an application firewall blocking access.
I would also ensure that named pipes as a protocol is enabled on the server.
Comment: named pipes are enabled  but i have to check for firewall port rule for port 1433
Answer: Few things to check for you:

firewall settings (is port 1433 open?)
is TCP/IP a valid method of connecting (you can check that in SQL Server Configuration tool)
does it allow remote logins?
is it reachable via SQL Server Management Studio?
Comment: @SaadAhmed from the machine it's installed or from machine your application is installed on?
Comment: a machine where my application installed on


Is every integral domain contained in a discrete valuation ring?

Question: Is is true that every integral domain which is not a field is contained in a proper subring of its fraction field which is a DVR?
Comment: If the ring is noetherian, then yes.
Answer: If $V$ is a valuation ring, then every overring of $V$ is also a valuation ring. Moreover, these are localizations of $V$. Suppose that $R$ is an overring of $V$ which is a DVR. Then $R=V_{\mathfrak p}$ with $\operatorname{ht}\mathfrak p=1$. All we need is a valuation ring $V$ such that $V_{\mathfrak p}$ is not noetherian for all height one primes $\mathfrak p$. In particular, every rank one valuation ring which is not a DVR is a counterexample.
Answer: No, this isn't true.  For instance, let $R$ be a valuation ring with value group $\mathbb{Q}$, with fraction field $K$.  If $x\in K\setminus R$, then $R[x]=K$, since for every $a\in K$, $ax^{-n}\in R$ for some $n\in\mathbb{N}$ (because $\mathbb{Q}$ is archimedean).  So if $S$ is a ring such that $R\subseteq S\subset K$, then $S=R$.  Since $R$ is not a DVR, this means there is no such $S$ that is a DVR.
Comment: What if we replace DVR with VR in the question. Then can we say something.
Comment: Yes, then it is a standard theorem that such a valuation ring exists (see [Wikipedia](https://en.wikipedia.org/wiki/Valuation_ring#Dominance_and_integral_closure), for instance).


xslt 1.0 eliminate duplicates and also check for conditions

Question: here is my input . I need to eliminate duplicate number and also check for the status not empty and status not Y, how do I do this in xslt1.0 ?
<depositAccount>
        <EligibleDepAccount>
           <type>TIP</type>
           <market>111</market>
           <number>12345678</number>
           <status>Y</status>
           <productCode>OBN</productCode>
        </EligibleDepAccount>
        <EligibleDepAccount>
           <type>TIP</type>
           <market>111</market>
           <number>12345678</number>
           </status>
           <productCode>OBN</productCode>
        </EligibleDepAccount>
        <EligibleDepAccount>
           <type>TIP</type>
           <market>111</market>
           <number>9999999</number>
           <status>N</status>
           <productCode>OBN</productCode>
         </EligibleDepAccount>
        <EligibleDepAccount>
           <type>TIP</type>
           <market>111</market>
           <number>5435678</number>
           </status>
           <productCode>OBN</productCode>
         </EligibleDepAccount>
</depositAccount>

output should like this..
     <depositAccount>
        <EligibleDepAccount>
           <type>TIP</type>
           <market>111</market>
           <number>12345678</number>
           <status>Y</status>
           <productCode>OBN</productCode>
        </EligibleDepAccount>
        <EligibleDepAccount>
           <type>TIP</type>
           <market>111</market>
           <number>9999999</number>
           <status>N</status>
           <productCode>OBN</productCode>
         </EligibleDepAccount>
        <EligibleDepAccount>
           <type>TIP</type>
           <market>111</market>
           <number>5435678</number>
           </status>
           <productCode>OBN</productCode>
         </EligibleDepAccount>
</depositAccount>

I tried using this code below and doesn't seem to work

#

    <xsl:for-each-group select="$depositAccount/EligibleDepAccount" group-by="number">
           <xsl:if test="count(current-group()) > 1">
                <xsl:if test="$depositAccount/EligibleDepAccount/status/text()='Y'">
                    <xsl:copy-of select="current_group()"/>
                </xsl:if>
            </xsl:if>
    </xsl:for-each-group>

#

help please
Answer: Using xsl:for-each-group won't work for you if you're using an XLST 1.0 porecessor. xsl:for-each-group is part of XSLT 2.0.
To solve grouping problems using XSLT 1.0 you can use a technique called "Meunchian Grouping".
Your expected output is not consistent with your goal "I need to ... check for the status not empty and status not Y" as you have a status element with a value of "Y" in your output.
Anyway, I think the type of XSLT you need is something like:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" indent="yes"/>

  <xsl:key name="eligibleDepAccountsByNumber" match="EligibleDepAccount" use="number" />

  <xsl:template match="/">
    <depositAccount>
      <xsl:apply-templates select="depositAccount/EligibleDepAccount[generate-id() = generate-id(key('eligibleDepAccountsByNumber', number)[1])]" />
    </depositAccount>
  </xsl:template>

  <xsl:template match="EligibleDepAccount">
    <xsl:if test="status/text() != 'Y'">
      <xsl:copy-of select="."/>
    </xsl:if>
  </xsl:template>
</xsl:stylesheet>

Comment: thank you dariom for your feedback, my bad I wanted to say "want to check if there is a status element value first and then check if status is Y after removing the duplicates of number
Comment: could you also tell me how do I do this in XSLT2.0 too please ?
Comment: You can simply modify the `test` attribute of the `xsl:if` element to satisfy your condition for the status element. I'm sorry but, I've never used XSLT 2.0! I've only used XSLT 1.0 - it's not typically something I use often so I haven't required XSLT 2.0. I'd suggest posting a new question.


Error! The first argument to the non-static Java function 'replace' is not a valid object reference

Question: I am trying to get ANT to create an HTML report of a JUNIT test in Eclipse but after I created the ANT build I get the following errors when I run it:
<code>[junitreport] Processing C:\Documents and Settings\Administrator\workspace\Home\junit\TESTS-TestSuites.xml to C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\null785926900
[junitreport] Loading stylesheet jar:file:/C:/ANT/apache-ant-1.8.3/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl
[junitreport] : Error! The first argument to the non-static Java function 'replace' is not a valid object reference.
[junitreport] : Error! Cannot convert data-type 'void' to 'reference'.
[junitreport] : Fatal Error! Could not compile stylesheet
[junitreport] Failed to process C:\Documents and Settings\Administrator\workspace\Home\junit\TESTS-TestSuites.xml
</code>
What do I need to do to fix this?
Here are the sections of my Build.xml I am trying to run:
<code><target name="Home">
    <mkdir dir="${junit.output.dir}"/>
    <junit fork="yes" printsummary="withOutAndErr">
        <formatter type="xml"/>
        <test name="Home" todir="${junit.output.dir}"/>
        <classpath refid="Home.classpath"/>
    </junit>
</target>
<target name="junitreport">
    <junitreport todir="${junit.output.dir}">
        <fileset dir="${junit.output.dir}">
            <include name="TEST-*.xml"/>
        </fileset>
        <report format="frames" todir="${junit.output.dir}"/>
    </junitreport>
</target>
</code>
Comment: After pointing the ANT build to the JDK instead of JRE I was able to get the HTML report.
Comment: Second, how should we know what's wrong if you don't post the code failing?
Comment: How did you point the ANT build to the JDK instead of JRE???
Answer: When I got this error I had to right click on my build.xml file in Eclipse, choose the "Run as Ant build..." option (3rd one in the menu) then click the JRE tab and select the "Run in the same JRE as the workspace" option and then proceeded to run the script.  For some reason this fixed the problem.  I honestly don't know why.
Answer: The Eclipse Bug is clearly documented Bug 384757.  The analysis suggests that Oracle introduced the bug.  I need Java version 7 but JunitReport needs Java version 5 and early versions of Java version 6.  The obvious way is to add the "bootclasspath" argument to the Ant junitreport task while the Java problem is fixed by Oracle in a future release.  Unfortunately Ant task junitreport does not support the bootclasspath option.  Is this something the people supporting Ant could do?
Answer: I met this situation while running my java program on Ubuntu 12.04 with *java 1.7.0_51* on Eclipse SDK Juno. I take Bhagyaraj's suggestion which is using apache-ant-1.9.2 instead.
(p.s. The default ant version of Eclipse Juno is *org.apache.ant_1.8.3*, and I use apache-ant-1.9.3)
You may following my steps to setup.

Download apache-ant-1.9.3-bin.zip and extract to a place where you want.
Open your eclipse and choose Window --> Preferences
You can see the Preferences window. On the left hand side please choose ant --> runtime
Now focus on right hand-site of the window. Make sure you are now on Classpath tab and choose Ant Home Entries(Default).The buttons on the right which is Ant Home... is now click-able.
No doubt, click on Ant Home... button and choose the folder where your ant-1.9.3 is. In this step, if you choose wrong folder, Eclipse may show the error message something like Specified Ant home does not contain a "lib" directory. If you choose the right directory, Ant Home Entries(Default) will become **Ant Home Entries()
Don't forget to click apply.

After change those, while you right click on build.xml file and choose Run --> 1 Ant Build, the error message won't show because your ant is now 1.9.3.
I also download apache-ant-1.8.4 to run my build file, but the error can't be solved.
Answer: I used the jdk1.6.45 and latest apache-ant-1.9.2-bin\
Problem solved.
As per note on MikeBach
This is bug#,
please read:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=384757
Fixed in Ant.
Regards,
Bhagyaraj
Comment: Also try: Run in the command prompt where your build.xml file present for quicker resoultion.(ANT: JAVA:1.70_45. and ant-1.9.2) it is really smooth, generated the report.
Answer: If you are using Eclipse/JUnit report with JDK 1.7, please use JDK  1.6.  There is a bug in JDK 1.7 with Eclipse/JUnit report similar to what you describe.  This may be a similar report: https://netbeans.org/bugzilla/show_bug.cgi?id=201022
Answer: I've tried using a few different JRE/JDK settings (all 1.6 and 1.7) with various problems (this or lack of access to XSL file in jar) for each.
It's not a perfect solution obviously but I don't seem to run into these issues if the JUnit report is "raw" in the buildfile -- not wrapped in a target.
Poor workaround obviously in that targets are an important aspect of Ant but sometimes for reporting build targets/dependencies aren't so mission critical. It's not so much of an issue for me yet because I'm running these reports in kindof a one-off fashion rather than as part of a build.
Answer: The Bug was introduced in Java 7u5 according to this comment.
Another comment explains how to workaround it, changing the bootclasspath. (DISCLAIMER: I didn't try and test this.)
This solution, however, worked fine for me:

Download ant-1.9.4
Eclipse>>Preferences>>Ant>>Runtime>>AntHomeEntries
Remove all 1.8.x classpath entries
Add all libs from 1.9.4 instead

According to Ant Changes, this has been fixed since 1.9.1


How to trigger a function on all images with a class when done loading in JQuery 3.X?

Question: I have a webpage on which a lot of images need to load. I want to show a div with a loading gif while the image is loading, but I want to fade out that div when the image is done loading. When I was searching the internet I found the ".load" function, but that's not working on the images. The ".on('load', function(){...})" doesn't work either.
This is what I tried, but doesn't work.

Comment: Any console errors?  Also where are you executing that load binding in relation to the markup on the page?  And I also do not see a jQuery include in your question.
Comment: @Taplar, I linked JQuery via a CDN link, but I didn't include that in the code above. I'm executing that load in a
Comment: @Taplar, Also, I get no console errors when executing
Answer: This is actually working fine.
https://codepen.io/tmdesigned/pen/NWqqXwy
Probably what you are experience is conflict with the gallery library you are using. They often duplicate images in the HTML to achieve their effects. I'd suggests looking at the final output in your inspector and see if the .next() logic still holds.
But, to answer your question if you remove that gallery, as I did in the link above, you'll see the 'loading' image fade out (in the example, all 6 images--3 display images, 3 loading images--are the same, but you can still see the effect).

Comment: I found out what I was doing wrong. I had another script placed before my custom script that only executed when the page was fully loaded. So obviously my custom code didn't run before that other script was finished running, and that was only gonna happen when the page (and all images) were fully loaded. So I placed this custom script before the other script, and now it works just fine. Thank you!


How to set a required field validation for html editor?

Question: I am using a html editor in my page and it is a required field which need to be validated on the button click even though i did not enter any text it is not firing on the button click can anyone help me out?
thanks in advance :)
Answer: You can Do it through Jquery . Just change the type of your button from'Submit' to 'button'
and use the below code
<code>$(document).ready(function(){
    $('#YourButtonID').click(function(){
          var EditorText=$('#YourEditorID').text();
          if(EditorText!='')
          {
              //Perform Your Actions
          }
          else
          {
            // Write any user interactive validation message
            alert('Kindly fill in some text in the editor');
          }
     })
 })
</code>
Hope This Helps You
Answer: code would help but if say for instance you're using "TinyMCE" I know that will validate with unobtrusive validation without any issues.
So, in your class you might have something like:
<code>[Required]
public String myHTMLField { get; set; }
</code>
..amongst other fields...
then in your view (which uses the above class) you would include the jquery validation and unobtrusive validation in there and on the form field have something like
<code>@Html.TextArea(m=>m.myHTMLField, Model.myHTMLField, new { @class="tiny-mce" })
@Html.ValidateMessageFor(m=>m.myHTMLField)
</code>
..where class="tiny-mce" is the trigger for applying the HTML Editor, and the unobtrusive validation will do the rest!


How to pass 2 or more array criteria in SUMIFS formula?

Question: I have a below table as below
A   B   C
a   aa  1
a   aa  1
a   dd  1
a   aa  1
b   aa  1
b   bb  1
b   aa  1
b   bb  1
c   cc  1
c   bb  1
c   bb  1
c   cc  1
d   cc  1
d   aa  1
d   bb  1
d   cc  1

When i put the formula

=SUMPRODUCT(SUMIFS(C1:C16,A1:A16,{"a","b","c"}))

it returns 12
However when i put

=SUMPRODUCT(SUMIFS(C1:C16,A1:A16,{"a","b","c"},B1:B16,{"aa","bb"}))

it returns only 5
Can one one help me with this. I dont wnat to use multi formula like

=SUMPRODUCT(SUMIFS(C1:C16,A1:A16,{"a","b","c"},B1:B16,"aa"})) + SUMPRODUCT(SUMIFS(C1:C16,A1:A16,{"a","b","c"},B1:B16,"bb"}))
Answer: I got the answer that i was expecting from another site.
Thanks http://www.excelforum.com/members/30486.html
=SUMPRODUCT(SUMIFS(C1:C16,A1:A16,{"a","b","c"},B1:B16,{"aa";"bb"}))
Answer: I would use this one:
=SUMPRODUCT(ISNUMBER(MATCH(A1:A16,{"a","b","c"},0)*MATCH(B1:B16,{"aa","bb"},0))*(C1:C16))

or, if C1:C16 always contains only 1, simply:
=SUMPRODUCT(1*ISNUMBER(MATCH(A1:A16,{"a","b","c"},0)*MATCH(B1:B16,{"aa","bb"},0)))

Comment: One question. What if i have a third column and want to add that as a criteria in the formula
Comment: use something like this: `=SUMPRODUCT(ISNUMBER(MATCH(A1:A16,{"a","b","c"},0)*MATCH(B1:B16,{"aa","bb"},0)*MATCH(E1:E16,{"someVal","someAnotherVal"},0))*(C1:C16))`
Comment: i got it =SUMPRODUCT(ISNUMBER(MATCH(A1:A16,{"a","b","c"},0)*MATCH(B1:B16,A19:B19,0)*MATCH(C1:C16,{"aaa"},0))*(D1:D16))
Comment: one Problem.. i use to pass file path and sheet name to the SumIFs INDIRECT("'"&FilePath&Sheets&"'!$AG$231:$AG$280"), can we do the same with Match?
Comment: it seems to me the same as for sumifs: `MATCH(INDIRECT("'"&FilePath&Sheets&"'!$AG$231:$AG$280"),{"a","b","c"},0)`
Comment: let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/51376/discussion-between-sathish-and-simoco)


Multiple Sub-domains with one IP address

Question: I know that it is not possible to configure DNS so that different subdomains get pointed to the same IP, but with different ports. I.e.:
<code>alfa.example.com 10.10.10.1 :550
beta.example.com 10.10.10.1 :560
</code>
Because DNS only provides names and addresses - no port numbers.
I have several subdomains, though they are not all for web applications. For example, some of them are been used for terminal servers, other are for mail servers etc.
For this reason, I need different port and I dont want to make the port fixed in the local machine .
Maybe the solution is by setting up proxy servers for those addresses. They can proxy requests  or  setting up server for the ports that can provide them to the client.
Can you please help me find the best solution?
Comment: @steevoo I'm afraid that makes zero sense. Ports are application dependent. If I put an IP address into an FTP client, it'll try and connect on port 21 by default. Internet Explorer will try and connect on Port 80 and so on. If you've written some custom service listening on a non-standard port then your client application will have to type that manually. There MAY be ways around that, but we'd need more detail.
Comment: It is not clear what you are trying to do! If I access alfa.example.com without any port, what does this mean? I should be connected to port 550?
Comment: -1; question is /completely/ unreadable and sounds like gibberish  even after @Khaled 's attempt at editing. I'm not even going to *try* giving an answer until I have *some* idea what the question actually is...
Comment: if i the server dont give any port , the client dont have any permission to enter the service that i provide. so the server must provide an ip with port so the client access it .
Comment: You need to provide more clarity on what you're trying to achieve. It helps if you work 'backwards' and tell us what you want to end up with, rather than what solution you're trying to engineer to get there.
Comment: i dont want to use standart port i want to provide different port and those ports should not be fixed at the client machine, i want a way to provide the port to the client as i provide the ip by the dns
Comment: DNS doesn't work that way, if you want a client to connect to a service on a non standard port, you need to somehow tell the client to use the non standard port, e.g. in a web browser you'd use `www.example.com:1234` to use port 1234 instead of 80, but there isn't a way of doing this automatically.
Comment: yeh i want to know this somehow u talk about, i want a way to provide the client by the port not necessary by dns,  did u have any solution that can solve this?
Answer: The question is unclear, but there are knowledge bits that may help you :

DNS has nothing to do with ports. It returns IP adresses.
Unlike what you say, It's perfectly licit to have two names/domain/subdomain pointing on the same IP address.
It's perfectly possible to host several websites (with different names) on the same web server. it's called "multi homing" and it works with the server recognizing which site the client is trying to access because it's in the web query. See "apache multi homing" on google on how it works.
If you need to access other services (like mail) with different names, just use different ports. It's easy to decide that smtp.toto.com is on port 1001 and smtp.titi.com is on port 1002. What confuses you is that those services use default ports which are not expressed. But when explicitely deciding the port to use, there is no more confusion.
for terminal service, well, it's the same machine so who care about using different ports for different names ?

P.S. not sure about how smtp (mail) works. Maybe it's possible to do multi-homing for it, too.
Comment: so there is no way to provide the port to the client ?????
Comment: @steevoo well, you just give it manually. Look at this page : http://support.google.com/mail/bin/answer.py?hl=fr&answer=180189 google gives us the ports on which we should access its mail servers. And we put them in our software. Can you be more explicit on your requirements ? Concrete example ?
Answer: I think the answer you're looking for is "No".
There are ways to redirect ports and so on, but ultimately, your client software has to make a request on a port, whether that be entered by the user or written into code or whatever. Either way, it's a client-side issue and you can't solve it server side. They aren't able to just make a request to an IP address in general.
As an example, when you type serverfault.com to in your address bar, Internet Explorer is really going to serverfault.com:80
There's no magic here, it just makes the assumption that a website is going to be on port 80 as that's the official port. The developers could just have easily forced us to choose each time, but they opted to be nice.
If the website was on port 81 for some reason the request would simply fail and you'd have to manually type serverfault.com:81


Rhomobile back function

Question: I'm having a problem getting the back button function to work in Rhomobile.
I've tried various methods of url_for(:index, :back => ....) etc etc and nothing seems to work. The problem with this method is (even if it worked) that it only allows navigation to a set place, rather than a dynamic history/back navigation.
The closest I've come to a working solution is by using this in the application_helper:
def page_back
    WebView.navigate_back
end

and then Back in the view.
This works, and i can navigate across views and even controllers. However, it generates a "Error loading page" error, even though it does actually render the right page...
Does anybody have any ideas?
Comment: Same issue Chris. And one more problem comes. Two consecutive Back do not occur. i.e if I try to  try to Back navigate twice, there is no back navigation for the second time.
Answer: Ok this is what I did in the end. I've decided against using rhodes now but here is what I came up with for this problem:
Added data-add-back-btn="true" to:

Then:

Title

    Back

Rhomobile back function


How to hide the php action file name in php form post method

Question: I have the different php file(process.php) to post the form data form login.html. I saw some of the website forms source code they did not give the direct .php file name. Instead they have given some folder name. I am trying to understand.
Comment: if they didn't specify a file name the form processor was likely an `index.php` file that apache had directory indexes turned on
Comment: Probably looking at a framework, but, you can accomplish what you are looking for with `mod_rewrite`, or an `index.php` file inside that directory
Answer: Most likely, this is achieved using "mod_rewrite": a mechanism for rewriting URLs on the fly. See the Apache docs for more detail: http://httpd.apache.org/docs/current/mod/mod_rewrite.html
Answer: The extension for a file/script can be altered or hidden using mod_rewrite rule in .htaccess file. Another scenario is the usage of framework. The url's in framework work under this concept http://www.example.com/controller/function .


Php array verificar se existe valores ou chaves

Question: [TotalPed] => Array
    (
        [VlrTotalIPI] => 0.00
        [VlrTotalItens] => 652.68
        [VlrTotalDesc] => 0.00
        [VlrTotalPed] => 652.68
        [PercComPed] => 0.00
        [PercComPed2] => 0.00
        [VlrFrete] => 0.00
        [TotalBaseIcms] => 0.00
        [VlrTotalIcms] => 0.00
        [VlrTotalBaseIcmST] => 0.00
        [VlrTotalIcmST] => 0.00
        [vFCPUFDestTot] => 0.00
        [vICMSUFDestTot] => 0.00
        [vICMSUFRemetTot] => 0.00
    )

Tenho este array em uma váriavel $meuArray. Gostária de saber como faço para verificar se os campos existem (keys).
Exemplo: [VlrTotalIPI] caso não exista falar que necessita deste campo (Acredito que tenha que comparar com um array onde estão só os campos necessários).
E também se existem valores para essas chaves, novamente caso não exista, apontar a chave que necessita de valor. Usando função claro, para fazer isso independente do Array.
Answer: Se vc precisa checar separadamente pode usar array_key_exists(), ou isset() para o nome da chave, e empty() para o valor.
if( array_key_exists( 'VirTotalPI', $meuArray ) ) {
    // chave existe
   if( ! empty( $meuArray['VirTotalPI'] ) {
       // não está vazio
   }
}

Se puder ser tudo junto, empty() resolve tudo sozinho (retorna verdadeiro se não existe ou se está vazio)


Cassandra-2.2.3 : Repeatedly facing "writing large partition error" even after multiple repairs

Question: We have a 6 node each 2 datacenter Cassandra cluster production environment setup. We encounter large partition warning. We ran 2 successful repairs, still this is not getting resolved. How can I analyze and fix this?
BigTableWriter.java:184 - Writing large partition system_distributed/repair_history:rf_key_space:my_table (108140638 bytes)
Mode: NORMAL
Not sending any streams.
Read Repair Statistics:
Attempted: 1171896
Mismatch (Blocking): 808
Mismatch (Background): 131
Pool Name                    Active   Pending      Completed
Large messages                  n/a        11              0
Small messages                  n/a         0       48881938
Gossip messages                 n/a         0         113659

Answer: The system_distributed.repair_history table is not one that you really need to concern yourself with.  Unfortunately, this can happen when a lot of repairs have been run.  With 2.2, the only real solution is to TRUNCATE that table every now and then.
Comment: Thanks Aaron, I am going to truncate it. Any chance this might impact future repairs?
Comment: @JikkuJoyce no, this table acts as a tracking mechanism for repairs, but has no bearing on future repairs run.
Comment: Thanks @Aaron, truncated the repair_history and its fixed  We used to get this same error for system/hints. We used to run repair to fix it, going forward seems like we can truncate it using nodetool.


How do you run a Python file in HTML?

Question: A while ago, I created some mini games with Python. And now i'm working with HTML. I know how to link a CSS file to an HTML file. But I do not know how to link a Python file to some words in an HTML file.
I have tried to directly href it to my Python file like this:
Play the Game

This is what I've got so far
{% load static %}

<link rel="stylesheet" type="text/css" href="{% static 'webinfos/style.css' %}">

Home

Alien Invasion

Explanation of Game

How to play

Origin

Play the Game

Crossy Road

Explanation of Game

How to play

Origin

Play the Game

Classic Snake Game

Tips&Tricks

Best Gameplays

Funny Moments

How to Play

Other stuff

I expected it so that when I click on the words that are linked to the file, it runs the game. But instead, it shows:
Page not found (404)
Can someone help me with this?
Comment: In Django you don't link the Python file, you link the route defined for your view.
Comment: But how will a Python game run in the browser?
Comment: Either use Pygame directly or use projects like Titanium or skulpt. But you can not make a web game in python. You have to use js or simply create it with C++ or Java.
Comment: I see that I can't run a python file in html directly
Answer: It's impossible to run a python file in the browser in the way that you're doing it. If you really want to run scripts in a browser it's best to look up JavaScript.
Answer: You could look into something called PyScript, they can also tap into the Python ecosystem, which has useful scientific modules such as NumPy, Matplotlib, and many more.
Comment: a link, an explanation, and all is good.

How do you run a Python file in HTML?


Stochastic integral $\in \lambda^2 $ or $\lambda^2(T)$

Question: Defining the stochastic integral as $$\int_0^t\phi_sdB_s$$if I can prove that $\phi_s \in \lambda^2$ (namely that $\phi_s$ is progressive and E[$\int_0^\infty \phi_s^2ds]< \infty$), which are the additional information that it gives me compared to know that $\phi_s \in \lambda^2(T)$ ( $\phi_s$ progressive and E[$\int_0^T \phi_s^2ds]< \infty$)?
And why these conditions imply the existence of the stochastic integral?
Comment: Hopefully you mean $L^2$ instead of $\lambda^2.$ Unless $\lambda$ is another measure...
Comment: $\lambda ^2=L^2([0,+\infty] \times \Omega, \mathcal P_r, ds \otimes \mathbb P)$
Comment: I think you have typos in your question and you mean $E\int_0^T \phi^2_sds < \infty$ instead of $E\int_0^T \phi^2_s B_s < \infty.$
Comment: @UBM yes sorry, now I correct
Answer: In the construction process of the stochastic integral $\int_0^t f(s) dB(s)$, the integral is first defined for integrands that are simple processes and then is extended to general integrands $f$. These general integrands $f$ have to satisfy the condition $E\int_0^T |f(s)|^2 ds < \infty  \quad \text{(*)}.$ We need this condition to guarantee that $f$ can be approximated by a sequence of simple processes $\{ g_n \}$. Since we already have defined the integral for simple integrands $g_n$, the stochastic integral for a general integrand $f$ is defined as the limit in $L^2$ of the sequence of random variables $\{ \int_0^T g_n(s) dB(s) \}$ where $\{ g_n \}$ converges in $L^2$ to $f.$
More specifically, assume we have defined the Ito integral (wrt to the BM) for integrands that are simple process and we have also proved the following two properties for that ("simple") integral:

Linearity of the integral.
Ito isometry.

We use condition (*) to define the space of integrands for which the integral can be defined. Let $\mathscr{M}^{2}([a,b];\mathbb{R})$ be the space of all real-valued measurable {$\mathcal{F}_{t}\}$-adapted
process $f=\{f(t)\}_{a\leq t\leq b}$ such that
$E\int_{a}^{b}|f(t)|^{2}dt<\infty.$
Lemma 1.
For any $f\in\mathscr{M}^{2}([a,b];\mathbb{R}),$ there
exists a sequence $\{g_{n}\}$ of simple processes such that
$$\lim_{n\rightarrow\infty}E\int_{a}^{b}|f(t)-g_{n}(t)|^{2}dt=0.$$
(This lemma is proved using condition (*). For a proof of the Lemma check  Oksendal- pag 27)
Now, in the next theorem, we use Lemma 1 to prove the existence of the integral.
Theorem
Let $f \in \mathscr{M}^{2}([a,b];\mathbb{R})$ and let $\{g_{n}\}$ be a sequence of simple processes such that
\begin{equation}
\lim_{n\rightarrow\infty}E\int_{a}^{b}|f(t)-g_{n}(t)|^{2}dt=0.
\end{equation}
Then there exists a random variable $X \in L^{2}(\Omega,\mathbb{R})$ such that
\begin{equation}
\lim_{n\rightarrow\infty}E \Big|\int_{a}^{b}g_{n}(t)dB(t)-X\Big|^{2}=0.
\end{equation}
Proof.
We know that $X_{n}:=\int_{a}^{b}g_{n}(t)dB(t) \in L^{2}(\Omega,\mathbb{R})$ for all $n \in \mathbb{N}$. We also know that $L^{2}(\Omega,\mathbb{R})$ is a Hilbert space with the norm $||X||^{2}:=E|X|^{2}=\int_{\Omega}|X(\omega)|^{2}dP(\omega)$, thus $L^{2}(\Omega,\mathbb{R})$ is a complete space.  Thus, we only have to prove that $\{X_{n}\}$ is a Cauchy sequence in $L^{2}(\Omega,\mathbb{R})$. Let $\epsilon>0$. By Lemma 1, there exists an $n_{0} \in \mathbb{N}$ such that $n \geq n_{0}$ implies  $E\int_{a}^{b}|f(t)-g_{n}(t)|^{2}dt < \frac{\epsilon}{4} $. Thus, $ \forall m,n \geq n_{0}$, we have
\begin{align*}
||X_{m}-X_{n}||^{2} & = E|X_{m} - X_{n}|^{2}\\
& = E\Big|\int_{a}^{b}g_{m}(t)dB(t) - \int_{a}^{b}g_{n}(t)dB(t) \Big|^{2}\\
& = E\Big|\int_{a}^{b}[g_{m}(t) - g_{n}(t)]dB(t) \Big|^{2} && \tag*{(linearity int)} \\
& = E\int_{a}^{b}|g_{m}(t) - g_{n}(t)|^{2}dt &&  \tag*{(Ito Isometry)} \\
& = E\int_{a}^{b}|(g_{m}(t) - f(t)) + (f(t) - g_{n}(t))|^{2}dt \\
& \leq 2E\int_{a}^{b}(g_{m}(t) - f(t))^{2}dt + 2E\int_{a}^{b}(g_{n}(t) - f(t))^{2}dt \\
& < \epsilon. \tag*{ (Lemma 1)}
\end{align*}
Therefore, $\{X_{n}\}$ is a Cauchy sequence $L^{2}(\Omega,\mathbb{R})$ and the limit X exists.
The $L^{2}(\Omega,\mathbb{R})$ random variable X is called the Ito integral of $f$ with respect to the BM and is denoted by
$$\int_{a}^{b}f(t)dB(t).$$
If we use $T$ in $E\int_0^T |f(s)|^2 ds < \infty$, we are only guaranteeing the existence of the stochastic integral integral on [0,T].
Note 1: we can define the integral for a more general class of integrands by imposing the weaker condition $\int_0^T |f(s)|^2 ds < \infty \text{ (**) }.$ The class of integrands that satisfy condition $\text{(**)}$ is "bigger" (i.e. it contains the class $\mathscr{M}^{2}([a,b];\mathbb{R}))$ but you loose the martingale property. The process $ I_t = \{ \int_0^t f(s) dB(s) < \infty;$ $0 \leq t \leq T \}$ for integrands $f \in \mathscr{M}^{2}([a,b];\mathbb{R})),$  is an square-integrable martingale. But if $f$ satifies "only" (**), then the process $\{ I_t \}$ is "only" a local martingale.
Note 2: You said in your question that the integrand $f$ must be progessively measurable, but when the integrator is the Brownian motion, it is possible to define the integral for integrands that are adapted (to the B.M. filtration) which is a wider class than the progessively measurable class.
Comment: Could you better explain why it guarantees the existence of the stochastic integral, namely why it imply the existence of the $L^2$ limit?
Comment: I edited the answer and give a proof above. The summary is: (condition (*) $\implies$ Lemma 1) and (Lemma 1 $\implies$ existence of the integral).
Comment: very grateful, amazing answer.
Comment: I have a question: if I have a stochastic integral define as: $\int_0^{\infty}X_sdB_s$ and I want to verify if this integral is well defined. Then I have to check that $X_s \in \lambda^2_loc$ namely I have to verify that, for all t $\int_0^tX_s^2ds < \infty$ is it right? instead If I wanna verify that $\int_0^tX_sdB_s$ is well defined is sufficient that I check that $X_s \in \lambda^2_{loc}(T)$ that is checking that $\int_0^TX_s^2ds < \infty$ (no more for all T). is it right? and the same reasoning if I wanna verify when an integral is well defined for a $X_s$ in $\lambda^2$ or $\lambda^2(T)$
Comment: in other word, if I want to verify the existence of a stochastic integral, I have to check if the integrands is in $\lambda$ or $\lambda(T)$ depending on the interval of the ingral. If it goes until infinity then I have to check for the integrand in $lambda$ otherwise in $\lambda(T)$
Comment: @Alias__:  Yes, that's my understanding.


Verificar a ocorrencia de cada letra em uma string - C

Question: Preciso escrever um procedimento que receba um ponteiro para uma string p e mostre(imprima)o número de ocorrências de cada letra dentro da palavra.
Exemplo: arara deve mostrar a=3 e r=2
         sapato deve mostrar s=1, a=2, t=1 e o=1
estava tentando pensar em uma logica em C Puro mas não consigo. Poderiam me ajudar?
Comment: Defina um array de inteiros com tamanho suficiente para cada letra do alfabeto (letra[27]) e inicialize com 0. Percorra sua string, caractere a caractere, e aproveitando uma particularidade do C faça: letra[tplower(palavra[i]) - 'a']++. Ao final imprima cada elemento de letra que seja diferente de zero. Para saber qual é a letra é só somar 'a' ao índice.
Answer: void procedure (char *palavra){
    int cont, x=0, cont2;
    char letra;

    for (cont=0; cont<strlen(palavra); cont++){
        letra=palavra[cont];
        for (cont2=0; cont2<strlen(palavra); cont2++){
            if(letra==palavra[cont2]){
                x++;
            }
        }
        printf ("\nocorrencias da letra %c = %d", letra, x);
        x=0;
    }
}

main(){

    char word[20];
    char *p = word;
    printf ("Digite uma palavra: ");
    fflush(stdin);
    gets(p);
    procedure(p);
}

Comment: Evite responder apenas com código. Explique um pouco a sua solução.
Answer: void verificarRepeticao(char [],int);
void verificarExistencia(char [],char, int *);
int main(){
int const quantodadeElementos = 50;
char vetorPalavra[quantodadeElementos];

printf("Informe uma palavra: ");
scanf("%s", vetorPalavra);

verificarRepeticao(vetorPalavra,quantodadeElementos);

return 0;

}
void verificarRepeticao(char vetorPalavra[], int quantidadeElementos){
int contador = 0, i = 0, j = 0, teste = 0;
char charVerificaAtual, vetorPalavraDois[quantidadeElementos];

for(i=0;i<quantidadeElementos;i++){
    vetorPalavraDois[i] = '\0';
}

for(i=0;vetorPalavra[i]!='\0';i++){
    charVerificaAtual = vetorPalavra[i];
    verificarExistencia(vetorPalavraDois,charVerificaAtual,&teste);
    if(teste == 1){

    }else if(teste == 0){
        for(j=0;vetorPalavra[j]!='\0';j++){
            if(charVerificaAtual == vetorPalavra[j]){
                contador++;
            }
        }
    vetorPalavraDois[i]=charVerificaAtual;
    printf("%c Ocorreu %d.\n", charVerificaAtual,contador);
    contador = 0;
    teste = 0;

    }
}

}
void verificarExistencia(char vetorPalavraDois[], char charVerificaAtual, int *teste){
int i=0, testedois = 0;

for(i=0;vetorPalavraDois[i] != '\0';i++){
    if(charVerificaAtual == vetorPalavraDois[i]){
        testedois = 1;
        break;
    }
}
*teste = testedois;

}


What is the strumming pattern for this cover (Under the Sea guitar cover)?

Question: What is the strumming pattern for this cover of Under the Sea?  There seems to be a percussive hit in there but it could just be my amateur ears.  And it seems he just using his index finger to strum?
Comment: There;s a percussive aspect to the strumming (as there always is) and he's using his thumb and index finger to strum. I'm not sure I understand the question. The strumming pattern is the one he's using.
Comment: @PeterJ "The strumming pattern is the one he's using"  Very helpful /s.  I think you know what I mean
Comment: I wan't being rude. I was wondering how it would be possible to explain the strumming any better than the video demonstrates it. Basically you move your hand up and down like he does. There's no special technique here but just up and down strumming. .
Comment: @PeterJ Just looking at the hand movement often isn't accurate though since you might be moving your hand up and down to keep the beat but not strumming.  Faith by George Michael is a good example of what I mean.  And unfortunately my amateur ears aren't good enough to distinguish these patterns yet
Answer: Okay, fair enough, perhaps my first comment was rather pointless. If you'd played George Michael's 'Faith' it would have been a different comment. What this guy is doing is just strumming up and down and using the back of his hand to damp the strings.
To do this requires that you strum with the back of your RH close to the strings. If you rest the back edge of your hand on the bridge far enough back that the strings are not damped and strum up and down and then gently bring your hand forward until it starts to damp the strings you'll get the idea.
If you simply have fun strumming and damping for a while you'll start getting a feel for it. For a masterly demonstration there is always Niles Rodgers.
I'd suggest just repeating a note on the open 6th string and getting the hang of damping, then try it with the open E and a B on the 5th string (a 'power chord') and then all the strings.
This sort of damping is crucial on an electric, especially a high volumes. It's the key to funkiness.
Usually the RH is just going up and down and the rhythmic interest comes from damping, stressing certain beats and missing the odd up or down stroke. Still, it's just up and down.
This guy is placing his thumb and first finger together and using his first finger as a pick. This is the best idea with nylon strings to save damage and for a certain sound but not so good on steel.
This is most definitely not rocket-science and if you just strum away for a while it should come naturally.


Demoting 2008 domain controllers in a multi-DC environment

Question: This seems like a silly question, but I've looked everywhere and cannot find the answer in any videos.
I am assuming that demoting a DC in AD in a multi DC environment is exactly the same process as demoting a DC in a single DC environment, except that in a single scenario, you are deleting Active Directory entirely.  Is that correct?
I'm 99% sure that demoting a single DC will not delete or alter Active directory on the other DCs, but I have no one to ask and I'm afraid I will make a huge mistake if I do not 100% know what I am doing.
The scenario I have is that we have 3 2016 DCs and 3 2008 DCs in a 2008 functional level domain.  I need to ditch the 2008 machines to raise the functional level.  What is the process to demote the 2008 DCs?
Answer: You can demote the 2008 without problem if, and only if you have the global catalogue on atleast one other alive DC.
Be sure the DFR/FRS replication work good too. (aka for SYSVOL, NETLOGON)
A bad replication would not kill your domain, but can give headache and block user login for the time you fix the replication, but a missing global catalogue might bring down your domain.


how to validate sigprocmask is working

Question: I am using sigprocmask to block signal and getting my process killed.
 It works but is there a way to validate that say using /proc/<pid>/status
 If I remove sigprocmask statements below the code does not work but I do not see any difference in /proc/<pid>/status with resepct to SigIgn,SigCgt,SigPnd ,Sig*
my $sigset_old = POSIX::SigSet->new;
my $sigset = POSIX::SigSet->new;
$sigset->emptyset();
$sigset->addset(&POSIX::SIGPOLL);
POSIX::sigprocmask(SIG_BLOCK,$sigset,$old_sigset);

while(1)
{

  POSIX::RT::Signal::sigwait($sigset);
  POSIX::sigprocmask(SIG_UNBLOCK,$old_sigset)
 <some code>
 ...
 ...
}

Comment: Can you show code that explicitly demonstrates a problem?  For example, code that prints the "SigBlk:" line from `/proc/$$/status` before and after you SIG_BLOCK?  Or code that _kill()_ s itself after you SIG_BLOCK?  Correcting for imports and typos (and ignoring the rather unusual part where you unblock after a _sigwait_), your code does what I'd expect in the `status` file.  Perhaps you're not looking at the right files
Answer: Instead of:
POSIX::sigprocmask(SIG_UNBLOCK,$old_sigset)

do:
POSIX::sigprocmask(SIG_SETMASK,$old_sigset)

The old signal mask does not contain your POLL signal, so it is not unblocked in the second call. What you want is either to set the old signal mask like shown or to unblock your signal with
POSIX::sigprocmask(SIG_UNBLOCK,$sigset)

This is incorrectly documented in many places in the internet e.g. https://www.oreilly.com/library/view/perl-cookbook/1565922433/ch16s21.html
Seems like often, one copies from the other.

how to validate sigprocmask is working


Remove extra whitespace in UItableView

Question: I've added a tableView in my ViewController and then a UItableView Cell.
I am getting this white space between my buttons and tableView.
How to fix?
Comment: Please, add your code to help you to fix this issue
Comment: for creating this i just used `Storyboard` :| no codes
Comment: what is the y position for your tableview?
Comment: Looks like the position or insets of `UITableView` are not set correctly to resemble your requirements... Check them in attributes inspector
Answer:
Select the view controller and on the utilities panel (the panel on right)
Attributes inspector > View Controller > Layout
Uncheck Adjust Scroll View Insets

Remove extra whitespace in UItableView


Why does drawing $\square$ mean the end of a proof?

Question: To end a proof, I often write "as was to be shown" or "q.e.d". Both of these terms make sense to me as a reader. On the other hand, I feel a little strange to put down $\square$ although I  saw it many times here and there. In fact, I learned $\square$ notation here. I wonder if anyone could give me a brief explanation of $\square$ notation in mathematics. Where does it come from? More importantly, how does it logically mean "end" of a proof? Thank you.
Comment: I think Halmos started using that box for "QED".
Comment: Strictly speaking, "q.e.d." (as stated) means something like "as was to be shown", so (strictly) it is only appropriate if the last thing in your proof, indeed, was the thing to be shown.  In Euclid, for example, the last thing is every proof is a re-statement of the theorem.  Heath's translation often just has "Therefore etc." and doesn't include the actual re-statment.  On the other hand, if the halmos means just "end of proof" then there is no such quibble.
Comment: I think it first appears in his Measure Theory book.  Halmos, by the way, was a great lecturer.  Went to many meetings, always taking pictures.  Unfortunately, he went through a Minox (tiny spy camera) phase, so many of the pictures were very low res.
Comment: A late addendum: John L. Kelley's *General Topology* (1955) says: "The end of each proof is signalized by ∎. This notation is also due to Halmos."
Comment: Throughout my academic career (fairly recently in history, mid/late 2010's), I have always only used QED or the solid black square tombstone $\blacksquare$. Most instructors prefer these as well. @GEdgar provides useful insight there on a possible distinction. Though I always prefer to restate my conclusion anyway, coming full circle - in my view it truly finishes off a proof.  I only ever see the empty square $\square$ on stackexchange where I have presumed people were lazy with their LaTeX.  A friend uses solid black diamond $\Diamond$.
Answer: It just means the same thing as q.e.d. Its introduction is usually attributed to Paul Halmos:

"The symbol is definitely not my invention — it appeared in popular magazines (not mathematical ones) before I adopted it, but, once again, I seem to have introduced it into mathematics. It is the symbol that sometimes looks like ▯, and is used to indicate an end, usually the end of a proof. It is most frequently called the 'tombstone', but at least one generous author referred to it as the 'halmos'.", Paul R. Halmos, I Want to Be a Mathematician: An Automathography, 1985, p. 403.

(This is quoted in Wikipedia)
Comment: @Chan: of course not. There is no logical relation between the number two and the character $2$, either...
Comment: @Olivier: or, try what Paul Sally does! http://books.google.com/books?id=0mOzVTs2vmwC&lpg=PP1&dq=paul%20sally&pg=PA6#v=onepage&q&f=false instead of the box, he uses a picture of himself smoking a cigar.
Comment: @Theo Buehler I love the //// . I should try ending my proofs with :D or xD for a change.
Comment: @J. M. I'm afraid that this will disappoint you, but I don't have a better reason than: I simply don't like the look of them (maybe this is because I didn't particularly like the lectures I mentioned in my previous comment). Be that as it may, I'm not a big fan of these end of proof signs in general, as good layout should be able to do without them entirely, but this may not be a popular position. I'm using the halmoses out of conformism more than by conviction.
Comment: Thank you. But is there a logic relation between `q.e.d` and $\square$?
Comment: @Olivier: Well, *de gustibus*... You could do as a lecturer of mine did: the number of slashes indicates what kind of proof ends so you can even interlace them: two slashes for a claim, three slashes for a lemma, four and five slashes for propositions and theorems. Immensely practical if you organize your lectures as he did: Theorem ... Proof: ... Lemma ... Proof ... /// ...(continuation of proof of theorem)... Claim ... proof ... // ...(continuation of proof of theorem) ... /////
Comment: @theo: halmoi? :)
Comment: Nice example, now it makes sense to me ;).
Comment: I'm glad that the "rudin" $////$ didn't get adopted more widely :)
Comment: @Theo: If you could satisfy my (morbid) curiosity, why are you glad about that fence of slashes not being more widely adopted? (Personally, I would likely feel dizzy reading one fence of slashes after another, but maybe your reasons are better/more logical...)
Comment: :) ${}{}{}{}{}$
Comment: My favorite alternative "end of the proof" notation is the tiny badger picture in Using the Borsuk-Ulam Theorem by Jiri Matousek (Borsuk means badger in Polish).  I have stared using little panthers.
Answer: See

When typesetting was done by a compositor with letterpress printing, complex typography such as mathematics and foreign languages were called "penalty copy" (the author paid a "penalty" to have them typeset, as it was harder than plain text).[8] With the advent of systems such as LaTeX, mathematicians found their options more open, so there are several symbolic alternatives in use, either in the input, the output, or both. When creating TeX, Knuth provided the symbol ■ (solid black square), also called by mathematicians tombstone or Halmos symbol (after Paul Halmos, who pioneered its use). The tombstone is sometimes open: □ (hollow black square).

http://en.wikipedia.org/wiki/Q.E.D.#Electronic_forms
Answer: I have been told that it had a practical application.  When a referee has read through the proof and checked its accuracy they could check the box.
Comment: Well, I don't think that this is very plausible. When I referee a paper it is very rare that a proof gets away with a single checkmark. More to the point: how do you check a big fat black rectangle as the sign originally was in Halmos's *Measure Theory* or Kelley's *General Topology*?
Comment: @t.b: Plausibility need not be the issue. Take it as a MNEMONIC, for crying out loud.
Comment: Nice example ;). Thank you.
Comment: How could this be a mnemonic? What are you trying to memorize with this story as the mnemonic? Do you have trouble remembering that the "end of proof" symbol is a box?
Answer: Perhaps it comes as a stretch, but consider the natural deduction proofs of Jaskowski.  You find a sequence of statements within boxes with the last statement outside of any of the boxes... see here.  So, you could interpret the box symbol as indicating the last statement as falling outside of the proof boxes, were the proof to get written in that style.  Or in other words, it indicates the last statement as a theorem.  This isn't to say that's a historically correct interpretation of this symbol though.
Comment: Your last sentence understates the reality... this is of course *not* the historically correct interpretation of the symbol.
Comment: The symbol does not "logically" *mean* "end of proof", it simply does. How does the glyph `2` "logically" mean the number two? It doesn't. Some things just *are*, and inventing an "explanation" is at best silly.
Comment: @Doug: It is patently clear that what you consider silly and what I consider silly are disjoint sets, just like what you consider clear and useful is disjoint from my own. If we don't intersect again, I don't think it will be my loss. Or yours, since you care for little beyond your idiosyncratic interpretation of what the universe "should be", as opposed to what it is.
Comment: Inventing explanations may seem harmless. However it is the source of disinformation. Read 1984, and find out how it was actually Big Brother who invented the Halmos box.
Comment: @Mana: Would you   P L E A S E  come here and say like you did before, "Guys, calm down, calm down." Doug was simply creating a MNEMONIC, for crying out loud. As he pointed out, there is no harm if the story is openly acknowledged as invented. The mnemonic for SOS follows the same pattern as Doug's story. That is, unlike most acronyms, the meaning ("Save our souls!") came AFTER the acronym was created (which was picked simply because it was easy to key), and therefore was an "invented" meaning. (An example of a harmful story is the supposed benefit to eyesight from eating carrots.)
Comment: @Arturo I would very, very much doubt them disjoint.  Remember, if there exists a single element where out sets of what we consider silly match, the sets are not disjoint.
Comment: @Mariano No question about that.  But perhaps this answer gives us an interpretation as to how the box symbol "logically" means end of proof.  Your historically correct answer, unfortunately, doesn't seem to do this as the OP wanted.
Comment: @Arturo Yes, the symbol, as interpreted historically does not mean "end of proof".  However, I do not see anything silly in inventing an explanation which makes such a symbol logical per se.  People have engaged in storytelling for centuries.  The explanation I gave here highlights proof boxes, which *do* help keep track of the scope of assumptions in proofs... and it does come as a good idea to keep track of the scope of assumptions in a proof.
Comment: @Asaf Yes inventing explanations comes as the source of disinformation, however, this only happens when invented explanations don't get claimed as invented.  I simply haven't claimed this explanation as anything but invented.
Comment: @MarianoSuárez-Alvarez:@xxx: Understating reality is a large part of what mathematics is all about. Failing to realize that makes you sound like the average high school physics teacher. To refresh, or kindle, this realization, read the answer given by user  to the question "Why do mathematicians use single-letter variables?" As  points out, this understatement of reality ("ideas are not bound by physical reality") is what allows for freedom and creativity in mathematics.
Comment: @Mike: this question is not a mathematical one. Even *if* it were true that understating reality is a large part of what mathematics is all about, it would be completely irrelevant here.
Comment: @MarianoSuárez-Alvarez: You're picking up the wrong end of the stick. I'm not saying that if you are doing mathematics you are understating reality, I am saying that if you are understating reality, you are doing mathematics:)
Answer: I had always used QED (quod erat demonstrandum) at the end of a proof until I was introduced to using Halmos' symbol.  Since it was a 4-sided symbol, my mind has always associated this "quad" symbol with "quod".


For any bounded set $A$ in a metric space $(X,d)$, $A$ is inside $B(x,\epsilon)$ for any $x\in X$ and for some $\epsilon>0$

Question: The idea came to my mind from $\mathbb R^n$, if a set $A$ is bounded there, then you can find a ball centered at $\vec 0$ which consists $A$.
Since $X$ is arbitrary metric space. So there is no unique element as $0$ (by saying unique element, it is unique and special in our hearts). Ergo, I should be able to do it for arbitrary elements in $X$.
Attempt:
Fix any $x_0\in X$ and let $A$ be bounded in $X$. So there is a ball centered at, say $a_0\in A$, for some $\epsilon_0$
$$A\subset B(a_0,\epsilon_0)$$
Now define $m=\sup\limits_{x\in B(a_0,\epsilon_0)} d(x_0,x)$
So $$A\subset B(a_0,\epsilon_0)\subset B(x_0,m)$$
Is there any amusing mistake? If it is wrong can you give me hint for counter-example? Or directly a counter-example?
Comment: Do you mean "For all $x \in X$ there is an $\epsilon > 0$ such that $A \subset B(x, \epsilon)$" or do you mean "There is an $\epsilon > 0$ such that for all $x \in X$, $A \subset B(x, \epsilon)$"? (The first is correct and the second is wrong.)
Comment: First one yes. .
Answer: What you did is correct, but a bit too complicated. If $A \subset X$ is bounded then $A \subset B(a_0, r)$ for some $a_0 \in X$ and some $r > 0$.
If $x \in X$ then for all $a \in A$, using the triangle inequality for the metric $d$,
$$
 d(x, a) \le d(x,a_0) + d(a_0, a) < d(x,a_0) + r
$$
so that $A \subset B(x, R)$ with $R = d(x,a_0)+ r$.


Changed singly linkedList to doubly linkedList

Question: I want to build doubly linkedList from singly linkedList
and the output is [1,10,5,16].
I think the problem is in append,insert and remove function
Could someone help me to change singly linkedList?
What i know about doubly linkedList is there are two node
one point to the next value
second point to the previous value
Here is my JS:

class DoublyLinkedList {
  constructor(value) {
    this.head = {
     value: value,
     previous:null,
     next: null
   };
   this.tail = this.head;
   this.length = 1;
  }
  append(value) {
    const newNode = {
     value: value,
     previous:null,
      next: null

   }
   this.tail.next = newNode;
  newNode.previous=this.head
  this.tail = newNode;
   this.length++;
   return this;
   }
   prepend(value) {
    const newNode = {
     value: value,
     next: null
    }
   newNode.next = this.head;
   this.head = newNode;
    this.length++;
     return this;
   }
   printList() {
     const array = [];
     let currentNode = this.head;
     while(currentNode !== null){
      array.push(currentNode.value)
       currentNode = currentNode.next
     }
    return array;
     }
     insert(index, value){
     //Check for proper parameters;
      if(index >= this.length) {
      console.log('yes')
       return this.append(value);
       }

      const newNode = {
      value: value,
      next: null
      previous:null
      }
      const leader = this.traverseToIndex(index-1);
      const holdingPointer = leader.next;
      leader.next = newNode;
      newNode.previous = this.head
      newNode.next = holdingPointer;
      this.length++;
      return this.printList();
      }
      traverseToIndex(index) {
       //Check parameters
      let counter = 0;
      let currentNode = this.head;
      while(counter !== index){
        currentNode = currentNode.next;
        counter++;
       }
      return currentNode;
      }
      remove(index) {
       // Check Parameters
      const leader = this.traverseToIndex(index-1);
      const unwantedNode = leader.next;
      unwantedNode.previous=leader.head;
      leader.next = unwantedNode.next;
       this.length--;
      return this.printList();
       }
      }

     let myDoublyLinkedList = new DoublyLinkedList(10);
     myDoublyLinkedList.append(5);
     myDoublyLinkedList.append(16);
     myDoublyLinkedList.prepend(1);
     myDoublyLinkedList.insert(2, 6);
     myDoublyLinkedList.remove(2);//Should return [1,10,5,16]
Answer: I've updated the append and prepend function. It should display correctly now
class DoublyLinkedList {
  constructor(value) {
    this.head = {
      value: value,
      previous:null,
      next: null
    };
    this.tail = this.head;
    this.length = 1;
  }
  append(value) {
    const newNode = {
      value: value,
      previous:null,
      next: null
    }
    this.tail.next = newNode;
    newNode.previous=this.tail;
    this.tail = newNode;
    this.length++;
    return this;
  }
  prepend(value) {
    const newNode = {
      value: value,
      previous:null,
      next: null

    }
    this.head.previous = newNode;
    newNode.next = this.head;
    this.head = newNode;
    this.length++;
    return this;
  }
  printList() {
    const array = [];
    let currentNode = this.head;
    while(currentNode !== null){
      array.push(currentNode.value)
      currentNode = currentNode.next
    }
    return array;
  }
  insert(index, value){
    //Check for proper parameters;
    if(index >= this.length) {
      console.log('yes')
      return this.append(value);
    }

    const newNode = {
      value: value,
      next: null,
      previous:null
    }
    const leader = this.traverseToIndex(index-1);
    const holdingPointer = leader.next;
    leader.next = newNode;
    newNode.previous = leader;
    newNode.next = holdingPointer;
    this.length++;
    return this.printList();
  }
  traverseToIndex(index) {
    //Check parameters
    let counter = 0;
    let currentNode = this.head;
    while(counter !== index){
      currentNode = currentNode.next;
      counter++;
    }
    return currentNode;
  }
  remove(index) {
    // Check Parameters
    const leader = this.traverseToIndex(index-1);
    const unwantedNode = leader.next;
    leader.next = unwantedNode.next;
    unwantedNode.next.previous=leader;
    this.length--;
    return this.printList();
  }
}

let myDoublyLinkedList = new DoublyLinkedList(10);
myDoublyLinkedList.append(5);
myDoublyLinkedList.append(16);
myDoublyLinkedList.prepend(1);
myDoublyLinkedList.insert(2, 6);
myDoublyLinkedList.remove(2);//Should return [1,10,5,16]


Why does my FileSystemWatcher not raise events after a period of time?

Question: I have a small vb.net application utilising the FileSystemWatcher hooked up to a UNC path, after an undetermined period of time (< day) events from the watcher are not raised.
Im capturing the file created event and passing the path to a processfile code block:
<code>Private Sub fsWatch1_Created(ByVal sender As Object, ByVal e AsSystem.IO.FileSystemEventArgs) Handles fsWatch1.Created
        'file created in path - process it!
         ProcessFile(e.FullPath)

    End Sub
</code>
Comment: Before we can help, we'll need to see the code you're talking about. Minimising shouldn't cause references to become unused.
Comment: I've found that minimizing isn't causing the issue, the FSW seems to stop responding after a period of time (as yet undetermined)
Comment: is the UNC drive available all the time? Are there no network issues?
Answer: To me it sounded like low-level problems with the network (that can't necessarily be fixed) - so a quick google search has yielded this article on CodeGuru:
http://www.codeguru.com/csharp/.net/net_general/eventsanddelegates/article.php/c9113
in which the author says that it's caused by intermittent network outages (they can go down more frequently than you think - and we're actually talking about the connection between just two machines here, which can be dropped for loads of reasons) and the watcher can end up getting corrupted.
The author hooks into the Error event, and recreates the watcher whenever it's raised.
Hope this helps.
Comment: I've implemented similar code so that fsw.error is handled and logged.

I'll leave this to run for a while and see how it goes, the FSW is running over a WAN link so its very plausible that this is the cause.

- Thanks for your help.


How do I embed an "EVA" view display in a twig template?

Question: I installed the "Twig Tweak" module for Drupal 8
I created an "EVA" display. The view id is "contenu_relation_groupe" and the display id is "entity_view_1".
I added the following in the twig template for my nodes:
{{ drupal_view('contenu_relation_groupe', 'entity_view_1') }}

But nothing is displayed. Any idea why?
I've never managed to embed an "EVA" view in a twig template.
Comment: EVAs are designed to be placed via the Manage Display screen on your entity. Maybe try that or switch your view to be a block and then try the twig tweak.
Comment: @sonfd OK, thanks but i need to display it in twig
Comment: If you add it to your display via Manage Display it will be available in your twig template, just like any other field, that's the whole point of the EVA display type.
Comment: @sonfd I is already enabled in the display, but the twig code returns nothing
Answer: EVAs get added as a field with name like VIEW_ID_DISPLAY_ID. They should appear in the content variable like any other field.
If you've added your EVA to the node's display you should be able to render your EVA, with the configuration from the Manage Display screen, like
{{ content.contenu_relation_groupe_entity_view_1 }}.


Architectural design for data consistency on distributed analytic system

Question: I am refactoring an Analytic system that will do a lot of calculation, and I need some ideas on possible architectural designs to a data consistency issue I am facing.
Current Architecture
I have a queue based system, in which different requesting applications create messages that are eventually consumed by workers.
Each "Requesting App" breaks down a large calculation into smaller pieces that will be sent to the queue and processed by the workers.
When all the pieces are finished, the originating "Requesting app" will consolidate the results.
Also, the workers consume information from a centralized database (SQL Server) in order to process the requests (Important: the workers do not change any data on the database, only consume it).

Problem
Ok. So far, so good. The problem arises when we include a web service that updates the information on the database. This can happen at any time, but it is critical that each "large calculation" originated from the same "Requesting App" sees the same data on the database.
For Example:

App A generates messages A1 and A2, sending it to queue
Worker W1 picks up message A1 for processing.
The web server updates the database, changing from state S0 to S1.
Worker W2 picks up message A2 for processing

I just can´t have worker W2 using state S1 of the database. for the whole calculation to be consistent it should use the previous S0 state.
Thoughts

A lock pattern to prevent the web server from changing the database while there is a worker consuming information from it.

cons: The lock might be on for a long time, since the calculation form different "Request Apps" might overlap (A1, B1, A2, B2, C1, B3, etc.).

Create new layer between the database and the workers (a server that controls db caching by req. app)

cons: Adding another layer might impose significant overhead (maybe?), and it is a lot of work, since I will have to rewrite the persistence of the workers (a lot of code).

I am pending to the second solution, but not very confident about it.
Any brilliant ideas ? Am I designing it wrong, or missing something ?
OBS:

This is a HUGE 2-tier legacy system (in C#) that we are trying to
evolve into a more scalable solution with as minimal effort as
possible.
Each worker is potentially running on different servers.
Comment: Sounds an awful lot like map/reduce to me.  Why would you write such a thing yourself?  I'd just use Hadoop.
Comment: I agree with @duffymo. You're going to spend the rest of your lives trying to make this to work, discovering that eventual consistency is the best you can hope for, and having to write manual reconciliation procedures to deal with node failure. You're better off suggesting a full rewrite in a language designed for this, perhaps ERLang, with hadoop.
Comment: I forgot to mention that this is a HUGE 2-tier legacy system (in C#) that we are trying to evolve into a more scalable solution with as minimal effort as possible. I believe changing everything to hadoop will be a massive task.
Comment: More massive than writing, debugging, and maintaining what Hadoop already does?  I would be sure before committing.
Comment: I am not very familiar w/ Hadoop, so help me out. This system has over 1 Million lines of code, and already does the segregation/calculation/aggregation (Map/Reduce), but it does In-Memory (single server). It also has a lot of intelligence on the SQL Server (stored-procedures, functions, etc.). Now I need it to scale-out, and I´ve migrated to this queue architecture easily w/ few weeks of development. Except for the database concurrency issues. Do you think Hadoop can help in my case ? if so, please point me in the right direction. (I can´t rewrite my whole application)
Comment: I'm not clear on how Hadoop solves this problem.  Hadoop might be one (of many possible) tools used to implement solution #2, but it certainly doesn't solve the problem out of the box.
Answer: I like option 2, especially if the amount of data needed for the full set of calculations isn't unreasonably large.  I assume there is a way to correlate (via id) calculations that belong to the same overall job?
When the first message of a set of calculations comes in, the worker that picks it up queries the database and for all the data necessary to do all calculations and creates a temporary data store.  What this data store would look like would depend on a lot of factors (size, structure, etc.), but it could be a blob/document, a set of data in a relational schema (isolated by correlationId), an entry in an enterprise cache, etc.
You'd need to be careful of the case when Worker 1 and Worker 2 are both working on the same set of calculations, since only one of them should create the data store, and both would need to wait until the store is fully populated before proceeding.
Comment: I can correlate the the calculations to the same overall job. I can generate an ID and set it to all the calculations. But discovering all the data that the job will need is a very complex task for me. I was considering adding a new server to the architecture that all workers will access instead of the database. this server will mantain a cache of the results from the database by job ID. what do you think ?
Comment: Aren't you back to the original problem, then?  Or does each calculation in the sequence only rely on the results of the previous calculation?
Comment: each calculation is independent from each other´s result, they only depend on data from the database. This "server" would be unique, acting as a facade for all connections to the database, so that it can manage everyone´s cache in-memory. Not very confident about it though.
Comment: Hmm, still not clear on how this would solve the problem.  Can't the database still change between messages A1 and A2?  I think you need to do something akin to taking a snapshot of the database when the first message arrives.
Answer: Can you version your DB ?
Lets say the requesting application stamps the start of the calculation with ct1. Now every message this calculation generates is stamped with the same timestamp.
And also each DB update stamps the DB state with the time of the update. So state S0 is on time t0, state S1 on t1 etc.
Now when a worker gets a message it needs to get the DB state where the update time is the largest that is smaller or equal to the message time. In your example, if A1 and A2 are stamped with ct1, and t1 > ct1, both workers will retrieve S0 and not S1.
This means of course that you need to hold several versions in your DB. You can clean those versions after a certain time if you know that your computations must have finished after some time window.
Comment: You have a good point. I could prepare every table to allow versioning, although I would need to rewrite the whole schema. Are you aware of any feature in Sql Server that would do that automatically or at least make it easier ?
Comment: Not really. But adding timestamp rows to your DB schema usually shouldn't be too difficult.
Answer: Thanks everybody for the help.
Since I believe this is problem might be usual in other scenarios, I would like to share the solution we chose.
Thinking more thoroughly about the problem, I understood it for what it really is.

I needed some sort of session control for each job
There was a cache in-process that served as a session control for each job

Now the calculation has evolved to be distributed, I just needed to evolve my cache to be distributed as well.
In order to do that, we chose to use an In-Memory Database (hash-value), deployed as a separate server. (in this case Redis).
Now every time I start a job, I create a ID for the job and pass it to their messages
When each worker wants some information from the database, it would:

Look for the data in Redis (with the job ID)
If the data is in Redis, use the data
If it is not, load it from SQL, and save it in redis (with the job ID).

At the end of the job, I clear all hashes associated with the job ID.