Winding number integral/index in plane

Question: Let $B(x_0,y_0)$ be an open unit disk.  Assume that $F(x,y)=(f_1 (x,y),f_2 (x,y)):\overline{B(x_0,y_0)}\rightarrow \mathbb{R}^2$ is a diffeomorphism. Assume also that $F(x,y) \ne (s_0,t_0) $, for all $(x,y)\in \partial B(x_0,y_0)$.
What is the elementary way to evaluate the following result?
$$\frac{1}{2\pi}\int_{\partial B(x_0,y_0)}\frac{(f_1-s_0) df_2-(f_2-t_0)df_1}{(f_1-s_0) ^2+(f_2-t_0) ^2}=sign \det F'(x_0,y_0)=±1. $$
Can that be shown by using Green's theorem and then change of variables formula? Since $F$ is a diffeomorphism, due to inverse function theorem $\det F'(x,y) \ne 0$, for all $(x,y) \in B(x_0,y_0)$, and by Jordan curve theorem $F(\partial B(x_0,y_0))$ is a Jordan curve. Therefore inner domain is simply connected and we can use Green's theorem. But I'm not sure how to calculate that integral.
Comment: Thanks! It was a typo. But what is the elementary/naked way to show that pullback substitution? One needs change of variables formula?
Comment: @Blatter: Thank you for your laconic comment. But if you have same relevant advices, please tell me. I belive that you do know what I'm trying to ask; winding number of a diffeomorphism with respect to a unit circle.
Comment: As you're probably aware, if
$$
\omega = \frac{x_{1}\, dx_{2} - x_{2}\, dx_{1}}{2\pi(x_{1}^{2} + x_{2}^{2})},
$$
(formally, $d\theta/(2\pi)$ on $\mathbf{R}^{2}\setminus\{(0,0)\}$), then your integral is
$$
\int_{\partial B(x_{0}, y_{0})} F^{*}\omega
  = \int_{F(\partial B(x_{0}, y_{0}))} \omega,
$$
a winding number, which can be $0$ (by Green's theorem, for example) if $F(\partial B)$ doesn't wind around the origin. In your integrand, do you mean "$f_{i} - f_{i}(x_{0},y_{0})$" instead of "$f_{i}$" (and "$F(x,y) \neq (0,0)$" is spurious)?
Comment: An hour ago it was just false in certain cases; now it doesn't make sense anymore.
Answer: Assume that $B$ is a disk with center ${\bf z}_0$ in the $(x,y)$-plane,  that
$$f:\quad \bar B\to{\Bbb R}^2, \qquad (x,y)\to(u,v):=\bigl(f_1(x,y),f_2(x,y)\bigr)$$
is a diffeomorphism, and that ${\bf 0}\notin f(\partial B)$.   Then
$$N:={1\over2\pi}\int_{\partial B}{f_1\>df_2-f_2\>df_1\over f_1^2+f_2^2}=
\left\{\eqalign{{\rm sgn}\bigl(J_f({\bf z}_0)\bigr)&\qquad\bigl({\bf 0}\in f(B)\bigr)\cr
0\qquad&\qquad\bigl({\bf 0}\notin f(B)\bigr) \cr}\right.$$
Proof. Consider the vector field
$${\bf A}(u,v):=\left({-v\over u^2+v^2}, \>{u\over u^2+v^2}\right)=\nabla\arg(u,v)$$
 in the punctured $(u,v)$-plane. I claim that
 $$N={1\over2\pi}\int_{f(\partial B)}{\bf A}\cdot d{\bf w}\ .\tag{1}$$
 Subproof.  Let $$t\mapsto\bigl(x(t),y(t)\bigr)\qquad(0\leq t\leq T)$$ be a parametrization of $\partial B$. Then
 $$t\mapsto {\bf w}(t):=\bigl(f_1\bigl(x(t),y(t)\bigr), f_2\bigl(x(t),y(t)\bigr)\bigr)\qquad (0\leq t\leq T)$$
 is a parametrization of $f(\partial B)$. It follows that
 $$\eqalign{&\int_{f(\partial B)}{\bf A}\cdot d{\bf w}
 =\int_0^T\left({-f_2\over f_1^2+f_2^2}\bigg|_{{\bf w}(t)}\dot u(t)+ {f_1\over f_1^2+f_2^2}\bigg|_{{\bf w}(t)}\dot v(t) \right)\ dt\cr
 &=\int_0^T \left({-f_2\over f_1^2+f_2^2}\bigl(f_{1.1}\dot x(t)+f_{1.2}\dot y(t)\bigr)+
  {f_1\over f_1^2+f_2^2}\bigl(f_{2.1}\dot x(t)+f_{2.2}\dot y(t)\bigr)\right)\>dt \cr
  &=\int_{\partial B}{f_1\>df_2-f_2\>df_1\over f_1^2+f_2^2}\quad.\qquad\square\cr}$$
 Note that
 $${\rm curl}\>{\bf A}(u,v)\equiv0\ .$$
When ${\bf 0}\notin f(B)$ we can apply Green's theorem in $(1)$ and obtain
$$N={1\over2\pi}\int_{f(\partial B)}{\bf A}\cdot d{\bf w}={1\over2\pi}\int_{f(B)}{\rm curl}\>{\bf A}(u,v)\>{\rm d}(u,v)=0\ .$$
When ${\bf 0}=f({\bf p})\in f(B)$ we  introduce $B':=B\setminus B_\epsilon({\bf p})$ and apply Green's theorem to $f(B')$. We then get
$$N={1\over2\pi}\int_{f(\partial B)}{\bf A}\cdot d{\bf w}={1\over2\pi}\int_{f(\partial B')}{\bf A}\cdot d{\bf w}+{1\over2\pi}\int_{f(\partial B_\epsilon)}{\bf A}\cdot d{\bf w}\ .$$
Since the first term on the right hand side vanishes we have
$$N={1\over2\pi}\int_{f(\partial B)}{\bf A}\cdot d{\bf w}={1\over2\pi}\int_{f(\partial B_\epsilon)}{\bf A}\cdot d{\bf w}\ .$$
Now $f(\partial B_\epsilon)$ is a tiny ellipse around ${\bf 0}$, and a suitable limiting argument should then prove that $N= {\rm sgn}\bigl(J_f({\bf z}_0)\bigr)$ in this case.
Comment: (+1) Incidentally, I'm guessing the new notation means $F(x_{0}, y_{0}) = (s_{0}, t_{0})$, so the condition "$F(x, y) \neq (s_{0}, t_{0})$ on the boundary" is automatic, and the boundary winds $\pm1$ times. Particularly, the question is in fact sensible, and you've answered it. :)
Comment: @Blatter. Can you clarify your methods?

Since circle $\partial B({\bf z}_0)$ is positively oriented, we know that the orientation of Jordan curve $f(\partial B({\bf z}_0))$ is ${\rm sgn}\bigl(J_f({\bf z}_0)\bigr)$, and if ${\bf 0}\in f(B)$, then the orientation of $f(\partial B_\epsilon ({\bf 0}))\subset f( B({\bf z_0}))$ is also ${\rm sgn}\bigl(J_f({\bf z}_0)\bigr)$.
If the vector field $\bf{A}$ is trivial, i.e. $${\bf A}(x,y)=\left({-y\over x^2+y^2}, \>{x\over x^2+y^2}\right)$$
Comment: it's easy to conclude from Green's theorem that $${1\over2\pi}\int_{f(\partial B_\epsilon (\bf 0))}{\bf A}(x,y)\cdot (dx,dy)={\rm sgn}\bigl(J_f({\bf z}_0)\bigr).$$
But, if the vector field $\bf{A}$ is not trivial, as $${\bf A}(f_1,f_2)=\left({-f_2 (x,y)\over f_1^2 (x,y)+f_2^2 (x,y)}, \>{f_1 (x,y)\over f_1^2(x,y)+f_2^2(x,y)}\right)$$
How can you calculate the integral $${1\over2\pi}\int_{f(\partial B_\epsilon (\bf 0))}{\bf A}(f_1,f_2)\cdot (df_1,df_2)=\space  ????.$$ Sorry if I stress this too much, but I really don't understand, and that calculation is at the heart of my original question.

Winding number integral/index in plane


Relationship duplicates data

Question: I have a view of content type documents wherein I want the logged in user to request access for each document and after it approved or rejected the status next to that list of documents should show approved or rejected respectively.
I created a custom module to capture the node id, the user id of the requester and the status of the request.
I then created a mymodule.view.inc file to add the fields of this custom module using handlers. This is the below code:
<?php

function mymodule_views_data() {
    $data = array();

    $data['mymodule']['table']['group'] = t('Document Approval');

    $data['mymodule']['table']['join']['node'] = array(
        'left_field' => 'nid',
        'field' => 'nid',
    );

    $data['mymodule']['nid'] = array(
        'title' => t('Nid'),
        'help' => t('The node id of the approval node'),
        'field' => array(
            'handler' => 'views_handler_field_node',
            'click sortable' => TRUE,
        ),
        'argument' => array(
            'handler' =>'views_handler_argument_node_nid',
            'name field' => 'title',
            'numeric' => TRUE,
            'validate type' => 'nid',
        ),
        'filter' => array(
            'handler' => 'views_handler_filter_numeric',
        ),
        'sort' => array(
            'handler' => 'views_handler_sort',
        ),
        'relationship' => array(
            'label' => t('Node'),
            'base' => 'node',
            'base field' => 'nid',
        ),
    );

    $data['mymodule']['uid'] = array(
        'title' => t('Uid'),
        'help' => t('The user id of the user requested access'),
        'field' => array(
            'handler' => 'views_handler_field_user',
            'click sortable' => TRUE,
        ),
        'argument' => array(
            'handler' =>'views_handler_argument_user_uid',
            'name field' => 'title',
            'numeric' => TRUE,
        ),
        'filter' => array(
            'handler' => 'views_handler_filter_numeric',
        ),
        'sort' => array(
            'handler' => 'views_handler_sort',
        ),
        'relationship' => array(
            'label' => t('User'),
            'base' => 'users',
            'base field' => 'uid',
        ),
    );

    $data['mymodule']['status'] = array(
        'title' => t('Status'),
        'help' => t('The status of the approval node'),
        'field' => array(
            'handler' => 'views_handler_field_node',
            'click sortable' => TRUE,
        ),
        'argument' => array(
            'handler' =>'views_handler_argument_node_nid',
            'name field' => 'title',
            'numeric' => TRUE,
            'validate type' => 'nid',
        ),
        'filter' => array(
            'handler' => 'views_handler_filter_numeric',
        ),
        'sort' => array(
            'handler' => 'views_handler_sort',
        ),
        /*'relationship' => array(
            'label' => t('Node'),
            'base' => 'node',
            'base field' => 'nid',
        ),*/
    );

    return $data;
}

I am able to see these fields in my view. I am confused as to how do I further use this in my views to get what I want. I want the user to see the status in front of each node.He should see all nodes. And for the user whose no record is found in my custom table he should also see all nodes with "request access" status.
I tried creating a relationship using nid of my custom table and adding a field status with requiring relationship, but I get duplicate results.
I would also like to know if there is any better way of handling this use case.
Answer: Try looking into Permissions by Term and similar modules that override how access is handled. That module can take care of hiding the nodes from users based on taxonomy terms. You can create a Vocabulary with access terms and assign nodes with them, and allow different user roles to view nodes based on that taxonomy.
Then in the Views listing all the nodes disable the node access checks:

 Disable access checks

Do not apply node_access checks to this query. Selecting this option omits that tag from the alterable query.

under Query settings.
This will list all the nodes regardless of the access rules, but it applies to the Views only. Once the user clicks through to the node the access check will kick in and they will/will not be able to view it based on the taxonomy access or other node access you set up.

Relationship duplicates data


codeship stuck using old image of codeship/google-cloud-deployment

Question: I've been updating one of our projects that is built and deployed using codeship pro. We use codeship/google-cloud-deployment docker image to deploy google cloud functions. I need features that are only available in a recent version of the gcloud sdk, but codeship always uses an old version the sdk and seems stuck fetching a cached version of the image.
codeship-services.yml
googlecloudproductiondeployment:
  image: codeship/google-cloud-deployment
  encrypted_env_file: deploy/deploy-production.env.encrypted
  cached: false
  volumes:
    - ./:/deploy

codeship-steps.yml
- name: Deploy CF to prod
  tag: ^deploy-production$
  service: googlecloudproductiondeployment
  command: /deploy/deploy/google-deploy-cf.sh

deploy/google-deploy-cf.sh
#!/bin/bash

set -e

PROJECT=my-project
FUNCTION_NAME=my-function
SOURCE_REPO=my-repo

# Authenticate on google SDK
codeship_google authenticate

# Re-deploy the CF
gcloud version
gcloud beta functions deploy $FUNCTION_NAME --region europe-west1 --runtime nodejs8 --env-vars-file /deploy/deploy/cf-env.production.yaml --trigger-http --source https://source.developers.google.com/projects/my-project/repos/${PROJECT}/fixed-aliases/${CI_BRANCH} --memory 128MB --entry-point run --timeout 540s

Output observed in codeship:
googlecloudproductiondeployment build/pull started
googlecloudproductiondeployment build/pull finished successfully
googlecloudproductiondeployment Activated service account credentials for: [***@***.iam.gserviceaccount.com]
googlecloudproductiondeployment Google Cloud SDK 204.0.0
googlecloudproductiondeployment alpha 2017.09.15
googlecloudproductiondeployment beta 2017.09.15
googlecloudproductiondeployment bq 2.0.34
googlecloudproductiondeployment core 2018.06.04
googlecloudproductiondeployment gsutil 4.31
googlecloudproductiondeployment kubectl
googlecloudproductiondeployment deployng
googlecloudproductiondeployment ERROR: (gcloud.beta.functions.deploy) unrecognized arguments: 2018-10-08 07:42:29 googlecloudproductiondeployment  --runtime (did you mean '--timeout'?)
googlecloudproductiondeployment  nodejs8
googlecloudproductiondeployment  --env-vars-file
googlecloudproductiondeployment  /deploy/deploy/cf-env.production.yaml

Expected output:
I expect to see Google Cloud SDK 218.0.0, the version noted in the last commit in codeship's google-cloud-deployment github repo.
Steps tried:

Adding :latest to the image in codeship-services.yml.
Clicking on Reset Cache on the project page on codeship.

Even after reseting the cache, I always see Image exists, using cached image in the logs for my googlecloudproductiondeployment service on codeship.

Using jet locally, I can fore codeship to pull the latest version by running docker rmi codeship/google-cloud-deployment before jet steps. However, I do not have control over the docker cache on codeship.

It seems codehip is stuck using an old version of the codeship/google-cloud-deployment image. On docker hub this image has no tags other than latest, so I don't know how to force codeship to get a specific version.  Please help!
Answer: Apologies for the trouble.
We've gone ahead and ensured that versions of codeship/google-cloud-deployment will remain current.
In general we will be tracking behind the most current Google Cloud SDK by two to three weeks. But this will maintain much closer parity to most recent versions. We can also expedite updates of Google Cloud SDK now as needed.
If you reset your project cache and restart your build, you will note (as of this time of writing) that the Google Cloud SDK is now set to version 219.0.1 for the codeship/google-cloud-deployment image.


Hudson won't execute windows batch commands after running a .bat script

Question: In hudson, after running a .bat script my slave refuses to run anything that comes afterward. It instead just said that it finished with a success.
Answer: Trying do a
call yourscript.bat

instead of just a
yourscript.bat

Comment: Thanks! This worked great, hudson and I seem to fight on the daily.
Comment: Zack: That's `cmd`'s behavior there.


Ordenação 2 Colunas ao mesmo tempo SQL Server

Question: Tenho a seguinte estrutura da tabela.
Ticket | Data | ID

O campo data é datetime, ticket, id e gerador são int.
O que eu preciso é que seja feita uma ordenação dos campos ticket e data ao mesmo tempo.
Resultado atual.
Ticket    Data/Hora
532       06/06/2018
532       10/08/2017
532       11/07/2018
532       01/03/2016

Resultado esperado.
Ticket    Data/Hora
532       01/03/2016
532       10/08/2017
532       06/06/2018
532       11/07/2018

Consulta atual abaixo.
select
w.service_req_id Ticket,
CONVERT(VARCHAR(10), w.to_time, 103) + ' ' + CONVERT(VARCHAR(8), w.to_time, 108) [Data/Hora],
'Interna' [Ação é Pública? (Pública/Interna)],
case when u.ref_id = '1' then '454'
     when u.ref_id is null then ur.ref_id else u.ref_id end as Gerador,
w.description +char(13)+char(10) Descrição,
cast(w.id as varchar(100)) as Seq
from work_report w
left join sysaid_user u on u.user_name = w.user_name
left join service_req se on se.id = w.service_req_id
left join sysaid_user ur on ur.user_name = se.responsibility
where w.service_req_id in(532)
and (w.description not in('') and w.description not in ('.'))
order by 1,6

Observe que tentei utilizado order by pra ticket e id, mas sem sucesso.
Answer: Você só precisar usar o ORDER BY de acordo com a prioridade:
ORDER BY w.service_req_id, w.to_time

SELECT – Cláusula ORDER BY
Classifica dados retornados por uma consulta no SQL Server. Use esta cláusula para:

Classificar o conjunto de resultados de uma consulta pela lista de colunas especificada e, opcionalmente, limitar as linhas retornadas a um intervalo especificado. A ordem na qual as linhas são retornadas em um conjunto de resultados não é garantida, a menos que uma cláusula ORDER BY seja especificada.
Determine a ordem na qual os valores da função de classificação serão aplicados ao conjunto de resultados.
Comment: creio ser mais seguro order by 1,2
Comment: @Motta já não funcionaria porque ordenara a data como se fosse string
Comment: O "convert" não converte para DATE ?!
Comment: @Motta não, naquele caso está convertendo para varchar. Fora que colocar a posição da coluna no order by é perigoso. Se você adicionar uma coluna antes quebra a lógica
Comment: O erro começa em armazenar data como string , começa a complicar queries que deveriam ser triviais.
Comment: @Motta sim mas isso não faz parte da pergunta


jquery nth child to root

Question:

$(document).click(function(){
  var i = 1;
  $("p:nth-child("+i+")").scrollintoview();
  i++;
});

Hi

Hi

Hi

Hi

I have here this code. I'm trying to make a search feature on every click. How can I search for these paragraphs one by one on every click with this structure of html. Is there any selector that will treat the ".parent" class as the parent element of these paragraphs? Thank you.
Comment: Your question is totally unclear.
Comment: You're setting `i` to `1` every time you call the function. Then you never use it. If you want to remember something between calls, it should be a global variable.
Comment: where are you using your i?
Comment: All your paragraphs are the first child in their respective divs, so `p:nth-child(1)` matches all of them.
Comment: I suspect what you want is `$("p").eq(i)`.
Comment: Or maybe `$(".parent div").eq(i).find("p")`
Comment: I've already edited the snippet. thank you.
Answer:
Declare i as a global.Then only its increment the value
And use jquery eq() function its match the p index
And target with .parent p
Do with class add and remove for switching color

Updated with switching color

var i = 0;
$(document).click(function(){
  $('.parent').find("p").removeClass('yellow').eq(i).addClass('yellow')
  i++;
});
.yellow{
 background-color:yellow;
}

Hi

Hi

Hi

Hi

Comment: this almost do the trick. Is it possible to shift that highlight from one p to another?
Comment: Thank you. But what if i want to scroll from one p to another? Sorry for not stating the main purpose on the problem. I'll edit it.
Comment: check this answer .It will same as you need https://stackoverflow.com/questions/54803901/how-to-scroll-to-next-div-using-javascript/54804025#54804025
Comment: Will check that. Thank you
Answer: Select all the paragraph elements and on click using i highlight them one by one

var i = 0;
$(document).click(function() {
$('p').css("background-color", "")
  $(Object.values($("p"))[i]).css("background-color", "yellow");
  i++;
});

Hi

Hi

Hi

Hi

Comment: this almost do the trick. Is it possible to shift that highlight from one p to another?
Comment: Thank you. But what if i want to scroll from one p to another? Sorry for not stating m main purpose on the problem. I'll edit it.
Comment: scroll animation??
Comment: Yes. If possible.
Comment: Check this answer https://stackoverflow.com/questions/31905765/javascript-scroll-from-one-div-to-the-other-when-scrolling

jquery nth child to root


Changes done in IIS Manager are reflected in web.config intead of applicationHost.config

Question: I had to install a third party product on my server. Somehow this tool changed stuff in the IIS Settings and now for example when I add ISAPI Filter to a Web Site it stores the setting in the web.config file of of the Web Site instead in the applicationHost.config.
How can I configure it back that settings are stored again in the applicationHost.config ?
Comment: As far as I am aware, some settings just *do* live in web.config rather than applicationHost.config.  Stuff that tells IIS where your sites are end up in applicationHost -- once it knows that, it can pull site-specific settings from web.config.  I *think* it depends on the component, of course, and how it chooses to implement IAppHostWritableAdminManager (http://forums.iis.net/t/1041000.aspx/1)
Answer: The third party product changed Feature Delegation for ISAPI Filters from ReadOnly to Read/Write. That change instructs IIS Manager to store the value in the web.config instead of applicationHost.config.


Argument of type 'Params' is not assignable to parameter of type 'string'

Question: I have passed data via snapshot and am now trying to receive it but am getting the following error

"[ts] Argument of type 'Params' is not assignable to parameter of type
  'string'."

When I sent the data I done a JSON.stringify and the data looked like this.
[
  {
    "caseData": "{\"getAllInfo\":{\"ticket\":{\"internalNum\":\"2500024035\",\"comp\":\"29\",\"reportedDate\":\"2018-07-20\",\"reportedTime\":\"00:00\",\"forceNumCharge\":\"7035551\",\"offenceSequence\":\"1\",\"aggrievedParty\":\"1\"}}}"
  }
]

Now when I try to retrieve the data and do a JSON.parse I get the error mentioned above.
this.caseData = JSON.parse(this.activatedRoute.snapshot.params);

Comment: What type is `this.caseData`?
Comment: it is `caseData: any;`
Answer: I may be wrong, but try with this.activatedRoute.snapshot.params['caseData']. In this case, you should probably put a debugger or a console.log(this.activatedRoute.snapshot.params) if you're doubting the way it's returned.
Comment: Yes this seems to giver back a cleaner data set and I can now filter through it


Conditions for validity of interior test

Question: In the case of a polygon (bounded by finitely many straight lines) in the plane, points can be tested for being inside the region bounded by the polygon by casting a ray from the point in any direction (not going through a vertex of the polygon) and inspecting the parity of the number of intersections with the polygon. In this question this algorithm was used to characterize the interior of a region bounded by a smooth curve. So my follow up question is:

Which conditions do we have to impose on a Jordan curve, such that the test described above works?

It is clear that any line through the region is supposed to intersect the curve only finitely many times, since otherwise parity is not defined. I just noted that the counterexamples I gave in the original questions (topologists sine circle / circle with antenna) are not given by Jordan curves, so I now tend to believe that a continuous embedding of the circle is enough. I would like to know this for certain though.
Thank you very much for your time!
Answer: You have not stated the test carefully enough. As stated, that test can be invalid even for polygons or smooth curves. For example, your Jordan curve could be a round circle, $c$ could be a point outside the circle, and the ray you pick could just happen to be a ray through $c$ that is tangent to the circle, intersecting that circle in exactly one point. Something similar could happen to a polygonal closed curve.
If you reformulate the test, it will work. For a smooth curve, the test works as long as the ray is transverse to the curve. For a polygonal curve, the test works as long as the ray passes through no vertex of the curve, which implies that the ray crosses the curve transversely. On top of that, for each $p$, a generic ray based at $p$ will satisfy this transversality condition. That makes the test very useful: as said the test is invalid for some special rays, but for generic rays it is valid.
There is indeed a general version of the test. On a Jordan curve $c$, every point $x \in c$ has a neighborhood $U$ and a homeomorphism $\phi : U \to (-1,+1) \times (-1,+1)$ such that $\phi(U \cap c) = (-1,+1) \times \{0\}$ and $\phi(x)=(0,0)$. Let's say that the ray $R$ crosses $c$ transversely at $x$ if $U$ and $\phi$ exist so that $\phi(R \cap c) - (0,0)$ has two components, one in $(-1,+1) \times (-1,0)$ and the otehr in $(-1,+1) \times (0,+1)$. Then the general test says: if a $R$ is a ray based at $p$, and if $R$ crosses $c$ transversely at each point of $R \cap c$, then $p$ is inside $c$ if and only if the number of crossings equals zero. In fact you could even apply this to a very general concept of "ray", namely any continuous, proper injection $R : [0,\infty) \to \mathbb R^2$ such that $R(0)=p$.
The difficulty, though, is that it that for general Jordan curves, there is no statement saying that "generic" rays cross the curve transversely. That means transverse rays to which the test for which the test is valid are hard to find.
Comment: Thank you very much indeed. I have few questions left. 1) has "generic ray" a specific meaning or do you use it as a replacement for "almost all rays"? 2) If I think of a polygonal approximation of the curve, only finitely many points on that curve are "bad". Moreover by refining the approximation accordingly every point inside (and similar outside) the curve will be bounded by a polygon. Cannot we deduce from this, that the transversal rays are "dense" in the set of rays starting at this point?
Comment: I used the term "generic" with specific vagueness (if I may be oxymoronic). In different situations, it will have different meanings. For the polygonal case, given $p$ disjoint from the Jordan curve, it means "for all but finitely many rays based at $p$", the only exceptions being the finitely many rays that pass through vertices of the polygon. For the smooth case, it means whatever conclusion comes out of applying Sard's theorem.
Comment: For your second question, that sounds like a good way of working, as long as you make sure that the polygonal approximation is close enough that the point $p$ does not move from the inside of the original curve to the outside of the approximating curve.
Comment: Thank you very much again!


Rails & Ahoy: No route matches [GET] "/ahoy/visits"

Question: I'm using the Ahoy gem to get visit information. But I notice in production, I'm frequently getting the below error:

No route matches [GET] "/ahoy/visits"

But the traceback doesn't show any files I recognize. Here's the full trace:
ActionController::RoutingError: No route matches [GET] "/ahoy/visits"
... 27 non-project frames
1
File "/app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.2/lib/action_dispatch/middleware/debug_exceptions.rb" line 21 in call
2
File "/app/vendor/bundle/ruby/2.0.0/gems/rollbar-2.6.3/lib/rollbar/middleware/rails/show_exceptions.rb" line 22 in call_with_rollbar
3
File "/app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.2/lib/action_dispatch/middleware/show_exceptions.rb" line 30 in call
4
File "/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/rack/logger.rb" line 38 in call_app
5
File "/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/rack/logger.rb" line 20 in block in call
6
File "/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/tagged_logging.rb" line 68 in block in tagged
7
File "/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/tagged_logging.rb" line 26 in tagged
8
File "/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/tagged_logging.rb" line 68 in tagged
9
File "/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/rack/logger.rb" line 20 in call
10
File "/app/vendor/bundle/ruby/2.0.0/gems/ahoy_matey-1.2.1/lib/ahoy/engine.rb" line 15 in block in call_with_quiet_ahoy
11
File "/app/vendor/bundle/ruby/2.0.0/gems/ahoy_matey-1.2.1/lib/ahoy/logger_silencer.rb" line 44 in silence_logger
12
File "/app/vendor/bundle/ruby/2.0.0/gems/ahoy_matey-1.2.1/lib/ahoy/engine.rb" line 14 in call_with_quiet_ahoy
13
File "/app/vendor/bundle/ruby/2.0.0/gems/request_store-1.2.1/lib/request_store/middleware.rb" line 8 in call
14
File "/app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.2/lib/action_dispatch/middleware/request_id.rb" line 21 in call
15
File "/app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/methodoverride.rb" line 22 in call
16
File "/app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/runtime.rb" line 18 in call
17
File "/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/cache/strategy/local_cache_middleware.rb" line 28 in call
18
File "/app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.2/lib/action_dispatch/middleware/static.rb" line 113 in call
19
File "/app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/sendfile.rb" line 113 in call
20
File "/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/engine.rb" line 518 in call
21
File "/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/application.rb" line 164 in call
22
File "/app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/lock.rb" line 17 in call
23
File "/app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/content_length.rb" line 15 in call
24
File "/app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/handler/webrick.rb" line 88 in service
25
File "/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb" line 138 in service
26
File "/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb" line 94 in run
27
File "/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb" line 295 in block in start_thread

Is this just a bot crawling all URLs? How can I find out where it's originating from based on the trace?
Comment: I'm having the same issue here. Did you manage to track it down?
Comment: Yeah actually - you can create a route to ahoy/visits, then create a controller action and just redirect back to root_url
Comment: Ok, thanks. So where's the origin of the request coming from? Is it crawler bots picking up the URL in the JS or from the actual rails engine itself?
Comment: A problem similar to this error came to me. [That's how I resolved this error.](https://stackoverflow.com/questions/47220823/ahoy-events-post-error-in-rails/47225383#47225383)
Answer: You need to mount the ahoy engine in your routes.rb file:
mount Ahoy::Engine => "/ahoy", as: :my_ahoy

Comment: is this still relavent ActionController::RoutingError (No route matches [POST] "/ahoy/visits"):
Answer: The cause of this problem seems to be bots crawling into places they shouldn't go. We solved this problem by adding a line to our robots.txt file:
User-agent: *
Disallow: /ahoy/

This should prevent bots from trying any route that begins with /ahoy/ such as our /ahoy/visits route. Not all bots respect the robots.txt file, but enough of them do that we now only rarely see this error occur.


IntelliJ Optimize Imports for the entire scala project

Question: One of the very useful features of IntelliJ is that when I am done editing a file, I can do a "optimize imports". this removes all the unused imports from my code.
This is very useful, but I have to do it for every file.
Can I do "optimize imports" for the entire project?
Answer: Select the source root in the project tree;
1. Hit the keyboard shortcut for "Optimize import"
MAC
Cmd-shift-A

Windows
Ctrl-shift-A

2. You will see

3. Hit Run
Comment: Excellent. I had no idea that running `Optimize Imports` after clicking on root would make a difference.

Just a word of advice to other developers landing in this answer, check your actual optimize imports short cut on `Code > Optimize Imports` tab –– Mine was `cmd + opt + o` :)
Comment: "Select the source root in the project tree;" this should be in bold
Comment: Nice, even recurses down into every dir and also provides an option to only do this on changed VCS files
Answer: First you build the project, In "build output" tab in left bottom corner, you will see lot of files with compilation errors. Select them all and press CRTL+ALT+O
A popup will open which will ask "Optimize import for 'module'"
Click Run.
Answer: Select your project -> right click -> Optimize import
Notice!:
You can do that for all file in project/module or just for uncommitted changes.


mysql search find number in range and greater than

Question: I've trying to write a search for a mysql table, but struggling if it's possible.
I have a table that may have multiple numbers, i.e. an object may be available in sizes [3, 6, 13, 26]
Initially separating them in to different rows allowed a search, but the same event would appear for everything within the Greater/Less Than or Between search range via: -
SELECT * FROM mytable WHERE SeqNumber >=$POSTmin AND SeqNumber<=$POSTmax;

SELECT * FROM mytable WHERE SeqNumber BETWEEN $POSTmin AND $POSTmax;

Unfortunately combining them in to 1 row, but with multiple sizes [3, 6, 13, 26] would only work on the first value within the range.
Searching on a single number does work with a LIKE: -
SELECT * FROM mytable WHERE SeqNumber LIKE '%$POSTvarible%';

But I would like to know if it's possible, if so how, I can search Max & Min if that number appears at random positions in a cell?
Comment: https://stackoverflow.com/questions/3653462/is-storing-a-delimited-list-in-a-database-column-really-that-bad
Comment: Can you possibly reword some of this?  The way you formulated some of the sub-questions or statements is very confusing. Like, what does this mean? "Unfortunately combining them in to 1 row, but with multiple sizes [3, 6, 13, 26] would only work on the first value within the range."
Comment: Thanks Sticky Bit
I'd like to hide behind proof of concept, but I know how to do it correctly and it's a lot of work, so it's just laziness.
Answer: I mean you can retrieve all matched sizes in one row using GROUP_CONCAT:
<?php
$POSTmin = 6;
$POSTmax = 30;

$query = "SELECT Name, GROUP_CONCAT(SeqNumber) SeqNumbers
FROM mytable
WHERE SeqNumber BETWEEN ? AND ?
GROUP BY Name;";

// get DB version using PDO
$stmt = $pdo->prepare($query);
$stmt->execute([$POSTmin, $POSTmax]);
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
print_r($rows);

PHP PDO GROUP_CONCAT test online


Calculo de Multiplicação em JavaScript

Question: Preciso fazer um calculo de porcentagem sobre um valor, porém dependendo do numero a ser calculado (se houver dizima periodica no resultado por exemplo) o resultado é arredondado e nao apresenta casas decimais, exemplo:
(estou calculando por 1.05 porque equivale a um acréscimo de 105%)
11.114,37 * 1.05 = 11.6697 (Por que sem casas decimais?)
11,11     * 1.05 = 11.55   (O correto seria 11,66)
Ou seja... O calculo está errado e as vezes nem aparece casas decimais..
Preciso dos resultados corretos com apenas 2 casas decimais.
Onde estou errando? Por favor me ajudem!

        <form action="" method="">

  Valor:

<input class="form-control"   name="PO4R_ORCADO" id="PO4R_ORCADO" type="text"   onblur="percentual();" >

<input class="form-control"name="PO4R_MAIS1" id="PO4R_MAIS1" type="text"  >
        </form>

RESOLVIDO!!!
Segue a funçao para quem passar pelo mesmo problema que eu!

Answer: O parseFloat só irá entender números com a casa decimal separada por '.' ao invés de ','. (https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/parseFloat)
Antes de dar o parseFloat, substitua a vírgula digitada no campo por ponto:
vl_fr1 = vl_fr1.replace(',', '.');

E para pegar apenas duas casas decimais no resultado final, use a função toFixed(), passando o número de casas decimais que deseja.
EDITADO
Dessa forma fica mais completo, pois se tiver uma string do tipo '11.111,50', após substituir a vírgula ficará '11.111.50', e o parseFloat também vai dar problema. A solução é substituir a vírgula mas também remover esse segundo ponto:
vl_fr1 = vl_fr1.replace(/\./g,'').replace(',', '.');

E só então dar o parseFloat. Lembrando que o toFixed arredonda valores, então '11670,0885' com duas casas decimais ficaria '11670,09'.
Comment: Isso é porque nesse caso tem mais de 1 ponto na string, vou editar a resposta para resolver também esse caso.
Comment: Muito obrigado por responder Mais continua sem casas decimais.. dando o replace como sugerido o valor para ser calculado ficou assim (11.114.37) O resultado foi (11.6697) continua sem casas decimais...  continua o mesmo problema :(
Comment: Editei a resposta.
Comment: Obrigado Voce resolveu meu problema!! Obrigado mesmo
Comment: Show. Se puder, marca a resposta como aceita. Boa sorte.
Answer: mais ou menos isso:
vl_fr1 = vl_fr1.replace(',', '.');

Calculo de Multiplicação em JavaScript


How to check button clicked in new UI button of unity 5.0

Question: I added the new UI buttons of unity 5.0 in place of the old GUI texture buttons
in these buttons how to i check when the button has been pressed and released
and how to make the Onclick event keep repeating itself
Answer: Add an Event Trigger component to your button . From there you can add a listener for OnPointerUp for when mouse is released and OnPointerDown for when mouse is pressed


How to replace a preprocess function entirely?

Question: I need to replace template_preprocess_links with my own preprocess function and I can't find in the documentation how to replace a preprocess function entirely. Here is my current HOOK_theme implementation:
/**
 * Implements hook_theme().
 */
function my_module_theme($existing, $type, $theme, $path)
{
  return [
    'links' => [
      'variables' => [
        'links' => NULL,
        'raw_links' => NULL,
        'attributes' => NULL,
        'heading' => NULL
      ],
      'override preprocess functions' => TRUE
    ]
  ];
}

But even with override preprocess functions set to TRUE, the core template_preprocess_links is still called and pollute the output with rendered links.
How can I replace this preprocess function entirely?
Answer: hook_theme() is for new theme implementations, not altering the existing ones, and 'override preprocess functions' can be used just from themes.
The hook you need to implement is hook_theme_registry_alter().
This example code shows how to remove a preprocess function for a theme implementation.
function mymodule_theme_registry_alter(&$theme_registry) {
  // Kill the next/previous forum topic navigation links.
  foreach ($theme_registry['forum_topic_navigation']['preprocess functions'] as $key => $value) {
    if ($value == 'template_preprocess_forum_topic_navigation') {
      unset($theme_registry['forum_topic_navigation']['preprocess functions'][$key]);
    }
  }
}

Removing all the preprocess functions would just require a line like unset($theme_registry['forum_topic_navigation']['preprocess functions'].
The same is true for Drupal 7. (See the example code given in hook_theme_registry_alter() - Drupal 7.)


How to calculate the angle of a trajectory without knowing the velocity

Question: How do I calculate the angle of a trajectory to hit the target, without knowing the velocity. I only know the max height, offset height and the distance to the target.

This is what I got so far (I don't know how to calculate offset height ):
 float GetAngle(Vector3 startLocation, Vector3 endLocation, float maxHeight)
 {
         float distance = Mathf.Sqrt(Mathf.Pow(startLocation.x - endLocation.x,2) + Mathf.Pow(startLocation.z - endLocation.z,2));

         float offsetHeight = endLocation.y - startLocation.y;
         //how do I calculate offset height in this equation ?
         return -Mathf.Atan (4 * maxHeight/ distance ) + Mathf.PI;
 }

I use this to calculate the velocity (works fine I only need the correct angle):

float LaunchVelocity (Vector3 startLocation, Vector3 endLocation, float angle)
 {
         float range = Mathf.Sqrt(Mathf.Pow(startLocation.x - endLocation.x,2) + Mathf.Pow(startLocation.z - endLocation.z,2));
         float offsetHeight = endLocation.y - startLocation.y;
         float gravity = Physics.gravity.y;

         float velocity = range * range * gravity;
         velocity /= range * Mathf.Sin(2 * angle) + 2 * offsetHeight * Mathf.Pow(Mathf.Cos(angle),2);
         return Mathf.Sqrt(velocity);
 }

Comment: look here http://stackoverflow.com/a/26174961/2521214 to get started ...
Answer: I got the solution:
float GetAngle(float height, Vector3 startLocation, Vector3 endLocation)
    {
        float range = Mathf.Sqrt(Mathf.Pow(startLocation.x - endLocation.x,2) + Mathf.Pow(startLocation.z - endLocation.z,2));
        float offsetHeight = endLocation.y - startLocation.y;
        float g = -Physics.gravity.y;

        float verticalSpeed = Mathf.Sqrt(2 * gravity * height);
        float travelTime = Mathf.Sqrt(2 * (height - offsetHeight) / g) + Mathf.Sqrt(2 * height / g);
        float horizontalSpeed = range / TravelTime;
        float velocity = Mathf.Sqrt(Mathf.Pow(verticalSpeed,2) +  Mathf.Pow(horizontalSpeed, 2));

        return -Mathf.Atan2(verticalSpeed / velocity, horizontalSpeed / velocity) + Mathf.PI;
    }

Comment: Very nice. Don't forgot to accept it so other's know it is solved.


Lawvere theories: an equivalence.

Question: I'm having trouble understanding Lawvere theories (as defined below).

Definition: A Lawvere Theory is a category $\mathcal{L}$ with finite products and with a distinguished object $A$ such that every object of $\mathcal{L}$ is (isomorphic to) a finite power of $A$; that is, for any $X\in\operatorname{Ob}(\mathcal{L})$, there is an $n\in\mathbb{N}$ with $X\cong A^{n}$. The object $A$ is called the fundamental object of $\mathcal{L}$. An arrow $\omega :A^{n}\to A$ is called an $n$-ary operation (and, in particular, arrows of the type $A^{0}=1\to A$ are called constants).

Here's an exercise in Turi's Category Theory Lecture Notes:

Let $\mathbb{N}^{\text{op}}$ be the opposite category of natural numbers and all functions. Show that Lawvere theories are equivalent to product preserving functors
  $$\mathbb{N}^{\text{op}}\to\mathbf{C}$$ that are bijective on objects.

The problem: I'm not sure what to do. The $\mathbf{C}$ doesn't help as it's undefined.

My attempt: Let $\mathcal{L}:\mathbb{N}^{\text{op}}\to\mathbf{C}$ be a product preserving functor bijective on objects. Then for any $(n_{i})_{I}\in\mathbb{N}$ for any set $I$, if $\prod_{i\in I}{n_{i}}$ exits, then $\mathcal{L}\left(\prod_{i\in I}{n_{i}}\right) = \prod_{i\in I}{\mathcal{L}(n_{i})}$ and for all $m, n\in\mathbb{N}$, $c\in Ob(\mathbf{C})$,

$\mathcal{L}(n)=\mathcal{L}(m)\Rightarrow n=m$
there exists $m_{c}\in\mathbb{N}$ with $\mathcal{L}(m_{c})=c$.

I then set up the commutative diagram(s) for the product with an arbitrary $(f_{i})_{I}$ such that $f_{i}: k\to n_{i}$ in $\mathbb{N}^{\text{op}}$ and took $\mathcal{L}$ of everything.
Then I got stuck.
I want to force this $\mathcal{L}$ to be a Lawvere theory. Once I've done that, I'll take a Lawvere theory and try to go in the other direction.

Have I even understood the question properly? Please help. I'd prefer HINTS ONLY.
Thank you :)

Second attempt (based on the comments): The trick is to consider what happens to $1\in Ob(\mathbb{N}^{\text{op}})=\mathbb{N}$. Note that the product in $\mathbb{N}^{\text{op}}$ is the coproduct in $\mathbb{N}$, so is simply addition.
Suppose $L:\mathbb{N}^{\text{op}}\to\mathbb{C}$ is a product preserving functor bijective on objects. Then for all $c\in Ob(\mathbf{C})$, there exists a unique $m_{c}\in Ob(\mathbb{N}^{\text{op}})=\mathbb{N}$ with $L(m_{c})=c$ and for any $m, n\in\mathbb{N}, L(m)=L(n)\Rightarrow m=n$.
Let $L(1)=A$ and note that if a product $\sum_{i\in I}{a_{i}}$ exists in $\mathbb{N}^{\text{op}}$ for $a_{i}\in Ob(\mathbb{N}^{\text{op}})=\mathbb{N}$, it is in $\mathbb{N}$ and so $I$ would be a finite set. Hence finite products must exist in $\mathbf{C}$. Now for $X\in\mathbf{C}$, $X=L(m_{X})$ for some $m_{X}\in\mathbb{N}$ so $X=L(m_{X})=L(\sum_{j=1}^{m_{X}}{1})=\prod_{j=1}^{m_{X}}{L(1)}=A^{m_{X}}$. Thus $X\cong A^{m_{X}}$. Therefore, the pair $\langle L, \mathbf{C}\rangle$ is a Lawvere theory.

Ideas for the converse: Let $L:\mathbb{N}^{\text{op}}\to\mathcal{L}$ such that $L(1)=A$ and . . .

$L(u)=U\cong V=L(v)$ iff $L(u)=L(v),$
$Y\cong A^{m}=L(m_{A^{m}})$ implies $ L(m_{A^{m}})=Y$, or
$L(m)=Y$ if (and only if) $Y\cong A^{m}$.

I've explored these ideas and they don't seem fruitful. I would like an explicit proof now please, $\color{red}{\large\text{not just hints}}$. This is really bugging me.
Comment: It says nothing of the sort. It says "equivalent". More precisely there is an equivalence between the category of Lawvere theories and the category of bijective-on-objects product-preserving functors with domain $\mathbb{N}^\mathrm{op}$, if you choose the appropriate notion of morphism on both sides.
Comment: Yes, you can do that.
Comment: The product in $\mathbb{N}^\mathrm{op}$ is the coproduct in $\mathbb{N}$, which is addition.
Comment: The category $\mathcal{C}$ _is_ a Lawvere theory, if you have a bijective-on-objects product-preserving functor $\mathbb{N}^\mathrm{op} \to \mathcal{C}$.
Comment: @Zhen Lin: Thank you. Given the definition above, though, I'm afraid that's little more than an assertion to me at the moment; I want to be able to show it :/
Comment: It is really a triviality once you understand the definitions properly. Think about what happens to $1$ in $\mathbb{N}$.
Comment: @Zhem Lin: I don't follow. I'm sorry. Isn't the exercise asking me to show that the *functors* are Lawvere theories, not the category $\mathbf{C}$? I'm not saying you're wrong - I just don't understand within the context of the exercise. Should it be rephrased?
Comment: @Zhen Lin: Right, so do you mean I should consider neither the functors nor the category $\mathbf{C}$ as fixed, taking a functor *and a category* as a Lawvere theory?
Comment: @Zhen Lin: Okay, that would make a LOT more sense. Thank you! :)
Comment: @Zhen Lin: I still can't prove this equivalence. I need to show the "$X\cong A^{n}$" part, treating $L(1)$ like $A$ for the functor $L:\mathbb{N}^{\text{op}}\to\mathbf{C}$. Maybe it's better if I work this out alone since it should be trivial :/
Comment: Well, $n = 1 + \cdots + 1$ in $\mathbb{N}$, no?
Comment: That's true. The product in $\mathbb{N}^{\text{op}}$ is simply multiplication . . . Right? And if $\lvert I\rvert =n$, indeed $L(1)=L(\prod_{i\in I}{1})=\prod_{i\in I}{L(1)}=L(1)^{n}$ etc. I've pocked at this with stick for a while - I still can't make $L(m_{X})=X$ fit the description :/
Comment: [@Zhen Lin: I've thought of using $(\mu_{j}: m_{X}\to 1)_{j\in J}$ in the commutative diagram for the product.]
Comment: @Zhen Lin: Thank you. I suck at this. It's fun though $\ddot\smile$
Answer: Let $\mathbf C$ be a Lawvere theory: i.e. a category with finite products such that there's an object $A \in \mathbf C$ for which for every other $X \in \mathbf C$ there's a $n \in \mathbb N$ such that $A^n\cong X$.
Let's consider $\mathbb N$ the category of natural numbers and all function between them.
Clearly we have a function between the objects of $\mathbb N$ and the objects of $\mathbf C$ defined as
$$\mathcal L\colon \mathbb N \to \mathbf C,$$
with $\mathcal L(n) = A^n$ for $n \in \mathbb N \setminus\{0\}$ and $\mathcal L(0)=\bullet$ the terminal object of $\mathbf C$.
Let $f \colon n \to m$ be a morphism in $\mathbb N$, or else a function between the sets $\{0,\dots,n-1\}$ and $\{0,\dots,m-1\}$.
For every $i \in \{0,\dots,m-1\}$ we can consider the family of morphism
$\langle \pi_i^j\rangle_{j=1,\dots,n}$ where
$\pi^i_j=1_A$ if $i \in f^{-1}(\{j\})$ other wise $\pi^i_j \colon A \to \bullet$ is the unique map in the terminal object $\bullet \in \mathbf C$.
These morphisms give us a morphism
$$\pi^i \colon A \to A^{f^{-1}(\{i\})}$$
for universal property of products
and then we get the product morphism
$$\mathcal L(f) = \prod_{i=1}^n \pi^i \colon A^n=\mathcal L(n) \to A^m=\mathcal L(m).$$
Clearly if $f=1_n$ for a $n$ then for every $i \in n$ we have $1_n^{-1}(\{i\})=\{i\}$ and so the $\pi^i=1_A$ for every $i$ and so $\mathcal L(1_n)=1_{A^n}$.
Doing the calculations you can prove also that $\mathcal L(g \circ f)=\mathcal L(f) \circ \mathcal L(g)$, for every pair $f \colon n \to m$ and $g \colon m \to k$, of course the calculation are a little complicated (I  would rather not to write here).
This functor is clearly product preserving, indeed for every $n \in \mathbb N$ we have that $\mathcal L(n)=A^n$ which is the n-fold product, and  every projection of $\mathbb N^\text{op}$ i.e. a map $p \colon 1 \to n$ in $\mathbb N$ we have that
$$\mathcal L(p) = \prod_{i=1}^n \pi^i \colon A^n \to A,$$
where every $\pi^i \colon A \to \bullet$ for $i \not \in \text{Im }p(0)$ and $\pi^i = 1_A$ for $i \in \text{Im }p(0)$.
So $\mathcal L(p)$ is the $p(0)$-th projection of the product $A^n$, of course now one should verify that these data verify the universal property which involve again some long calculations.
Forgive the lack of some details, but I think that adding them wouldn't make the answer more clear.
Hope this helps.
Comment: @Shaun sure of course. Btw $\bullet$ the terminal object is also the empty product so it must exists in every category with finite products. :)
Comment: Thank you so much for your patience in writing that out for me, @Giorgio Mossa! I'm confident that I can take it from here. [I first need to check the existence of $\bullet$.] I hope you understand if I accept once I've got the damn thing!
Comment: Again, thank you. I'm not sure I understand how $\mathcal{L}$ is bijective on objects though. What if there exists an $X$ such that $A^{n}\neq X\cong A^{n}$? [The same question, I suppose, covers how we can overlook $A^{n}\times\bullet\cong A^{n}$.]
Comment: Oh, I see; it's a bit of a [misnomer](http://ncatlab.org/nlab/show/bo+functor).
Comment: [I'm following Turi's lecture notes. Maybe the term was covered in additional exercises or some other supplement.]

Lawvere theories: an equivalence.


Facebook C# SDK: Traverse The JsonArray To Get The Value of Tracking Data

Question: This is a followup to:
(OAuthException) (#15) The method you are calling must be called with an app secret signed session
C# equivalent of file_get_contents (PHP)
Facebook API: Can I Invite A Test User To My Application?
So I'm at the final step now. I managed to invite users and get the request info once the invited user accepts the invitation. Now I need to traverse the result object (JsonArray) and get the value of the data field which is the tracking data that is sent with the Request Dialog
I've tried using dot syntax to traverse the object and some other things but I couldn't get it. So here's my code (which doesn't work):
        dynamic requestInfo = fb.Get("/me/apprequests/");
        if (requestInfo.data.Count > 0)
        {
            //var c = requestInfo.data.data;
            var a = requestInfo[0]["data"];
            ViewData.Add("TrackingData", "the value");
        }

And here's the result:

{"data":[{"id":"1001200425907","application":{"name":"MyFirstTestApp","id":"193005690721590"},"to":{"name":"Margaret
  Diibjcfhg
Sadansteinskymanbergwitz","id":"499203687"},"from":{"name":"Nancy
  Diibjcfhf
Changwitz","id":"499203686"},"data":"someCode","message":"Invitation
  to the test
  application!","created_time":"2011-05-
18T09:31:40+0000"}]}
Comment: I'm unfamiliar with C#, but have you tried requestInfo["data"][0]["data"]?
Comment: @echeese: I cannot thank you enough! That actually worked! Could you post that as an answer so I could accept it? :)
Answer: The data you are looking for is in requestInfo["data"][0]["data"] I used the JSONView addon for Firefox to help me traverse the structure to give you the answer, and I recommend it to help you figure out stuff like this in the future.
Comment: I did not even know about this addon! Thanks again! :)


SVG does not flex to the bottom to the screen

Question: My SVG element is not flexing towards the bottom (or top) of the screen i.e. shrinks in size when there is no space. However, when there is no space the SVG slides down overflowing the page as shown in the GIF.
I tried setting max-height and min-height but that did not work. Using flex: 0 1 auto;, as I saw in another question on StackOverflow, also did not work.
Expected: Image getting smaller as space decreases with no resulting overflow.

.content {

  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  flex: 1 0 auto;

  max-width: 100%;
  height: auto;

}

.waveContainer {

  position: absolute;
  z-index: -1;
  max-height: 100vh;

  top: 0;
  left: 0;
  right: 0;
  bottom: 0;

}

#wave {

  position: absolute;
  z-index: -1;

}

.flexParent {

  height: 100;

  display: flex;
  justify-content: space-between;
  align-items: center;

  width: 100%;
  max-width: 1600px;

  bottom: 0;

  padding-right: 10px;
  padding-left: 10px;
  padding-bottom: 10px;
  z-index: 1;

}

.contact {

  width: 300px;
  height: 71px;
  border: none;

  background: #009ABC;
  border-radius: 18px;

  border-style: solid;
  border-color: #ffffff;

  font-family: Alata;
  font-style: normal;
  font-weight: normal;
  font-size: 30px;
  text-align: center;
  letter-spacing: 0.3em;
  color: #ffffff;

}

.contactContainer {

  z-index: 2;
  max-height: 500px;

}

.programmer {

  max-height: 500px;

}

#programmer {

  max-width: 100%;
  height: auto;

}

button:hover {

  cursor: pointer;
  color: black;
  border-color: black;
  background: #047f9b;
  transition: 1s;

}

button:active {

  padding: 0;

}

  <svg id="wave" data-name="Component 1 – 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0 1920 1080" preserveAspectRatio="none">
    <defs>
      <clipPath id="clip-path">
        <rect id="Rectangle_1" data-name="Rectangle 1" width="100%" height="100%" fill="#fff" stroke="#707070" stroke-width="1" />
      </clipPath>
    </defs>
    <g id="Mask_Group_1" data-name="Mask Group 1" clip-path="url(#clip-path)">
      <path id="Vector_3_3" data-name="Vector 3 3" d="M827.436,426.125C1163.09,111.934,1825.38,153.689,1986.77,0L2157,822.019,12.675,854-34,562.171C215.951,541.969,491.785,740.316,827.436,426.125Z" transform="translate(-46 122)" fill="#00d1ff" />
      <path id="Vector_2_2" data-name="Vector 2 2" d="M827.436,426.125C1163.09,111.934,1825.38,153.689,1986.77,0L2157,822.019,12.675,854-34,562.171C215.951,541.969,491.785,740.316,827.436,426.125Z" transform="translate(-37 195)" fill="#00bae2" />
      <path id="Vector_1_1" data-name="Vector 1 1" d="M831.436,426.125C1167.09,111.934,1829.38,153.689,1990.77,0L2161,822.019,16.675,854-30,562.171C219.951,541.969,495.785,740.316,831.436,426.125Z" transform="translate(-42 273)" fill="#009abc" />
    </g>
  </svg>

        <svg id="programmer" width="594" height="451" viewBox="0 0 594 451" fill="none" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none">
          <g clip-path="url(#clip0)">
            <path d="M287.383 398.746C159.532 389.016 7.06427 289.944 14.8267 187.933C22.589 85.9218 170.256 -9.0419 298.107 0.688383C425.958 10.4187 499.553 201.06 491.791 303.071C484.029 405.082 415.234 408.476 287.383 398.746Z" fill="#00D1FF" />
            <path d="M298.106 415.131C445.502 415.131 564.991 407.81 564.991 398.779C564.991 389.748 445.502 382.427 298.106 382.427C150.709 382.427 31.2211 389.748 31.2211 398.779C31.2211 407.81 150.709 415.131 298.106 415.131Z" fill="#004150" />
            <path opacity="0.1" d="M298.106 409.329C423.655 409.329 525.433 404.487 525.433 398.515C525.433 392.543 423.655 387.702 298.106 387.702C172.557 387.702 70.7791 392.543 70.7791 398.515C70.7791 404.487 172.557 409.329 298.106 409.329Z" fill="black" />
            <path d="M111.919 451C173.731 451 223.839 446.631 223.839 441.242C223.839 435.852 173.731 431.483 111.919 431.483C50.108 431.483 0 435.852 0 441.242C0 446.631 50.108 451 111.919 451Z" fill="#004150" />
            <path opacity="0.1" d="M111.919 447.537C164.569 447.537 207.25 444.648 207.25 441.084C207.25 437.52 164.569 434.631 111.919 434.631C59.2698 434.631 16.5889 437.52 16.5889 441.084C16.5889 444.648 59.2698 447.537 111.919 447.537Z" fill="black" />
            <path d="M500.116 85.4526H103.48V396.669H500.116V85.4526Z" fill="#3F3D56" />
            <path d="M297.285 127.983H199.436C199.28 127.984 199.125 127.953 198.981 127.894C198.836 127.834 198.705 127.747 198.595 127.636C198.484 127.526 198.396 127.395 198.337 127.251C198.277 127.107 198.246 126.952 198.246 126.796C198.246 126.64 198.277 126.485 198.337 126.341C198.396 126.196 198.484 126.065 198.595 125.955C198.705 125.845 198.836 125.757 198.981 125.698C199.125 125.638 199.28 125.608 199.436 125.608H297.285C297.6 125.609 297.901 125.734 298.124 125.957C298.346 126.18 298.47 126.481 298.47 126.796C298.47 127.11 298.346 127.412 298.124 127.635C297.901 127.857 297.6 127.983 297.285 127.983V127.983Z" fill="#F2F2F2" />
            <path d="M92.6445 231.236C91.5742 232.571 93.116 234.506 92.8801 236.201C92.7233 237.327 91.7965 238.187 91.4106 239.257C91.0109 240.365 91.2228 241.592 91.0712 242.76C90.9191 243.61 90.6941 244.444 90.3987 245.255C89.7196 247.677 89.2457 250.152 88.9818 252.653L87.5709 263.19C87.3261 264.776 87.1771 266.375 87.1247 267.979C87.1958 269.177 87.1157 270.38 86.8863 271.559C86.5738 272.71 85.8821 273.717 85.4167 274.816C84.9514 275.915 84.7357 277.244 85.3643 278.258C83.2591 280.011 82.6331 283.455 84.1051 285.766C84.3854 286.126 84.6046 286.53 84.754 286.961C84.8353 287.564 84.7359 288.177 84.4682 288.723L83.0416 292.525C82.6765 293.498 82.561 294.979 83.5762 295.201C82.7353 296.074 82.0802 297.109 81.6504 298.243C81.4419 298.812 81.3796 299.425 81.4692 300.024C81.5588 300.624 81.7975 301.191 82.1633 301.675C82.5177 301.986 82.8195 302.352 83.057 302.759C83.1965 303.327 83.1605 303.923 82.9537 304.47C82.7404 305.3 82.6992 306.165 82.8328 307.012C82.9665 307.859 83.272 308.669 83.7306 309.393C84.2058 310.108 84.8788 310.668 85.6673 311.006C86.4559 311.344 87.3258 311.445 88.1708 311.297C91.0245 310.653 93.5888 309.637 96.4662 310.165C102.661 311.302 108.877 312.444 114.877 314.359C121.725 316.546 128.356 319.753 135.514 320.426C135.985 320.522 136.474 320.446 136.894 320.211C137.258 319.865 137.485 319.399 137.532 318.899C138.269 315.441 139.007 311.984 139.744 308.526C140.636 304.693 141.314 300.814 141.777 296.907C142.029 294.385 142.101 291.849 142.173 289.315L142.743 269.149C143.01 266.177 142.614 263.182 141.582 260.382L138.303 249.912C136.432 243.938 132.138 238.639 130.61 232.568C129.643 228.725 128.928 224.601 126.334 221.606C122.635 217.336 116.236 216.672 110.635 217.406C108.105 217.738 105.553 218.31 103.364 219.622C100.833 221.14 98.9688 223.53 97.1651 225.866C95.6786 227.791 94.1655 229.338 92.6445 231.236Z" fill="#009ABC" />
            <path d="M105.722 290.551C106.184 292.541 107.153 294.376 107.746 296.331C108.74 299.606 108.656 303.133 109.648 306.409C110.064 307.784 110.667 309.104 110.966 310.509C111.663 313.785 110.645 317.174 109.382 320.276C108.118 323.377 106.579 326.436 106.169 329.76C105.88 332.101 106.295 334.744 108.1 336.264C109.973 337.841 112.695 337.734 115.135 337.524C116.011 337.5 116.876 337.32 117.689 336.993C119.554 336.11 120.34 333.902 120.777 331.884C122.238 325.122 121.821 318.113 121.396 311.208L120.285 293.15C120.071 289.674 119.842 286.125 118.771 282.787C118.381 281.573 117.702 279.119 116.593 278.344C115.494 277.576 112.358 277.542 110.998 277.478C104.617 277.178 104.688 286.085 105.722 290.551Z" fill="#FBBEBE" />
            <path d="M112.792 223.877C111.489 223.195 109.847 223.489 108.588 224.249C107.371 225.082 106.306 226.116 105.438 227.307C102.622 230.745 99.6408 234.689 100.058 239.113C100.215 240.772 100.85 242.342 101.281 243.952C103.169 251.009 101.081 258.473 101.32 265.775C101.459 269.994 102.377 274.144 103.291 278.266C103.478 279.107 103.777 280.08 104.59 280.364C105.201 280.576 105.861 280.303 106.466 280.073C108.72 279.24 111.141 278.962 113.524 279.263C115.908 279.563 118.184 280.433 120.16 281.799C121.671 280.993 121.105 278.443 120.766 276.764C119.76 271.775 121.126 266.628 122.786 261.817C124.445 257.006 126.431 252.201 126.706 247.119C127.017 241.361 125.108 235.741 123.224 230.291C122.813 229.101 122.364 227.854 121.411 227.032C120.595 226.425 119.66 225.998 118.667 225.778C116.666 225.187 114.64 224.845 112.792 223.877Z" fill="#2F2E41" />
          </g>
          <defs>
            <clipPath id="clip0">
              <rect width="594" height="451" fill="white" />
            </clipPath>
          </defs>
        </svg>

      <button class="contact" onclick="document.location.href='contact.html'"> VIEW </button>

CODEPEN
Answer: Add flex-basis CSS property in the styling.


What are best practices for Drupal 7 my.conf settings?

Question: I posted the following wiki to GDO to try to consolidate best practices for Drupal implementations:
http://groups.drupal.org/node/289613
There's just so much written out there, but the documentation is often old or very personalized to one person's my.conf file.
What have other folks used.  Starting with https://tools.percona.com/wizard seems to be the best approach, but the Wizard doesn't know anything about Drupal.
Answer: You need to profile this yourself, every server is different - there's not really any such thing as 'best practice' here; get mysqltuner up and running, and follow the recommendations.
Don't try to think of it in terms of Drupal, rather in terms of any web application which needs optimising. If you get too hung up on the 'Drupal' aspect you'll end up looking in the wrong places to optimise


Table para Excel demorando demais

Question: Bom , tenho uma consulta no banco de dados , que me retorna a depender dessa consulta coisa de 5k linhas a 30k linhas , estou gerando já em excel através do código abaixo , contudo quando me traz cerca de mais de 5k de informações , ele demora muito para carregar . Alguém poderia ajudar em relação ao código ou outra forma de gerar o excel ?
excel.php:

<?php
   $file = 'planilha.xls';
   header ("Content-type: application/x-msexcel");
   header ("Content-Disposition: attachment; filename=\"{$file}\"" );
   header ("Content-Description: PHP Generated Data" );
?>
<?php
    define('DB_HOST'        , "");
    define('DB_USER'        , "");
    define('DB_PASSWORD'    , "");
    define('DB_NAME'        , "");
    define('DB_DRIVER'      , "sqlsrv");

    require_once "Conexao.php";

try{
  //inicia a conexao
   $Conexao     = Conexao::getConnection();

   $filial1 = $_POST[];
   $filial2 = $_POST[];
   $data_inicial = $_POST[_];
   $data_final = $_POST[];

  //faz a consulta na tabela procurando palavras do form
   $query       = $Conexao->query (" EXECUCAO DA MINHA PROCEDURE ");
   $teste       = $query->fetchAll();

  }catch(Exception $e){
        echo $e->getMessage();
        exit;
    }
?>

        <?php
        foreach($teste as $CLIENTE) {
    ?>

                        <?php echo $CLIENTE[]; ?>

                        <?php echo $CLIENTE[]; ?>

                        <?php echo $CLIENTE[]; ?>

                        <?php echo $CLIENTE[]; ?>

                        <?php echo $CLIENTE[]; ?>

                        <?php echo $CLIENTE[]; ?>

                        <?php echo $CLIENTE[]; ?>

                        <?php echo $CLIENTE['']; ?>

                        <?php echo $CLIENTE[]; ?>

                        <?php echo $CLIENTE[]; ?>

                        <?php echo $CLIENTE[]; ?>

                        <?php echo $CLIENTE[]; ?>

                        <?php echo $CLIENTE[]; ?>

                        <?php echo $CLIENTE[]; ?>

                        <?php echo $CLIENTE[]; ?>

                        <?php echo $CLIENTE[]; ?>

                        <?php echo $CLIENTE[]; ?>

                        <?php echo $CLIENTE[]; ?>

                        <?php echo $CLIENTE[]; ?>

                        <?php echo $CLIENTE[]; ?>

                        <?php echo $CLIENTE[]; ?>

                        <?php echo $CLIENTE[]; ?>

                        <?php echo $CLIENTE[]; ?>

            <?php
        }
    ?>

Comment: Normalmente revisões de códigos precisam ser mais específicas e requerem mais detalhes.
Comment: No caso , eu apresentei o meu código de como estou gerando o Excel , minha duvida está na parte de como poderia melhorar esse código em especifico . Descrevi meu código inteiro e expliquei o motivo de está realizando uma possível melhora .
Answer: Vou adicionar algumas considerações, mas dificilmente será uma resposta específica ao seu problema.
Existem diversas formas de "atacar" esse problema, a primeira delas é aumentar os recursos da maquina de forma que o script gere o conteúdo de forma mais rápida, essa solução é relativamente fácil, porém dificilmente escalável, vai chegar uma hora que não vai existir mais máquina única capaz de gerar o conteúdo.
A segunda forma é agendar a criação da tabela e informar ao usuário quando a mesma estiver pronta, ou seja, o usuário em vez de clicar em gerar a tabela e esperar a tabela ficar pronta, ele passaria a solicitar (por meio de um botão ou algo) e seu sistema colocaria a criação em background para ser executada no tempo necessário, quando o arquivo estiver pronto você informa ao usuário por email ou algum outro mecanismo.
Se você precisa do conteúdo de forma periódica, pode fazer um cronjob para executar o script durante a noite ou algum horário que o servidor recebe menos carga, armazenando o resultado e fornecendo o arquivo já computado quando solicitado.
Uma última consideração, é a query SQL em si, que na pergunta foi omitida, talvez seja legal você verificar quanto tempo ela demora a ser executada, talvez o problema nem seje realmente no PHP.
Comment: $query       = $Conexao->query ("EXEC procedure '$x,'$y','$z','$fw' "); essa é a minha query .

Table para Excel demorando demais