How to create a version of boost::range::transform that has an extra paramter for capturing context

Question: For example I have a vector
std::vector<int> source;

and a struct
struct Foo {
 int x;
 int y;
}

and I wish to do the following
Foo foo;
auto tr = source | boost::adaptors::transform([&](int i){return i+foo.x;};

However the above doesn't compile in the version of boost(1.55) and the compiler version(VS-2010) I am required to use. The problem is that when the lambda captures a variable by reference, the transform adaptor ends up trying to use the assign constructor which is illegal and fails to compile. However if nothing is captured then it all works.
My naive solution would be to wrap transform with another overload such that
Foo foo;
auto tr = source | boost::adaptors::transformed(foo, [](int i, Foo f){return i+f.x;};

This seems to be the pattern preferred by the std library. For example std::lower_bound uses this pattern.
but as soon as I try to think about how to do that I get stuck in template madness trying to wrap the original transform function. If somebody could show me how to generate the overload I require I am sure I could extrapolate that to the other overloads I need.
The alternative solution is instead of using lambdas is to use full functors for each function but this is ugly if I can at least use non capturing lambdas.
Comment: Have you tried capturing a `std::reference_wrapper` by value?
Comment: can you modify the code so it's in the form of a complete compilation unit, along with correct includes? That way, it's easier for us to play with
Comment: `boost::adaptors::transform` is the non-`|` version. I think you mean `boost::adaptors::transformed`, which works fine with capturing lambdas
Comment: @caleth I meant transformed. Fixed now
Comment: @RichardHodges On Godbolt https://godbolt.org/g/cHm7g9 I can't pick the version of boost with the bug though on goldbolt. 1.55
Comment: @Caleth The problem is due to an old version of boost and an old version of visual studio. The error is a bug in boost 1.55
Comment: You just need to have a valid everything else: https://godbolt.org/g/H4SRfR
Comment: @Caleth I know that works. The problem is with an old boost and old compiler. I'm not asking for anybody to prove that linked code  compiles. I know it does under perfect conditions. I'm asking how to wrap transformed so that I use a different mechanism for capturing context.
Comment: @Caleth the problem is I that as soon as the compiler generates a functor rather than a function pointer boost::transform fails. I am asking a specific question. How to wrap boost::adaptors::transformed. I'm not asking how to fix the bug.
Answer: All the machinery of boost::adaptors::transformed funnels down to boost::iterator::transform_iterator. transformed is a type alias, so transformed(fun) is constructing an object, it isn't a function call to be overloaded.
The simplest thing would be to copy iterator/transform_iterator.hpp and range/adaptor/transformed.hpp into a bitransform_iterator.hpp and bitransformed.hpp with an extra Param p (and rename UnaryFunctor to BinaryFunctor for clarity)
Comment: Thanks for answering the question in the direction Im looking for +1. Any chance you would fill out the answer with more detail. I guess what dissapoints me about boost::range is the non trivial way to compose and build on existing infrastructure. I assumed naively that I could easily wrap **transformed** in a function but it seems, as you point out, you always have to start at zero and build again to implement extended features. Again thanks for the pointers.


Apache simple redirect not working

Question: I'm trying to redirect all requests from my website to a subdir but it doesn't work. This thing is going to make me crazy and any help would be appreciate.
In conclusion, I want this :

http://mywebsite/test or http://mywebsite/test42 or http://mywebsite/everything

to

http://mywebmysite/mydir

Here is my rule :
RewriteEngine On

RewriteCond %{REQUEST_URI} !^/mydir/$

RewriteRule ^(.*)$ /mydir/

But it doesn't work... Apache doesn't redirect. What am I doing wrong??
Thank you,
Regards.
Comment: Try adding the passed argument to '/mydir'. Something like **RewriteRule ^(.*)$ /mydir/$1 [NC,L]** where NC flag indicates "no case" detection (upper or lowercase matching) and L indicates to stop processing rules afterwards (not required but good practice in the event you have other rules later on).
Answer: First make sure .htaccess and mod_rewrite are working. If .htaccess is not enabled, add AllowOverride All to Apache configuration file to enable .htaccess
For redirecting test
RewriteEngine On
RewriteRule ^/?test/(.*)$ /mydir/$1 [R,L]
or for everything
RewriteEngine On
RewriteRule ^(.*)$ /mydir/$1 [R,L]

Apache simple redirect not working


Como adaptar esta função para funcionar sem precisar do ID do elemento?

Question: Tenho uma função e quero adaptá-la para funcionar sem precisar do ID do elemento (document.getElementById("slides");). Vi que existe a possibilidade de fazer isso usando o operador NEW porém tive dificuldades. Tem algum exemplo prático que possa ajudar?
pg      = 0;
sg      = 20000;
ft      = document.getElementById("slides");
sn      = ft.getElementsByTagName("div");
tt      = sn.length-1;
st      = ["content-slide show-slide", "content-slide"];

//onclick
function slide(i){"proximo"==i&&md_n(),"anterior"==i&&md_p()}

//próximo
function  md_n(){
    if(pg < tt){
        pg=pg+1;
        sn.item(pg).setAttribute("class", st[0]);
        if(pg > 0){
            sn.item(pg-1).setAttribute("class", st[1]);
        }
    }else if(pg > 0 && pg == tt){
        pg=0;
        sn.item(pg).setAttribute("class", st[0]);
        sn.item(tt).setAttribute("class", st[1]);
    }
    console.log("slide: "+pg);
}

//anterior
function md_p(){
    if(pg > 0){
        pg=pg-1;
        sn.item(pg).setAttribute("class", st[0]);
        if(pg > -1){
            sn.item(pg+1).setAttribute("class", st[1]);
        }
    }else if(pg > -1 && pg != tt){
        pg=sn.length-1;
        sn.item(pg).setAttribute("class", st[0]);
        sn.item(pg-(tt)).setAttribute("class", st[1]);
    }
    console.log("slide: "+pg);
}
//play
start = setInterval(function(){md_n()}, sg);

Answer: Sem o id, uma opção é buscar pela propriedade class. document.getElementsByClassName("nome_da_class");.
Note que isso retorna um array, independente de encontrar um único elemento.
Exemplo
var e = document.getElementsByClassName("nome_da_class");
console.log(e[0]); // imprime no console o primeiro que encontrou.

Para ter todos que encontrou, faça uma laço de repetição
for (var i = 0; i < e.length; i++) {
    console.log(e[i]);
}

De outra forma teria que ler o documento inteiro por todos os documentos até encontrar propriedades específicas do elemento que procura como nome da tag, largura, altura, etc.
Esteja ciente de que postei apenas exemplos, sem tratamento de erros. Por exemplo, no mínimo deve verificar se algo foi encontrado, se não retornou falso, nulo ou undefined, enfim.
Answer: Desta maneira pode selecionar elementos com os seletores normais css.
querySelector() devolve um elemento (o primeiro que encontrar), ou nenhum (caso não haja um elemento com a propriedade desejada)
Já querySelectorAll() devolve todos os elementos (array) com a propriedade desejada, caso existam

var heyClass = document.querySelectorAll('.hey')[0]; // primeiro elemento
var heyData = document.querySelector('[data-name="yoo"]'); // primeiro elemento
var spanTag = document.querySelectorAll('span')[0]; // primeiro elemento

console.log(heyClass);
console.log(heyData);
console.log(spanTag);

Comment: O problema de eu selecionar os elementos pela classe é que desta forma geraria conflito caso eu tentasse implementar mais de um slide por página
Comment: Editado em cima, pode dar os atributos que quiser, nesse caso use querySelectorAll(), como demonstro em cima. Desta maneira consegue obter todos os slides da página. Expliquei em baixo como funciona
Comment: Perfeita a explicação Migue, porém note que ao implementar dois "Slides"  na página não é possível eu usar a mesma função, conforme no exemplo a seguir: -> https://jsbin.com/zihosivexo/edit?html,js,output
Comment: Tem de fazer um ciclo for para percorrer todos os slides: http://jsfiddle.net/4huzr/2676/ . Tente implentar assim com está no inicio do js
Comment: Mesmo dessa forma ainda não deu certo: https://jsbin.com/zihosivexo/edit?html,js,output


how address path works in xcode

Question: I want to load html5 page, in my UIWebView in xcode, when I added files in my project for example: "for my html5:
I have css folder I have javascript file I have images, and my folder structure is like:
css/
javascript/
images/
when I adde these folders in xcode and I run the program, xcode can n't get the address, it can load the html page but with out any  picture, javascript and css since they are in the other folders, I know, when I put all file together not in separate folder everything works but I want to have real folder structure in my xcode (I don't want to use group) would you please help me
for example
here it's works
   NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"about.html" ofType:nil]];

but when I add about in one folder like
 NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"test/about.html" ofType:nil]];

the link it dosent work, How can I fixed this path problem in xcode
when I run about.html if all css,javascript and images are located in about folder everything works in xcode
but when I have them in separate folder about can not load the css / javascript and images
would you please give me some hints
Thanks in advance!
Edit ::
 NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"page1.html" ofType:nil]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];

I want to use something like this folder : test/
[NSBundle mainBundle]pathForResource:@"test/page1.html" ofType:nil]];

Answer: You need to set the baseURL of your UIWebView instance to be the URL of the directory in your main bundle with the content in it, and your links from your html need to be relative.
The code below is a basic way, given my content is in the root of the main bundle.
//find my html file
NSString *htmlFilePath = [[NSBundle mainBundle] pathForResource:@"htmlfile-to-load" ofType:@"html"];
//load it into an NSData
NSData *htmlData = [NSData dataWithContentsOfFile:htmlFilePath];
//get the URL of the bundles resource directory
NSURL *baseURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] resourcePath] isDirectory:YES];
//load tableView
[self.webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:baseURL];

You may need to get your baseURL differently, but that's the idea.
Comment: Thank you for you reply would you please give me one example
Comment: sorry for lots of question , but I can not run your code, but when I use this code in EDIT part I can just one page with out new path

how address path works in xcode


Linear Programming problem: optimal solution, feasable solution space, range variation coefficient, shadow prices, right hand side ranges

Question: here is linear programming question I am having trouble with. Can you show me how to solve this problem in the most easy to use fashion?
For the following Linear Programming problem answer the questions (a) to (e) below:
<code>    Max Z = 3x + 2y

    Subject to:
    2x + y <= 8
    x + y >= 4
    y <= 10
    x, y >= 0
</code>
(a) Solve the problem to find the optimum solution. Clearly label and show the feasible solution space on your diagram.
Comment: Thank you calculus. Answering "(a) Solve the problem to find the optimum solution. Clearly label and show the feasible solution space on your diagram." would already help a lot. What is the best approach to go about things here? Graphical method?
Comment: This is not a homework site. You are supposed to show your work/thoughts on the problem to get a favourable response.
Comment: This is not a homework question - as you should know looking on the date - it is rather an examination question of the past years - I am looking for a right answer so I can recheck to know I am doing everything right.
Comment: @dazzle Please select **one** of the five questions where you stuck. An answer for $a)-e)$ is impossible.
Comment: I corrected the question and reduced it only to a) so its not having to many questions.
Answer: First you solve the constraints for y. For the first constraint I post the step.
$2x+y\leq 8 $
Subtracting 2x on both sides.
$y\leq 8-2x \quad$  (red line)
The key point here is the $\leq$-sign. The feasible region is below the red line. Next constraint:
$x + y \geq 4$
$y\geq 4-y \quad$ (grey line)
The feasible region is above the grey line. The third constraint is
$y\leq 10 \quad$ (black line).
This constraint is not binding due to the first constraint. And finally we have the constraint $x,y\geq 0$. Thus we have to regard the first quadrant only.

I hope it is obvious to you that the green area is the feasible space. The optimal solution can be found graphically. Let denote the value of the objective function as $z$.
$z=3x+2y \ \ $ Solving for $y$.
$z-3x=2y$
$y=\frac{z-3x}{2}$
To start we set $z$ equal to $0$. $y=-\frac{3x}{2}$
This equation can be drawn into the graph as well. It is the thick blue line. Now you push the line parallel upward till the line touches the feasible space the last time. The thin blue lines illustrate the process. The last point where the (shifted) objective function and the feasible space have a common point is $(x^*,y^*)=(0,8)$
Comment: Calculus, thank you very much for this detailed answer!
Comment: @dazzle You´re welcome.


Find the function $u: \mathbb R ^2\to \mathbb R^2$ that holds the property $d^3u(x,y)=0$

Question: Find the function $u: \mathbb R ^2\to \mathbb R^2$ that holds the property $d^3u(x,y)=0$
I really would like some help with this problem because I don't even know where to start.
I thought taking the formula
$$d^3u=\frac{\partial ^3u(x,y)}{\partial x^3}dx^3+3\frac{\partial ^3u(x,y)}{\partial x^2 \partial y}dx^2dy+3\frac{\partial ^3u(x,y)}{\partial x \partial y^2}dxdy^2+\frac{\partial ^3u(x,y)}{\partial y^3}dy^3$$
but I don't know where to go from here. I would appreciate some help
Comment: I guess the trivial solution $u(x,y)=(0,0)$ $\forall x,y\in\mathbb{R}$ will not suffice...
Answer: Looking at your formula one can say the following: $d^3u(x,y)=0$ iff all third partial derivatives $$u_{xxx},\quad u_{xxy},\quad u_{xyy},\quad u_{yyy}$$ vanish identically. This is the case if all second partial derivatives
$$u_{xx},\quad u_{xy},\quad u_{yy}$$
are constants, etcetera. It follows that the most general $u:\>{\mathbb R}^2\to{\mathbb R}^2$ with $d^3u=0$ has the form
$$u(x,y)=\bigl(f(x,y),g(x,y)\bigr)$$
with $f$ and $g$ polynomials of total degree $\leq2$ in $x$ and $y$.
Answer: By dividing $d^3 u(x,y)$ over $(dx)^m(dy)^n$ where $m+n=3$ and $m,n\in\{0,1,2,3\}$, we obtain$${d^3 u(x,y)\over dx^3}=0\\{d^3 u(x,y)\over dx^2dy}=0\\{d^3 u(x,y)\over dxdy^2}=0\\{d^3 u(x,y)\over dy^3}=0$$which yields to the general solution$$u(x,y)=a_1x^2+a_2xy+a_3y^2+a_4x+a_5y+a_6$$
Comment: Can you explain a bit more? I don't understand how did you get to the general solution
Comment: Sure. Note that from $u_{xxx}=0$ we obtain $$u=f_1(y)x^2+f_2(y)x+f_3(y)$$ and from $u_{yyy}=0$ we obtain $$u=f_4(x)y^2+f_5(x)y+f_6(x)$$. Also we get similar information from $u_{xxy}=u_{yyx}=0$. Packing then all together, we find the general solution.
Comment: Ohh I got it. Thank you very much
Comment: You're welcome. Good luck!!


Since symfony/framework-bundle 5.2: Accessing the "validator" service directly from the container is deprecated, use dependency injection instead

Question: Estou rodando test unitário pelo phpunit e está retornando este warning no symfony.
Since symfony/framework-bundle 5.2: Accessing the "validator" service directly from the container is deprecated, use dependency injection instead.
Estou realizando uma injeção de dependência conforme o alerta sugere. Mas infelizmente continua retornando este warning.
Alguem tem alguma dica?
Trecho do código no test:
    protected function setUp(): void
    {
        parent::setUp();
        $grupamentoRepository = $this->entityManager->getRepository(GrupamentoVariavel::class);
        $validator = self::getContainer()->get('validator');
        $this->grupamentoAction = new GrupamentoVariavelAction($grupamentoRepository, $validator);
    }

Trecho do código na classe:
 public function __construct(GrupamentoVariavelRepository $grupamentoRepository, ValidatorInterface $validator)
 {
        $this->grupamentoRepository = $grupamentoRepository;
        $this->validator = $validator;
 }

Answer: Você fez a injeção de dependência, mas ainda está usando o validator do container.
    protected function setUp(): void
    {
        parent::setUp();
        $grupamentoRepository = $this->entityManager->getRepository(GrupamentoVariavel::class);
        // $validator = self::getContainer()->get('validator');
        $validator = $this->validator;
        $this->grupamentoAction = new GrupamentoVariavelAction($grupamentoRepository, $validator);
    }

O mesmo poderia ser feito com o GrupamentoVariavelRepository::class.
Comment: Não é bem assim. A versão do symfony que estou utilizando não tem este $this->validator. Geralmente recupero pelo self::getContainer(). Mas por algum motivo tá retornando como depreciado.
Comment: O construtor que você postou não é o da classe onde está o método `setUp()`?
Comment: Lucas Não é de uma classe que vai ser testada é da classe GrupamentoVariavelAction
Comment: E você não pode adicionar esse construtor no seu teste?
Comment: Porque ? Outros trestes fazem o mesmo com outras classes e funciona. somente este que esta gerando warning quando injeto pelo container
Comment: Eu trabalho com Laravel, não sei como funcionam todos os detalhes do Symfony. Se quiser saber o porque disso é melhor consultar a documentação ou grupos focados no framework (por exemplo, no Discord).
Comment: Entendi. Manda um grupo de discord para que eu possa saber mais informações sobre o assunto. Pode ser ?
Comment: No site deles deve ter, realmente não sei de nenhum.


Probability of circuit operation

Question: I have a question, which is relate to the following topic.
Assuming the following circuit, the probability that the entire system works is given by:
$$P[X]\cup P[Y] = P[X] + P[Y] - P[X\cap Y],$$
given P[X] is defined by the branch AB and P[Y] by CDE. Now, what is the probability that A is not working given the system works?
I would write it as
$$P[A'|Z] = \frac{P[A'\cap Z]}{P[Z]},$$
where $P[Z]=P[X]\cup P[Y].$
Intuitively, one could consider
$P[A']\cap P[Z] = P[A']P[Z]$. However, this only holds when $A'$ and $Z$ are independent. Since the system works independently from branch $AB$ when $C$, $D$ and $E$ are working, one could use $P[A'\cap (C\cap D \cap E)] = P[A']P[C]P[D]P[E]$.
Finally, I reach my question. Why should one still use $P[Z]$ in the denominator, i.e.,
$$P[A'|Z] = \frac{P[A'\cap (C\cap D \cap E)]}{P[Z]}\quad (1)$$ rather than
$$P[A'|C\cap D \cap E] = \frac{P[A'\cap (C\cap D \cap E)]}{P[C\cap D \cap E]}\quad (2)?$$
Equation (1) must be used in order to reach the same answer as given in the book. However, it bugs me that the conditional probability equation requires an "adaptation".
Answer: The question is to calculate the probability that A is not working knowing the system works so $$P[A'|Z] = \frac{P[A'\cap (C\cap D \cap E)]}{P[Z]}\quad (1)$$
as you mentioned it.
The second equation you wrote is literally what is the probability that A is not functioning knowing the bottom branch is working. You would agree that the bottom branch working or not has nothing to do with A working or not, hence those two events are independent and you get simply:
$$P[A'|\cap (C\cap D \cap E)] = P[A'] * P[C\cap D \cap E]\quad (2)$$
Comment: This does not fully answer my question. Why "bending" the conditional probability equation, i.e., $P[A|Z] = P[A]P[W]/P[Z]$, is the way to go? In (1), Replacing $Z$ in the numerator by $C\cap D\cap E$ gives me the idea that the following must be true $Z=C\cap D\cap E$ and it's not, otherwise we would also have $C\cap D\cap E$ in the denominator.
Comment: Z=C∩D∩E  is not true they are not similar events.
You should not be confused by the fact that maybe in this case,  those events have the same probability.
Said differently, imagine that P(Z) was equal to 1/6 you would not have concluded that event Z is the same as  getting a 6 with a faire dice !

Probability of circuit operation


Loop until correct answer is given

Question: Hi could some one please help. I am very new to Python and need help with something I am creating. I would like to to print six statements and then ask the user to enter their answer. The answer needs to be ie. S2, S10 etc. etc. If not true would like it to loop again until correct input has been given.
Please see below:
print("S0 = Initail Issue ")
print("S2 = Information Issue ")
print("S3 = Internal Review & Comment Issue ")
print("S4 = Suitable for Construction in DPP Stage only ")
print("S10 = Construction Issue")
print("CR = Construction Record (As Built)Issue\n")
Initial = "S0"
Information = "S2"
Review = "S3"
DPP = "S4"
Construction = "S10"
As_built = "CR"

Suitability = (input("Look above on the list of suitability is it?\n ").upper())
Suit = {"Initial", "Information", "Review", "DPP", "Construction", "As_built"}
while True:
    Suit = Suitability
    if Suit == Suitability:
        break
    else:
        print("is not the correct information! ")

    Suitability = (input("Look above on the list of suitability is it?\n ").upper())

Comment: What help do you need?  Is something not working as you expected?  Are you having trouble moving forward?  From reading your post, I get no feeling as to what you do or do not understand about the problem, Python, or even programming in general.  Where are you stuck?
Comment: Hi Wyck, The issue I have is a can enter any letters and it will accept the input. What I would like it do is only accept S0,S2,S4,S10 or CR. If those are met will like it move on. If not re-ask the question until the answer is met. Thanks in advanced.
Answer: print("S0 = Initial Issue ")
print("S2 = Information Issue ")
print("S3 = Internal Review & Comment Issue ")
print("S4 = Suitable for Construction in DPP Stage only ")
print("S10 = Construction Issue")
print("CR = Construction Record (As Built) Issue\n")
Initial = "S0"
Information = "S2"
Review = "S3"
DPP = "S4"
Construction = "S10"
As_built = "CR"

validOptions = [Initial, Information, Review, DPP, Construction, As_built]

while True:
    Suitability = (input("Look above on the list of suitability is it?\n ").upper())
    if Suitability in validOptions:
        break
    print("is not the correct information!")

print("You entered", Suitability)

I used if  item  in  container syntax to validate the input by checking to see if the provided input is in a list of valid options.
I also restructured your loop so that you only have to express the input prompt once in your code.
Comment: _Disclaimer:  I am not a Python programmer!_
Comment: Thanks Wyck, Works perfectly and make sense now

Loop until correct answer is given


questions on GO space

Question: There is a proposition from the paper: A broader context for monotonically monolithic spaces.
I have several questions:
Q1, Does every GO-space have $\chi(X)\le c(X)$?
Q2, why $d(X)\le \omega_1$?
Q3, why the author said, $\{X\setminus F_\alpha: \alpha < \omega_1\}$ is point-countable and uncountable which is a tradiction?
If you can answer one question of these, I will also vote you. Thanks ahead.
Answer: See Juhasz' "cardinal functions in topology", where it is shown that for linearly ordered spaces (and hence for GO-spaces as well, as these are subspaces of ordered spaces) $\chi(X) \le c(X)$
and $c(X) \le d(X) \le c(X)^{+}$ (around page 18).
So this answers the first 2: these are standard cardinal function facts.
The last follows from $X$ having calibre $\omega_1$, which means that any uncountable family of non-empty open subsets of $X$ there is an uncountable subfamily with non-empty intersection. The stated family is such a family of non-empty open subsets, but as it is point countable (every point is in at most countably many members) every uncountable subfamily has empty intersection. So this contradicts the calibre $\omega_1$ property.
Comment: Juhász doesn't actually give the argument for $\chi(X)\le c(X)$; he just mentions that Nelly Kroonenberg showed it. Cellularity and density aren't hereditary, so the fact that $d(x)\le c(X)^+$ for a LOTS $X$ doesn't immediately generalize to GO-spaces; some argument is needed.
Comment: $c(X) = hl(X)$ for GO-spaces (also for monotonically normal spaces), and $d(X) = hd(X)$ as well for such spaces. So in GO space they are hereditary. But I agree some argument is needed. I'm not sure whether $d(X) \le c(X)^{+}$ generalizes to MN spaces.
Answer: $\newcommand{\cl}{\operatorname{cl}}$Let $\langle X,\le,\tau\rangle$ be a GO-space.

If $x\in\cl(\leftarrow,x)$, let $\langle x_\xi:\xi<\kappa\rangle$ be a strictly increasing sequence in $(\leftarrow,x)$ converging to $x$, where $\kappa$ is the cofinality of the order $\big\langle(\leftarrow,x),\le\big\rangle$; we may assume without loss of generality that $(x_\xi,x_{\xi+1})\ne\varnothing$ for each $\xi<\kappa$. Otherwise let $\kappa=\omega$, and let $x_n=x$ for each $n\in\omega$.
Similarly, if $x\in\cl(x,\to)$, let $\langle y_\xi:\xi<\lambda\rangle$ be a strictly decreasing sequence in $(x,\to)$ converging to $x$, where $\lambda$ is the cofinality of $\big\langle(x,\to),\ge\big\rangle$; we may further assume that $(y_{\xi+1},y_\xi)\ne\varnothing$ for each $\xi<\lambda$. Otherwise let $\lambda=\omega$, and let $y_n=x$ for $n\in\omega$.

Then $\{(x_\xi,y_\eta):\xi<\kappa\text{ and }\eta<\lambda\}$ is a nbhd base at $x$ of cardinality $\chi(x,X)=\max\{\kappa,\lambda\}$. If $x$ is isolated, then $\chi(x,X)=\omega\le c(X)$, so assume that $x$ is not isolated. Without loss of generality $x\in\cl(\leftarrow,x)$ and $\chi(x,X)=\kappa\ge\lambda$. But then $\left\{(x_\xi,x_{\xi+1}):\xi<\kappa\right\}$ is a family of $\kappa$ pairwise disjoint, non-empty open subsets of $X$, so $\chi(x,X)=\kappa\le c(X)$. It follows that $\chi(X)\le c(X)$.
Being a GO-space, $X$ is a dense subspace of some LOTS $Y$, and it's easy to see that $c(X)\ge c(Y)$. Theorem $2.8$ of István Juhász, Cardinal Functions in Topology (available from the link in reference $[2]$ here) says that if $Y$ is a LOTS, then $hd(Y)=d(Y)\le c(Y)^+$, so $d(X)\le c(Y)^+\le c(X)^+$.
(The answer to the first question is mentioned in a note in Juhász, but the argument isn't actually given.)
Henno has answered the third question, but I think that there's a slightly easier way to look at it that doesn't involve explicit mention of point-countability at all. Since $\mathscr{F}$ is an increasing chain of closed sets whose union is $X$, the family $\mathscr{U}=\{X\setminus F_\alpha:\alpha<\omega_1\}$ is a decreasing chain of open sets with empty intersection. We're assuming that no $F_\alpha=X$, so the sets $X\setminus F_\alpha$ are all non-empty. $X$ has calibre $\omega_1$, so there is an uncountable $\Lambda\subseteq\omega_1$ such that $\bigcap_{\alpha\in\Lambda}(X\setminus F_\alpha)\ne\varnothing$. But $\mathscr{U}$ is a chain, and $\Lambda$ is cofinal in $\omega_1$, so $\bigcap\mathscr{U}=\bigcap_{\alpha\in\Lambda}(X\setminus F_\alpha)\ne\varnothing$, which is a contradiction.
Comment: I realised the chain argument, but I meant to stick as closely as I could to the paper's argument.
Comment: @Henno: I suspected as much, but I thought it worth having both available.
Comment: @BrianM.Scott: From the proposition, it seems that every space $X$ has caribre-$\omega_1$ and $d(X)=\omega_1$, then the space is separable. Is it right?
Comment: @Paul: I think you meant $d(X)\le\omega_1$; yes, if $d(X)\le\omega_1$ and $X$ has calibre $\omega_1$, then this argument shows that $d(X)=\omega$.
Comment: @BrianM.Scott: Thanks.
Comment: @Paul: You're welcome.

questions on GO space


Strategic form: Nash equilbrium

Question: I am currently working through a question where I have to find any Nash equilibrium not in pure strategies, together with the associated payoffs.

I have managed to identify the pure strategy Nash equilibria: (4,10) and (5,7).
As far as I can see, there are no pure strategies for either player which are strictly dominated.
In order to find any Nash equilibrium not in pure strategies, do I delete (4,10) and (5,7) from the matrix?
I.e. so the matrix becomes:

I'm not too sure what to do from this point onward, do I need to set up some sort of a linear system such as:

3σ+1-σ-τ = 2(1-σ-τ)
9π= 8π+6(1-π-ρ)

And substitute τ=1-σ and ρ=1-π into the system?
Answer: Hint: No, do not delete (4,10), that would be a mistake. Observe instead that the mixed stategy $$x=(0,\epsilon, 1-\epsilon)$$ for $\epsilon>0$ (small enough) of player A (rows) dominates his first strategy (u). Thus you can delete (u) to obtain $$A=\pmatrix{0&4&0 \\5&0&2}\qquad \text{ vs } \qquad B=\pmatrix{0 &10& 0\\7 &0 &6}$$ Now similarly the mixed strategy $$y=(1-\epsilon,\epsilon, 0)$$ for $\epsilon>0$ (small enough) of player B (columns) dominates his strategy (r) and therefore you can delete it. This leaves you with $$A=\pmatrix{0&4 \\5&0}\qquad \text{ vs } \qquad B=\pmatrix{0 &10\\7 &0}$$ form which you can find all three Nash equilibria of the game (2 in pure strategies and one completely mixed)!
Answer: Here is my solution:

The pure strategy nash equilibria are $(m,c)$ and $(d,l)$.

In order to proceed with finding mixed strategies, I am going to delete $\mathcal r$ and $\mathcal u$ as they seem to be weakly dominated.

After solving a few simple linear equations:
$\left[ \pi^{*},\rho^{*},\sigma^{*},\tau^{*} \right]$=$\left[ 0,\frac{7}{17},\frac{4}{9},\frac{5}{9} \right]$

Strategic form: Nash equilbrium


Excel and VBscript giving me Invalid procedure call or argument

Question: I am writing a VBScript to create a calendar and at this line, I am getting an error that says
With objExcel.Range("A1:U28")
    '.FormatConditions.Add xlCellValue, xlEqual, "=TODAY()" --- CRASH
    objExcel.Range("A1:U28").FormatConditions.Add xlCellValue,xlEqual,"=Today()" // CRASH
    .FormatConditions(1).Font.ColorIndex = 2
    .FormatConditions(1).Interior.ColorIndex = 1
End With

Error: Invalid procedure call or argument
Comment: Anyone know why this isn't working or how I can fix it?
Answer: In VBScript, you have to explicitly define constants like xlCellValue (and you can't use named parameters via :=). cf info
Comment: I am still stuck in my VBA world apparently


Synesthesia, is it helping the absolute ear?

Question: For info this is it https://en.wikipedia.org/wiki/Synesthesia
I'm not a synesthete that's why I ask the synesthetes who really are and who really hear music in color
You see what? Shapes take shape in the field of vision? Yes but, is that useful for the absolute ear, kind depending on the drawing you see, can you tell if it is a F or a F# for example?
Comment: A friend of mine says he sees colour according to note, chord type, with hints as to the 'flavour' Maj, min,7th etc. He also says that as he approaches 60 his perfect pitch is slipping, so now things seem to be in the wrong colour :\
Comment: I'd be inclined to guess it's the other way around, that perfect pitch is requisite for being able to consistently assign colors to pitches. (Non-music-related synesthete speaking, very jealous of people who can do that).
Answer: I've had in-depth conversations with maybe 15 people with absolute pitch over the years, and in almost all the cases, synesthesia did not play a significant role. In a couple of cases there was some suggestion of it, but nothing major.
So I would say that "color hearing" is a useful metaphor for explaining how some people distinguish notes without reference, but it should not be taken literally.
Comment: Re-read my comment. I have one friend who **absolutely** and **literally** sees pitch as colour, which is why he's now confused [& rather annoyed] by notes having the wrong colour as he gets older. He's tried describing it, but it's just like trying to explain a rainbow to a blind man. I cannot see what he does.
Comment: …but it **can** be literal, see my comment above.
Comment: This doesn't address the question.  And there most certainly are people with color, and object, synesthesia relative to sound.
Comment: I know 3 close friends who very definitely have perfect pitch. Only one of them has synesthesia. One doesn't necessarily involve the other.
Comment: @Tetsujin, the comment above talks about colors or flavors related to "chord type", "Maj", "min", "7th" - i.e. relative pitch, not absolute pitch. And yes, of course, different chords and intervals have different "colors" or "flavors", in fact I'd say that everyone can feel that. But with regard to the actual OP question, i.e. literally seeing colors as the method for having absolute pitch, while I wouldn't rule it out entirely, and while it might be possible in some rare cases, my own direct and indirect experience suggests that usually it just doesn't work like that.


What is the difference between ring $\mathbb{Z}_n$ and congruence to modulo $n$.

Question: What is the difference between ring $\mathbb{Z}_n$ and congruence to modulo $n$.
Are they same thing or what are significant differences between them except we can use integers greater than $n$ for modulo operations. They look like the same.
Comment: Congruence modulo $n$ is a _relation_, so it cannot be a _ring_. They are entirely different types of things; this alone should suffice as an answer.
Comment: @Marc That's not true generally - see my comment to your answer.
Comment: @BillDubuque: just for clarity: by "That" you apparently mean "Congruence is a relation". You claim congruence _can_ be defined as a subalgebra (of $\Bbb Z\times\Bbb Z$ in this case). That's fine with me, although it's not likely that OP considers it this way. And even then, this subalgebra is rather different from $\Bbb Z_n$.
Comment: @Marc You stated that "a congruence cannot be a *ring*". That is false. In fact that a ring congruence *is a ring* is an *essential* property of a congruence. One cannot argue such semantic points so simply.
Comment: @BillDubuque: As I said, it's fine with me; have a nice day. But I actually meant to say a relation cannot be a ring; maybe that is not even quite true set-theoretically, but I don't care.
Answer: First, review the definition of what a ring is.
In particular, it's a type of algebraic structure with two different binary operations defined on it (sometimes referred to as "addition" and "multiplication").
Next, review the definition of the ring $\mathbb{Z}_n$ and you will see that the two binary operations on it are just addition mod $n$ and multiplication mod $n$.
These are interrelated concepts, but the former is a type of algebraic structure with operations, and the latter ($+$ mod $n$ and $\times$ mod $n$) are examples of operations; so they are certainly not one and the same.
Answer: They are of one, but they are different kinds of mathematical objects.
Congruence modulo $n$ is an equivalence relation on $\Bbb Z$, whereas $\Bbb Z_n$ is a ring, namely the quotient ring by the congruence modulo $n$ relation (meaning that two elements of $\Bbb Z$ are regarded identical in $\Bbb Z_n$ iff they are congruent mod $n$).
Answer: To elaborate on my comment, something positive can be said about the relation between the congrence modulo $n$ and the ring  $\Bbb Z/n\Bbb Z$: the latter is the quotient of the the ring $\Bbb n$ by the relation of congrence modulo $n$.
This means the elements of $\Bbb Z/n\Bbb Z$ are classes of the relation of congrence modulo $n$ (which is an equivalence relation; any equivalence relation gives a partition of the set it is defined on into equivalence classes). Moreover the operations of addition and multiplication in $\Bbb Z/n\Bbb Z$ are derived from those operations in $\Bbb Z$: to perform one of these operations, one chooses elements (representatives) from the classes to be added/multiplied, one performs the corresponding operation upon them in $\Bbb Z$, and finally one takes the class (modulo $n$) of the resulting number.
It is a non-trivial fact, which can be proved, that every set of choices of representatives will give the same end result (a class modulo $n$); this is why the quotient ring of $\Bbb Z$ by the relation of equivalence modulo $n$ is defined in the first place. (And it explains why there is no such thing as a quotient ring $\Bbb R/n\Bbb R$; in this case the required property for defining multiplication fails.)
Comment: Generally it is not true that congruences are defined to be merely a *set*-theoretic object such as an equivalence relation. That fails to capture the *algebraic* essence of a congruence. Instead, congruences are more naturally defined *algebraically:* a congruence of a general algebraic structure $\,\rm A\,$ is a certain sub-*algebra* of $\rm\,A^2$ (containing the diagonal $\rm\,A(1,1),\:$ etc). For example, see my [answer here,](http://math.stackexchange.com/a/16157/242) which discusses in detail ring congruences on $\,\Bbb Z\,$ from this viewpoint.
Comment: @BillDubuque: Doubtless you are right (although I think what you say is essentially the same as saying an equivalence relation that is also compatible with the algebraic operations so that these can be transferred to the quotient; this is just what I said, differently), but I doubt whether OP has the mathematical maturity to understand your answer. Or indeed mine.


Criteria for monoid

Question: I'm struggling to understand how to test for an identiy.
Take, the finite group $(G,*) = \{1,2,3,4,6,8,12\}$ where * denotes the binary operation of greatest common divisor.
It is my understanding that an identity does exist in the form $e=1$ as $\forall a \in G$ $a*e=e*a=e$. This would be true for every element of G.
Where am I getting confused as G is declared in my textbook as a non-monoid.
Comment: You should look a little bit closer at your textbook, how is the operation $*$ defined in this case? It's not always true that $*$ is the *normal multiplication operation*.
Comment: That particular subset of the integers is not closed under integer multiplication, so it's not a semigroup or a monoid. My guess is there is something more in the passage you're reading that might make things make sense, like a modulus or something.
Comment: Yes I can't believe I missed it. The binary operation * is in fact for the greatest common divisor. I now understand that G is closed under gcd, but surely the identity, e=1 still exists.
Comment: Identity, if existing, does not necessarily have to be 0 or 1. Different binary operations have different (if existing) identities. 1 is not an identity here since $1*2=2*1=1$, not $2$.
Comment: In fact, $1$ *cannot* be the identity, because for all elements $g\in G$ we have $g*1=1,$ but we *should* have $g*1=g$ if it were an identity. In fact, we can prove that since $1$ has the property that $1*g=1$ for all $g\in G,$ then there *is no identity* in $G$.
Answer: First of all you need to use the correct definition of the identity.
"$e$ is an identity" is defined as "$\forall a\in G, a*e=e*a=\mathbf{a}$", not $e$.
Hint: Use the definition of the identity to prove why we do not have an identity here.
Please only read the hidden part if you still do not understand the question AFTER thinking about it carefully for some time.
Being an identity in this semigroup is equivalent to (please fill in). Then prove that the (please fill in) property does not hold for any element.

 (Please fill in) is being a multiple of all elements of $G$.

Criteria for monoid


What are the different maintenances a piano should receive during its lifetime?

Question: For the past three months, I have been doing extensive search prior to buying my acoustic piano about how to keep the piano in good shape.
Most of the information I found online was about the things I should avoid doing to not damage it. But there are very little information about the things I am supposed to do to actually maintain it.
The followings are some of the few things I was able to find, though it's quite fuzzy:

A piano should be tuned at least once a year, otherwise it can go too much out of tune (which can damage the piano). Some suggest the minimum is twice per year to accomodate to the new weather (cold and hot, winter and summer). You can go higher, but it isn't mandatory.
When the piano technician comes to tune the piano, it can also be the occasion for them to clean the inside of the piano, because accumulating dust can add moisture, which can rust the strings faster. Which is why the lead is kept closed if the piano is not used.
One website suggested that once a year, the "piano harmony" (approximate translation) should be checked. I think it's about whether or not the keys weights are still even across the keyboard.
One other website suggested that, every two years, the piano requires a overhaul of the mechanics and the strings.

I also have some vague memories about some more thorough overhaul or something after a longer time (5, 10 years or something), or even restoring the piano after 20 years. But I am finding little information beside the basics of tuning, and keeping it within a stable humidity and temperature environment.
I'm thinking some of these might not be forcefully mandatory though. So, until I can return to the piano shop and ask them directly, is there anything mandatory, beside tuning, that you need to do to care for your piano?
Answer: Tuning is the main issue, and the advice you've read is good. Once each year is a minimum; twice is better. More often for a piano receiving particularly heavy use. My pianos are used a few hours each day, and twice a year is fine.
The "overhaul" you're reading about is likely "regulation." That's a process by which a technician goes through the entire action and adjusts weights, angles, padding, hammers, ... anything that might affect the evenness of sound or touch. It is not something that needs to be done regularly for a personal-use instrument (as opposed to, say, one in a concert hall) as regular tuning will allow most adjustments to be made as they become needed.
There are other routine, but not "regular" kinds of maintainance, like voicing or needling the hammers, that are done as needed, typically as part of tuning unless a substantial amount of work is needed. "Voicing" is the process of shaping the hammers to adjust tone quality; needling is a process of "fluffing up" hammers that become compacted over time.
In twenty years of piano ownership, I've had regulation done once -- by choice, because I wanted to understand the process, rather than by necessity -- voicing done once, because I was naive about what the piano needed, and needling done once for reasons I no longer recall. On a second piano, 10 years old, I've needed nothing but regular tuning.
Comment: @Clockwork In general you can trust your technician to let you know if there's a problem. If it's small enough they might just fix it for you, but more typically they'll let you know and give you an estimate on any cost. You can and should also ask if there's a particular concern. For example, you might notice a sticky key or a note that doesn't sound quite right to your ear. You can always ask the tuner to take a look. As far as cleaning, my technician will sometimes do a quick cleaning as part of the tuning (basically, using an air hose to blow the dust out of the piano), but not always.
Comment: When I used to have three studio pianos on the go, they were tuned (in UK) every few years. They stayed at concert pitch between tunings (important factor), and everything sounded and played well, so I felt there was no point in doing more. Having moved, my remaining upright is now 5 yrs on from its last tuning session - played every day, in a non-centrally heated studio, and still at concert pitch. Don't see any reason to have it tuned any time soon! Wonder if *not* playing a piano is more detrimental?
Comment: @Clockwork - each to his own. Being a cheapskate, I'm reticent to spend money unneccesarily. If it ain't broke...  But, if I had a problem, or felt it was out of tune, it would be time to send in the experts.
Comment: So basically I can assume that the piano technician will do what needs to be done along with tuning if needs be? Or does it mean I should also ask for "checking" and cleaning?
Comment: @Tim I do remember reading something about if it's played on very much, it might need to be tuned more. And if it doesn't get played at all, some things could happen too, can't remember what.
Comment: I only stumbled on that other question where someone asked if they should tune their piano because it's still perfectly in tune after 18 months. I'm thinking I would still call the technician at least once every year. They're better fitted at determining whether or not the piano is out of tune, and for any care the piano might need.


htaccess maintenance page with a url variable exception

Question: I searched for a while, but couldn't find the exact answer. So here it goes.
I have a membership site that has a PayPal IPN listener. This needs to be active and accesable at all times!
I am doing a maintenance update today that might take a few hours. How do I add an execption for a URL like this in my .htaccess page:
http://mycoolwebsite.com/?listener=IPN

Here is my .htaccess page so far:
# activate rewrite engine
RewriteEngine On

# ip address so i can access
RewriteCond %{REMOTE_ADDR} !=xx.xx.xx.xx

RewriteCond %{REQUEST_URI} !^/img/.*$
RewriteCond %{REQUEST_URI} !^/maintenance\.php$

Thanks NINJAS!
Answer: You can have your rules like this:
# activate rewrite engine
RewriteEngine On

# skip /?listener=IPN from rewrites
RewriteCond %{QUERY_STRING} ^listener=IPN$
RewriteRule ^ - [L]

# rest of your rules follow

PS: I notice that you just have 3 RewriteCond lines without any RewriteRule line. Which is not really doing anything for you.
Comment: oh, really ? I didn't even see that. So I can just take out the RewriteCond if front of those to correct it?
Comment: Yes I guess you can, I am unsure what those lines are doing.
Comment: ha! so I can just do this
`%{REMOTE_ADDR} !=xx.xx.xx.xx
%{REQUEST_URI} !^/img/.*$
%{REQUEST_URI} !^/maintenance\.php$`


How to pass more than one environmental variable name to `by` parameter in dplyr `join` functions?

Question: Let's say I'm writing a wrapper function for full_join (but the question applies to left_join, right_join, and inner_join). The join variables need to be specified by the user in the function call and the function needs to allow for situations when the join variables had different names.
here is the example outside of a function given in the help pages.
full_join(band_members, band_instruments2, by = c("name" = "artist"))

Here is the function that I expected to work:
join_wrapper <- function(data1 = band_members, by1, by2) {
  by1 <- enquo(by1)
  by2 <- enquo(by2)

  data2 <- band_instruments2

  full_join(data1, data2, by = c(quo_name(by1) = quo_name(by2)) )
}

However, I get this error message:
Error: unexpected '=' in: "full_join(data1, band_instruments2, by = c(quo_name(by1) ="
I've also tried as_name() instead of quo_name(), and creating a separate character vector containing the join-by information to pass to by in full_join() like this:
join_wrapper <- function(data1, by1, by2) {
  by1 <- enquo(by1)
  by2 <- enquo(by2)

  data2 <- band_instruments2

  .by = c( quo_name(by1) = quo_name(by2) )

  full_join(data1, data2, by = .by )
}

All this does is shift the error from the full_join call to the .by = call. I even tried using set_names() as suggested in this answer: https://stackoverflow.com/a/49342789/9154433, but I still get the same error message.
Interestingly, this works if the join variables have the same name as in:
join_wrapper <- function(data1, by1) {
  by1 <- enquo(by1)

  data2 <- band_instruments

  full_join( data1, data2, by = quo_name(by1) )
}

join_wrapper(band_members, name)

In my real-world problem, data2 is created within the function, so an alternative solution would involve dynamically naming the join_by variable to match the join_by variable in data1. However, I'm not using dynamic dots, so the := function doesn't work and using "assign" within the mutate call as in: mutate(band_instruments2, assign(quo_name(by1), artist)) returns the new column name as assign(quo_name(by1), artist).
Answer: We can use the curly curly operator inside join_by():
library(dplyr)

join_wrapper <- function(data1 = band_members, by1, by2) {

  data2 <- band_instruments2

  full_join(data1, data2, by = join_by({{ by1 }} == {{ by2 }}))
}

join_wrapper(by1 = name, by2 = artist)
#> # A tibble: 4 × 3
#>   name  band    plays
#>   <chr> <chr>   <chr>
#> 1 Mick  Stones  <NA>
#> 2 John  Beatles guitar
#> 3 Paul  Beatles bass
#> 4 Keith <NA>    guitar

Created on 2023-03-08 with reprex v2.0.2
Comment: @reprex_v2.0.2 what package/library is the `join_by()` function in? I have dplyr loaded and cannot find it in the help. I also get he error "could not find function "join_by"" when I run your code.
Comment: @ESELIA: It's in dplyr v 1.1.0.
Comment: Huzzah! I was running dplyr v 184.108.40.206. Just installed all updates and it works. A note for others, the solution still works if you enquo the passed variables. i.e. `join_wrapper <- function(data1 = band_members, by1, by2) { enquo(by1); enquo(by2); data2 <- band_instruments2; full_join(data1, data2, by=join_by({{by1}} == {{by2}})) } works too. Thanks @repex_v2.0.2 !


Zeroes of multivariate polynomials

Question: Assume you have $m$ points $x_1,\ldots,x_m$ in $\mathbb{R}^d$ and you want to find a polynomial $p$ in $d$ indeterminates such that $p(x_i)=0$ for all $i$, and the value of $p(x)$ is negative at any other point. Is this possible/can you construct one such polynomial?
Answer: Sure. Let $p$ be
$$p(x) = -\prod_{i=1}^m ||x-x_i||^2$$
Answer: Yes, it is possible.
Note that the Euclidean distance from a point $x\in \Bbb R^d$ to the point $x_1$ is always positive, except that it is $0$ at $x_1$. In addition, if you square the distance, what you have is a polynomial.
And the same is true for all the other points $x_i$. So if you multiply them all together you get a polynomial which is $0$ only at the points $x_i$, and strictly positive everywhere else. Finally, if you put a minus sign in front, you get the polynomial you're after.

Zeroes of multivariate polynomials


I want to get more than two targets in output of model machine learning

Question: I want to get two classes in the prediction of the classification model with text.
model_RandomForest = RandomForestClassifier(n_estimators=100,criterion='gini', random_state=0)

if I can add a parameter of number output
Comment: "more than two targets" versus "I want to get two classes" - the difference suggests that you do not consider "targets" and "classes" as synonyms. Is this intentional? If so, what is the difference between your definitions? But a Random Forest is just a forest of decision trees. The outcome is whatever value you put in the leaf nodes.
Answer: If you have multi-label samples, you just need to define the class labels as a 2d numpy array.
Example:
from sklearn.ensemble import RandomForestClassifier
import numpy as np

np.random.seed(0)

X = np.random.rand(10,3)
y = np.random.rand(10,2)
y[y>0.7] = 1
y[y<=0.7] = 0

clf = RandomForestClassifier(max_depth=2, random_state=0)
clf.fit(X, y)

Predict the multi-class labels:
clf.predict(X[:5,:])

array([[0., 0.],
       [0., 0.],
       [0., 0.],
       [0., 0.],
       [1., 0.]])

In sklearn, this is known as multilabel-indicator.

'multilabel-indicator': y is a label indicator matrix, an array of two
dimensions with at least two columns, and at most 2 unique values.


Filtrar elementos com RadioButton em HTML e JS e RegEx

Question: Eu tenho o seguinte problema. Eu tenho 3 elementos label e quero, conforme a opção radiobutton escolhida filtrá-los.
O problema é que quando quero filtrar pelo nome que termina em -ivo não funciona, mas o resto sim.
Eis o código HMTL:

    <input type="radio" name="filter" value="*" checked="checked" /> show all

    <input type="radio" name="filter" value="ivo" /> nome que acaba em ivo

    <input type="radio" name="filter" value="iva" /> nome que acaba em iva

Passiva

Passiva

Agressivo

e o JS
// init Isotope
var $grid = $('.grid').isotope({
  itemSelector: '.element-item',
  layoutMode: 'fitRows'
});
// filter functions
var filterFns = {

  // show if name ends with -ium
  iva: function() {
    var name = $(this).find('.name').text();
    return name.match( /iva$/ );
  }
};

var filterFns2 = {
  sivo: function() {
      var name2 = $(this).find('.name').text();
      return name2.match( /ivo$/ );
  }
};
// bind filter on radio button click
$('.filters').on( 'click', 'input', function() {
  // get filter value from input value
  var filterValue = this.value;
  // use filterFn if matches value
  filterValue = filterFns[ filterValue ] || filterValue;
  $grid.isotope({ filter: filterValue });
});

Answer:
Uma pequena mudança no seu código, e ele funcionará, perfeitamente, observe.

// init Isotope
var $grid = $('.grid').isotope({
itemSelector: '.element-item',
layoutMode: 'fitRows'
});

// filter functions
var filterFns = {

// show if name ends with -ium
iva: function() {
  var name = $(this).find('.name').text();
  return name.match( /iva$/ );
},

ivo: function() {
    var name2 = $(this).find('.name').text();
    return name2.match( /ivo$/ );
  }
};

// bind filter on radio button click
$('.filters').on( 'click', 'input', function() {
// get filter value from input value
var filterValue = this.value;
// use filterFn if matches value
filterValue = filterFns[ filterValue ] || filterValue;
$grid.isotope({ filter: filterValue });
});


Ctrl + Left mouse Click (multiple selection) in mac

Question: I am going to use Ctrl + Left-mouse Click to multiple select object using javascript/jquery.
Below is what I used with jQuery, I test in windows' chrome it is fine and can be used to multiple selection, however, when I use Mac Sarifa to open the page and do the multiple selection, it comes some problems:
When I hold down control Key and click an object I what to select, it will come out a contextmenu.(It seems Mac has this default set, just like right click in windows), however, I do not want this menu show, I just want it can behave like windows, how can I do? Any suggestion is appreciated, thanks.
 $(document).bind('keydown', function (e){

        if(e.keyCode === 17)//Ctrl
        {
            _this.Ctrl = true;
        }
    });
 $(document).bind('keyup', function (e)
    {
        if(e.which === 17)//Ctrl
        {
            _this.Ctrl = false;
        }
    });

Answer: In Mac OSX the appropriate way to implement multiple selection is with the CMD key. It works like this in all native apps and IMO it should work the same way in the browser. What I would suggest you to check for the key in the mouse event handler instead of storing the key on keydown and reseting it on keyup like this:
function isMac() {
    return navigator.userAgent.indexOf('Mac OS X') != -1;
}

$(document).bind('mousedown', function (e) {
    if (isMac() && e.metaKey || !isMac() && e.ctrlKey) {
        // Multiple selection
    }
});

The implementation of isMac is taken from here - http://css-tricks.com/snippets/javascript/test-mac-pc-javascript/.
Comment: for me the simple version `e.ctrlKey || e.metaKey` also seems to work fine
Comment: only problem: as the mac also has a ctrl key you might not want to attach your handler to that key on a mac.
Comment: I do agree with @Jakob here - if we take either of them, both CTRL and CMD keys will do the same on the Mac. Even worse - this will capture the Windows key on Windows, which is definitely the desired result here. Usually the CMD key substitutes for CTRL on Windows and Linux. That's why I suggested the more complicated code.


Rewrite URL after redirecting 404 error in htaccess

Question: How to redirect 404 , in htaccess I have add this
ErrorDocument 404 http://example.com/404/
ErrorDocument 500 http://example.com/500/
# or map them to one error document:
# ErrorDocument 404 /pages/errors/error_redirect.php
# ErrorDocument 500 /pages/errors/error_redirect.php

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^/404/$
RewriteRule ^(.*)$ /pages/errors/404.php [L]

RewriteCond %{REQUEST_URI} ^/500/$
RewriteRule ^(.*)$ /pages/errors/500.php [L]

# or map them to one error document:
#RewriteCond %{REQUEST_URI} ^/404/$ [OR]
#RewriteCond %{REQUEST_URI} ^/500/$
#RewriteRule ^(.*)$ /pages/errors/error_redirect.php [L]

It has reduce but they are increasing, is there a way how can I redirect properly or maybe I'm mising something. How can I fix all of them ?
Thanks
Answer: You dont need to use RewriteRules. You can simply use an absolute path instead of using full url as your errordocument target :
ErrorDocument 404 /pages/errors/404.php


How can I, using Knockout, make a div only viewable when a value from a dropdown is selected?

Question: When I select "USB Access Request" from the dropdown which is pulled from a SHarepoint list, I want to view a div.
Dropdown
Application:
                <select data-bind="value: $data.selectedApp, options: $parent.applications, optionsText: 'ApplicationName', optionsCaption: 'Choose an Application'" style="width: 32px" name="Application list" id="dataBox">
                </select>

Div I want to show

        <input type="checkbox" /> Tick this box if there is an end date for the
        permissions.

Date: <input type="text" id="datepicker"/>

I have removed the script I had as it was completely wrong but will add it if necessary.
Answer: You want to bind the value of the dropdown to a view model observable, like selectedApp. Make sure it's defined in your view model like self.selectedApp = ko.observable();.
<select data-bind="value: selectedApp, options: $parent.applications, optionsText: 'ApplicationName', optionsCaption: 'Choose an Application'" style="width: 32px" name="Application list" id="dataBox">
</select>

Then use the visible binding to show the div only when selectedApp has a value:

    <input type="checkbox" /> Tick this box if there is an end date for the permissions.

Date: <input type="text" id="datepicker"/>

Comment: I just realized how little info I gave you, anyway I added in more details but  Ill try out your answer now. thanks,


I would like to read from a list and display the matching value based on a condition

Question: <code>=IFERROR(ARRAYFORMULA(IF(LEN($A$9:$A),(IFS($B$9:$B=IDs!$A$3,IDs!$B$3)
</code>
If i use the above formula, i would have to repeat it for about 2000 times. Due to the length of my data.
Any suggestion pls.
Answer: Assuming you have a list of ID's (IDs!B3:B) you would want to return when a match is found between the values in B9:B and IDs!A3:A, you could try
<code>=Arrayformula(if(len(A9:A), iferror(vlookup(B9:B, ID!A3:B, 2, 0)),))
</code>
If that is not what you want to achieve, please clarify and if possible share a copy of your spreadsheet.
Comment: Thank you. This is what i wanted. :)


Number of iterations required for $x_n$ to be correct to 100dp

Question: Given $a \in (0.5, 1)$, one seeks to compute $\frac 1a$ using Newton–Raphson method with
$$f(x) = a − \frac 1x$$
Taking $x_0 = 1.5$, compute $x_2$ and estimate which $x_n$ is first
correct to $100$ decimal places, taking the error as $|ax_k − 1|$
This is part c) of the question, part b) says a=0.7 but I am not sure if that is applicable here.
Also i know that $x_{k+1} = 2x_k - ax_k^2$
I'm really confused by this question because I really don't know what method I should be using. I know I want the error to be less than $1\times 10^{-100}$ but that's about it.
Comment: What is the Newton iteration for the given function? Is it really division-free?
Comment: See also https://math.stackexchange.com/q/2271001/115115
Comment: @LutzL the iteration is xk+1 = 2xk - 2a(xk^2). And I saw your answer to that questions but I am still really unsure about mine
Comment: Please add all already known facts to your question so that it becomes clear what exactly the problem is. $\epsilon_0^{2^n}<0.5·10^{-100}$ or $\epsilon_2^{2^{n-2}}<0.5·10^{-100}$ can be solved for $n$ by taking the logarithm twice.
Comment: @LutzL Done what you asked
Answer: You know from some simple computation that $1-ax_{n+1}=(1-ax_n)^2$ and thus by induction
$$
|1-ax_n|=|1-ax_0|^{2^n}
$$
As $|1-ax_0|\le\frac12$ given your data and
$$
\log_2(\log_2(2·10^{100}))=8.380213456543983
$$
one gets a not too large upper bound on the number of steps. Of course, close to $\frac23$ one will need less steps than that.
Comment: don't understand any of this. But thanks, I'm assuming this is correct
Comment: Which part of my data said |1-ax0| < 1/2 ?? I've just done my way and I get the answer to be like 39/40
Comment: With the given interval for $a$ and $x_0=\frac32$, you get $ax_0-1\in [\frac12,1]·\frac32-1=[\frac34,\frac32]-1=[-\frac14,\frac12]$.


Predicate in a method signature, Lambda expression

Question: The code below is just an example. The predicate of string is a
I'm wondering if the code below may not be written more simply :
    public static bool IsValid(Predicate<string> condition, string test)
    {
        return condition(test);
    }

And the call :
Validator.IsValid(s => s.StartsWith("Test"), "Test with a lambda expression")

EDIT
Sorry for the lack of details. The code above is just an example but the IsValid method will take a Predicate parameter, not a Predicate so here the signature :
    public static bool IsValid(Predicate<T> condition, T obj)
    {
        return condition(obj);
    }

Comment: I'm confused. Are you asking if there's a simpler way to write `return condition(test);`?
Answer: Yes, it can be written more simply:
"Test with a lambda expression".StartsWith("Test")

Your IsValid method adds absolutely no value here... If you know the predicate you're going to pass to IsValid, why can't you evaluate it directly instead of calling a "helper" method?
Comment: It's just for the example but the IsValid method will take a Predicate parameter, not a Predicate.
Answer: Personally I think it's cleaner to put the lambda as the last parameter, wherever possible, as it's makes the code easier to read:
public static bool IsValid(T obj, Predicate<T> condition)
{
        return condition(obj);
}

Validator.IsValue(foo,f=>f.Value==1);

Comment: It's just as useless as the previous version... why would you need a method that will just execute a predicate you provide to it? You can just as well execute the predicate yourself


status page empty

Question: I'm trying to display my Facebook status on my personal website. I tried this great tutorial http://johndoesdesign.com/blog/2011/php/adding-a-facebook-news-status-feed-to-a-website
The code work great for a couple of Facebook page that I own. But for a specific FB Page I get to step 4 and then get nothing.
{
"data": [
]
}
Not sure what I'm doing wrong? Any thoughts
The Facebook Page is http://facebook.com/KINGDOM.Gentlemans.Club
(remove space after http://)
The Facebook Page_ID is
114357805248420
Example
https://graph.facebook.com/114357805248420/feed?access_token=???????
Does someone know why I get a blank data page?
Thank you
Marc
Answer: I can't find your page on Facebook (over 21 from the USA), so your problem is one of two things:

Your ID and page username are wrong. I should be able to see your page at facebook.com/USERNAME or facebook.com/PAGE_OR_USER_ID. I can't see it at either of these from the information in your original post.
You've got country and/or age restrictions on your page. If that's the case, your generic App access token isn't going to work. To show the feed of a restricted page on a website, Facebook requires you use the access token of a user who has permission to see your page. This prevents your restricted content from being shown to people who shouldn't be looking at it. If you don't have any restrictions on your site, then you don't need an access token to view the results.

BTW, don't EVER post real access tokens on SO. Anyone can harvest and use them. You should reset your KingomFeed app access token NOW.

status page empty


Recyrcleview Android

Question: No meu caso vou precisar colocar vários botões em um recyrcleview tem como reconhecer em que botão foi  clicado ou somente a posição de um item na lista?

<TableRow
    android:id="@+id/tableRow1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <Button
        android:id="@+id/nome"
        android:layout_weight="1"
        android:background="@drawable/cell_shape"
        android:gravity="center"
        android:padding="10dip" />

    <Button
        android:id="@+id/divisao"
        android:layout_weight="1"
        android:background="@drawable/cell_shape"
        android:gravity="center" />

    <Button
        android:layout_weight="1"
        android:background="@drawable/cell_shape"
        android:gravity="center"
        android:padding="10dip"
        android:text="LANÇAR" />
</TableRow>

Answer: Você pode fazer uma interface que terá um método que será implementado na sua Activity, passar este listener para seu adapter setar o onClickListerner para o seu botão dentro do adapter e chamar o método da interface que você implementou.
Exemplo
Parte 1
public interface OnClickButton{
    void onClick(View view);
}

Parte 2
public class SuaActivity extends AppCompatActivity implements OnClickButton{

@Override
protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.seu_arquivo_xml);

   seuAdapter.OnClickButton(this);
}

@Override
public void onClick(View view) {
   //Aqui você consegue capturar o id da View clicada
   switch(view.getId()){
       case R.id.nome:
           //ação
           break;
       default:
           break;
   }
}

Parte 3
public class MyRecyclerAdapter extends RecyclerView.Adapter<MyRecyclerAdapter .MyViewHolder> {

    private OnClickButton onClickButton;

     public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
        public Button btNome;

        public MyViewHolder(View view) {
            super(view);
            btNome= (Button) view.findViewById(R.id.nome);

            btNome.setOnClickListener(this);
        }

        @Override
        public void onClick(View view) {
            onClickButton.onClick(view);
        }
    }
.
.
.

Tente esta solução, abraços!
Comment: Muito obrigado cara...

Recyrcleview Android


how to overcome from this "'module' object is not callable"

Question: File "C:/Users/kanha/PycharmProjects/automatic_game/bot.py", line 25, in <module>
    imagegrab()
  File "C:/Users/kanha/PycharmProjects/automatic_game/bot.py", line 20, in imagegrab
    image = ImageGrab(box)
TypeError: 'module' object is not callable

the error message im getting how to reslove it?
Comment: `ImageGrab` is a module so you can't call it. Maybe you meant to call `ImageGrab.ImageGrab` or `ImageGrab.grab`, or you meant to do something different in the import line like `from ImageGrab import ImageGrab`.
Comment: what is the import line?
Answer: ImageGrab is a module so you can't call it. From a quick look at the docs, it looks like you meant to call
ImageGrab.grab


php based website that displays page content based on URL?

Question: I would like to make a website that is php and only requires one php document to display the content. It's kinda hard to explain, so let me try my best.
Some websites use a directory based system such as this:
web.URL.com/index.htm
web.URL.com/about.htm
web.URL.com/blog.htm

and so on.
This involves creating a text file for each page.
So, the goal here is to create one page that acts like a frame, and displays content based on the Url, so it will be acting like the above method, but is only one page. I'm pretty sure you can do this, but don't know the proper way to word it or what vocabulary to use when typing it in to google.
Some questions you may have:
Q:Why not use parameters like this:
web.url.com?pgid=some+page

A: I would like the url to be as clean as possible when it comes to the visitor typing the url. For example, this is much easier to remember:
web.url.com/about

than this:
web.url.com?p=about

Q: Wordpress??
A: We want our own stuff. Wordpress is great, but not for our project.
Q: JQuery?
A: PHP please.
Thank you in advance!
Comment: JQuery is clientside, not serverside. You can utilize PHP and jquery together...
Comment: possible duplicate of [Clean URLs - How do I accomplish this?](http://stackoverflow.com/questions/8331782/clean-urls-how-do-i-accomplish-this)
Answer: With PHP alone, I don't think it's possible. However, it's likely that your webserver is running Apache, which makes this task fairly straightforward by transforming your pretty URLs into ugly URLs (with query strings) that your PHP script can handle. Your visitors have no idea this is happening; they aren't redirected or anything.
I strongly recommend you take a look at this tutorial, and its followup. The second tutorial contains the information you need for this task (starting in this section), but I strongly recommend reading the first tutorial to gain a deeper understanding of what you're doing.
Essentially, those tutorials will teach you how to specify (ugly, scary-looking) URL-rewriting rules in a file called .htaccess. These rules will transform (or "rewrite") your pretty URLs into less pretty ones that your PHP script can handle.
For example, yoursite.com/about would actually be accessing yoursite.com/index.php?page=about, or something along those lines.
For some sample code, here's a snippet 95% copied and pasted from this tutorial:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?page=$1 [L,QSA]

As that link explains, it will forward all requests to index.php, unless an actual file or directory is being requested.
Answer: Use a RewriteRule based .htaccess. Then you can have all non-existing files redirected (internally in Apache) to a general index.php with the requested path as a query string ?p=about. The redirecting is handled internally, so http://example.com/about is the external URL to that page.
Answer: You can have a switch statement checking $_GET values and output the page based on the provided parameter. Also, you will have to add some mod_rewrite rules to route those requests.
Answer: Use PHP URL rewrite. PHP will enteprate part of your URL as query string


TYPO3 Extbase: How to store NULL in DB for empty numeric fields?

Question: In a form Viewhelper I have lots of numeric fields, which should be empty by default, not filled with '0' or '0.00'.
I need this, because there should be a different handling of the data in the saveAction, depending on left empty fields or filled in values (including 0).
For this reason I set the field properties in the database table to NULL by default, like:
CREATE TABLE IF NOT EXISTS `tx_myext_domain_model_result` (
    mw double (10,2) DEFAULT NULL,
    mw2 double (10,2) DEFAULT NULL,
    ....
);

TCA looks like this:
  'mw' => array(
    ...
        'config' => array(
            'type' => 'input',
            'size' => 30,
            'eval' => 'double2,null'
        )
    ),

Also, in the Result model class, the corresponding properties are initialized with NULL;
/**
 * mw
 *
 * @var float
 */
protected $mw = null;

I did this check to assure that NULL is handled over to the getter for empty form fields:
public function setMw($mw) {
        if ($mw == NULL)
            $this->mw = 999;
        else
            $this->mw = $mw;
}

This did what I excepted: The mw field DB was set to '999' for a empty form field.
But now, switched back to normal setter,
public function setMw($mw) {
       $this->mw = $mw;
}

fields in the DB table are only left NULL when all other form fields are left empty, too. I.e. as soon as I enter a value in one of the form fields, all other empty form fields are set to '0' on save.
Adding null to the TCA eval field didn't do the trick, neither.
How can I change this behaviour? I'm using TYPO3 6.2.x
Comment: Whats your TCA configuration? Maybe you can use `type converter` in your controller (`initializeAction`).
Comment: Added TCA. How to use type converter? I don't wont to change the type; I it's just NULL that should stay NULL. The action shouldn't be the problem, as NULL arrives in the getter.
Answer: step 1: in initializeAction set null for the property
step 2: the idea with checking $mw is null is preaty good idea. TYPO3 not always do what you can assume using logical thinking :) So check if(is_null($mw)) $this->mw = null
this two things should do the trick
you can also set a default value in setter param
setMw($mw = null)
Comment: I don't understand why there is a difference between `$this->mw = $mw` and  `$this->mw = NULL` when $mw  _is_ NULL ? What do you mean with set null in initializeAction? The property shouldn't be always null, only when the form field is left empty... `is_null()` does not work because 0 should be stored in the DB.
Comment: 1. TYPO3 may not set null when you think it will set
2. initializeAction is an action that is in every model but you don't need to use it. It initialize diffrent things. For example if you have collection than i this action you will have initialization of it. It is kind of constructor
3. If null should be only when it is empty then when you will set default value of property to null it should do the trick. I wrote that: `setMw($mw = null)` this will set null as default
Comment: 1. This has nothing to do with TYPO3, it's just PHP - or logical: It's the same thing like saying `$mw = 1; $this->mw = $mw` and `$this->mw = 1;` will have a different effect . 2. I know what intitializeAction is, but how will this solve my problem? Why should I set $mw=NULL in there when it's NULL anyway? NULL arrives  in he setter, so the action wouldn't change anything 3. I just want to store NULL in the DB when I set $mw=NULL (equal to a empty form field). But for some reason, Extbase will not allow this. `setMw($mw = null)` and calling `setMw(null)`should lead to the same result.
Comment: About `it's just PHP` you can be suprised how many times i've bashed my head into the wall cause i thought like you ;) back to the problem. empty form field will not always set null in setter method in extbase. I think you should just try to set default null as param of setter.
about the initializeAction you`re correct. if we're talking about existing object then it will have no efekt, it will have efect only while creating new object. still I think that null as default in setter can help. Did you tried it ?
Comment: :) You got me - I didn't try it yesterday. But now I checked it, and it doesn't work, neither. BTW I got a hint that `if ($mw == NULL)` doesn't do what I expect it to do, because `0 == NULL` is true... So it's still all logical. I have to check with triple `===`
Comment: then I think you can write an `if` in your setter method to be sure that null is set. this is a bit stupid but maybe it will work


Let be $A=$ $\begin{pmatrix} 2 & 1 \\ 8 & 3 \end{pmatrix}$ and $H=SL_n(\mathbb{R})$ show that $HA=AH$

Question: Let be $A=$ $\begin{pmatrix}
2 & 1 \\
8 & 3
\end{pmatrix}$
and $H=SL_n(\mathbb{R})$ show that $HA=AH$
Well i take $x\in H$ then $det(x)\neq 0$
and $xA=Ax'$ because $A\in GL_n(R)$ and $Sl_n(R)$ is normal in $GL_n(R)$ is right?
Comment: It looks as if the idea is to *prove* that $SL_2(\Bbb R)$ is normal in $GL_2(\Bbb R)$.
Comment: Wich we have already proved, e.g. [here](https://math.stackexchange.com/questions/359976/is-sl-n-mathbbr-a-normal-subgroup-in-gl-n-mathbbr?rq=1).
Answer: This follows from   multiplicativity of the determinant. $HA$ is exactly the set $D$ of all 2 by 2 matrices with determinant $-2$. Indeed,
clearly $HA \subset D$ and if $M \in D$ then $H^{-1}D \in SL_2$. The same argument applies to $AH$.
Comment: Yes, this is exactly the argument to show also that $SL_n$ is a normal subgroup of $GL_n$.


Automatic Model Validation When Generating the Models using Entity Framework Database First Approach

Question: Consider the following property UserName of a Model Class. You can see that the validation criteria are added over it manually.
<code>[Required]
[StringLength(100, MinimumLength = 6)]
public string UserName { get; set; }
</code>
Now again consider the following code:
<code>public string UserName { get; set; }
</code>
The same property without the validators. Now when I am generating the model class using Entity Framework Database first approach I am getting the later result (means a property without having validators). But in the database there are constraints added over each attribute.
So is there any tool/way that I can use those constraints and generate the model class having properties like shown in code 1 (that is property with validators).
Answer: No there is no ready to use tool which would add these attributes for you. You can modify T4 template to create these attributes for you but for that you need to understand how EF metadata are stored. You can add attributes yourselves manually in buddy classes.


Is there a way to run Istio sidecar within virtual-node on azure?

Question: I have an AKS cluster on Azure with virtual-nodes enabled (virtual-kubelet/azure-aci v1.3.2) and it works OK (a little flakey, but does mostly work). My problem is that as soon as I enable istio side car injection on any deployment I want to run on a virtual-node, the istio-proxy sidecar won't start, preventing the entire pod from starting up. I believe the problem is that v1:status.podIP is not yet supported in virtual-kubelet/azure-aci, and the istio sidecar spec makes use of it.
Has anyone had this problem? I can't find anything much about istio + virtual kubelet on the googlez.
I'm working around the problem for the time being by using PERMISSIVE mtls mode on the one dependency it relies on being able to make http calls to, and turning off side car injection via an annotation on the deployment. This is not ideal.
Thanks
Comment: Did you make any progress on this? Searching for "istio + virtual kubelet" on the googlez now leads here :)
Comment: Hey @roomaroo nope - didn't get anywhere at all with this. Frankly, been getting nada from azure support about this and other issues we've been experiencing on there.
Comment: I stumbled upon the same issue today and was wondering if any of you guys able to make any progress on this?
Comment: @ktumu nope - we gave up using ACI/Virtual-node about 6 months ago - between the not being able to use istio and other unsupported k8s features (graceful termination period) it just wasn't worth it. I haven't checked to see if these things have been resolved yet.
Answer: Edit: The Istio CNI plugin can be a workaround.
Haven't tried it but the documentation says:

For application pods in the Istio service mesh, all traffic to/from the pods needs to go through the sidecar proxies (istio-proxy containers). This istio-cni Container Network Interface (CNI) plugin will set up the pods' networking to fulfill this requirement in place of the current Istio injected pod initContainers istio-init approach.

Reference: https://github.com/istio/istio/tree/master/cni
Istio uses an init container to get the istio container started. But Init containers are not yet supported in Virtual Nodes.
That explains why the Istio is not getting started in your virtual nodes.
The microsoft documentation says:

Virtual Nodes functionality is heavily dependent on ACI's feature set. In addition to the quotas and limits for Azure Container Instances, the following scenarios are not yet supported with Virtual nodes:

Using service principal to pull ACR images. Workaround is to use
Kubernetes secrets
Virtual Network Limitations including VNet peering, Kubernetes network policies, and outbound traffic to the
internet with network security groups.
Init containers
Host aliases
Arguments for exec in ACI
DaemonSets will not deploy pods to the virtual nodes
Virtual nodes support scheduling Linux pods. You can
manually install the open source Virtual Kubelet ACI provider to
schedule Windows Server containers to ACI.
Virtual nodes require AKS
clusters with Azure CNI networking.
Using api server authorized ip
ranges for AKS.
Volume mounting Azure Files share support
General-purpose V1. Follow the instructions for mounting a volume
with Azure Files share
Using IPv6 is not supported.
Comment: CNI gets rid of istio-init container only and the sidecar envoy proxy would still get injected into app pods.


Proof of Kolmogorov's $0$-$1$ Law in Shiryaev

Question: I know this theorem has been discussed in a lot of posts on this site however I was unable to find an answer that deals with the particular proof I am trying to understand. I'm interested in the proof of Kolmogorov's $0$-$1$ law given in the book "Probability by Albert Shiryaev". The statement is as follows,
Theorem:
Let $\xi_1,\xi_2,\ldots$ be a sequence of independent random variables and let $A \in \cap_{n=1}^\infty \mathcal{F}_n^{\infty}$, i.e an element of the tail $\sigma$-algebra. Then $\mathbb{P}(A)=0$ or $1$.
We define $\mathcal{F}_n^k = \sigma(\xi_n,\xi_{n+1},\ldots,\xi_{k})$ with the convention $\mathcal{F}_n^{\infty}=\sigma(\xi_n,\xi_{n+1},\ldots)$.
Proof:
Clearly we have $A \in \mathcal{F}_1^\infty=\sigma(\xi_1,\xi_{2},\ldots)=\sigma(\cup_n \mathcal{F}_1^n)$. We can find sets $A_n \in \mathcal{F}_1^n$, $m\geq1$, such that $\mathbb{P}(A \Delta A_n) \to 0$ as  $n \to \infty$. Hence,
$$\mathbb{P}(A_n) \to \mathbb{P}(A), \quad \mathbb{P}(A_n \cap A) \to \mathbb{P}(A) .$$
But as $A \in \cap_{n=1}^\infty \mathcal{F}_n^{\infty}$, the events $A_n$ and $A$ are independent for every $n \geq 1$. Hence it follows that $\mathbb{P}(A)=\mathbb{P}(A)^2$, which completes the proof.
Now first of all I presume the $m$ is a typo and this should be an $n$. The only issue I'm having with this proof is the claim that you can approximate the event $A$ by an event in $\mathcal{F}_1^n$, and by approximate I mean in the sense of the pseudo metric defined by the symmetric difference operation.
Shiryaev has an exercise in a previous chapter which he refers to in this proof that says given a probability space $(\Omega,\mathcal{F},\mathbb{P})$ and an algebra $\mathcal{A}$ such that $\sigma(\mathcal{A})=\mathcal{F}$, for any $B \in \mathcal{F}$ and $\epsilon>0$ there exists a set $A \in \mathcal{A}$ such that,
$$\mathbb{P}(B \Delta A) \leq \epsilon. $$
In the proof above the set in which we are taking the $A_n$'s are one, not necessarily an algebra as unions of $\sigma$-algebras need not be an algebra and secondly they do not even generate the $\sigma$-algebra that $A$ belongs to, i.e $\mathcal{F}_1^\infty$. So my question is why we can apply this result ?
Just to be 100% clear the proof is transcribed correctly, i.e the possible typo of $m\geq1$ does appear in the book.
Comment: $\bigcup_{n}F_{1}^{n}$ is an algebra.
Comment: Thanks for the comment, yes this is a detail I have missed. However what this allows us to claim is for any $\epsilon$ we can find a set $A_\epsilon \in \cup_n \mathcal{F}_1^n$ such that $\mathbb{P}(A \Delta A_\epsilon) \leq \epsilon$. So say we choose $\epsilon = 1/n$, then the proof is stating we can always find an $A_n \in \mathcal{F}_1^n$ such that $\mathbb{P}(A \Delta A_n) \leq 1/n$. But we have no right to say that the set $A_n$ is a member of $\mathcal{F}_1^n$, we can only claim it is a member of the union of all the $\mathcal{F}_1^n$'s.
Comment: You are correct. We obtain $A_n \in F_{m(n)}$. But we can pad the sequence by adding copies of some elements to obtain a sequence with $B_n \in F_n$.
Answer: Thanks to the comment by @Mason I believe I have figured out the problem. We are free to say that $\cup_n \mathcal{F}_1^n$ is an algebra as it is an increasing union of $\sigma$-algebras. Thus the density result can be applied. However as I outlined in my comment the problem is now in claiming that each $A_n \in \mathcal{F}_1^n$. The density result only tells us that there exists some set in $\cup_n \mathcal{F}_1^n$ such that $\mathbb{P}(A\Delta A_n) \leq \epsilon_n$.
This can be answered in the following way. Originally I assumed that the $m$ that appeared in the proof was a typo, I know believe this is not the case. In fact I think the typo is that the line,
"We can find sets $A_n \in \mathcal{F}_1^n$, $m \geq 1$, such that $\mathbb{P}(A \Delta A_n) \to 0$ as $n \to \infty$."
Should actually read,
We can find sets $A_n \in \mathcal{F}_1^m$, $m \geq 1$, such that $\mathbb{P}(A \Delta A_n) \to 0$ as $n \to \infty$.
The difference being that each $A_n$ is a member of $\mathcal{F}_1^m$ for some $m$ which is the same as saying $A_n \in \cup_n \mathcal{F}_1^n$. The main point is that with this statement we are not claiming to know exactly which $\sigma$-algebra these sets $A_n$ belong to, we only know they must belong to one of them.
However any time I need to claim that there is typo in a very well respected book in order for me to understand the proof, it usually means that I just completely misunderstood the argument in the first place! Hence any opinions on my analysis would be very much appreciated.


Does using a balance board help with skateboarding balance? If not what can help?

Question: I'm having a midlife crisis and want to start skateboarding! :)
I actually have to work so I can't take the skateboard out that often. I was thinking that there may be something that I can do in the house while watching TV that will help with my skateboarding.
I've seen balance boards where you stand on a board, the board sits on top of a cylinder and you essentially can rock left/right as the cylinder rolls underneath the board.
Here's a link to how to build your own.  There are other variations. Some actually look like a skateboard deck.
Will this help me develop balance on the skateboard?
Answer: The single best thing you can do to get better at skateboarding is stop watching TV and go out and skate. It won't take you long to get the basics, but having played with various balance boards and decks I can confidently say that while they will improve your balance there is no substitute for just getting out and skating around, up and over kerbs, along streets etc.
If you want to do it, give up a couple of hours of TV a day and skate solidly. It will work.
I learnt at age 23, having never skated before, although I had snowboarded and surfed. What did it for me was using a board for my commute - after about 2 weeks I started feeling the movements correctly, and even began to dream about ollying!
Answer: Try putting your skateboard on something that your wheels cant move on such as grass or cobbled ground (definitely avoid sand and dry dirt) and try a few ollies or try lifting your nose into the air and staying in a "manual" position keeping your shoulders in line with the board and also making sure you have the right width of board if your toes or heel are dangling really far off the board (if the balls of your feet aren't still on the board when your heel rests on the back side) you will require a wider board giving you much more stability and control. people often disregard or don't take these factors into consideration I myself have just bought a wider deck and I feel much more comfortable and I've been skating for 4 years now. Keeping your shoulders in line with board will make sure your board doesn't rotate in front or behind you.
In addition, using balance boards will only help you balance while standing still. You will have to brave the streets to learn how to balance when pushing as your centre of gravity is constantly moving. the best way I know to keep balanced while pushing is to never mongo (basically never push with your front foot. keep your strongest foot placed on the front bolts near the nose. this is because pushing with you front foot means that you take much longer to bring your foot back to rest on the front as opposed to on the back. this would allow a lot more room for stumbling and instability. Pushing with your back foot is much more reliable.)


Lambda calculus function with unrestricted domain and nontrivial finite range?

Question: In the untyped lambda calculus, one of the first encountered expressions is:
$F = Const(I) = \lambda x.\lambda y.y$
It is easily seen that a property of this expression is that the set of possible evaluation "results" - the normal / non-reducible forms belonging to the equivalence classes under beta reduction of $Fz$ for arbitrary $z$ - is finite and consists of a single element $I = \lambda y.y$.  In this simple case every equivalence class (just one!) has a normal form, ie. evaluation of every $Fz$ terminates, every $Fz => I$.
Is there an expression $G$ for which the set of possible results of evaluation of the $Gz$, with unrestricted $z$, is finite, non-empty, and contains at least two elements?   Can it be proven that this expression does not exist?
Comment: @Taroccoesbrocco, Church Rosser only holds if the starting term is same ,but here z is unrestricted right?
Comment: @SohamSaha - The problem is that the only way we have to "look inside" of an arbitrary lambda expression is to apply it to some argument.  So, to compare values for equivalence, some restrictions / type assertion is necessary!  So it is known that there is no way to "build a lambda term that gives true whenever it gets some x, but false otherwise", for an arbitrary argument.  (consequence of Scott-Curry theorem).    It almost seems like this line of inquiry and the general undecidability result should be enough to answer the question negatively, but I cannot make a proof - so far...
Comment: Have you ever heard of confluence or the Church-Rosser theorem, which implies the uniqueness of normal forms?
Comment: Just thinking, can we **build a lambda term that gives true whenever it gets some x, but false otherwise**? Then we can feed it x to get 1 term, and all others will give something else
Comment: Church-Rosser: each of my "equivalence classes" contains at most one normal form. I'm asking for the set of all such normal forms over all classes, ie. "evaluating the function completely where it possible to do so for every argument z
in the universe and gathering up all the answers."
Comment: Can you prove this part: ' So it is known that there is no way to "build a lambda term that gives true whenever it gets some x, but false otherwise", for an arbitrary argument.'?
Comment: Am I right in thinking that your G acts as a segregator, separating two or more types of statements into multiple groups? And the type is based on some overarching similarity in between same-classed terms?
Answer: EDIT: As discussed in the comments following this answer, there is a problem in the proof.
I have been literally reading about lambda calculus for two-three months, so please help me correct any mistakes.
I am targeting at the case where the ultimate result set has 2 terms.
Now let $z_1$ and $z_2$ be two terms such that $Gz_1$ is not equivalent to $Gz_2$. Now take $A$ and $B$ as the beta-closed sets that contain $z_1$ and $z_2$ respectively.
Now using the Scott Curry theorem, $A$ and $B$ should be recursively inseparable. But we can use the $G$ function to separate them, which is a contradiction.
We can extend this to higher sized result sets too, I think.
Is my logic reasonable?
Comment: How would you use $G$ (an expression of the lambda calculus) to separate $A$ and $B$ (ie. realize or define a recursive function that determines if a given $Gz$ with $z \in A \cup B$ is in $A$ or $B$)?  Usually applying Scott-Curry involves invoking a recursion theorem or internal model of the calculus...  But I'm not asking for a procedure for placing a given $z$ in one of those sets - or implying one exists - I'm only asking for a $G$ such that $A \cup B$ (or other finite disjoint collection) covers the universe.
Comment: To put a point on it, if I drop the requirement that the collection of sets be finite, I can just take $G$ to be the identity $\lambda x. x$, right?  No undecidability theorems have been offended in doing so!
Comment: I don't think I am knowledgeable about the topic enough to reply. Should I delete my answer? as I believe that as per your comment my proof is incorrect
Comment: I appreciate your thinking about the question!  No need to delete.  (This stuff is new to me too...)


How to bind table view with multiple sections that represent different data types using RxSwift and RxSwiftDataSources?

Question: I am trying to create a table view with multiple sections using RxSwift. Each section displays data representing a different type.
I found the RxSwiftDataSources library and implemented the example from their documentation.
Here is a quick runthrough of how that example is implemented:
A custom data type CustomData is defined:
struct CustomData {
  var anInt: Int
  var aString: String
  var aCGPoint: CGPoint
}

Then, the representations for the section are added (note that SectionModelType is implemented here):
struct SectionOfCustomData {
  var header: String
  var items: [Item]
}
extension SectionOfCustomData: SectionModelType {
  typealias Item = CustomData

   init(original: SectionOfCustomData, items: [Item]) {
    self = original
    self.items = items
  }
}

Finally, some sample data is created and bound to the table view:
let sections: [SectionOfCustomData] = [
  SectionOfCustomData(header: "First section", items: [CustomData(anInt: 0, aString: "zero", aCGPoint: CGPoint.zero), CustomData(anInt: 1, aString: "one", aCGPoint: CGPoint(x: 1, y: 1)) ]),
  SectionOfCustomData(header: "Second section", items: [CustomData(anInt: 2, aString: "two", aCGPoint: CGPoint(x: 2, y: 2)), CustomData(anInt: 3, aString: "three", aCGPoint: CGPoint(x: 3, y: 3)) ])
]

I now want to modify the example and only want to display Strings rather than instances of CustomData in the second section, so somewhat like this:
let sections = [
  SectionOfCustomData(header: "First section", items: [CustomData(anInt: 0, aString: "zero", aCGPoint: CGPoint.zero), CustomData(anInt: 1, aString: "one", aCGPoint: CGPoint(x: 1, y: 1)) ]),
  SectionOfString(header: "Second section", items: ["a", "b", "c"])
]

This will obviously not compile as sections now contains elements of different types SectionOfCustomData an SectionOfString. I tried to work around this by trying to declare sections as [SectionModelType] but this doesn't work, the compiler complains with:
Protocol 'SectionModelType' can only be used as a generic constraint because it has Self or associated type requirements
Comment: Did you already got a solution?
Answer: You can use enums for wrapping different types.
Using enum, SectionOfCustomData definition should be like this:
enum SectionOfCustomData: SectionModelType {

  typealias Item = Row

  case customDataSection(header: String, items: [Row])
  case stringSection(header: String, items: [Row])

  enum Row {
    case customData(customData: CustomData) // wrapping CustomData to Row type
    case string(string: String)             // wrapping String to Row type
  }

  // followings are not directly related to this topic, but represents how to conform to SectionModelType
  var items: [Row] {
    switch self {
    case .customDataSection(_, let items):
      return items

    case .stringSection(_, let items):
      return items
    }
  }

  public init(original: SectionOfCustomData, items: [Row]) {
    switch self {
    case .customDataSection(let header, _):
      self = .customDataSection(header: header, items: items)

    case .stringSection(let header, _):
      self = .stringSection(header: header, items: items)
    }
  }
}

And configureCell looks like this:
let dataSource = RxTableViewSectionedReloadDataSource<SectionOfCustomData>()
...
dataSource.configureCell = { [weak self] (dataSource, tableView, indexPath, row) -> UITableViewCell in

  switch dataSource[indexPath] {
  case .customData(let customData):
    let cell: CustomDataCell = // dequeue cell
    self?.configure(cell: cell, with: customData)
    return cell

  case .string(let string):
    let cell: StringCell = // dequeue cell
    self?.configure(cell: cell, with: string)
    return cell
  }
}

Comment: Should be `switch original` instead of `switch self` in `init`?