Horizontal scrolling section in the center of a page

Question: Im new to this so i hope someone can help!
I want to make a horizontal scrolling section (by click) like on this page: http://www.ritchiejacobs.be.
The section has to be responsive, the height should be auto and the container should be in the center.
I didn't came any further then this: jsfiddle.net/fwqekgk8/
Thank you!
Comment: You could achieve that by using [fullPage.js](http://alvarotrigo.com/fullPage/) using the option `autoScrolling:false`.
Answer: They use a list, not a section. Maybe u can try a list for it!


Automatically change field when another field value is selected

Question: I have a content type called Jobs.
This include a field contact which is user reference.
I have another content type called Job application.
This includes a node reference based on Jobs and field contact which is user reference.
I want when a user selects a job in the node reference select list on the job application form to automatically change the contact field in that form which the value that exists in the contact field for the relevant job selected.
Example:
Job: Educator
contact: Michael
On Job application upon selected the job "educator" the user reference field should automatically take the value Michael.
Any ideas on how to solve this? Would Rules work and if so how? If through programming, is there a module that allows for injecting code for content types?
Preferably I am looking for a solution that does not involve programming.
Answer: This sounds like a bad case of data de-normalization. You shouldn't have a "Contact" field on your "Job application" content type if it's simply going to duplicate whatever is already in the "Job" content type.
If you're simply wanting to be able to see who the contact is for a given application, use the "Rendered entity" formatter for the job reference field on the application content type. (I'm assuming you're using the Entity Reference module?) In the formatter settings, choose a view mode that only displays the contents of the Contact field on the job node.
This way, if the contact ever changes for the job, it'll live-update across all job applications.
Comment: I didn't even know there is such a live relation being able to work on Drupal. The reason for the replication is that I want to restrict node access for job application to only the appropriate contact for the job related to the job application. In my example, that would mean that only Michael can view that job application and no other user on drupal. Is there a way that I can achieve this?
Answer: You need to create a new role and give permission to that role and include Michel accordingly to that role from people tab on administrative menu.
Comment: Yes but what if there are multiple jobs with different contacts. Yes, this can restrict viewing to only a group of people but still one contact can view another contact's assigned job application. For security purposes its best if only the assigned contact can view a job application.


how not to lose state from parent component to child component

Question: I have a view which shows all posts. There's a filter above those posts and user can filter posts depending on what options he chooses. After he chooses the options, filtered posts get returned.
Let's say user filtered posts and after that clicked on one of the posts, it means that parent component which was showing posts will be destroyed. If now, user(who is on the specific post page) clicks back button, it will take him to all posts page, but filters won't be persisted since parent component got destroyed and then created.
One solution to persist filters and filtered posts after clicking back button from specific page is to use vuex. when user chooses filters, we store the object in vuex. when user clicks back button, store would already have the filters. The problem is following this way causes some problems for me and takes much more time.
Any other way you can think of ? I can't use keep-alive since it seems i can only use it for dynamic components and not any other way.
Comment: Just store the filter further up the component tree so it doesn't get destroyed.
Comment: That's not the way. it seems like i was wrong and they are not related as parent-child
Comment: Ok, but does it really matter? Just store the filter high enough so it doesn't get destroyed. Why is that "not the way"?
Comment: That's the problem mate.. I just looked at (specific post page and all posts page) are two different routes.
Comment: I'm not sure why that means my suggestion won't work? Vue children can [emit events](https://vuejs.org/v2/guide/components.html#Listening-to-Child-Components-Events), which means the filter component can send the chosen filter up the tree to a parent that won't get destroyed, and upon navigating back to "all posts", the filter is passed down again and active.
Comment: If they are two different pages then the filter data will be lost regardless. Maybe you could use local storage to store the current filter then on page load, change the filter to what is in local storage.
Comment: Vuex, to persist state between component creation sounds perfect to me. Maybe you could elaborate on the vuex problems you're having.
Answer: I see 2 options here:

Vuex - it's used for state management, best to use when you need to communicate between 2+ components. You can will need a set of methods that will update the filter values in your store, e.g.:

const store = {
  category: null,
  tag: null,
  date: null
}

const actions = {
  updateFilter({ commit }, payload) {
    commit('updateFilter', payload); // example payload structure: { filterName: 'category', filterValue: 'reviews' }
  }
}

const mutations = {
  updateFilter(state, payload) {
    state[payload.filterName] = payload.filterValue;
  }
}

export default {
  namespaced: true,
  store,
  actions,
  mutations
}

And you need to bind these actions to via @click events on your website. Then you need to bind the values from the store with your filters method (probably also you'll want to execute filtering method when your posts list changes, so you can use watcher  for example)

If you're using Vue router and history mode, you can store your filters via query params:

router.push({ path: 'blog', query: { category: 'reviews' }})

So your url will become blog?category=reviews - and when you change your url to clicked article and then click back, you'll go first to the url with latest query params set you had (but of course you need to create a method that will filter out on component create the post list based on provided filters)
The additional win for the 2nd option is that you'll be able to share the link with other people (so they will gonna see the filtered posts in the same way as you do).


Chain rule for $\ln(-f(\pmb{x}))$

Question: I am trying to figure out how to calculate, for a smooth function $f:\mathbb{R}^{n}\rightarrow \mathbb{R}$ the second and higher order derivatives of $\ln(-f(\pmb{x}))$. I am not sure the notation, but I would guess this is written like this:
$$\frac{d^{2}}{d\pmb{x}^{2}} \ln(-f(\pmb{x})).$$
The wikipedia entry on vector valued functions mentions multiple different types of derivatives and a set of notes I found online refers to Hilbert spaces, Metric matrices and other notions which I think are too general for what I want to calculate (and they are also at a level of mathematics beyond what I understand).
So far, I can convince myself that the first derivative I want should look something like
$$\frac{d}{d\pmb{x}}\ln(-f(\pmb{x})) = -\frac{\nabla f(\pmb{x})}{f(\pmb{x})}$$
but then I get pretty stuck for the second derivative. I tried to write it out like this
$$\frac{d}{d \pmb{x}}-\sum_{i=1}^{n}\frac{f(\pmb{x}_{i})}{f(\pmb{x})}$$
however, I can't imagine what kind of chain rule I could apply here.
I should point out that I have yet to take a course in vector calculus, but I have a textbook which covers some and none of the information even seems related.
Answer: I'm going to suggest that you restrict your attention to the partial derivatives, i.e., how $\ln(f(x_1, \ldots, x_n))$ varies when you vary $x_i$. For this, you can think of this as a one-variable calculus problem, and the result is
$$
\frac{d\ln(f(\mathbf x))}{dx_i} = \frac{1}{f(\mathbf x)} \frac{df(\mathbf x)}{dx_i}.
$$
By long tradition, this derivative with respect to one of the variables is denoted by rounded "d" rather than the ordinary "d", so we write instead
$$
\frac{\partial \ln(f(\mathbf x))}{\partial x_i} = \frac{1}{f(\mathbf x)} \frac{\partial f(\mathbf x)}{\partial x_i}.
$$
Now you can repeat that process, and ask what is the derivative of that expression with respect to a variable $x_j$.
The results is
$$
\frac{\partial^2 \ln(f(\mathbf x))}{\partial x_i \partial x_j}
= \frac{\partial}{\partial x_j} \left(\frac{1}{f(\mathbf x)} \frac{\partial f(\mathbf x)}{\partial x_i} \right) \\
= \frac{\partial}{\partial x_j} \left(\frac{1}{f(\mathbf x)} \right) \left( \frac{\partial f(\mathbf x)}{\partial x_i} \right) + \left(\frac{1}{f(\mathbf x)} \right) \frac{\partial}{\partial x_j} \left( \frac{\partial f(\mathbf x)}{\partial x_i} \right) \\
= \frac{-\frac{\partial f(\mathbf x)}{\partial x_j}}{f^2(\mathbf x)} \left( \frac{\partial f(\mathbf x)}{\partial x_i} \right) + \left(\frac{1}{f(\mathbf x)} \right) \left( \frac{\partial^2 f(\mathbf x)}{\partial x_i \partial x_j} \right) =
$$
For each $i$ and $j$, that's a number; those numbers, arranged in a matrix, are the second derivative. The matrix is also called the "Hessian" of $f$, and properly speaking, I should say that the Hessian is the representation of the second derivative -- which is a bilinear form -- with respect to the standard basis, but I think that's probably too much information just now.
Let me apply that to
$$
f(x, y) = x \sin y
$$
The partials with respect to $x$ and $y$ are (in a notation where we use subscripts to denote derivatives)
$$
f_x(x, y) = \sin y \\
f_y(x, y) = x\cos y ||.
$$
The second partials are
$$
f_{xx}(x, y) = 0 \\
f_{xy}(x, y) = \cos y \\
f_{yx}(x, y) = \cos y \\
f_{yy}(x, y) = -x\sin y
$$
and the Hessian is
$$
H(f)(x, y) = \begin{bmatrix} 0 & \cos y \\ \cos y  &\ -x \sin y\end{bmatrix}.
$$
Now if you degine $g(x, y) = \ln(f(x, y))$, you can do the same computation for $g$ and find its hessian, and see whether it matches what I wrote that it should be above.
Comment: This is the $ij$-element of the matrix, so your $H(f)$ should be $H(f)_{ij}$. Also: you lost two partials in the first fraction. If we say that the column-vector of partial derivatives is the gradient, then you can write this mess (for all $i$ and $j$ together) as $$H(g) = \frac{1}{f^2(x)} (\nabla f(x)) (\nabla f(x))^t + \frac{1}{f(x)} H(f)(x)$$, i.e., as involving an outer product of the gradient with itself, and the hessian of $f$.
Comment: Thank you, this was very helpful. I am having a little bit of trouble following the indices though. It seems like I can rewrite your equation into $\frac{-\frac{f(\pmb{x})}{x_{j}}}{f^{2}(\pmb{x})} \left(\frac{\partial f(\pmb{x})}{\partial x_{i}} \right) + \frac{1}{f(\pmb{x})} H(f)(\pmb{x})$, but does the first term simplify? I don't see any nice way of arranging it.
Comment: I think I finally worked out all the details and understand now. Thank you again.

Chain rule for $\ln(-f(\pmb{x}))$


Nginx rewrite *.domain.tld/page to domain.tld/page

Question: I can not set up a redirect from *.domain.tld/personal to domain.tld/personal
server {
    server_name domain.tld www.domain.tld *.domain.tld;
    listen 184.108.40.206;
    set $root_path /var/www/user1536/data/www/new.domain.tld;
    location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
        root $root_path;
        access_log /var/www/nginx-logs/user1536 isp;
        access_log /var/www/httpd-logs/domain.tld.access.log ;
        error_page 404 = @fallback;
    }

    location /personal {
        if ($http_host != domain.tld) { rewrite ^ http://domain.tld/personal; }
    }

    location / {
        proxy_pass http://22.214.171.124:81;
        proxy_redirect http://188.8.131.52:81/ /;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
    }
    location ~* ^/(webstat|awstats|webmail|myadmin|pgadmin)/ {
        proxy_pass http://126.96.36.199:81;
        proxy_redirect http://126.96.36.199:81/ /;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
    }
    location @fallback {
        proxy_pass http://22.214.171.124:81;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
    }
    location ^~ /webstat/ {
        auth_basic "Restricted area";
        auth_basic_user_file /var/www/user1536/data/etc/42338471.passwd;
        try_files $uri @fallback;
    }
    include /usr/local/ispmgr/etc/nginx.inc;
}

Comment: And what exactly happening?
Comment: domain.tld//persona//personal//personal//...
Answer: You should use another server block for the redirect.
server {
    server_name *.domain.tld;
    listen 126.96.36.199;

    location /personal {
        rewrite ^ http://domain.tld/personal permanent;
    }
}

And then you should remove the location block from the other server block, and remove *.domain.tld from the server_name directive.


What does Jaynes mean by "mollusk-like quality"?

Question: I am trying to read Prior Probabilities  (1968), by Edwin T. Jaynes.
In two sections he discusses mollusk-like qualities [of parameter spaces]:

The real problem, therefore, must be stated rather differently [than that of Jeffreys and Bayes]; we suggest that the proper question to ask is: "For which choice of parameters does a given form such as that of Bayes or Jeffreys apply?" Our parameter spaces seems[sic] to have a mollusk-like quality that prevents us from answering this, unless we can find a new principle that gives them a property of "rigidity".
Stated in this way, we recognize that problems of this type have already appeared and have been solved in other branches of mathematics. In Riemannian geometry and general relativity theory, we allow arbitrary continuous coordinate transformations; yet the property of rigidity is maintained by the concept of the invariant line element, which enables us to make statements of the definite geometrical and physical meaning independently of the choice of coordinates.

What does mollusk-like quality actually mean in this context?
Answer: The reference is to Einstein's foundational work on relativity theory. He refers to a "mollusc" (non-rigid) space in this work.

For this reason non-rigid reference-bodies are used which are as a whole not only moving in any way whatsoever, but which also suffer alterations in form ad lib. during their motion. Clocks, for which the law of motion is any kind, however irregular, serve for the definition of time. We have to imagine each of these clocks fixed at a point on the non-rigid reference-body. These clocks satisfy only the one condition, that the "readings" which are observed simultaneously on adjacent clocks (in space) differ from each other by an indefinitely small amount. This non-rigid reference-body, which might appropriately be termed a "reference-mollusk," is in the main equivalent to a Gaussian four-dimensional co-ordinate system chosen arbitrarily. That which gives the "mollusk" a certain comprehensibleness as compared with the Gauss co-ordinate system is the (really unqualified) formal retention of the separate existence of the space co-ordinate. Every point on the mollusk is treated as a space-point, and every material point which is at rest relatively to it as at rest, so long as the mollusk is considered as reference-body. The general principle of relativity requires that all these mollusks can be used as reference-bodies with equal right and equal success in the formulation of the general laws of nature; the laws themselves must be quite independent of the choice of mollusk.

The statement concerns transformation groups of continuous parameter(s) to obtain compactness and invariance. It is a topic of consideration in differential geometry. Jaynes is trying to formulate a hybrid between the considerations of a Bayesian statistician accommodating multiple disparate prior constraints (e.g. we have 90% believe $\theta > 0$ or $\theta$ has a unimodal distribution) and the Bayes' / Jeffreys' approach of having a "naive" / uniform possibly improper prior. His hybrid may be envisioned as being "mollusk" like in shape by having a complex space (impact of prior specifications) but a well-defined measurable compact property (preferences of Bayes and Jeffreys).
Comment: Although Jaynes' use of "mollusk-like" is undefined and opaque, I have a hard time applying this interpretation in the two places where the term is used. He first uses it in sharp contradistinction to "rigidity," suggesting he is thinking of a mollusk as a relatively *shapeless* and flabby animal rather than in terms of the shape of its shell. The next use is in a context about "definite geometrical and physical meaning," where "mollusk-like" once again appears to mean *the opposite* of such definiteness.
Comment: @whuber I added a quote from a cited reference that I stumbled upon whence googling "mollusk" and Einstein geometry. I don't know how illuminating it will be. Both Einstein and Jaynes appeal to the "mollusc" as being a highly general space with some properties (differentiability) that permit some mathematical results to be obtainable (like linearization and local optimization, perhaps). So it's used in the sense of a tradeoff, and the two opposite sentiments are intended to convey as much to reader--I *think*.
Answer: I think Einstein's use of the mollusc was simply a counterpoint to the concept of a "rigid body". If you were to rapidly accelerate a titanium anvil (from behind, as in a push) it would physically shorten an infinitesimal amount in the direction of travel. A jellyfish, on the other hand, undergoing the same process would be considerably more distorted...
.
Comment: A different example might be in order, because jellyfish are in a different phylum than molluscs: that is, the two are about as similar as we are to an insect.  Regardless, could you explain how this might apply to the parameter spaces in the original question?
Comment: @whuber My thoughts exactly. A jellyfish fits better than most molluscs though since many of the latter have shells, cuttlebones, pens - i think the only "molluscs" i can think of that are truly all soft bodied are the octopus and certain gastropods like seaslugs and nudibranchs. Einstein i think was simply leaning on the literal meaning of the word, which sits in German as a synonym for the native German word "Weichtier", simply soft animal, which is literally the idea he wants to get across. I don't think he was thinking hard biology!
Answer: The reference mollusc is be understood as a visual picture for a physical implementation of the most general coordinate system that is mathematically conceivable in general relativity. Since the mollusc is non-rigid in space it should have enough degrees of freedom to implement any spatially varying non-linear coordinates. The clock at each point of the mollusc is also non-linearly changing with time.
In actual fact, however, the reference mollusc would only physically implement a 3+1 spacetime coordinate system which can be spatially foliated. The actual most general coordinate system would require 4 independently and completely arbitrarily running non-linear clocks at each point of the mollusc, or a smartphone displaying 4 arbitrarily changing numbers. These 4 ever changing numbers for each point of the mollusc would be able to physically capture virtually every imaginable mathematical coordinate system. Usually, in general relativity you would like to ensure also continuity, so nearby clocks (or smartphones) on the mollusc should show 4 similar numbers.
One may also measure the metric associated with the mollusc coordinate system: according to the equivalence principle it is also possible to construct at each point of the mollusc a local inertial frame in addition to the non-linear coordinates of the mollusc discussed above. The local inertial frame provides rigid (special-relativistic) coordinates and exists for a tiny amount of time and has a tiny spatial extension (freely falling elevator gedankenexperiment). You may then compare the local inertial coordinates with the local non-linear mollusc coordinates. For example, think about the elevator having infinitely thin glass walls so that you can compare the coordinate values of say the elevator walls inside (rigid special relativistic coordinate system) with those outside (non-linear general relativistic mollusc). Once you have both sets of coordinates for enough points on the elevator wall, you may compute all the components of the local metric by transforming from one coordinate system to the other because this is what the metric does: it describes how distances of your locally rigid special relativistic system transform to changes in your locally non-linear coordinate system values. Therefore, this comparison of coordinate values of two different coordinate systems for the same local neighbourhood on the mollusc provides a physical implementation of how to measure the metric associated with the mollusc coordinate system in an actual physical situation.
Incidentally, if you then also measure the local energy tensor you can locally test the validity of the Einstein field equations because you already have measured the metric (and its derivatives by measuring the metric for a little larger local environment).
Therefore, the whole point of the mollusc is to provide a visual picture of how one might physically implement (at least in principle) measurements of the mathematical quantities used in general relativity. Such a picture might help the beginner to understand the theoretical concepts and their possible operational meaning.
NB: as for the generalisation of the mollusc in which you put 4 independent and arbitrarily running clocks at each point of the mollusc, one may even continue this line of thinking and put, say 6 arbitrarily running clocks at each point, or, equivalently, display 6 numbers per smartphone. Then one would find out that the same situation can be also described in a 6 dimensional coordinate system. However, by doing enough experiments you would then find out that this introduces more degrees of freedom than needed to describe every physical phenomenon. This way you could test the dimensionality of our spacetime, and thereby find out that you do not need 6 numbers since 4 numbers per point would be enough to describe everything also in general relativity (or you may find out that they are not enough and win a Nobel prize:)


Bayesian modelling a player's score for a game broken up into separate rounds

Question: I am trying to model a player's score in a game. The game is broken up into 5 rounds, and their final score (S) is the sum of their scores in each round. (S = r1 + r2 + r3 + r4 + r5; all > 0).
I'm trying to set up this scenario as a Bayesian modelling problem where initially we come up with an initial prediction S - a prediction from a regression model based on other variables which influence the score (lets call them V1, V2, V3). This part is fine - next is what I'm not so sure about: I want to be able to use some sort of Bayesian sequential updating to update my prediction for S after each round.
So:

Before the game, we use variables V1, V2, V3 to make a prediction for
S
After r1, we use the r1 score to update our prediction for S, also
taking into account any changes in variables V1, V2, V3
Repeat after r2, r3, r4, r5

I've been reading about Gaussian processes, Kalman filters, MCMC and other processes using Bayesian logic which seem like they would be applicable to my problem, but I'm not sure where to start regarding coding this up in Python or R.
I'd love some help with the any or all of following questions:

Is there a name for the exact type of problem I'm trying to solve?
How can I set up this problem using pymc3, Rstan or similar?
Where can I find an example of a paper, blog post, whatever with somebody applying Bayesian modelling to a situation like this that will help me get started?
Answer: I recommend modeling the incremental gained through the rest of the game to avoid correlation with the sums.  Here is one strategy which can be performed as a GLM or MCMC model in Stan:
Define: $S_i = \sum_{j = i}^5 r_j$
Fit 5 models:
$$S_1 = f_1(V1, V2, V3) + \epsilon$$
$$S_2 = f_2(V1, V2, V3, r_{1}) + \epsilon$$
$$S_3 = f_3(V1, V2, V3, r_{1}, r_{2}) + \epsilon$$
$$S_4 = f_4(V1, V2, V3, r_{1}, r_{2}, r_{3}) + \epsilon$$
$$S_5 = f_5(V1, V2, V3, r_{1}, r_{2}, r_{3}, r_{4}) + \epsilon$$
Prior to round 1:
$$\hat{S} = \hat{S_1}$$
after round 4, but before round 5:
$$\hat{S} = r_1 + r_2 + r_3 + r_4 + \hat{S_5}$$
In the Stan context, you would be doing this (pseudocode for linear regression, but you can use any GLM you want):
Calcs:
$$\beta_i V = \beta_{i,0} + \beta_{i,1} V_1 + \beta_{i,2} V_2 + \beta_{i,3} V_3$$
$$\theta_i r_i = \sum_{j=1}^i \theta_j r_j$$
Priors:
$$\beta_i \sim MVN(., .)$$
$$\sigma_i^2 \sim Gamma(., .)$$
$$\theta_i \sim MVN(., .)$$
Sampling:
$$S_1 \sim Normal(\beta_1 V, \sigma_1^2)$$
$$ ... $$
$$S_5 \sim Normal(\beta_5 V + \theta_5 r_5, \sigma_5^2)$$
You could also make this easier by fitting MCMC GLMs using bayesglm in the arm package in R.
Comment: Thanks for your answer - I'm going to try this approach. Going to keep the question open for a while to encourage some more discussion


How can I make a slideshow with tabbed navigation/menu?

Question: I'm trying to make a slideshow that looks something like this

I'm using views slideshow but I could change it up if need be. Preferably views though.
My problem is the navigation to the right. I have created a content type for this slideshow and fields for the image, the green title and the black subtitle. The slideshow should run by itself and highlight the proper menu item in the sidebar, but also allow for the user to change slide by clicking a menu item.
Any ideas on if and how this could be done?
Comment: I imported the image into the question, but please consider setting a better title on the question yourself.
Comment: Didn't know how to include it. Changed the title to make it clearer.
Comment: I don't think you have enough reputation to be allowed to inline images yet, but on the other hand I couldn't find a reference on that in the privileges list. So I included it for you, I do expect people to write useful titles though, so that I won't fix for others ;)
Comment: Yes you are right I should have written a better title. Anyway, there I fixed it! :)
Answer: In most Views slideshows I've seen, the navigation is just part of the normal slideshow, but themed to not overlap, unlike the images.
Configure the View to select whatever information you need in the navigation, end then make your theme place the navigation to the right.
I would be surprised if VS does not already have functionality for connecting clicks on some elements with sliding to a certain image, but I don't know the ins and outs of the module enough to give more specific recommendations.
Comment: Ok, thanks for the input. My main problem seems to be that I can't get the pagers to be anything else than the standard dots.

I do pick pager > pager type : fields > title:

But I still get the dots :(
Answer: In the settings for the slideshow, under Format > Slideshow | Settings you need to add a pager widget (top or bottom is up to you). When you check the Pager checkbox, more options open up. The Pager Type is Fields by default and under that are a list of fields that have been added to the view already. You can select one or more of those fields and the fields you choose will become your pager.
Screenshot:
https://docs.google.com/file/d/0B0gUI3V589rmcEJJOExCRjFpR1k/edit?usp=sharing
Comment: Yeah I'm trying this, but it's not working. I'm getting dots as pagers no matter how I do.

This is correct right?

http://oi44.tinypic.com/291izhe.jpg
Comment: It could be that you are just seeing the li dots. Can you provide a screenshot of the view preview?
Comment: Nahh those are real pagers, there's a div for each one of them with classes such as "views-slideshow-pager-field-item-dot-filled".

Here is an image from within views, the pagers don't show here for some reason. http://oi39.tinypic.com/2ihxohf.jpg

And here is an image from the site:
http://oi39.tinypic.com/72xhf8.jpg
Comment: I exported my view so you could import it and see what I've done: https://docs.google.com/file/d/0B0gUI3V589rmUHFCTW5hR3BobkU/edit?usp=sharing
Comment: How do I use this? I can't find any import options.
Comment: /admin/structure/views/import
Comment: I'm just getting an empty admin page there with the admin bar but nothing else.

http://oi44.tinypic.com/e19004.jpg
Comment: What version of Drupal and Views are you using?
Comment: Drupal 7. Views 3.x-7.x-dev.

I just noticed that the dot's are from the CSS. I've inherited this theme and page from another developer so I'm not so used to it yet.

Anyway, the two pager divs where styled as dots. But even removing that styling, they don't show anything since there is nothing beeing outputted in the pager divs for some reason.
Comment: is the views UI module enabled?
Comment: Yeah it's activated.
Comment: Then I have no idea what to tell you!
Comment: It's ok you did your best! :)
Comment: I got this now. I updated to the latest dev-version of views slideshow, cleared my cash - and tada! The titles appear as pagers when I chooose them.
Comment: Thats great news


VisNetwork in R: Adjust length of edges

Question: Is there a way to adjust the length of the edges in VisNetwork so that they are overall a bit longer? Some arrows are a bit hard to see right now especially with the thicker edges.

This is my edge list and nodes list
nodes_t <- structure(list(ahaid = c("6140002", "6140005", "6140007", "6140008",
"6140010", "6140011", "6140012", "6140013", "6140016", "6140017",
"6140065", "6140080", "6140090", "6140215", "6140255", "6140270",
"6140310", "6140420", "6140428", "6140430", "6140465", "6140583",
"6140620", "6140630", "6140690", "6140780", "6140850", "6140900",
"6140923", "6140980", "6141010", "6141020", "6141095", "6141110",
"6141130", "6141170", "6141300", "6141355", "6141395", "6141410",
"6141430", "6141450", "6141500", "6141530", "6141570", "6141630",
"6141640", "6141660", "6141705", "6141720", "6141890", "6141900",
"6141940", "6141955", "6142000", "6142200", "6142280", "6142350"
), weight = c(129L, 67L, 72L, 111L, 193L, 56L, 32L, 601L, 406L,
151L, 19L, 56L, 25L, 1909L, 22L, 6L, 38L, 6L, 264L, 1416L, 169L,
133L, 98L, 87L, 387L, 53L, 63L, 101L, 91L, 32L, 11L, 55L, 456L,
34L, 225L, 62L, 31L, 158L, 185L, 24L, 6L, 43L, 47L, 112L, 93L,
94L, 12L, 46L, 175L, 161L, 30L, 452L, 234L, 379L, 86L, 19L, 85L,
135L)), row.names = c(NA, -58L), class = "data.frame")

edges_t <- structure(list(from = c("6140002", "6140008", "6140010", "6140012",
"6140013", "6140013", "6140013", "6140016", "6140017", "6140080",
"6140215", "6140215", "6140215", "6140215", "6140215", "6140215",
"6140215", "6140215", "6140215", "6140215", "6140215", "6140215",
"6140428", "6140430", "6140430", "6140430", "6140923", "6141020",
"6141095", "6141095", "6141170", "6141660", "6141940"), to = c("6140430",
"6141095", "6140215", "6140430", "6140630", "6141450", "6141720",
"6140215", "6140690", "6140215", "6140310", "6140428", "6140430",
"6140583", "6140690", "6141095", "6141130", "6141395", "6141530",
"6141630", "6141900", "6142000", "6140690", "6140850", "6141530",
"6141900", "6141130", "6141955", "6141300", "6142350", "6141355",
"6141955", "6141955"), weight = c(19L, 22L, 7L, 8L, 9L, 17L,
9L, 15L, 19L, 12L, 22L, 7L, 27L, 90L, 14L, 20L, 13L, 32L, 9L,
11L, 34L, 8L, 7L, 11L, 17L, 16L, 6L, 16L, 7L, 5L, 10L, 17L, 18L
)), row.names = c(NA, -33L), class = "data.frame")

This is my code
vis.nodes <- nodes_t
vis.links <- edges_t
vis.nodes$borderWidth <- 2
vis.nodes <- vis.nodes %>% mutate(size = weight/16)

vis.links$width <- 1+edges_t$weight/4
vis.links$arrows <- "to"

library('visNetwork')
p <- visNetwork(vis.nodes, vis.links, width="400%", height="1600px")

Comment: Could you please provide the code that you used to make this plot?
Comment: Where is your `edges_i`?
Comment: That was a typo -- it should be edges_t
Comment: Is this your complete code, because I can't reproduce your plot?
Answer: You could use the visEdges function with argument length to change the length of the edges. Since I can't reproduce your plot, I created a reproducible example:
library(visNetwork)
library(dplyr)
# Data
nodes <- data.frame(id = 1:2)
edges <- data.frame(from = 1, to = 2)

# Plot with length 100
visNetwork(nodes, edges) %>%
  visEdges(arrows = 'to', length = 100)

# Plot with length 400
visNetwork(nodes, edges) %>%
  visEdges(arrows = 'to', length = 400)

Created on 2022-12-18 with reprex v2.0.2
As you can see the first plot has an edge length of 100 pixels and the second plot has an edge length of 400 pixels.

If you want to have variable lengths, you could add an variable length to your edge dataframe like this:
library(visNetwork)
library(dplyr)
# Data
nodes <- data.frame(id = 1:2)
edges <- data.frame(from = 1, to = 2, length = c(100, 400))

# Plot
visNetwork(nodes, edges) %>%
  visEdges(arrows = "to")

Created on 2022-12-18 with reprex v2.0.2

VisNetwork in R: Adjust length of edges


Execute jquery function if Ajax callback form complete

Question: I got a custom ajax callback which replaces my checkbox options based on the select option.
Now after the checkboxlist get's updated i need to execute a jquery function on those checkboxes.
How can i execute this custom jquery function after the callback is done, so after the checkboxlist is updated.
Form element:
        $widget['select_box'] = array(
            '#type' => 'select',
            '#title' => 'Select bussen',
            '#options'  => $options,
            '#validated' => TRUE,
            '#default_value' => '_none',
            '#attributes' => array('class' => array('select-province')),
            //The callback
            '#ajax' => array(
              'callback' => 'ajax_select_callback',
              // 'wrapper' is the HTML id of the page element that will be replaced.
              'wrapper' => 'replace_select_div',
            ),
        );

        //Form element wich get updated
        $widget['select_box_2'] = array(
            '#type' => 'checkboxes',
            '#title' => 'Select bussen',
            '#options' => ...,
            '#prefix' => '
',
            '#suffix' => '
',
            );

Ajax callback function:
    function ajax_select_callback($form, $form_state) {
      // The form has already been submitted and updated. We can return the replaced
      // item as it is.
    return $form['line_item_fields']['field_bussen_select']['und'][0]['select_box_2']

    }

Jquery function i run on the checkboxes:
    jQuery("input[type='checkbox']").change(function () {
        jQuery(this).parent().siblings('ul')
            .find("input[type='checkbox']")
            .prop('checked', this.checked);
    });

Answer: I think if found the answer at :https://drupal.org/node/171213.
Section: JavaScript on your AJAX form
"Attach jQuery to Drupal.behaviors, that way it can be run anytime new DOM elements are inserted. One example, if you're using AJAX in Views, each time a section of the page reloads, it will reload/run jQuery."
Didn't test it, because i don't need it anymore :), but still good to know!
Answer: Wrap your JS function in Drupal.behaviours, it will work after section reloads
(function ($) {
  Drupal.behaviors.myModuleBehaviours = {
    attach: function (context, settings) {
      $("input[type='checkbox']").change(function () {
        $(this).parent().siblings('ul').find("input[type='checkbox']").prop('checked', this.checked);
      });
    }
  }
})(jQuery);

Answer: Work with ajax_commands
your callback could be:
function ajax_select_callback($form, &$form_state) {
  $commands = array();
  // Replace the form element.
  $commands[] = ajax_command_replace('#edit-select_box_2-SELECTOR', render($form['select_box_2']), array());
  // Invoke any JavaScript func
  $commands[] = ajax_command_invoke(NULL, 'your_custom_js', array());

  // more commands...

  return array(
    '#type' => 'ajax',
    '#commands' => $commands,
  );
}

And in JS:
jQuery.fn.your_custom_js = function () {
  ....
};

This is untested, its just the elegant way to go.
Answer: Please find below the nice and easy to understand tutorial for calling javascript function after ajax event in Drupal 7:
http://www.jaypan.com/tutorial/calling-function-after-ajax-event-drupal-7


Session Variables Not Being Stored

Question: I have the following PHP code:
session_start();
$zip = $_GET['zip'];
$_SESSION['zip'] = $zip;
echo $_SESSION['zip']; //output is 98121, or whatever value I assigned

Then when I go to the next page using the following code:

What day and time would you like your stuff picked up?

            <button class="previous">Previous</button>
            <button class="next">Next</button>

<form action="/wordpress/junk-details" method="post">
<?php for($j = 0; $j < 7; $j++): ?>
    <div class="date_container" id="date_container_<?php echo $j;?>" >
        <?php for($i = 0; $i < 7; $i++): ?>

        <?php endfor; ?>

<?php endfor; ?>

            <button class="next" id="goto_step2" type="image" value="next step">Next Step: Details</button>

</form>

and I do a var_dump($_SESSION), the value is NULL. I've checked my php.ini file, but didn't see anything out of the ordinary. I've searched other similar topics on SO, but none of those have helped.
Here is a list of links I've tried:
PHP Session data not being saved
PHP Session not Saving
PHP Session Data Not Being Stored
Here are some details that might help:

I'm using PHP 5.5.3

I'm using a Mac OSX 10.9
I'm using the localhost as a server
This issue is on both Chrome and Firefox browsers
This is a wordpress site
I'm not sure what this could be. My sessions work when I use them on the back of my Wordpress plugin
Comment: Does the next page also contain `session_start();` ? It's not in there, from what I can tell.
Comment: No. It does not contain `session_start()`
Comment: Then that's your problem. If you want your session variables to appear on any other page, it must be included.
Comment: So every page has to have `session_start()`?
Comment: Well holly crap! It worked like a charm!!! Make that your answer and I'll upvote and accept! Thank you so much! I didn't realize I needed that!
Answer: If you want your session variables to appear on any other page, then session_start(); must be included inside all your pages using sessions.

Footnotes:
Should you happen in the future to get the following error message: headers already sent, you could add ob_start(); just above session_start();
Relevant links:

http://www.php.net/manual/en/features.sessions.php
http://www.php.net/session_start
http://www.php.net/ob_start
http://www.php.net/header
Comment: No biggie, hey it happened to me too way back when. Just sharing the wealth ;-) @Blaine
Comment: Lol... I know how that goes. I appreciate the speedy response and you sharing the wealth. I'm sure I'll be able to pass this along at some point.
Comment: You're very much welcome. I left a link in my answer for you to read up on. It contains a lot more information. @Blaine
Answer: add session_start(); on the top of your page in which you want to set session variable or retrive session variable value

Session Variables Not Being Stored


Calculating the mean analytically in R

Question: I would like to calculate the mean analytically (by integration) of a random variable $X$ in R. The formula for the expected value is:
$$
E[X] = \int_{-\infty}^{\infty}  xf_N(x)dx
$$
Assume that $X \sim f_N(x_i|\mu=50, \sigma=1)$. I code this up in R in the following way:

my.mean.function <- function(X, MEAN){   X*dnorm(X, mean = 50 , sd=1) }

I then calculate the integral:
integrate(f= my.mean.function, lower =-Inf, upper = Inf)

However, this integral is not producing the expectation 50. What am I doing wrong?
Comment: You forgot to sort it! and one more mistake ... my.mean.function <- function(X){   X=sort(X);X*dnorm(X, mean = 2 , sd=1) }
integrate(f= my.mean.function, lower =-10, upper = 10). Just change the parameter to yours.
Comment: Thanks for this. @Matteo Lisi's solution works without sorting.
Answer: You are not doing anything wrong as far as I can tell. I think the problem is that your integrand is approximately zero almost everywhere except for a small range around 50. From ?integrate

If the function is approximately constant (in particular, zero) over
  nearly all its range it is possible that the result and error estimate
  may be seriously wrong.

Indeed integrate gets it correctly if the proportion of values over which the integrand is approximately zero is reduced, either by reducing the range of integration or alternatively by increasing the standard deviation.
Specifically, while this fail:
> integrate(function(x){x*dnorm(x,mean=50,sd=1)}, -Inf, Inf)
9.385682e-98 with absolute error < 0

these two gets it correctly:
> integrate(function(x){x*dnorm(x,mean=50,sd=5)}, -Inf, Inf)
50 with absolute error < 0.0037
> integrate(function(x){x*dnorm(x,mean=50,sd=1)}, -100, 100)
50 with absolute error < 1.6e-05

Comment: One would not think that the integrate function had this quirkiness. Helps to read the manual.

Calculating the mean analytically in R


How to assign a percentage of in SQL?

Question: | proj_id | list_date  | state  | Status     |
|   1     |   03/05/10 |   CA   | Finished   |
|   2     |   04/05/10 |   WA   | Unfinished |
|   3     |   03/05/10 |   WA   | Finished   |
|   4     |   04/05/10 |   CA   | Finished   |
|   5     |   03/05/10 |   WA   | Unfinished |
|   6     |   04/05/10 |   CA   | Finished   |

What query can I write so to determine the percentage of projects in each listing month and state are finished?
I currently have written the following code to group the amount of projects by its month and state
select
    month(list_date), state_name, count (*) as Projects
from
    projects
group by
    month(list_date), state_name;

How do I then incorporate the percentage of projects in each listing month and state that are finished or unfinished?
Desired output:
     | list_date | state  | Proj_Count | % Finished
     |   March   |   CA   |     2      |    10%
     |   April   |   WA   |     3      |    20%
     |   July    |   WA   |     6      |    50%
     |   August  |   CA   |     5      |    40%

Comment: Which [DBMS](https://en.wikipedia.org/wiki/DBMS) product are you using? "SQL" is just a query language, not the name of a specific database product. Please add a [tag](https://stackoverflow.com/help/tagging) for the database product you are using `postgresql`, `oracle`, `sql-server`, `db2`, ...
Comment: Possible duplicate of [How to calculate percentage with a SQL statement](https://stackoverflow.com/questions/770579/how-to-calculate-percentage-with-a-sql-statement)
Comment: I'm using MySql
Answer: Put this in the select:
100 * count(case when state = 'Finished' then 1 else null end) / cast(count(*) as float)

I wasn't clear if you want the percentage finished by state and month, or just by month. If the latter it's a bit more involved
Count counts the non nulls in a set. If the state is finished, 1 is returned. If the state is anything else, null is returned and it doesn't contribute to the count
Note that this calc above will be done using INT so we cast one of the operands to a float (or whatever decimal point supporting type your database has) so that the calc is done using decimal places instead. Without this some db would simply produce 0 because small_int/large_int is always 0
Answer: You can easily do this with the avg() aggregation function:
select month(list_date), state_name, count(*) as Projects,
       avg(case when status = 'Finished' then 100.0 else 0 end) as percent_finished
from projects
group by month(list_date), state_name;

To see how this works, just work it out on an example:
Finished        100
Unfinished        0
Finished        100
Unfinished        0
Unfinished        0

The average is (100 + 100) / 5 = 40.  That is the percentage you are looking for.
Comment: Quick question - do you mind explaining the rationale/action of the code mentioned above? This would help me a lot to understand. I'm having a hard time understanding the avg (case when status = 'finished' then 100.0 else 0 and how that results in percent_finished.

How to assign a percentage of in SQL?


Erro 404 ao inserir dados no banco usando PHP com WampServer

Question: Estou com o seguinte código que insere na minha DB um nome e cidade utilizando PHP.
<?php
$link = mysqli_connect("localhost", "root", "admin");
mysqli_select_db($link, "crud");
?>

<!DOCTYPE html>

    <meta charset="UTF-8">
    <title>Title</title>

<form name="form1" action="" method="post">

            Insira o Nome
            <input type="text" name="t1"

                Insira a Cidade
                <input type="text" name="t2"

                <input type="submit" name="submit1" value="Cadastrar">

</form>

<?php
if(isset($_POST["submit1"]))
{
    mysqli_query($link, "INSERT INTO table1 values('$_POST[t1]', '$_POST[t2]')");
}

?>

Toda vez que tento inserir, eu recebo o erro "404" no meu navegador.
Comment: Você deve colocar o attr action do form, para uma pagina php, que pegara os dados e irá inserir no banco
Comment: obrigado pela resposta colega, mas porque eu teria que redirecionar a página? a inserção esta sendo feita em: "if(isset($_POST["submit1"]))
{
    mysqli_query($link, "INSERT INTO table1 values('$_POST[t1]', '$_POST[t2]')");
}
"
Comment: O erro ocorre após a inserção ?
Comment: ele da erro 404 conforme a imagem: [IMG]http://i65.tinypic.com/ip3yvd.png[/IMG]
Comment: Desculpa, eu editei sem querer no código, mas na realidade eu estou, inclusive ja editei o código no quote, por outro lado o erro persiste :/
Comment: Considere revisar seu código linha por linha, e corrija os erros de sintaxe primeiro.
Comment: Percebo que a porta padrão do wampserver é 3306, porém a porta mostrada na url da página quando tento executar o código via phpStorm é 63342, será que poderia ser isso? e como faço pra alterar isso?
Answer: Vamos por partes. Quando você instala o wampserver (no windows) é criada uma pasta em C:\wampserver. Nessa pasta há uma chamada www (C:\wampserver\www) que equivale a você chamar pelo navegador a url http://localhost (por padrão na porta 80, que o navegador omite, mas seria algo como http://localhost:80). Então, se você colocar o seu arquivo, por exemplo chamemos de inserir.php, dentro da pasta C:\wampserver\www, você poderia acessar pelo navegador algo como http://localhost/inserir.php e tudo funcionaria corretamente.
A parte em que você diz que a porta padrão do wampserver é 3306, você deve estar se referindo a porta padrão do servidor de banco de dados mysql.
Para você executar o codigo diretamente do phpstorm algumas configurações deve ser feitas. Alguns links sobre como fazer essas configurações:

Documentação phpstorm
Configurando phpstorm com xampp (basta desconsiderar a parte de xampp)
Configure phpstorm with wampserver
Comment: Meu caro Juven_v, você acertou em cheio!, pena que não posso honrar sua resposta por ser iniciante nesta comunidade, porém, é exatamente isso, minha dúvida foi solucionada quando configurei um interpretador manual para o phpStorm. Caso alguém mais passe pelo mesmo problema, este video: https://www.youtube.com/watch?v=953mNQ5KuBI, me ajudou!


window.maximize function is undefined

Question: I wanted to open a new node webkit window and maximize it. However, I get undefined function for window.maximize() when I launch the new window.
Also other options for the new window are not working like frame and toolbar. What could have been the reason for this?

mainApp.js

<code>function waitForConsoleThenStart() {
    if (typeof global.window !== 'undefined') {

        try {
            var myWin = global.window.open("http://www.google.com", {
                "frame": true,
                "toolbar": true,
                "transparent": false
            });

            console.log(myWin);

            myWin.on("loaded", function () {
                console.log("I am loaded.");
                myWin.maximize();
            });
        }
        catch(e) {

        }

        window.maximize();

    } else {
        setTimeout(waitForConsoleThenStart, 100);
    }
}
waitForConsoleThenStart();
</code>
This is how my manifest looks like:

package.json

<code>{
  "name": "kissa-base",
  "main": "index.html",
  "node-main": "mainApp.js",
  "window": {
    "icon": "app/img/tpc-ohcis-logo-48x48.png",
    "toolbar": true,
    "frame": false,
    "transparent": true
  }
}
</code>
Answer: try this
<code> var gui = require('nw.gui');
 gui.Window.open("http://www.google.com",{"fullscreen":true});
</code>
I believe you are not opening a new nwjs window but a html window.
Comment: I have tried this in my mainApp.js but it's not working. However, now it's already okay. I just removed node-main and import my mainApp.js in my index.html. Now working fine.

window.maximize function is undefined


Uniformly integrable sequence has norm convergent subsequence?

Question: The task would be to find a subsequence of a uniformly integrable(UI) sequence $\{ f_n\}_1^\infty$ on $[0,1]$, such that this subsequence has a limit in the $L^1[0,1]$-norm(wrt. Lebesgue measure). I already know, that this is possible in the weak sense(Dunford-Pettis theorem), and I know a counterexample, if $\{ f_n\}_1^\infty$ is only bounded in the $L^1[0,1]$-norm(here it suffices to take $f_n(x)=n\chi_{[0,\frac1n]}(x)$, $\chi$ denoting the characteristic function, but this sequence is not UI). I also don't think that it is possible in the UI-case, but I don't know an explicit counterexample.
Answer: First note that if the statement was true, then it would also be true for complex valued sequences of functions (if $(f_n)_n$ are uniformly integrable, then so are the real and imaginary part. Now take a subsequence along which the real part converges in $L^1$, and take a further subsequence on which the imaginary part converges).
Thus, it is enough to provide a complex-valued counterexample. Since the sequence $(f_n)_n = (e^{2\pi i n x})_n$ is bounded in $L^\infty$, it is uniformly integrable. Now assume that $f_{n_k} \to f$ with convergence in $L^1$. This easily implies $\int_0^1 f \cdot e^{2 \pi i l x} d x = \lim_k \int_0^1 e^{2 \pi i (l + n_k) x} d x = 0$ for all $l \in \Bbb{Z}$. By basic Fourier analysis, this implies $f =0$ almost everywhere. Because of $\|f_n\|_{L^1} = 1$, we thus cannot have $L^1$ convergence $f_n \to f$.


Identificar origem de locks do banco de dados

Question: bom dia!
Em meu servidor, possuo o SqlServer 2008R2 Express.
Estou tendo problemas de lock no banco de dados, porém, não estou conseguindo identificar qual processo ou qual aplicação pode estar causando estes locks.
Já procurei no Visualizador de Evento do Windows e não consegui identificar nada que ajudasse.
No SQLServer aparecem os processos na situação "Suspended" e isso fica prendendo novas consultas.
Vocês indicam alguma ferramenta para auxiliar na procura da causa destes locks, ou, quais são os procedimentos que eu devo realizar para tentar identificar?
Comment: pode usar o "*SQL Server Profiler*" e criar um *Trace*, tem uma opção para visualizar *deadlocks*
Answer: Fernando, você pode utilizar o procedimento sp_whoisactive para atividades de monitoramento, inclusive auxiliar na detecção da origem do lock.
Sugestão de leitura:

Different techniques to identify blocking in SQL Server
Understanding and resolving SQL Server blocking problems
Comment: Olá José! obrigado pela sua resposta, foi de grande ajuda os artigos que você indicou.
Comment: Fernando, os dois artigos são completos; o primeiro é didático; o segundo, embora _árido_, também contém informações úteis.


Fundamental Solution of $\Delta^{2}$ in $\mathbb{R^{2}}$

Question: we are to show that the fundamental solution of $\Delta^{2}$ in $\mathbb{R^{2}}$ is given by :
$$
V(x_{1},x_{2})= \frac{1}{8\pi}r^{2}\ln(r),\qquad r=|x-\xi|,
$$
and write the solution of $\Delta^{2}w=F(x_{1},x_{2})$.
My approach: Let $x=\left(x_{1}, x_{2}\right) .$ We have :
$$
V(x)=\frac{1}{8 \pi} r^{2} \log (r)
$$
In polar coordinates: (here, $V_{\theta \theta}=0$ )
$$
\begin{aligned}
\Delta V &=\frac{1}{r}\left(r V_{r}\right)_{r}=\frac{1}{r}\left(r\left(\frac{1}{8 \pi} r^{2} \log (r)\right)_{r}\right)_{r}=\frac{1}{8 \pi} \frac{1}{r}(r(2 r \log (r)+r))_{r} \\
&=\frac{1}{8 \pi} \frac{1}{r}\left(2 r^{2} \log (r)+r^{2}\right)_{r}=\frac{1}{8 \pi} \frac{1}{r}(4 r+4 r \log r) \\
&=\frac{1}{2 \pi}(1+\log r)
\end{aligned}
$$
The fundamental solution $V(x)$ for $\Delta^{2}$ is the distribution satisfying: $\triangle^{2} V(r)=\delta(r)$
$$
\begin{aligned}
\Delta^{2} V &=\Delta(\Delta V)=\Delta\left(\frac{1}{2 \pi}(1+\log r)\right)=\frac{1}{2 \pi} \Delta(1+\log r)=\frac{1}{2 \pi} \frac{1}{r}\left(r(1+\log r)_{r}\right)_{r} \\
&=\frac{1}{2 \pi} \frac{1}{r}\left(r \frac{1}{r}\right)_{r}=\frac{1}{2 \pi} \frac{1}{r}(1)_{r}=0 \quad \text { for } r \neq 0
\end{aligned}
$$
Therefore, we have that $\Delta^{2}V(r)=\delta(r)$. Hence, $V$ is the fundamental solution and the solution of:
$$
\Delta^{2} \omega=F(x)
$$
if given by:
$$
\omega(x)=\int_{\mathbb{R}^{2}} V(x-y) \Delta^{2} \omega(y) d y=\frac{1}{8 \pi} \int_{\mathbb{R}^{2}}|x-y|^{2} \log |x-y| F(y) d y
$$
Is this proof correct? if so, how could we establish an even more rigorous proof, since this proof is not rigorous enough?
Comment: Indeed, the proof is correct.
Comment: Thank you, can you provide an alternative rigorous way?
Answer: For a more rigorous proof (as you wish), we have that for $v \in C_{0}^{\infty}\left(\mathbb{R}^{n}\right),$ we want to show
$$
\int_{\mathbb{R}^{n}} K(|x|) \Delta^{2} v(x) d x=v(0)
$$
Suppose $v(x) \equiv 0$ for $|x| \geq R$ and let $\Omega=B_{R}(0) ;$ for small $\epsilon>0$ let
$$
\Omega_{\epsilon}=\Omega-B_{\epsilon}(0)
$$
$K(|x|)$ is biharmonic $\left(\Delta^{2} K(|x|)=0\right)$ in $\Omega_{\epsilon} .$ Consider Green's identity $\left(\partial \Omega_{\epsilon}=\partial \Omega \cup\right.$
$\left.\partial B_{\epsilon}(0)\right)$
$$
\begin{aligned}
\int_{\Omega_{\epsilon}} K(|x|) \Delta^{2} v d x &=\underbrace{\int_{\partial \Omega}\left(K(|x|) \frac{\partial \Delta v}{\partial n}-v \frac{\partial \Delta K(|x|)}{\partial n}\right) d s+\int_{\partial \Omega}\left(\Delta K(|x|) \frac{\partial v}{\partial n}-\Delta v \frac{\partial K(|x|)}{\partial n}\right) d s}_{\displaystyle=0,\;\;\;\text{since $v\equiv0$ for $x\geq R$}} \\
&+\int_{\partial B_{\epsilon}(0)}\left(K(|x|) \frac{\partial \Delta v}{\partial n}-v \frac{\partial \Delta K(|x|)}{\partial n}\right) d s+\int_{\partial B_{\epsilon}(0)}\left(\Delta K(|x|) \frac{\partial v}{\partial n}-\Delta v \frac{\partial K(|x|)}{\partial n}\right) d s \\
\lim _{\epsilon \rightarrow 0}\left[\int_{\Omega_{\epsilon}} K(|x|) \Delta^{2} v d x\right] &=\int_{\Omega} K(|x|) \Delta v^{2} d x
\end{aligned}
$$
On $\partial B_{\epsilon}(0), \quad K(|x|)=K(\epsilon) .$ Thus :\begin{aligned}
\left|\int_{\partial B_{\varepsilon}(0)} K(|x|) \frac{\partial \Delta v}{\partial n} d S\right| &=|K(\epsilon)| \int_{\partial B_{\epsilon}(0)}\left|\frac{\partial \Delta v}{\partial n}\right| d S \leq|K(\epsilon)| \omega_{n} \epsilon \max _{x \in \bar{\Omega}}|\nabla(\Delta v)| \\
&=\left|\frac{1}{8 \pi} \epsilon^{2} \log (\epsilon)\right| \omega_{n} \epsilon \max _{x \in \bar{\Omega}}|\nabla(\Delta v)| \rightarrow 0, \quad \text { as } \epsilon \rightarrow 0 \\
\int_{\partial B_{\epsilon}(0)} v(x) \frac{\partial \Delta K(|x|)}{\partial n} d S=& \int_{\partial B_{\epsilon}(0)}-\frac{1}{2 \pi \epsilon} v(x) d S \\
&=\int_{\partial B_{\epsilon}(0)}-\frac{1}{2 \pi \epsilon} v(0) d S+\int_{\partial B_{\epsilon}(0)}-\frac{1}{2 \pi t}[v(x)-v(0)] d S \\
&=-\frac{1}{2 \pi \epsilon} v(0) 2 \pi \epsilon-\underbrace{\max _{x \in \partial B_{\epsilon}(0)}|v(x)-v(0)|}_{\rightarrow 0,(v \text { is continuous})}=-v(0) .
\end{aligned}
\begin{aligned}
\left|\int_{\partial B_{\epsilon}(0)} \Delta K(|x|) \frac{\partial v}{\partial n} d S\right|=&|\Delta K(\epsilon)| \int_{\partial B_{\epsilon}(0)}\left|\frac{\partial v}{\partial n}\right| d S \leq\left|\frac{1}{2 \pi}(1+\log \epsilon)\right| 2 \pi \epsilon \max _{x \in \bar{\Omega}}|\nabla v| \rightarrow 0, \quad \text { as } \epsilon \rightarrow 0 \\
\int_{\partial B_{\epsilon}(0)} \Delta v \frac{\partial K(|x|)}{\partial n} d S &=\int_{\partial B_{\epsilon}(0)}\left(-\frac{1}{4 \pi} \epsilon \log \epsilon-\frac{1}{8 \pi} \epsilon\right) \Delta v(x) d S \\
& \leq \frac{\epsilon}{4 \pi}\left|\log \epsilon+\frac{1}{2}\right| \cdot 2 \pi \epsilon \max _{x \in \partial B_{\epsilon}(0)}|\Delta v| \rightarrow 0, \text { as } \epsilon \rightarrow 0
\end{aligned}
$$
\therefore \quad \int_{\Omega} K(|x|) \Delta^{2} v d x=\lim _{\epsilon \rightarrow 0} \int_{\Omega_{\epsilon}} K(|x|) \Delta^{2} v d x=v(0) $$
[Note] : To prevent any misunderstanding, note that in $K(|x|)=K(c)$, for $|x|=\epsilon$, we have :
$$
\begin{aligned}
K(|x|) &=K(\epsilon)=\frac{1}{8 \pi} \epsilon^{2} \log \epsilon, & \Delta K=\frac{1}{2 \pi}(1+\log \epsilon) \\
\frac{\partial K(|x|)}{\partial n} &=-\frac{\partial K(\epsilon)}{\partial r}=-\frac{1}{4 \pi} \epsilon \log \epsilon-\frac{1}{8 \pi} \epsilon, & \frac{\partial \Delta K}{\partial n}=-\frac{\partial \Delta K}{\partial r}=-\frac{1}{2 \pi \epsilon}
\end{aligned}
$$


Stuck with figured bass notation for inverted 7th chord

Question: My apologies for the "name this chord" question, but i'm stuck trying to identify this harmony.

The figured bass notation indicates to me that the bass note should be the seventh of a 7 chord.  The note C is a minor 7th above D or a major 7th above D-flat.  The issue is that both Dm7 and D7 contain notes that aren't within the chord we're looking at.  A basic online "chord namer" is telling me that what we have here is a Cmaj9/11sus2.
Can you please help clear this up for me?  I'm still getting used to figured bass notation.
Thank you so much!
Please see context here (I believe it's C major, treble clef in staves 1 and 2; bass clef at the bottom):
Comment: What are the clefs and key signatures?
Comment: Also what is the surrounding context?
Comment: @286642 this helps, but it's still impossible to give a definitive answer if you don't provide the details we asked for. You ask if it would be D or Dm (which now I think likely is neither), but how can we know if we don't know if the key signature has F or F#? Moreover, figured bass isn't really a chord notation, functional interpretation depends on the context.
Comment: I understand.  Please see update in the post.
Comment: A "quiescenza"--a schema I found online while look at galant schemata
Answer: TL;DR

The figured bass notation indicates to me that the bass note should be the seventh of a 7 chord.

Not quite. The figured bass means that one of the upper voices will be a seventh above the bass note. Specifically, the B is a seventh above the bass's C.
The literal chord progression is

C7  F/C  Bdim/C  C

The situation is similar to Case 2, below; the bass is suspended while the upper voices shift higher.
Full explanation
The figure 7-4-2 is indicative of a suspension and can arise in a couple of ways.

The 7 occurs in a suspended voice in a move to a third inversion (6-4-2) seventh chord.
The upper voices move over a suspended bass.

Case 2 is most similar to the chord progression in the OP.
Case 1: Upper voice suspension1
We begin with a root position I chord. The destination is a third inversion V7 chord, but initially the I chord's third is suspended, forming a 7 against the bass, before resolving downward to complete a 6-4-2 chord.

Case 2: Bass suspension2
Now beginning with a root position V triad, the three upper voices rise to form a 7-4-2 chord before the bass drops a step to form a root position IV chord.

1. The example is from Figured Harmony at the Keyboard: Part 1 by R. O. Morris (Oxford University Press, 1933), page 27, exercise 4. I have transposed from the original.
2. As in note 1, but from page 26, example 4, mm. 4–5, transposed and with my own realization.
Comment: @user1079505 The 6 refers to the interval above the bass, which would be A. The B in the given chord is presumed to be a suspension from the previous chord and to resolve to A in the next.
Comment: @AndyBonner whether that is true depends on which of the given figures is a suspension.  The 4/2 figures normally denote a seven chord in third inversion, that is, with an implied _6._  That would be shown on a lead sheet as D/C or D7/C, so it's very much a D chord if this answer is correct.
Comment: What do you mean by "6 of the following chord"? This Dm already has a 6 (B), assuming I interpret the chord correctly as C-D-F-(A)-B
Comment: @user1079505 This is where context matters to how we name chords. This isn't a D chord at all; it's a C7 chord during which two voices are occupied in a little ornamental motion. The D and F pitches simply haven't resolved to C and E. (Assuming that that's what's going on. It's a pretty safe assumption, but it would have been nice to have a bigger image.)
Comment: @user1079505 a 4/2 chord normally has an implied 6, as you note, but in this case because there's a 7 there is no 6.  To indicate a seventh and a sixth you'd need to write both figures explicitly.
Comment: @phoog I believe my revised post addresses all of the comments, but if you have a moment to double-check me, much appreciated.
Comment: OP mentions quiescenza... now I think that it's neither Dm, nor C, but G7/C...
Comment: ...or maybe Bo/C, if we're limited to 4 voices?
Answer: The full chord progression is: C7 F/C Bo/C C

C7 is a secondary dominant to F
F/C is IV chord in second inversion
Bo/C, the chord you ask about, is a dominant (Bo is G7 without G, or viio) with C, that is the root of tonic, or 4 of V chord, in the bass voice
C is obviously the tonic, to which the dominant resolves.

How does Bo/C even work? The dominant chord includes the leading tone B, which wants to resolve to C. You normally don't want to include C already in the dominant chord, as it spoils this tension. But there are two more components: the horizontal motion (or rather lack of thereof) of the pedal tone, and cliché recognizability of IV-V-I cadence.

The figured bass notation indicates to me that the bass note should be the seventh of a 7 chord. The note C is a minor 7th above D or a major 7th above D-flat. The issue is that both Dm7 and D7 contain notes that aren't within the chord we're looking at.

The simple rule of reading figured bass is that, unless it includes accidentals, you add diatonic notes from the bass note. C, in C major with 2-4-7 means C-D-F-B – there is no doubt about it. There might be doubt about possible adding some more notes, which depends on the style and context.
Secondly, interpreting a chord in isolation is not always useful, especially not for harmonic analysis. As you can see from the discussion, you could interpret such 4 notes in many ways, but not every of them would make sense, depending on the context.
Some interesting examples of quiescenzas:


Finding the sum of the series with $a_n = \frac{4n}{6n+7}$

Question:
In my calc 2 course, one of the homework problems is to let
$$a_n = \frac{4n}{6n+7}$$
and then find the limit of its sequence and the sum of its series.

I started with the limit:
$$\lim_{n\to \infty} \frac{4n}{6n+7}$$
Using L'Hopital, I ended up with $\dfrac{2}{3}$ as the answer.
The sum of the series is where I seem to be having trouble.
So with $\sum_{n=1}^\infty \frac{4n}{6n+7}$, I generated the first 3 terms of the series:
$$\frac{4}{13} + \frac{8}{19} + \frac{12}{25} + \cdots $$
To me this series does not appear to be geometric, so I tried to utilize a definition I was provided with in class:

A series converges iff the sequence, $S_n$ converges. If $S_n$ converges, we say that $\lim_{n\to \infty} S_n = S = \sum_{n=1}^\infty \frac{4n}{6n+7}$, where $S$ is some real finite number.

Based on this, the sum of the series would have to also be $\frac{2}{3}$ but when I entered this as my answer, it was marked as incorrect.
So at this point, I'm thinking I might have gotten this definition incorrect or there is some way to algebraically manipulate $a_n$ to get a geometric "form" that I'm not seeing.
Comment: Since the limit of $a_n$ is not $0$, its series diverges.
Comment: You are in the case where $S_n$ does not converge.
Comment: @JMoravitz Oh boy...we had defined $S_n$ as the sequence of partial sums. I completely forgot about that as I was working. Thanks.
Comment: @UnderMathUate - In the words of my advanced calculus teacher, using L'Hopital to compute the limit of $a_n$ is "using a cannon to kill a flea." It was a good-natured response when I suggested computing a similar limit to yours via L'Hopital (and that's how I intend it here). Whenever you need the limit at infinity of a quotient of non-constant polynomials of the same degree, divide numerator and denominator by the high power of the variable. You'll be left with the ratio of the leading terms after taking the limit.
Comment: I just checked my notes, and I don't seem to have anything about that written down. Would one of you mind posting an answer with further explanation?
Comment: "*A series converges iff the sequence, $S_n$ converges*"  You must have grossly misheard what they were talking about.  A series converges iff the sequence **of partial sums** $S_n = \sum\limits_{k=1}^n a_k$ converges.  This is a totally different statement than saying the sequence of **summands** $a_n$ converges.  Consider $\sum\limits_{n=1}^\infty 1 = 1+1+1+1+1+1+1+\dots$
Comment: https://en.wikipedia.org/wiki/Term_test
Answer: There are already several complete answers here. I would like to suggest a strategy.
Spend a little time just thinking about the shape of the problem before you start applying tools.
When $n$ is large, the fraction
$$
\frac{4n}{6n+7}
$$
is very close to
$$
\frac{4n}{6n } = \frac{2}{3}
$$
(since the $+7$ in the denominator is negligible)
so that will be the limit of the sequence. You don't need anything like L'Hopital's rule to prove that. I would accept a student's statement that it was "obvious" if the surrounding work was good. If you do want a more formal proof, write
$$
\frac{4n}{6n+7} =
\frac{4}{6+7/n}
$$
and look at the limit of the numerator over the limit of the denominator.
Once you know the terms are near $2/3$ when $n$ is large you know the sequence ehds up looking like
$$
\cdots + 2/3 + 2/3 + \cdots
$$
which clearly diverges. The general term does not have limit $0$.
Comment: Thanks for this! Simplifying the steps really makes the answer a lot more clear.
Answer: You obviously confused the limit of the sequence $a_n $ with that of its partial sums:
$$S_n=\sum_{k=1}^n a_k,
$$
which diverges in this case because $\lim_{n\to\infty} a_n=\frac23\ne0$.
Comment: Yep, I just realized that's exactly what happened.
Answer: Since you seem to be unfamiliar with the term test for series divergence I am writing a more detailed answer. Let $(a_n)_{n\geq 1}$ be a sequence of real numbers. We define the sequence of partial sums for $(a_n)$ as follows:
$$s_n = a_1 + a_2 + \dots + a_n, \;\; n\geq 1$$
We say that the series with general term $a_n$ (or $\sum a_n$) converges if the sequence $(s_n)$ converges to a real number $l$. A necessary condition for a series to converge is that $a_n \to 0$. We can see this by noting that
$$a_n = s_n - s_{n-1}, \;\; n \geq 2$$
Assuming that $s_n \to l$ we can take limits on both sides of the above equality and conclude that $a_n \to l - l = 0$ since $(s_{n-1})$ converges to $l$ as well.
In your case, you have shown that $a_n \not\to 0$ so by contraposition the series with general term $a_n$ cannot converge.


How to bind currently selected tab to a property on scope

Question: I have multiple tabs being displayed using ng-repeat on a collection in the scope.
Now I need a "CurrentSelection" property on the scope which should be binded to the active Tab's name. Here's the code which I am trying but it's not working, I am always getting false.
<uib-tab ng-repeat="mapping in template.mappings track by $index" heading="{{mapping.name}}({{mapping.targetEngineVersion}})"
                     active={{mapping.active}}>

Here I have written a function which tells the active tab's name:
private getMapping() {

    return this._scope.template.mappings.filter(function(mapping){
      return mapping.active;
    })[0];

        }

Answer: I think you will need to have a uib-tabset and then using the active property to select the active tab.
<uib-tabset active="active">
    <uib-tab ng-repeat="mapping in template.mappings" heading="{{mapping.name}}({{mapping.targetEngineVersion}}) {{mapping.active}}" index="$index">
</uib-tabset>

 $scope.change = function(){
    for(var i = 0; i < $scope.template.mappings.length; i++){
      if($scope.active === i){
        var x = 0;
        if(i+1 < $scope.template.mappings.length){
          x = i+1;
        }
        $scope.active = x;
        break;
      }
    }
  };

here is a link to a working example. http://codepen.io/mkl/pen/bepOOa


Separate home page per domain in multilingual setup (i18n)

Question: I have a multisite Drupal with 2 domains, that should have separate home pages, but I can't get it working. I've created a node for each.
Now, I've tried to configure it in the Configuration > Site information > Default Home Page panel. There is note on top of the page: "This form is domain-sensitive, be sure you select the proper domain before saving." ; Therefore I guess that "home page" parameter is per domain?
But it doesn't work : each time I change this field (value : node/92), all domains are affected.
Is it supposed to work? Is there another way to do it?
Comment: Yes, that's what Domain Access is made for, isn't it ?
Comment: Is this multisite ?
Answer: I would

Setup a "Page manager"-page, and call it "Front".
Set the homepage to "/front".
Create one variant for every domain in the front-page. Fill with relevant content.
Create a ctools "Domain access plugin". That wouldn't be many rows of code, see my brief tutorial
Use the access plugin to setup a selection rule for every variant/domain.
Answer: After some search, it is a known conflict between Domain Access and I18N : http://drupal.org/node/1650498
As written, the fix is to :

upgrade i18n to version 1.6 (or latest)
upgrade Variable to 2.0 (or latest)
upgrade Domain Access to latest
enable and set Domain Variable module.

Then,

Go to Domains List > Variables Tab > Site Informations > Check "Default Home Page"
Go to your domain > You have 2 parameters tabs > Go to the * 2nd * Parameters Tab > Site informations > set your Default Home Page for this domain.

That should work perfectly !

NOTE : There are 2 others ways of setting different frontpages that DOES NOT WORK (at least for me) :

Configuration > Site information > Default Home Page
Domain > 1st Parameters Tab > Site Home Page

Don't use them.


Kline calculus intuitive chapter 3 problem 14

Question: I am starting to get frustrated as I am not able to comprehend these questions because they simply do not make sense to me.

A body is dropped. At the instant when it has fallen $100$ feet, a second body is to be projected downward with an initial velocity which will enable it to catch up with the first body in $10$ seconds after the second body is released. What is the requisite initial velocity?

Here is the problem and answer to it:
https://scienceanswers.wordpress.com/2012/09/24/problem-3-2-14-page-48/.
First what I do not understand is why is $t_0$ for the second body $2.5$ seconds. Shouldn't it be $0$ seconds if it didn't travel any distance? Second if we integrate $a=32$ we get $v(t)= 32t+C$. Why can't I say that a time $2.5$ seconds which is supposedly $t_0$ for the second body $v(t)=0$ and just solve for $C$. I am never sure how to set the parameters such as $v$, $s$ and $t$.
Comment: @MathematicsStudent1122  Notice that the units are $a = 32~\text{ft}/\text{s}^2$.  The author is American.  Physicists use SI units, so $g = 9.8~\text{m}/\text{s}^2$.
Comment: Sort of weird you'd have $a=32$. If it's a body dropping, $9.8$ would be more accurate.
Answer:
A body is dropped. At the instant when it has fallen $100$ feet, a second body is to be projected downward with an initial velocity which will enable it to catch up with the first body in $10$ seconds after the second body is released. What is the requisite initial velocity?

Notice that the time the second body is released depends on when the first body has fallen $100~\text{ft}$.  Since the first body falls from rest, the distance it falls in $t$ seconds is
$$d = \frac{1}{2} gt^2$$
Since the distance is given in feet, we take $g = 32~\text{ft}/\text{s}^2$.  Hence, we can determine when the first body has fallen $100~\text{ft}$ and when the second body is released by solving the equation
$$100~\text{ft} = \frac{1}{2}\left(32~\frac{\text{ft}}{\text{s}^2}\right)t^2$$
Solving for $t$ yields
\begin{align*}
200~\text{ft} & = \left(32~\frac{\text{ft}}{\text{s}^2}\right)t^2\\
\frac{200~\text{ft}}{\left(32~\dfrac{\text{ft}}{\text{s}^2}\right)t^2} & = t^2\\
\frac{25}{4}~\text{s}^2 & = t^2\\
\frac{5}{2}~\text{s} & = t
\end{align*}
where we discard the negative solution for $t$ since the first body cannot fall before it is dropped.  Hence, the second body is released $2.5~\text{s}$ after the first body is dropped.
To determine when the second body catches the first, we must set the distances they have fallen equal to each other.  We know that $t$ seconds after the first body has dropped, it has fallen
$$d_1(t) = \frac{1}{2}\left(32~\frac{\text{ft}}{\text{s}^2}\right)t^2$$
Since the second body does not begin to fall until $2.5~\text{s}$ after the first body is dropped, the distance the second body falls $t$ seconds after the first body is dropped is
$$d_2(t) =
\begin{cases}
0, & t < \dfrac{5}{2}~\text{s}\\
v_0\left(t - \dfrac{5}{2}~\text{s}\right) + \dfrac{1}{2}\left(32~\dfrac{\text{ft}}{\text{s}^2}\right)\left(t - \dfrac{5}{2}~\text{s}\right)^2, & t \geq \dfrac{5}{2}~\text{s}
\end{cases}
$$
where we have used the formula $$d(t) = v_0t + \frac{1}{2}at^2$$ for the velocity of an object with initial velocity $v_0$ and acceleration $a$, with $a = 32~\text{ft}/\text{s}^2$.
Since the second body catches up to the first body $10~\text{s}$ after the second body is released, which is $10~\text{s} + 2.5~\text{s} = 12.5~\text{s}$ after the first body is released, we obtain
\begin{align*}
d_1(12.5~\text{s}) & = d_2(12.5~\text{s})\\
\frac{1}{2}\left(32~\frac{\text{ft}}{\text{s}^2}\right)(12.5~\text{s})^2 & = v_0\left(12.5~\text{s} - 2.5~\text{s}\right) + \frac{1}{2}\left(32~\dfrac{\text{ft}}{\text{s}^2}\right)\left(12.5 - 2.5~\text{s}\right)^2\\
\frac{1}{2}\left(32~\frac{\text{ft}}{\text{s}^2}\right)(12.5~\text{s})^2 & = v_0\left(10.0~\text{s}\right) + \frac{1}{2}\left(32~\dfrac{\text{ft}}{\text{s}^2}\right)\left(10.0~\text{s}\right)^2\\
2500~\text{ft} & = v_0(10~\text{s}) + 1600~\text{ft}\\
900~\text{ft} & = v_0(10~\text{s})\\
90~\dfrac{\text{ft}}{\text{s}} & = v_0
\end{align*}
Comment: Sorry for the late reply but thank you for the response. So if I understand correctly t_0 for the second body is basically 2.5 seconds am I right?
Comment: That is correct given that we are measuring the time from when the first body is dropped.


MongoDB error reporting

Question: After a save operation ($col->save($w);) an exception occur. But I just get following:
Fatal error: in D:\......\x.php on line 41
MongoException: in D:\......\x.php on line 41

How to get a more informative error message? Is there any config to enable error reporting for MongoDB?
Answer: To check out what errors you are getting, you can check the error codes you are getting when exception is raised. Check out the error code here at PHP driver for mongo
Answer: To check if there was an error on the most recent db operation performed, you can use MongoDB::lastError.
var_dump($db->lastError());

For your information
If you run with driver version 1.3.0, new Mongo has been DEPRECATED. Relying on this feature is highly discouraged. Please use MongoClient instead.

MongoDB error reporting


How to rotate a Globe, So that when selecting a position on globe using mouse click on it don't tilt the Globe sideways?

Question: I have achieved Globe rotating on mouse click on any particular panel on the Globe and the panel position gets in the Center of the Camera on click but the problem is Globe travels the shortest distance between the two points (Camera Center and Next Position on Globe).
As per the image currently Globe jumps to next position and tilts like this

As per this Image I need Globe to result in this rotation where NorthPole and SouthPole remains at their side looking through the camera.

public List<GameObject> characters = new List<GameObject>();
private Quaternion targetRotation = Quaternion.identity;

public void CharacterPosition(int charNum)
{
    Quaternion diff = Quaternion.FromToRotation(characters[charNum].transform.up, camera.transform.position - transform.position);
    targetRotation = diff * transform.rotation;
    transform.DORotateQuaternion(targetRotation, 1f);
    hitAgainNumber = charNum;
}

"characters" List conists of the panels on the globe on multiple positions.
DoTween Plugin is used for the Rotation.
I will be very thankful if someone helps me with that.
Comment: why `Quaternion.FromToRotation(characters[charNum].transform.up, camera.transform.position - transform.position);`? wouldn't you rather want `characters[charNum].transform.forward` ?
Comment: @derHugo No because I used `characters[charNum].transform.up` to get the normal of the plane, which was selected.
Answer: Explanations are in the comments:
public List<GameObject> characters = new List<GameObject>();
private Quaternion targetRotation = Quaternion.identity;

public void CharacterPosition(int charNum)
{
    // Use cross products to find the closest vector to Vector3.up which is orthogonal
    // to the direction from the sphere to the camera.
    // This direction is to be the sprite's forward after we rotate the sphere
    Vector3 charGoalUp = camera.transform.position - transform.position;
    Vector3 charGoalRight = Vector3.Cross(charGoalUp, Vector3.up);
    Vector3 charGoalForward = Vector3.Cross(charGoalRight, charGoalUp);

    // Get the goal rotation for the character using `LookRotation`:
    Quaternion charGoalRotation = Quaternion.LookRotation(charGoalForward, charGoalUp);

    // Determine the world rotation that needs to apply to the character:
    // delta * char_start = char_end -> delta = char_end * inv(char_start)
    Quaternion worldCharDelta = charGoalRotation
            * Quaternion.Inverse(characters[charNum].transform.rotation);

    // Apply that same world rotation to the globe:
    targetRotation = worldCharDelta * transform.rotation;

    transform.DORotateQuaternion(targetRotation, 1f);
    hitAgainNumber = charNum;

}

Comment: In the above pictures in the question, camera position is (0,0,-10). If I change the camera position to something else with different position and rotation the character will not result in the Center of the Camera.

https://imgur.com/a/xSnZ7yX
In this Image Camera Position is (0,5,-10) and Rotation is (25,0,0). The Character should be in the center as per the Image. But its not happening like this. The next picture explains what I am getting in result.
https://imgur.com/1ucTHsR.

I hope this will help you.
Comment: Thank you mate. The updated code works as per my requirement and tested it in AR too.

I have another problem in the same project, Would you like to help me in that too?
Comment: I am having just one issue when I implement this code on Globe and try to use the Globe in AR then the character doesn't always face the camera, it rotates in front of the camera but not in the center of it.
Comment: @VarunSaini It's hard to understand what you mean without a picture. Can you include a screenshot of that in the question?
Comment: @VarunSaini I tested it out on my machine and found the fix. That should work for you.
Comment: @VarunSaini Sure, feel free to [ask](https://stackoverflow.com/questions/ask)


How did Malcom Young tame the feedback?

Question: I realise that Malcolm Young played a fair amount of solid-body Gretch guitars but for a certain amount of songs he played hollow-bodied Gretsch's as well. How did he not succumb to unruly feedback? At the volumes, ACDC played at and with all that gain I'm not sure how exactly he ever got a reasonable tone with such a guitar in such an environment?
Comment: You might be surprised how little gain is needed to get the tone he gets.
Comment: Using a P.A. to send the sound out to the audience, the sound level on stage doesn't need to be that high that feedback is created. If it is, he'd do like the rest of us, and mute anything likely to feed back, using either/both hands.
Comment: All I.know is eye contact with my amp is enough to have my acoustic feedback.
Comment: Carefully  :-)   is how
Comment: @NeilMeyer  as ***someone**** famously said,  "you're holding it wrong" .   Point that speaker (not amp) away from you.
Answer: He might have put socks into the cavity. He did the same with a guitar that had empty pickup sockets.
"Malcolm Young's iconic 1963 Gretsch Jet Firebird guitar was originally red, given to him by AC/DC's early producer Harry Vanda. The guitar had the neck and middle pickups removed. Young later removed the red paint and, for a while, placed his socks in the pickup cavity to stop feedback"
https://www.musicradar.com/news/guitars/13-idiotic-ac-dc-facts-179026
(#3)

How did Malcom Young tame the feedback?


Split Array Function on Email PlainBody() MSG using Google Script

Question: I use the following code below to grab emails, get the plainbody(), date and messageto bring them into Google sheet in COLUMN A.
Then in the spreadsheet I copy down the formula in COLUMN C
=ARRAYFORMULA(IFERROR(SPLIT(A3,"|")))

(Which I tested this works as well - not sure if one is preferred)
=SPLIT($A2,"|")

I'd like to combine these functions and have attempted the following
function getEmails() {

    var ss = SpreadsheetApp.getActiveSheet();
    var threads = GmailApp.search("is:starred in:TanWebOppCRM");

    for (var i=0; i<threads.length; i++) {
        var messages = threads[i].getMessages();

        for (var j=0; j<messages.length; j++) {
            var msg = messages[j].getPlainBody();
            var dat = messages[j].getDate();

            var msgParse = '=SPLIT($A2,"|")';
            /*var msgParse = '=ARRAYFORMULA(IFERROR(SPLIT($A2,"|")))';*/
            ss.appendRow([msg, dat, msgParse]);
        }
        threads[i].moveToTrash();
    }
}

This DOES "WORK". For example - I know I just sent myself a test email that can be extracted. I know the next row that WILL be appended is Row 30 - and change the code
 var msgParse = '=SPLIT($A2,"|")';

to
 var msgParse = '=SPLIT($A30,"|")';

Then the extraction works, and you see the split happen.
If I was to import 2 new rows - obviously
$A30 /* stays A30 - so I tried-
var msgParse = '=SPLIT($A[j],"|")';

Just to see if the [j] dynamically changed - even though I know j is for message loop
The question...

how do I get the following line to increment to the append row value
so that each loop changes the row reference to the appended row - so if I was starting from row 30
var msgParse = '=SPLIT($A30,"|")';
var msgParse = '=SPLIT($A31,"|")';
var msgParse = '=SPLIT($A32,"|")';

Is what the incremental msgParse value data would be.
Answer: You can construct the formula via string concatenation.
If you always just append you can just get the last row and add 1 (because the new row will be one row below) and use that as the row reference:
var msgParse = '=SPLIT($A' + (ss.getLastRow() + 1) + ', "|")';

Comment: I tried a dozen different ways including something close to this - but never got it exact. Question though - I'm about to try this - should their be more " quotes or is one missing in the beginning?
Comment: sorry, i messed up single and double quotes, please check the updated answer
Comment: I started with the " at the beginning then realized the above and came up with the same thing. But however - it's not parsing any longer. In the Editor - I noticed "sheet" is not blue. Looking at my original script  - it's not declared below. But the last few things I had done either errorred or did not process. Do you have any ideas? I'm accepting your answer on split array as soon as I confirm it worked.
Comment: I accepted this answer because my question was about the array split. Moving the suggested answer OUT OF the first FOR loop -and run a log on it - it outputs what I expect. For some reason it just doesn't execute in the for loop so I'll open a different question. Thanks @Robin
Answer: Since I'm new to Script - and I couldn't find this answer - I wanted to add my own answer.
@Robin definitely pointed me in the right direction - I didn't realize I can use string concatenation - however the solution provided did not increment and once that string concatenation was written - it remain for the rest of the FOR loop
The final piece was adding a counter - I could probably eliminate the first row = variable and there is probably a way to make this more efficient But it took in 20 sample emails from gmail and parsed them into spreadsheet in maybe 6 or 7 seconds.
function getEmails() {

    var ss = SpreadsheetApp.getActiveSheet();
    var threads = GmailApp.search("is:starred in:TannerWebOppCRM");
    var row = ss.getLastRow();

    for (var i=0; i<threads.length; i++) {
        var messages = threads[i].getMessages();
        var newrow = row + 1;

        for (var j=0; j<messages.length; j++) {
            var msg = messages[j].getPlainBody();
            var dat = messages[j].getDate();
            var msgParse ='=SPLIT($A'+ (newrow) + ', "|")';
            ss.appendRow([msg, dat, msgParse]);
            newrow = newrow + 1;
        }
        threads[i].moveToTrash();
    }
}

To complete this post I wanted to include the update and addition to the answer I accepted because that technically answered my question - just didn't put it into context how to make it work in my script.
Comment: Glad you could get it to work. Try providing sample data next time, that way whoever answers also has the chance to validate the correctness of their answer.
Comment: @robin - I would have had I had a problem with the split but in my original question I had confirmed the split worked 2 or 3 different ways. I also posted that your suggestion did the split. This was in **no** way about validating the data -  besides data sample would have been as easy as some|data|here just by looking at the split. Why I posted the answer was that your answer was incomplete - as the contents of the script and the fact it needed to increment was visible in the initial script. Every other variable was incremental in that FOR loop except your answer.


Interpretation of residual plots

Question: Here is a question in the book of Freedman p.189.

 The answers provided are
(a) ( i)&(ii)
(b) not used
(c) something wrong
My biggest confusion is the answer for (c), what is wrong with this residual plot?
The second biggest headache is (a) could be an answer represented by both (i) and (ii). Intuitive it seems ok. But I am unsure how it get calculated as 1000 from (i), (ii).
Hope to hear some helps. I wish an explanation at 1st year level without invoking the term endogeneity/exogenous etc.
Answer: Picture (iii) denotes a clear linear relationship, which should have been detected and exploited by the initial linear regression; that lead to these residuals. That is why something went wrong.
The absolute observed errors in (i) and (ii) lie between 0 and 2000. None comes close to 5000.
Edit:
Let there be $n$ individuals. If the linear regressions follows the form of
$$y_{i} = \beta_0+\beta_1x_{i}+\epsilon_{i}$$ and $\epsilon_{i}$ follows a linear pattern as well, i.e. $\epsilon_{i}={\beta_\epsilon}_0 + {\beta_\epsilon}_1x_{i}+{\epsilon_2}_{i},$ then plugging this error term into the above linear regression yields $$y_{i} = \beta_0+\beta_1x_{i}+{\beta_\epsilon}_0 + {\beta_\epsilon}_1x_{i}+{\epsilon_2}_{i}.$$ You can easily rearrange the above expression into $$y_{i} = (\beta_0+{{\beta_\epsilon}_0})+(\beta_1+{\beta_\epsilon}_1)x_{i}+ {\epsilon_2}_{i}.$$ Note, this too is linear. The algorithm will find those $\beta$s which minimize the sum of squared errors, and that is the one with no linear part in $\epsilon$.
Comment: It is lots clearer now and I've ticked.
Comment: I have tried to make it more clear by my addition to the above answer.
Comment: See my comments. I don't think this solution is correct despite the fact it was selected as the appropriate solution. Moreover, your interpretation of autocorrelation as being the potential explanation @ math101 does not account for the issue of endogeneity at all. Endogeneity is caused by a selection problem, omitted variables, simultaneous causality, etc. not autocorrelation of the error terms (unless we're working with lagged models this doesn't factor into the problem of endogeneity).
Comment: why residual plot should not present a linear relationship. On freedman 185 I saw a similar plot for the RMS error and it looks similar to the plot in c). I believe your answer is correct. But I do not clearly understand your explanation  on why iii) is wrong. (I did insufficient studies on this topic and perhaps forgotten after studying regression analysis 10 years ago) Could you elaborate?
Comment: Let's assume, in the given pictures the x-axis is the predicted value, the y axis the residual. In (iii) a large prediction goes along with a large residual, a small prediction goes along with a negative prediction, both boosting the "least squares". If the modell predicted every prediction larger, then the residual would be less positive and if it predicted each prediction smaller, the residuals would be less negative. Does that make sense? I take for granted, that we talk about OLS regression (everything else would have to be announced) which optimizes for small "squares".
Comment: basically you mean the residuals go up with the prediction, which indicate some linear relationship which could leads to the issues: autocorrelated errors? By the way, I do not understand the sentence "If the modell predicted every prediction larger, then the residual would be less positive and if it predicted each prediction smaller, the residuals would be less negative."...
Answer: Well, let's think about the broader picture first. What does the residual set graph tell us? It's graphing the relationship between some $x_{i}$, an independent variable used in the regression, and the error $\hat{e}_{i} = \hat{Y}_{i} - Y_{i}$. This graph provides a visual aid to tease out relationships between the unexplained component and the non-stochastic elements of the estimation process.
Okay, so how is RMSE calculated?
$RMSE = \sqrt[]{\frac{\sum_{n=1}^{N}(\hat{Y_{i}}-Y_{i})^{2}}{N}}$.
So, just looking at the set of values the residual can take, I see you have values of $\hat{e}_{i}$ which approach the absolute value of 2000. It's harder to decisively say without knowing the number of observations but the RMSE seemingly exceeds 1000 in either case. So, if I had to go with either a or b, I'd choose b.
The third case is a standard example of something we call endogeneity, i.e. $E[e_{i}|x_{i}] \neq 0$.
Edit: It looks like the image is the set of potential residuals realizations. If so, just plug in the largest set of values for $\hat{e}_{i}$ possible for a low $n$ regression and you will see the RMSE is larger than 1000.
Comment: @JuliusBilly I understand the curves in the plots as reasonable borders of a scatter plot, not as the residuals liing on that lines. So the residuals lie anywhere in between -x and +x with x close but smaller 2000. It may well be, that many of those points reflect residuals of zero or close to zero. How can you tell "certainly" that the RSME exceeds 1000?
Comment: I believe you are correct as well and this is an example of endogeneity. However I do not see how you could visualise $E[e_i|x_i]\neq 0$. Could you explain? This is exercise 2 p.189 of the book by Freedman. There is no other detail about RMSE given. The chapter label as RMS errors this is perhaps why it is labeled that way.
Comment: @math101 Pick a value of $x_{i}$ on the x-axis for the third image to the left or right of the set of values the residuals can take. Does its center lie about the x-axis? No. Hence, this is endogenous. If the set's center completely sat about the x-axis then you would have exogeneity.
Comment: @Bernhard your explanation seems more likely. I will edit my answer above. It does seem like the convex hull of residual values or something of that flavor. So, my reasoning goes as following (assuming you are correct and the number of observations we see is low enough): if that is the set of values the residual can take, then the residual can be something like 1500. If you plug this into the RMSE formula you get a value much larger than 1000.
Comment: @JuliusBilly I do not understand the statement " Does its center lie about the x-axis?" You picked a point $x_i$, what do you mean by this point center lie about x-axis?
Comment: @math101 all I'm saying is, take a value of x in c. Move it to the right a bit (think about drawing vertical lines that cross the x-axis). Those are your $E[u_{i}|x_{i}]$ for two different values of $i$. Are the bands of the set the same for both of those values of x (or even close)? No. Are the bands close to zero? No. Hence, it's endogenous.

Interpretation of residual plots


Maven GroupId with special characters

Question: One best practice for choosing the Maven groupId says to choose the groupId according to the domain name of the company. Some domain names contain special characters, especially hyphen-minus. And moreover with the new non-ASCII-domains a domain name can also contain non-ASCII-characters.
Now my questions:

Can I use the minus in the groupId? What are reasonable alternatives?
How do I handle special characters of non-ASCII domain names in the groupId?
A concrete problem: I have to find groupIds for three independent companies:
Company A's domain is "heccare.de"
Company B's domain is "heccare-international.de"
Company C's domain is "heccare-int.de"

What are reasonable groupIds?
Comment: "Can I use the minus in the groupId?" - what happened when you tested it?
Answer: Per Oracle's documentation on package naming, hyphens (namely, -) in DNS names should be replaced with underscores (namely, _), names that begin with a number should be pre-underscored (so me.123.com becomes com._123.me), and names that conflict with a reserved keyword should be post-underscored (so int.me.com becomes com.me.int_).
Unicode characters are fine, as per the spec for identifiers (for instance, Character.isJavaIdentifierStart('é') evaluates to true).
Your group names would canonically be de.heccare, de.heccare_international, and de.heccare_int, respectively.
Answer: Using your domain name as a groupID is not a bad idea, but it's not necessary. JUnit's groupID is simply "junit":
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>

I've seen other groupIDs that are a combination of domain name, and something more descriptive, such as com.mycompany.webapi, com.mycompany.wslib, com.mycompany.database.util etc... of course, the only thing that resolves to an actual domain is mycompany.com but I don't think that's a problem.
And as for special characters, the dash is OK (just noticed that I have a dependency on Apache Commons I/O, whose groupID is "commons-io") , but non-ASCII characters, you'll just have to try and see!

Maven GroupId with special characters