Differentiating Stochastic Integral

Question: I was wondering how to write the following integral in differential form: $$\int^t_0 f(s,t)dW_s$$ where $W_s$ is a standard Brownian Motion. In my understanding, if $f(s,t)$ can be written as $f(s)g(t)$, we can take $g(t)$ out of the integral and apply Ito's Lemma. However, if we are unable to separate the functional form of $f(s,t)$, how can I differentiate the integral? Thanks for your help!
Answer: We look at the integral at time $t+dt$:
\begin{equation}
\begin{split}
\int_0^{t+dt}f(s,t+dt)dW_s &= \int_0^{t+dt}\left[f(s,t)+\partial_t f(s,t)dt \right]dW_s \\
&= \int_0^{t}\left[f(s,t)+\partial_t f(s,t)dt \right]dW_s+\left[f(t,t)+\partial_t f(t,t)dt \right]dW_t
\end{split}
\end{equation}
In the first line we expanded the integrand around $t$ in the second argument of $f$. In the second line we approximated the integral from $t$ to $t+dt$ by its integrand evaluated at $t$. Now we may use the rules of stochastic calculus to drop the term $dt\, dW_t$ and write
\begin{equation}
\begin{split}
\int_0^{t+dt}f(s,t+dt)dW_s &= \int_0^{t}f(s,t)dW_s + dt\cdot \int_0^{t}\partial_tf(s,t)dW_s + f(t,t)dW_t.
\end{split}
\end{equation}
Thus, if we define
\begin{equation}
\begin{split}
X^{(0)}_t=\int_0^{t}f(s,t)dW_s, \quad X^{(n)}_t=\int_0^{t}f^{(0,n)}dW_s,
\end{split}
\end{equation}
where $f^{(0,n)}$ is the $n$'th derivative of $f$ in the second argument, $X^{(0)}_t$ satisfies the Ito SDE
\begin{equation}
\begin{split}
dX^{(0)}_t=X^{(1)}_t dt+f(t,t)dW_t.
\end{split}
\end{equation}
One remark: In practice this SDE is not very helpful on its own, since $X^{(1)}$ is of the same form as $X^{(0)}$ and its SDE depends on $X^{(2)}$, and so on. This generates a closure problem, requiring us to always know one of the integrals beforehand. However, if $f^{(0,n)}\equiv 0$ for some positive integer $n$, we get a closed system of SDEs
\begin{align}
dX^{(0)}_t&=X^{(1)}_t dt+f(t,t)dW_t,\\
dX^{(1)}_t&=X^{(2)}_t dt+f^{(0,1)}(t,t)dW_t,\\
\vdots\quad & \qquad\qquad\vdots\\
dX^{(n-2)}_t&=X^{(n-1)}_t dt+f^{(0,n-2)}(t,t)dW_t,\\
dX^{(n-1)}_t&=f^{(0,n-1)}(t,t)dW_t.
\end{align}

Differentiating Stochastic Integral


Twitter Red/Blue Confusion

Question: On Twitter I notice with some people the tweet button and their names are blue but with other people these things are red, why is this?
Answer: People can set their own colour scheme for their profile in Twitter. The default is the typical Twitter blue, if you see a profile with a different colour they probably changed it.

Twitter Red/Blue Confusion


1 Cor. 2: 8- in the context of "if they had (known the glorious Lord)", could "they" also refer to Roman political leaders?

Question: Text: 1 Corinthians 2: 8 (ESV)
"None of the rulers of this age understood this, for if they had, they would not have crucified the Lord of glory."
Answer: 1 Corinthians 2:8

None of the rulers of this age understood it, for if they had, they would not have crucified the Lord of glory.

rulers
ἀρχόντων (archontōn)
Noun - Genitive Masculine Plural
Strong's Greek 758: Present participle of archo; a first.
Strong's Concordance

archón: ruler, chief
Usage: a ruler, governor, leader, leading man; with the Jews, an official member (a member of the executive) of the assembly of elders.

NASB Translation

authorities (1), leaders (1), magistrate (1), official (2), official's (1), prince (1), ruler (1), ruler (13), rulers (16).

Thayer's Greek Lexicon

ἄρχων, ἄρχοντος, ὁ (present participle of the verb ἄρχω) (from Aeschylus down), a ruler, commander, chief, leader: used of Jesus, ἄρχων τῶν βασιλέων τῆς γῆς, Revelation 1:5; of the rulers of nations, Matthew 20:25; Acts 4:26; Acts 7:35; universally, of magistrates, Romans 13:3; Acts 23:5; especially judges, Luke 12:58; Acts 7:27, 35 (where note the antithesis: whom they refused as ἄρχοντα καί δικαστήν, him God sent as ἄρχοντα — leader, ruler — καί λύτρῳ — τήν); Acts 16:19. οἱ ἄρχοντες τοῦ αἰῶνος τούτου those who in the present age (see αἰών, 3) by nobility of birth, learning and wisdom, power and authority, wield the greatest influence, whether among Jews or Gentles

Could "they" also refer to Roman political leaders?
Definitely yes according to the above lexicons.
Now let's check the context.

1 Corinthians 2:6 We do, however, speak a message of wisdom among the mature, but not the wisdom of this age or of the rulers of this age, who are coming to nothing. 7No, we declare God's wisdom, a mystery that has been hidden and that God destined for our glory before time began. 8None of the rulers of this age understood it, for if they had, they would not have crucified the Lord of glory. 9However, as it is written:
"What no eye has seen,
what no ear has heard,
and what no human mind has conceived"
the things God has prepared for those who love him—
10these are the things God has revealed to us by his Spirit.

The context also confirms that it is talking about the leading people of Jews and Gentiles (Romans and Greeks).
Answer: The operative word is ἄρχων (archón) meaning, "ruler", "chief".  If I paraphrase BDAG, we have four types of rulers for whom this word is used:

Jewish leaders: Acts 14:2, 23:5, 13, 35, Matt 9:18, 23, 20:25, Luke 8:41, 18:18, etc.
Earthly, gentile rulers/authorities: Matt 20:25, Acts 4:26, 16:19, Rom 13:3, 1 Cor 2:6-8, Titus 1:9, etc
Christ Himself, Rev 1:5.
Transcendental figures including evil spirits: Matt 9:34, 12:24, Mark 3:22, Luke 11:15, John 12:31, 14:30, 16:11, 1 Cor 2:6-8, Eph 2:2, etc.

Note that BDAG places the meaning of ἄρχων (archón) in 1 Cor 6-8 in both the category of Jewish AND gentile rulers.  However, I would not necessarily exclude the fourth category above either.
Meyers says (of 1 Cor 2:6):

τῶν ἀρχ. τ. αἰῶν τ.] These are the rulers generally (comp Acts 13:27),
the dominant powers (proceres) of the pre-Messianic time among Jews
and Gentiles.

Note that Paul says that the "rulers of this age" crucified the Lord of Glory.  While the Jewish leaders agitated and begged Pilate to crucify Jesus, it was Pilate who actually had the authority to do so and who finally issued the death warrant.  However, Pilate would not have done this without the insistence of the Jewish leaders who stirred up the mob.  Thus, BOTH Jewish and gentile (Roman) leaders were equally involved in crucifying Jesus.
Bengal's Gnomen also observes:

to the princes of the world, 1 Corinthians 2:8, etc.—ἀρχόντων, of the princes) 1 Corinthians 1:20. Paul uses a word of wide
signification, in which he comprehends men of rank both among the Jews
and Greeks.


pros and cons of the anthropic principle

Question: The anthropic principle has become a very popular explanation among theoretical physicists lately. Life is unlikely, but only life can observe, so we find ourselves in an unlikely position, so to speak. What I would like to ask is just how unlikely is life? Is the evolution of life generic for most laws of physics, or extremely unlikely with extreme fine-tuning? What is so controversial about the anthropic principle? No one is surprised to find themselves on an Earth-like planet orbiting a long lived star at just about the right distance from the star with plenty of liquid water, a thick atmosphere and plenty of carbon amidst the sterile antiseptic reaches of space. What are the major pros and cons? String theory conveniently provides a multiverse and a landscape.
Comment: Dear @Wilsor, I wouldn't be able to guess it's a homework. Well, one may surely design laws of physics qualitatively similar to ours but laws which wouldn't allow any kind of life we may think of. It's enough to change some constants of Nature by 10 percent or so and key atoms, stars, nuclei will become prohibited, making it impossible for sensible structure to evolve. Indeed, it's not surprising that we must find ourselves in a Universe and on a planet that admits life: it's a tautology. The controversial part is the implicit claim that no "better" explanation beyond this tautology exists.
Comment: So the controversial part of the anthropic principle is that it makes the assumption that some things are random - and urges physicists not to ask the question "why" any longer - which means that it discourages further research. It invites the people to be satisfied with a plausible explanation that doesn't really explain or predict much and that could be fundamentally wrong. It's an explanation that, if adopted at any earlier stage of the history of science, would slow down the further scientific progress. It's similar to religion: don't calculate and just admire God's greateness
Comment: @LubošMotl: any chance you might consider posting that as an answer?
Comment: Is this homework?
Comment: Indeed, in the whole history of science, we were ultimately able to find better and more accurate explanations of various things. We could have said that the energy levels of atoms etc. were a priori random and Nature just chose a collection of random numbers and the only constraint was that these numbers - energy levels - allowed life to evolve. Except that it was proven that the levels were not random: today we're able to calculate all (thousands) of them just from a few starting parameters. There are things in subnuclear physics we can't precisely calculate today; but we shouldn't give up.
Comment: I agree with Lumo and as I always say, the anthropic principle is just a lazybones approach to avoid working things out further in a mathematically and physically consistent manner. So come on guys ... ;-P
Comment: @LubošMotl I second the motion you turn the comments into an answer. I agree that it is an uninteresting tautology that leads to intellectual laziness.
Answer: i don't think the cons are meaningful, at least in two ways.
1) the anthropic principle does not stop people in the spot to think about these issues. If people discover good reasons why the universe is special (or seems to be), no amount of anthropic principle will make those reason vanish (assuming they are really good)
2) as a fan of modal realism* i think the anthropic principle is an unavoidable fact of existence. We are by construction on a special frame of reference; for instance, the odds of life evolving near the big bang are negligible. The combined viewpoint of anthropic principle and modal realism is akin to the copernican revolution coming from a ptolemaic dogma: Although in this case, there is no way that we can elucidate these questions with observations.
*(the idea that there is no substantial difference between possible universes (in a mathematical sense) and "real" universes; the former will also have entities that might ask themselves big questions.)
Answer: Any string theorist who is not in massive denial and hiding their heads in the sand knows that string theory predicts an exponentially large landscape of stable and metastable compactifications. That much is an objective fact of string theory. Any string theorist worth their salt also knows a generic inflationary state leads to chaotic inflation, and given some likely conditions eternal inflation. Some parts decay to a lower energy compactification, but those which don't inflate exponentially faster to more than compensate. Combine eternal inflation starting from some metastable state with a Planck sized vacuum energy with the landscape, and a multiverse is an inevitable result. Most bubbles are not hospitable to life but it is tautological that observers will always find themselves in a bubble which is just right for life.
The multiverse explanation of the anthropic principle is actually a prediction of string theory, and any string theorist not too chicken to face reality will realize this simple truth.
Comment: This answer is assuming that eternal inflation is compatible with holography and this is not at all obvious.
Comment: Hm ok, after rereading it I some kind of like this answer somehow, +1. But nevertheless, I think it would be nicer if the extent of the landscape could be reduced physically and/or mathematically to finally detect the "needle(s) in the haystack".
Comment: Is this an ironic answer making fun or is it meant serious ...?
Answer: What exactly is it being selected for in the anthropic principle? Conscious observers, but what is consciousness? Intelligent life, but why not nonintelligent life? Humans specifically, but why not some other intelligent lifeform? Why isn't a planet of apes only but no humans enough? Anyone wishing to take the anthropic principle seriously has to explain why we humans lie on the side of selection. Evolutionarily speaking, a universe with a planet of only apes is far more likely than a universe with a planet containing humans. Why aren't neanderthals or hunter gatherers enough? According to neo-darwinism, progressive evolution is never inevitable. Is it because of the higher population growth afforded by advanced technology, but even with a factor of a million in additional population, might it be that less than every one in a million planets with neanderthal level intelligence leads to intelligence advanced enough to cause extreme population growth?
Comment: no, it is exactly like you said at the beginning: life, intelligent or not, is what pre-conditions automatically certain stability and "well-behavedness" in the physical laws. The intelligent part is only important to us because we are studying those laws and trying to figure out the patterns that seem "unnatural", and discussing such things in forums that live in computers that work with electric power.
Answer: The often stated claim that the anthropic principle makes no concrete predictions is a BALD FACED LIE propagated by detractors hoping to smear the good name of the anthropic priciple. Hoyle predicted a carbon nuclear resonance at a particular energy level because that is what is needed for nucleosynthesis of the heavier elements, and we turned out to be right. Weinberg predicted the correct order of magnitude for the cosmological constant at a time when almost everyone thought it was exactly zero.
Comment: You describe it as "Hoyle predicted carbon nuclear resonance because that is necessary for heavier elements and life, using the anthropic principle". I would say "Hoyle started from the (obvious) observation that nucleosynthesis of heavy elements occurred in our universe, and reached conclusions about the mechanism by which it must have occurred". I don't see how the anthropic principle is at all helpful for this. For example: We see that Saturn has rings, therefore we can reason about how those rings came about. Hmm, but Saturn's rings are unnecessary for life...who cares??
Comment: very interesting. +1
Comment: ""Hoyle predicted a carbon nuclear resonance at a particular energy level because that is what is needed for nucleosynthesis of the heavier elements, and we turned out to be right."" Ah, You and Hoyle made that prediction?
Answer: The anthropic principle has many "flavors" but they have in common the basic observation that many characteristics of our universe appear to be uniquely suited - some would say "designed" for humankind.  While there are indeed strong patterns and high levels of directionality to be found in nature, particularly in the fields of biology and chemistry, they are general evolutionary trends on which our species happens to be on one part of a very long pathway.
Rather than being the product of some kind of "creator" they are simply features of the way the wonderful machinery of nature happens to work.
See my recent book "The Goldilocks Effect: What Has Serendipity Ever Done For Us?" (free download in e-book formats from the "Unusual Perspectives" website) for more info on this broad evolutionary model.
Answer: If the anthropic principle were true, we humans will be the meaning and purpose of the universe. No longer will we be accidental inessential insignificant beings in an indifferent meaningless purposeless universe. We will be at the heart of the universe itself. We will be of utmost importance. Our lives will have cosmic significance.
Comment: The anthropic principle, as most physicists use the term, is the idea is that there are gazillions of universes and the overwhelming majority of them are bleak, empty, uninhabitable places. A few, including ours, happen to harbor intelligent life, and here we are in one of those. If this is the correct picture, it certainly does not imply that the humans are special or that the laws of physics and/or the universe care whether or not humans exist. It implies the exact opposite.
Comment: this assuming existence in itself is a thing. But if you believe in modal realism, even hypothetical beings in mathematically possible universes are able to ask themselves questions about the universe


Convert object to JSON omitting certain (private) properties

Question: I've been using dean edwards base.js (http://dean.edwards.name/weblog/2006/03/base/)  to organise my program into objects ( base.js is amazing btw, if you havent used it before !).Anyway, my question is generic and you don't have to know base.js to know my answer.
I have a property  in one of my objects called ref which is a reference to a DOM element, and this object is meant to be saved as JSON using JSON.stringify, but as you can imagine since DOM elements are circular structure, I won't be able to convert the object into JSON.
Now to get around this problem I have a method called html() which is meant to return the ref property, but I need to have ref as a private property which is only accessible from within the object, and hence won't be sent to stringify.
What's the best way to do that?
Comment: I don't follow. Can you show some before/after results?
Answer: You probably know that you cannot have private properties in JavaScript.
Interestingly, if you pass an object to JSON.stringify which has a method toJSON, JSON.stringify will automatically call that method to get a JSONable representation of that object. So all you have to do is implement this method.
For example you can create a shallow copy of the object which only contains the properties you want to copy:
MyConstructor.prototype.toJSON = function() {
    var copy = {},
        exclude = {ref: 1};
    for (var prop in this) {
        if (!exclude[prop]) {
            copy[prop] = this[prop];
        }
    }
    return copy;
};

DEMO
Another way would be to use a custom replacer function, but it might be more difficult to control which ref to exclude and which one to keep (if different objects have ref properties):
JSON.stringify(someInstance, function(key, value) {
     if(key !== 'ref') {
         return value;
     }
});

DEMO
Comment: this is a great answer, I really appreciate it
Answer: here is sample to to set variable visibility
function Obj(){
       this.ref = 'public property'; // this property is public from within the object

       var ref = 'private proerty'; // this property is private.

       var self = this;

        this.showRef = function(){
            alert(ref);
            alert(self.ref);
        };
    }

var obj = new Obj();
obj.showRef();

Comment: thanks for the answer, but the problem with your solution is that the private property defined in that way is not accessible by other methods in the same object, which is what I need


Prove that the Ky Fan norm satisfies the triangle inequality

Question: How can one simply see that Ky Fan $k$-norm satisfies the triangle inequality? (The Ky Fan $k$-norm of a matrix is the sum of the $k$ largest singular values of the matrix)
Comment: @user4727 Thanks for the edit.  Are you aware of the original papers by Ky Fan (~1950)?  The reason why it is called the "Ky Fan norm" is because he proved it is a norm first.  This might be a good opportunity for some "research"!  :)
Comment: Could you please define the Ky Fan $k$-norm and let us know what you already tried?  Also, is this homework?
Comment: The Ky Fan $k$-norm of a matrix is the sum of the $k$ largest singular values of the matrix
Answer: For any $k$-plane $U$ in $\mathbb{C}^n$, let $i_U$ be the inclusion of $U$ into $\mathbb{C}^n$ and let $p_U$ be the orthogonal projection of $\mathbb{C}^n$ onto $U$.
Lemma: Let the singular values of $A$ be $\sigma_1 \geq \sigma_2 \geq \cdots \geq \sigma_n$. Then $\max_{U, V} \ \mathrm{Tr} \left( p_V \circ A \circ i_U \right)= \sigma_1+ \cdots +\sigma_k$, where the max is over all pairs of $k$-planes in $\mathbb{C}^n$.
Proof is left for the reader, using his or her favorite definition of singular values.
Then $\max_{U, V} \ \mathrm{Tr} \left(p_V \circ (A+B) \circ i_U\right) \leq  \max_{U, V} \ \mathrm{Tr} \left( p_V \circ A \circ i_U \right) +  \max_{U, V} \ \mathrm{Tr} \left( p_V \circ B \circ i_U \right)$.
Comment: @glS The domain/codomain are essential here. Note that $i_U: U \to \Bbb C^n$ and $p_V : \Bbb C^n \to V$, so that $p_V \circ A \circ i_U$ is a map between $k$-dimensional vector spaces.
Comment: Right. If you like matrices better than maps, then the lemma is that $\sigma_1 + \cdots + \sigma_k$ is $\max X^T A Y$, where $X$ and $Y$ run over $n \times k$ matrices with orthogonal columns. If $X$ is  such a matrix, and $U$ is its column span, then $\iota_U$ is given by the matrix $X$ and $p_U$ by the matrix $X^T$.
Comment: isn't it the same to use $p_U$ rather than $i_U$ here? If by $i_U$ you mean the operator $i_U(x)=x$ for all $x\in U$, isn't this the same as the corresponding projector onto $U$?
Comment: I see what you mean, thanks (assuming you just missed a trace in the comment). So in terms of matrices, you are essentially maximising $\operatorname{tr}(A U)$ over all matrices $U$ with rank $k$ which act as a unitary in a $k$-dimensional subspace. Which would make this sort of a generalisation of  $\max\operatorname{tr}(AU)=\operatorname{tr}|A|$ where the maximisation is over all unitaries $U$.


Using required sign for inputs with default value

Question: Should we use a required sign (*) for the inputs which cannot be left empty since they always contain some default value?
Answer: Well, sure.
But be careful!
As a general practice, I tend to avoid defaulting fields that do not have an appropriate default. Instead, use a Please Select... option (or similar) that acts as an empty placeholder.
For example, the Gender field in your example doesn't have an appropriate default—there is no "default gender". Additionally, if someone just "skips" the field, they'll now have submitted their form with inaccurate data which they didn't provide themselves.
Side note: be careful talking about collecting gender in forms around here... you'll get an earful really quick.
On the other hand, fields like Notification frequency or App background color could very well be safely defaulted.
Regardless of if the required field has an empty state, add the required indicator.

It logically fits the idea of what the indicator represents: data that must be submitted with the form is marked as required, regardless of if the user can erase it.
It will minimize the likeliness of a user failing to submit a form properly due to a missing field.
It is a non-obtrusive way to communicate a valuable attribute of the form field.
It is a common convention. Modern web forms as well as government documents use this symbol (or similar) for denoting required fields.

I can't really think of a strong argument against it. Just implement it so it's not distracting and fits into the aesthetics of your site/app.
Comment: The question is - should it be used for the fields which CANNOT BE EMPTY? As in example above, the field 'Gender' cannot be missed since it always has some option selected.
Comment: @RomanPavlyk I see. I initially understood "cannot be empty" to mean "is required". Edited.


What happens if you turn on multiple VPN connections?

Question: I'm on ubuntu 17 and i just added a few vpn options. I noticed you can turn all of them on, but which one takes precedent? If all of them are on, do they just fall back on the other if one of them fails?
Answer: That highly depends on how they are configured.  Some tunnels are configured to route only traffic that is destined for the other end of the tunnel, while others are configured to route all traffic.  Which one takes precedent (where your traffic goes) is highly dependent on any routes they might setup and the order in which you enable them.  If you'd like an answer specific to your configuration, you'll need to provide those configurations and your routing table (both while they're connected and disconnected).
Guessing from the names I'm going to assume both of those tunnels are configured to pass all traffic.  If that's the case, it's likely that the second tunnel you enabled established it's tunnel through the first tunnel you enabled.  This probably doesn't make you any more secure and will likely slow down your connection.
Comment: I would - quite roughly - distinguish between "corporate VPNs" and "privacy VPNs". "Corporate VPNs" are the ones people use to access resources on some internal network (usually a corporate network) from outside, eg. for remote working. "Privacy VPNs" are the ones people use to hide/change their IP address, so that it looks that they access Internet from somewhere else than they actually are. The former usually pass only _some_ traffic (although they may be as well configured to pass all traffic), the latter usually pass _all_ traffic.
Comment: That distinction is not useful within the scope of the question.  Also, since it is already established that tunnels can be configured to handle only certain routes vs all routes; that distinction is already established within the context of the question as the question was concerning "what happens..." vs "whats the difference..."


What does "most logical" mean about the next badge on the profile?

Question: I am confused about how the next badge is generated. I found a post about it here. It said that the "Progress to next badge" bar automatically selects the badge you're closest to earning (or that's most logical to go to next). What does "most logical" mean? How does the system determine which badge is the most logical one?
Answer: You have answered your own question - the 'most logical' badge is the one that you are closest to achieving, or in other words the one you have progressed the closest to achieving.
One way I have noticed is if you calculate what % completion you are at for each of the badges.  If there are 2 or more the same, then it is sorted by priority (gold, then silver, then bronze).
For example, one of mine:

Looking at the top row:
Fanatic and Proofreader are both at 77/100 or 77% complete, Fanatic is first because it is gold; Proofreader is second. Then in third place is Archaeologist, at 58/100 or 58% complete, finally for this example in fourth place is Marshall at 283/500 or 56.6% complete.
Observing the changes in my 'Select your next badge' screen tends to indicate to me that the % badge completion is the major part of the logic.
Comment: But bronze is easier to get. Why first gold?
Comment: I imagine it is a function of how easy it is to get the badge - on some sites, it is not that easy to get Proofreader, whereas getting Fanatic is by just checking in with a site each day.


Example that does not contradict the Dominated Convergence Theorem

Question: Hi I am doing a past exam paper and I am stuck on one of the questions. Let $\mu=\lambda$ be the Lebesgue measure on $\mathbb{R}$; define the sequence of functions $f_{n}(x)=\frac {1}{n} \chi_{[0,n]}(x):\mathbb{R}\longrightarrow\mathbb{R}$ where $\chi_{[0,n]}$ is the characteristic function of $[0,n]$. Explain why this example does not contradict the Dominated Convergence Theorem. I know $\int\lim_{n\to\infty} f_{n}(x)d\lambda=0$ and $\lim_{n\to\infty}\int f_{n}(x)d\lambda=1$. To show this example does not contradict the Dominated Convergence Theorem I would need to show there is no measurable function $g\geq0$ with $\int g d\lambda<\infty$ that dominates $f_{n}(x)$  but I don't know how to show this. Any help would be appreciated.
Answer: If $g$ dominates the $f_n$'s, then on the interval $[n,n+1]$, $g(x)\geq f_{n+1}(x)=\frac{1}{n+1}$. Hence
$$\int_0^{n+1}g(x)\,d\lambda\geq\sum_{k=1}^{n+1}\frac{1}{k}$$
so $g$ is not integrable on $(0,\infty)$.


session variable mixup in ASP.NET?

Question: Is it possible for ASP.NET to mix up which user is associated with which session variable on the server? Are session variables immutably tied to the original user that created them across time, space & dimension?
Comment: I have a session where they are, in fact, getting mixed up.  http://stackoverflow.com/questions/1646274/asp-net-session-mix-up-using-stateserver-scary
Answer: It depends on your session provider, if you have overriden the session key generation in a way that is no longer unique, then multiple users may be accessing the same session.
What behavior are you seeing?  And are you sure there's no static in play with the variables you are talking about?
Answer: To answer your original question: Sessions are keyed to an id that is placed in a cookie.  This id is generated using some random number crypto routines.  It is not guaranteed to be unique but it is highly unlikely that it will ever be duplicated in the span of the life of a session.  Even if your sessions run for full work days.  It would probably take years for a really popular site to even generate a duplicate key (No stats or facts to back that up).
Having said all that it doesn't appear that your problem is with session values getting mixed up.  The first thing that I would start to look at is connection pooling.  ADO pools connections by default but if you request a connection with a username/password that is not in the pool it should give you a new connection.  Hint that may be a performance bottleneck in the future if your site is very large.  It has been a while since I worked with SQL Server, in Oracle there is a call that can be made to switch the identity of the user.  I would be surprised if there was no equivalent in SQL Server.  You might try connecting to your DB with a generic username/password and then executing that identity switch call before you hand back the connection to the rest of your code.
Answer: while anything is possible. . . .
No, unless you are storing session state in sql server or some other out of process storage and then messing with it. . .
Answer: The session is bound to a user cookie, the chances of that messing up in a normal scenario is very unlikely, however there could be issues if using distributed session state.
Answer: It's not possible. Sessions are tied to the creator.
Do you want to mix up, or do you have a case when it looks like mixed up?
Answer: More information:
I've got an app that takes the userid/password from the login page and stores it in a session variable. I plop it into my connection string for making calls to SQL Server.
When a table gets updated, we're using 'system_user' in the database to identify the 'last updated by' user. We're seeing some odd behavior in which the user we're expecting to be listed is incorrect, and it's showing someone else.
Answer: Can you pop in the debugger and see if the correct value is indeed being passed on that connection string?  It would quickly help you idenfity which side the problem is on.
Also make sure that none of the connection code has static properties for connection or user, or one user may have their connection replaced with that of the most recent user before the update fires off.
Answer: My guess is that you're re-using a static field on a class to hold the connection string.  Those static fields are re-used across multiple IIS requests so you're probably only ever seeing the most recently logged in user in the 'last updated by'.
BTW, unless you have a REALLY good reason for doing so then you shouldn't be connecting to the DB like this.  You're preventing yourself from using connection pooling which is going to hurt performance under high loads.

session variable mixup in ASP.NET?


How to search for Debian CLI packages?

Question: I recently installed Debian for CLI purposes.
I am looking to install CLI packages, I want to know how to search for packages (CLI packages such as nano)?
Answer: To find CLI packages in Debian, you can look for packages tagged as interface::command-line, either using the tag search engine, or on your system by installing debtags and running
debtags search interface::command-line

Both approaches have options to refine the search. See the Debtags wiki page for more details.
This does have limits: packages aren't all tagged appropriately. You can also look for packages which depend on libncurses6:
apt-rdepends -r libncurses6

Answer: When installing Debian, you have the option of installing no desktop-environment.  That will leave you with a CLI-only (headless) machine.  If you installed a desktop-environment during that step, you will need to uninstall the desktop environment.  sudo apt purge gnome may be sufficient.
Once the machine is headless, sudo apt install whatever you like to arm the installation, but avoid the -y to ensure you are prompted before actually installing anything. Review The following NEW packages will be installed: before continuing.  If it includes packages like adwaita-icon-theme or x11-common, then you know this is not a headless package and you should abort the installation.
Stephen's answer is a more direct answer to how to search for CLI packages, but I thought it was worth answering "how can I know that specific package is CLI" without relying on debtags.
Comment: Under Debian, one can also run [`sudo tasksel`](https://wiki.debian.org/tasksel) to deselect the desktop environment, which will be effectively the same as removing `task-desktop` package.
Answer: If you know the executable name (e.g. nano, as mentioned in the question), you can use apt-file to search for specific executable file in all available packages.
# apt-file search bin/nano
mocha: /usr/share/nodejs/mocha/node_modules/nanoid/bin/nanoid.cjs
mocha: /usr/share/nodejs/mocha/node_modules/nanoid/bin/nanoid.test.js
nano: /bin/nano
nano-tiny: /bin/nano-tiny
nanoc: /usr/bin/nanoc
...

There may be false positives, but it is useful to find some packages where you know specific command, but don't know the package name.
apt-file itself requires installation and it needs to download database of filenames.
Comment: As I understand the question, the OP already knows package names and want to find a way to tell whether `nano` is CLI or GUI.
Answer: You could prevent GUI packages from being installed, e.g. by putting the client-side X11 library on hold with
sudo apt-mark hold libx11-6

or by pinning this package via /etc/apt/preferences
Package: libx11-6
Pin: origin ""
Pin-Priority: -1

At this point, installation of GUI packages should be impossible, so any package you manage to install will be CLI. Try installing the packages you need: if they are all CLI, you'll just get them installed, if not, you'll get a list of non-CLI packages for which you need to find an alternative.
This will not give you a list of all CLI packages, but I'm not sure how useful such a list will actually be, unless you want to install every single one of them.
Comment: It might be worth adding `libwayland-client0` as well. However excluding `libx11-6` will also exclude programs which support running with or without X, for example Emacs; for Emacs this isn't a blocker (there's an `emacs-nox` package), but there may be other which are artificially excluded.
Answer: To search for a package on the cli I usually
apt-cache search 'name'

This returns a list with all packages with 'name' in the description
To get a detailed view of the package run
apt-cache show 'name'

Comment: He doesn't say he wants to search using the CLI, he says he wants the search to return packages with only CLI softwares.

How to search for Debian CLI packages?


Disable citrix receiver startup on login

Question: I have installed citrix receiver on my home macbook.  It auto starts on login yet it does not show an entry in the Login Items tab under the Users and Groups pane of System Preferences.  How can I disable the service from starting on login?
Answer: Like @cheezsteak mentions, starting and stopping is done through launchctl. The process below allows you to stop autostart at boot.
First, I fetched a list of all "citrix" processes that run on startup:
launchctl list | grep citrix

In order to remove them completely from starting up automatically, I use the following commands:
launchctl remove com.citrix.ServiceRecords
launchctl remove com.citrix.ReceiverHelper
launchctl remove com.citrix.AuthManager_Mac

The only issue now is that when you open the Citrix Receiver application, you may get something like the following error:

Unable to connect to the citrix AuthManager service

To fix this, you manually need to start the services again:
launchctl load /Library/LaunchAgents/com.citrix.ServiceRecords.plist
launchctl load /Library/LaunchAgents/com.citrix.ReceiverHelper.plist
launchctl load /Library/LaunchAgents/com.citrix.AuthManager_Mac.plist

Unfortunately, this is a bit of a cumbersome process. Especially to repeat it every now and then. But I've made it simple as an Automator task, which runs the mentioned commands to start the service and immediately after start the Citrix Receiver.
Actually, I have no doubt that it is relatively easy for Citrix to make this configurable as a preference. There is actually a discussion on their forum about this, but it appears dead and without response. For the time being - and as mere principle - I choose the hard way myself.
For further reference about launchctl, this AskDifferent answer is quite helpful.
Comment: 1-liner: `launchctl list | grep citrix | awk '{print $NF}' | xargs launchctl remove`
Comment: @AT, to let you know. I've tried your 1-liner, but it's not removing all at once, I've to execute them thrice in my case.
Comment: this is not working for me, when I restart, everything is still there...
Answer: The following services are are started at login by launchd
/Library/LaunchAgents/com.citrix.AuthManager_Mac.plist
/Library/LaunchAgents/com.citrix.ReceiverHelper.plist
/Library/LaunchAgents/com.citrix.ServiceRecords.plist

You can use launchctl to stop the processes like so
launchctl stop com.citrix.AuthManager_Mac

However I am currently unable to prevent launchd from autoloading these services through launchctl.  It is irrelevant because the Citrix Receiver App will not start those services when it starts and will therefore not work if they were stopped or disabled.
I did notice these services are unneeded if using the the companies web app.  Considering that one can just delete the above .plist files and only use the web app.
Comment: I do not understand what your solution consists of? What is the answer to "How can I disable the service from starting on login?"
Comment: @Chachni This was my best attempt to answer my own question.  Moriarty gave an answer that seemed to work for more people so I approved that.  Granted this was all over 5 years ago so neither might not work with the latest version of OSX.  You might need to inspect with what has changed with the launchctl command.
Comment: ok thanks! I gave another answer that is working now for me.
Answer: Creating an app in Automator with shell script works fine to unload at startup without removing the plist files.
You have to add :
launchctl unload –w /Library/LaunchAgents/com.citrix.AuthManager_Mac.plist
launchctl unload –w /Library/LaunchAgents/com.citrix.ReceiverHelper.plist
launchctl unload –w /Library/LaunchAgents/com.citrix.ServiceRecords.plist

Add this app to run at startup and it'll solve the error when you open the Citrix Receiver application.
Answer: I mainly followed the answer from the Citrix Discussion
macOS: prevent workspace/receiver from starting at login/boot.
In short:

In /Library/LaunchAgents, I changed the name of com.citrix.ReceiverHelper.plist to com.citrix.ReceiverHelper.plist_bu just to keep a copy for the future.

I opened com.citrix.ServiceRecords.plist and com.citrix.safariadapter.plist and set the value "RunAtLoad" to "false".
Answer: I removed Citrix from my mac as it was so annoying. I had to run the code above in Terminal in order to kill the live Citrix first. There were still error messages coming up and I found that there were files with citrix in their name in Library/LaunchAgents and Library/LaunchDaemons, I deleted those, Citrix seems gone from my computer.
For those who have to live with Citrix, I am suggesting keeping the app but getting rid of those launch files anyway to avoid seeing this come up at startup.
Answer: This has been annoying me forever as well.  I tried the above steps via Terminal & to delete the Plists for citrix but would not stop auto launching on my MacBook Air.
The following Citrix Uninstall worked for me & allowed the Citrix Desktop application to be deleted.
The Uninstall seems to do a reasonable cleanup of itself as well.
https://docs.citrix.com/en-us/citrix-workspace-app-for-mac/install-uninstall.html
Finally!!!!
Answer: Was having the same problem with my new work mac, (oddly enough my old one did not do this) where I really am not supposed to be messing around with system files etc. and do occasionally need to use the app. It looks like as of yesterday(!?) the option to launch at startup or not, is finally a built in toggle in the menu app:
https://docs.citrix.com/en-us/citrix-workspace-app-for-mac/ear.html
Unfortunately the version on my mac is 23.01.1.60 (2301), and tells me there are no updates. Maybe in the next couple of days...


How did Odin give or lose the Tesseract?

Question: I'm confused about how the Tesseract can be in Thor if it was lost 600 years ago, as I know Asgard gave up the red Infinity Stone because they already had another Infinity Stone. What's going on?
Comment: https://marvelcinematicuniverse.fandom.com/wiki/T%C3%B8nsberg
Comment: What exactly are you asking?
Comment: In fact, the tesseract was lost for 1147 years! from 965 to 2012
Answer: The question is imprecise, as you didn't properly tag or indicate the Thor movie you are referencing. However, I believe you are talking about Thor: Ragnarok, where Hela passes by the Tesseract while pillaging Odin's vault.
The Tesseract was brought back by Thor in The Avengers, while also bringing Loki into custody. The Tesseract was thus locked in Odin's vault along with other artefacts. Later on, in Thor: The Dark World, the Asgardians manage to capture the entirety of the Ether; but they decide to entrust The Collector with it. They refuse to keep two Infinity Stones together because of the sheer dangerousness of the Stones.
Thus the Tesseract is kept within Odin's vault until Thor: Ragnarok, where it is stolen by Loki when escaping Asgard. Finally, Thanos comes to take it by force in Avengers: Infinity War.
For the record, the Tesseract does appear in the first Thor movie, in the stinger only. It was recovered by Howard Stark from the bottom of the ocean (where it landed in Captain America: The First Avenger) and given to the top-secret Project PEGASUS to be studied extensively. In Thor's stinger, a brain-washed Erik Selvig participates in Project PEGASUS while under Loki's influence, which directly ties into Avengers' opening sequence.
Comment: I believe that he confused *Thor* with *Captain America: the First Avenger*
Comment: @PeregrineLennert in this case, since Captain America happened before Thor, we can only assume the Tesseract was given to humanity as a gift by the Asgardians, because it was kept in a religious mural. But this is at best a guess ; Marvel (in)famously likes to avoid explaining the relationship between Norse mythology and MCU!Asgardians.
Comment: @Caelistis I believe Odin lost the Tesseract on Earth(Norway to be exact) during the battle with the Frost Giants. It was then found by Red Skull at the beginning of TFA.


Sync failed:-857 The remote database identified by remote ID '%1' is already synchronizing or the database connection is unusable:

Question: I am working with iOS native application in iOS using objective C and SUP as middleware .I am using the same provisioning profile for two fifferent application to run in iPAD.
My application was working well before . But now when I try to run it is showing an error like,
The remote database identified by remote ID '%1' is already synchronizing or the database connection is unusable: unable to access the lock for that remote ID
Error code  -10343
What can I do to solve this?
when I searched in google I got some informations like
'The MobiLink server could not access the lock for the remote ID in the consolidated database or the MobiLink system database. The remote ID may have been locked by another synchronization, or the database connection may be unusable. Please check the database connection and try the synchronization later.
Please help me ...Thanks for any help in advance...
'
Answer: I think this is because the database is locked by some applications.


Group theory - Finite or Infinite group

Question: I am just beginning to learn Group theory. As an example of finite groups our Professor wrote this group with just two elements, given by
$$
\left( \begin{array}{cc}
0 & z \\
z^{-1} & 0\end{array} \right),\:\:\:
\left( \begin{array}{cc}
z & 0 \\
0 & z^{-1}\end{array} \right)
$$
where $z \:\epsilon\:\mathbb{C} $. Here there infinitely as many values $z$ can take. I am quite confused why we call this a finite group. In general I wish to understand how exactly we find if a group is finite or infinite.
Answer: Your professor meant that you choose and fix a $z \in \mathbb{C}$. You have to choose a non zero $z$ to make sense of $z^{-1}$. Now consider those two elements, and call them $a$ and $b$.
EDIT: Following Berci's comment, you actually need $z$ to be a root of unity, i.e. $z$ should be such that $z^n=1$.
Then the group they generate is finite:
1) Show that both $a$ and $b$ have finite orders, using matrix multiplication.
2) Same way "see" the relation between $ab$ and $ba$ and try to conclude that the group must be a finite group.
Comment: Well, for many complex $z$, both $a$ and $b$ will have infinite order. In order to get finite group, $z$ has to be a root of unity.
Comment: @voldemort ,@Berci : So then, in my case with all generality, the group i have written down is of infinite order right ?
Comment: @user38249: yes in general it's an infinite group.
Comment: @Berci: Yes you are correct. :). Thanks.
Answer: To partially address your general question, whether or not a general group is finite can be a very hard problem. Just to whet your appetite, take a look at Burnside's problem, posed in 1902, which asked whether every group all of whose elements could be expressed as products of terms from a finite list, each of which has finite order, is finite. It took until 1964 to prove by counterexample that the answer is actually no! There are groups which are finitely generated and in which every element is of finite order but which are not finite.
Proving that a particular group is finite will often depend on techniques particular to the family to which it belongs or sometimes even ad hoc techniques. Although, most "sensible" examples will admit a "sensible" attack--in your class you may find that if you're asked as an exercise to prove a group is finite it may be easy enough to give a strategy for enumerating all the elements of the group and then prove that the algorithm eventually halts. This works, for example, for cyclic groups, permutation groups, matrix groups over finite fields, dihedral groups, etc. Proving that an infinite group is infinite is often easier, since most "sensible" examples of infinite groups will have at least one element of infinite order, despite the counterexamples to the Burnside problem.

Group theory - Finite or Infinite group


How to get advantage on all four ranged attacks in one round?

Question: Specifically, I want to attack 4 times with Eldritch Blast as a 17th level Warlock. What is the easiest and cheapest way to gain advantage on all 4 attacks?
Comment: You aren't using Eldritch Blast 4 times at Level 17. A single cast of Eldritch Blast produces 4 beams, each with a separate attack roll.
Comment: Incidentally, I'm pretty sure Enhance Ability doesn't grant advantage on attacks - attacks are not ability checks.
Comment: I am confuse. How on earth are you supposed to get four attacks as a Warlock? Did they have Extra Attacks in the playtest?
Comment: I was totally looking at the class, and forgot to look at the spell description.
Answer: The best way to do this - Have an ally cast Greater Invisibility on you. An Invisible attacker has advantage automatically, and with Greater Invisibility you can attack without losing the Invisibility. This will grant you advantage for as long as the spell persists.
Comment: @Miniman I'm sorry but I don't see how it makes logical sense to be able to negate invisibility but not its effects.
Comment: By a strict RAW reading of the Invisible condition, it doesn't actually matter whether the target can see through Invisibility or not. I can't guarantee your DM won't throw a book at your head if you tell him this, though.
Comment: "An invisible creature is impossible to see without the aid of magic or a special sense." Then, in an entirely separate dot point, with no connection drawn between the two: "Attack rolls against the creature have disadvantage, and the creature's attack rolls have advantage."
Comment: It doesn't say anything about negating the Invisible condition. And I said a RAW reading, not a logical one
Comment: Is that assuming your target does not have blind sight or tremor sense?
Comment: @Miniman How? By a strict reading, the invisible condition is negated by a "special sense," such as tremorsense, blindsight, or truesight.
Answer: TL;DR
Play a drow warlock, and take the eldritch invocation Devil's Sight. Faerie Fire grants advantage against any creature illuminated by it. Devil's Sight allows you to see in magical darkness, and the Darkness spell grants advantage.

Other ways of gaining advantage:
Being Unseen
From PH 194:

When a creature can't see you, you have advantage on attack rolls against it

Conditions
If any of these apply to your target then you will have advantage:

Blinded
Paralyzed
Petrified
Prone (and attacker within 5')
Restrained
Stunned
Unconscious

Class Abilities

Cleric with Trickery domain. At level 2 they can use Channel Divinity to create an illusionary double. If both you and your double are within 5' of the creature then you have advantage.
Paladin with Oath of Vengance. At level 3 they can use Channel Divinity for the Vow of Enmity that gives them advantage on attack rolls against 1 creature
Rogue with Assassin archetype. At level 3 they gain the Assassinate ability and have advantage on any attack rolls against creatures that haven't taken a turn in the combat yet

Spells
Any spell that inflicts one of the earlier conditions or causes you to become unseen (eg - Blindness/Deafness, Greater Invisiblitiy) will give you advantage.  These spells specifically grant advantage:

Faerie Fire
Foresight
Otto's Irresistable Dance
Comment: @briddums Yes; suggest you edit the opening paragraph to firmly state that it is "Faerie Fire and Pact with Archefey" or "Darkness and Devil's Sight."
Comment: Nice list, but one problem- Eldritch Blast is a ranged attack, so if you do it from 5' away the disadvantage will cancel out the advantage from Duplicity.
Comment: You can't cast Faerie Fire and Darkness at the same time; both take Concentration.
Comment: @Progredi You can't have 6 levels of Monk and 17 levels of Warlock, and Eldritch Blast isn't a melee attack.
Comment: I think you are missing one more.  Under class abilities of Monk under Monastic Traditions under Way of the Shadow at 6th level you get Shadow step and that gives you advantage if you use shadow step and use a melee attack on the same turn after the teleport.
Comment: @SirTechSpec Not a problem with the Crossbow Expert feat
Comment: @DrunkCynic Don't need to cast both Darkness and Faerie Fire at the same time. They're 2 different methods of getting advantage on attack rolls
Comment: @briddums True. I suggest adding that to your answer.
Answer: Ways to get advantage

Use inspiration
Have stealth
DM rules you have it because of something situational
target is suffering from a condition that grants advantage

Only reliable option: On a previous turn (yours or a party member's) someone will have needed to inflict a status like restrained on the target.
The only reliable way to have advantage for that many attacks is to be making them against a target that is restrained or paralyzed.
I find it highly unlikely that even if 4 members of the party had inspiration that they would give it up to you for the nova round you are trying to build. Stealth + your own point of inspiration is still only 2 attacks. DM fiat is too situational to rely on and even still would probably only net you 1 use of advantage.
Comment: Flanking doesn't really exist anymore. It's been reduced to "a rogue can sneak attack if an ally is beside the creature"
Comment: Flanking exists in 5e right? not sure the exact rules on it as I dont have my book near by. but if the enemy was flanked by the allies wouldnt all the attacks have advantage?
Comment: There are optional flaking rules in the PHB, but iirc it's only for melee attacks.
Answer: The cheapest method is to take the Devils Sight Invocation combined with a darkness creating spell, like Darkness or Hunger of Hadar.
Answer: If this is all you want your high level warlock to do is get advantage on eb - take 13 levels rogue(archane trickster) and use free action to slap your target with your mage hand to give you 4 eb's with advantage.
Comment: @DanHenderson If you're a 13/4 Rogue/Warlock, you're character level is 17, giving you 4 beams for Eldritch Blast.
Comment: How exactly are you supposed to have 13 levels of rogue when you're a 17th-level warlock?
Comment: @DrunkCynic ah, you're right, I missed that attribute of cantrips.
Answer: A familiar can 'Help' you granting advantage on your first attack roll.  The Owl seems the best at this.


Differential Pair routing insight for USB 2.0 circuit involving a USB C connector with multiple D_N and D_P pins

Question: I'm bringing USB 2.0 into a PCB design from a USB C receptacle. I've already accounted for the 5.1k resistors needed but I'm stumped on how best to run a differential pair with DP1, DP2, DN1 and DN2 on my PCB layout. I would appreciate any insight on how best to manage this. My prior experience has been with USB micro 2.0 with single lines of D_P and D_N. Do I tie them together with vias bridging on top and then perform a diff pair? Or do I connect both with a "U" loop and run a longer length with diff pair? I'll happily adjust my question if it is too vague. Thank you for any insight.
Comment: For USB 2.0 there is not too much pairing consideration to have as long as you don't go overboard.
Answer: Yes, you can tie both DP and DN signals together to form a single diff pair. At USB 2.0 speeds the way you tie them together is not very important. Of course you will always have a long nub in the form of the unused wire in the cable that can degrade the signal, especially with longer cables. You can get around this by using multiplexer ICs designed for this case such as the USB3740. With these chips you will need some way to recognize the USB C plug orientation and that can be done by looking at the CC lines or using another dedicated chip such as the UTC2000 which does this for you.


How to document changes to a project

Question: A company I work with uses a "skeleton" project as base scaffolding for each project they have.
I work on several edits to the skeleton. Some of them are few lines on huge source files. What's a good way to document all the edits I'm making?
Comment: At a minimum, write commit notes when you check-in into the version control.
Answer:
Follow your employer's policies on documenting the edits you make.
Follow the policies on documenting the edits you make on any specific projects that have different policies.  Generally, it's possible to do both of these, so you should do both.  There's only a conflict if one policy or the other tells you to not follow the other policy or the one.  In case of a conflict, the project generally wins, within the scope of the project's own files, and the employer generally wins outside of the scope of the project's own files.
If neither your employer nor your projects have policies on how you document the edits you make, come up with something that seems reasonable and suggest it.
If, by this point, you still don't have policies that direct how you document the edits you make, good luck, and you have my sympathy.  When I was in this situation (company chose to not have a policy), I tracked all of my changes in my own version control repository (because the company also chose to not have one of those) to the best of my ability and looked for other work.  But that's what I did; you are free to choose your own path.

How to document changes to a project


The tag [media] is used for both music / video as well as mediums?

Question: It seems that the media tag is ambiguously used. Sometimes it applies to music/video, and sometimes it applies to physical media like CDs.
What should we do with it?
Comment: Not sure about the terminology or how common it is, but would synonymizing `media` to `audio-video` or `audio-visual-media`, and retagging the others to `storage-media` work?
Comment: I hear 'media' used more commonly with entertainment/audio/video.
Answer: As always trying to see the humor in all this.
Media , this tag should not be used for media players, it should be used for the medium used and the media that a player might play.  Because 90% of questions about Media players are about playing media, off of a medium, it would still apply :-) .  The net is a medium, and most people tagging it media, want to use the medium to transport media , it would still apply.
If the terms seems ambiguously applied, it would be a fault of the English language, and how it has been bent to fit different ways.  To fix that would be to define the medium (singular), and the media (plural).  I really doubt that people picking tags are going to select medium, over media.
While I would agree that Storage-Medium , Media Files, Document Media , might separate the tags into less ambiguous terms, that isn't going to have anyone choosing them.
Media is not the news and tv, news and tv use media , and is a medium , an in-betweener. In the same way Mediums are in-between the live and the  dead. tv/radio got termed "The Media" , which doesn't make them media when there is only one. Properly stated A Media is still a Medium, although they don't necessarily talk to the dead. :-)
Media is the publications, and communications, and informations, pictures , sounds ,  proper singular term is actually medium again.  The storage area , be that paper or plastic or dvd or hard drive is actually also a medium, unless there are 2, then it is media.  Original Latin meaning Middle. I would extrapolate to the term being the "middle man", the medium by which things are transferred , making the WEB a medium, and the stuff going down it media.
For radio and tv, and web , media are the items that the information is stored on.  They purchased media for which to record.  so The Media buys media, now often using the medium of the web, which sends media to The Media, so they can make their choices.  Then this media is shipped via a medium, to The Media , who will use it to store media.  But they are buying media, because they are not buying a single medium. :-)
Or as the dictionary says:
the etymologically plural form media is often used as a singular to refer to a particular means of communication, as in This is the most exciting new media since television. This usage is widely regarded as incorrect; medium is preferred. A stronger case can be made in defense of the use of media as a collective term, as in The media has not shown much interest in covering the issue. As with the analogous words data and agenda, the originally plural form has begun to acquire a sense that departs from that of the singular: used as a collective term, media denotes an industry or community. Thus the example sentence given here would not be appropriately paraphrased as No medium has shown much interest in covering the issue, which suggests that the disinclination abides in the means of communication itself rather than in its practitioners. If media follows the pattern of data and agenda, this singular use may become entirely acceptable someday. But despite its utility, many people still regard it as a grammatical error.
The American Heritage® Dictionary of the English Language
My vote? change the world, re-write the English language, or leave it alone because it will be back.  Myself, I dont plan on caring about it being grammatically incorrect, it is like saying a Mac isnt a PC (personal computer) it doesn't mater as long as we know what your talking about.


How to handle delivery time slots that expire before purchase is complete?

Question:
I have an e-commerce web app where you can choose among multiple time slots for your delivery. There are some rules that depend on when the purchase is completed.
For instance, if I purchase something before 2:00 PM, I'm able to select same-day delivery.

Some customers might select same-day delivery when it's 1:55 PM, but as they continue through the checkout process, the 2:00 PM deadline is met, so their purchase is rejected.

How should I handle this situation?
Currently, whenever the user reaches the "select delivery time" step of the checkout process, backend sends all the possible time slots, according to the business logic at that moment.
I have a few ideas on mind (like allowing a 10-minute "grace period", or giving a detailed explanation when the purchase fails do to this reason), but since this seems to be a common problem, I would rather use an existing solution than re-inventing the wheel.
Comment: When they click the check out button, you need to validate their booking slot, if it is no longer valid then simply inform them the slot is no longer available and present them with alternative options.
Answer: This is a good finding and I appreciate considering a solution for your users. I had this issue with food ordering apps that were allowing me to order some food from a restaurant that closed at the same time I placed my order and as I was waiting for my ordered I got called and announced that the food won't be delivered.
You could move the time slot to the last step to minimise the time period from order start to order finish.
Another solution would be to disable the 2:00 delivery if the order is made from 13:45 on.
Answer: In this situation, the offer of the same day delivery is an 'exploding offer'. In other words once the time runs out the offer is no longer available.
To communicate clearly:

In the case where the user is at risk for a rejected same day delivery, you will need to warn the user of the remaining time left. When this is not a risk, this is less critical. How long does the form take on avg.? If user has 5 mins to fill out the whole form, it's possible you could have something like a a count down clock, within a non-modal dialogue. When the time passes, the user could be interrupted and asked to select a new delivery time, while keeping the remaining form saved in state. The Same day option is now removed, or disabled out with an explanation the time has expired.

In order to prevent rework:

In the case where the user is at risk and loses the time slot they have selected, you will want to save any unaffected information in the form so that the user doesn't have to fill out portions of the form again. EG: Don't make them refill the shipping destination again.
like your suggestion above. It makes sense if the user will not have enough time to complete the form, to remove the option entirely. If it takes the user 5 mins to complete the form, and the offer will expire within 4 mins when the user logs in, there is no need to display this option at all...or if the option is disabled, explain here it's too late in the day to opt for same day delivery.


i'm working in office and my office chair is damage. and i ask to my manger but he always ignore me. what to do

Question: I am working in an office. The office chair is damaged. I complained to my manager already but he ignored me deliberately. Every time I request to him to provide a new chair, he promises me today or tomorrow and so far 2 months have gone by but still has not replaced the chair. What should I do? Should I send an email to headoffice about chair? What should I write in that email?
Comment: You could swap your chair for his and see if he notices then...might not go over so well, but I doubt he would ignore you then.
Comment: The so-called "duplicate question" is not even remotely similar. He's not asking for brand new top of the line equipment, which was not even needed, which is what the other guy was asking for. He's asking for fixing an already broken chair, that has already been broken for the past two months.
Comment: Why the downvotes? Seems like a totally reasonable question to me (although likely a duplicate)
Answer: If it were me, I'd email the boss before I'd contact HQ.
Written requests usually get taken more seriously (since by implication, they can be forwarded to management by the original sender if they're not acted upon).

Dear Mr. XX,
As you know, my chair is broken. It has been broken since date Y. You've said I would get replacement chair the following week on date Y, date X, date W, and finally on date Z.
This broken chair is an occupational health and safety issue. Please order a replacement office chair for me.

Also, it may help if you've already done some of the research in the catalog yourself, to help expedite the ordering.

Below is a link to the exact chair that we usually order from our approved vendor ABC.
It's listed at $XX
Thank you,
John YY
PS: Attached is a picture of the currently broken chair in question.

That being said, if you believe that your relationship with your boss has already deteriorated to such a point, that he might fire you for sending such a message to him, then you might want to consider using a different strategy altogether.
Also, if the chair doesn't look broken from the picture alone, then don't send it. Only attach that picture if it obviously looks broken. This is not for your boss's benefit. This is in case that message needs to be forwarded to HR, or up the chain of command.
Comment: I'd maybe drop the paragraph about "having done anything to upset the boss" and add a statement that the broken chair is an occupational health and safety issue.
Comment: @HorusKol, Good call.


Apex batch - limit on the number of chunks

Question: According to Salesforce documentation for Apex Batch jobs, it is possible to query 50 million records by using Database.QueryLocator in the start method. Is there any limitation on the number of chunks of data? In other words, if the limit of rows is 50 million, Can I divide the data to be processed to 50 million chunks?
Answer: The chunk size depends on the API version. In API version 20.0 and earlier, the chunk size is 100 records. In API version 21.0 and later, the chunk size is 200 records.
Comment: How many chunks can I create? is that n number of chunks? or there is a limit. And with a limit, I do not mean the batch size but the number of chunks(baches) that can be created. I do not think that there are limits on the number of chunks but I want to make sure.
Comment: It depends in your Api version as i mentioned
Comment: by chunks, I do not mean the number of the records in each batch transaction, I mean the number of "chunks" that can be used to divide the whole data. For instance, if I need to process 10000 records I can use a batch and process everything in transactions of 5 chunks where every chunk has a size of 2000. My question is if there is a limitation on the number of chunks.
Comment: I think we have only limit is number of batches per day.This limit is 2000 batches per 24 hour .(On rolling basis)
Answer: I couldn't add a comment, so i'll just add it as an answer.
I think what you mean is scope and not chunks, which specifies the number of records to pass into the execute method, which is between 1 & 2000.
there is actually another Limitation, i would recommend you to check the Governor Limits


DALI - ARC Power Control Commands - What about them is 'ARC' related

Question: Commands used in DALI are described as ARC Power Control.  If I am Directing an LED fitting to a particular dimming level, what about the command has any relevance to an 'ARC' description.  Where does 'ARC' fit with the DALI protocol for Dimming a fitting?
New User ... Very impressed your resource... Thank you for it.
Answer: This term is a hangover from the original standard which was for fluorescent lamps only where it was used to differentiate between the power in the lamp and the power drawn from the supply by the ballast.
DALI started off as an annex to IEC60929 "A.C. supplied electronic ballasts for tubular fluorescent lamps - Performance Requirements" Annex E.4 - Control by Digital Signals. It is now IEC62386.
Subsequently, the standard has added support for many lamp types which do not use arcs to generate light, including low voltage halogen, incandescent and LED, but the term has remained for historical reasons.
Within IEC standards, terms not given in the definitions section should be found in Electropedia.
Comment: Thanks Martin,  So the ARC part would have been referring ot the amount of power drawn by the ballast?  And now just really refers to the dimming level that the fitting would be directed to go to.  True .... ?
Comment: No, the arc power is in the lamp, since that's where the arc is. You wouldn't want to control the power in the ballast, that is an unavoidable side effect of having to drive the lamp.


Red and blue chameleon

Question: I want to say there's a chameleon which is sometimes red and sometimes blue. I can express it as 'there's a chameleon sometimes red and sometimes blue,' but can I also express it as 'there's a red and blue chameleon'?
Comment: Your first sentence (including _which is_) is the best. _Red and blue_ implies that it is both colours at once.
Comment: You could also indicate that it's not red and blue at the same time by saying "there's a chameleon that changes between red and blue".
Answer: "The chromatophores in this chameleon's skin can alternate between red and blue hues."
This gives the reader more information about the mechanism chameleons use to change colors, as well as indicating that the red and blue colors are not produced simultaneously.
Fascinating information here about chromatophores in frogs, lizards and fish (vertebrates) and in invertebrates like octopi, cuttlefish and other cephalopods.

Red and blue chameleon


SVM Working in information retreival

Question: I have some URLs and i have to extract some features from these URLs to filter out some desired URLs. I have to give input those filtered URLs to SVM so as to classify those URLs as relevant and irrelevant. What will be the exact input to SVM?
Comment: can svm be used for feature selection?
Answer: You would probably need to use an XML reader and Natural Language Programming techniques to create features from the data which would be useful in determining relevancy.  You would also have to label the URLs as relevant or irrelevant.
Both the class labels and the features would be the input into your [SVM].

SVM Working in information retreival


What could cause a loud clunking sound when I turn on the hot water in my shower?

Question: When I turn on the hot water in my shower there is a loud clunking sound. I'm afraid the vibration may cause a joint to loosen and leak. Any idea as to why this is happening and what I can do to correct it?  The house is 57 years old and I think the plumbing is original.  Thanks.
Answer: Sounds like a classic case of a "water hammer".
http://en.wikipedia.org/wiki/Water_hammer
If you have access to the feed line anywhere (even in the basement) you should be able to confirm the hammering by placing a hand on the line when someone else turns on/off the faucet.  You will feel the line kick at the moment you hear the sound.
One fix is to install a cushion (foam, rubber, etc) around the pipe where it makes contact with the joist or nearby wood, or add additional hangers onto the pipe to prevent the line from moving freely.  It's also possible to install a "hammer arrester" which contains a small diaphragm which prevents the water flow from stopping suddenly.
Answer: Classic water hammer prevention was simply a vertical deadend that permanently trapped air to cushion rapid pressure changes. It can be installed anywhere in the system that is easily accessed
Comment: Can you explain how to install it? I've heard that the air can be absorbed into the water over time, leaving the pipe full of water instead of air. Is this true?


Measuring the pressure

Question: I need to determine the pressure existing in a liquid in order to calibrate a pressure transducer. Does anyone know which instrument we can use to detect a pressure of a slowly flowing liquid? For example, imagine  I am applying a pressure to a liquid through the piston of a syringe and I need to determine the pressure existing inside the barrel of the syringe (in the liquid). I should be able to detect pressure ranging from 2-30 mmHg. If anyone got any clue, please share your knowledge. Just the name of the instrument/instruments enough for me to dig out information.
Comment: Did you google "pressure meter"?
Answer: It appears that you want to calculate gauge pressure in the liquid - ie relative to the surrounding atmospheric pressure (which can vary).
A simple method for calibrating the transducer is to immerse it in a known depth $h$ mm of water. The gauge pressure is then $h/13.56$ mmHg. 13.56 is the relative density of mercury compared with water.
However this does assume that the atmospheric pressure is the same when measuring as it was during calibration, so you will need to apply a correction for any difference. You can measure atmospheric pressure with a manometer.
Comment: The way you suggested is short and sweet. That is simple and easily doable. Thanks for sharing your idea. I appreciate it!

Measuring the pressure


VNC Suddenly stops receiving Connections

Question: I have a fit PC that essentially runs just a subversion server and as a test server for web applications.  I upgraded a while back to 10.04 LTS and no issues.  I don't have any keyboard or monitor installed on it, I just access the desktop through VNC, and while a little slow, it works perfectly fine.
Suddenly, today, I'm having an issue accessing Subversion.  I tried to VNC to the machine, but it's refusing connections.
I've SSH into the server and reboot, but still no dice.  I can manage OK (usually) on my own with the desktop, but I don't use the terminal very often, so I'm kind of stuck now and hoping someone has an idea...
I can confirm that the VNC Server is being started at startup.  I run netstat and can see the following:
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
<code>Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:5901            0.0.0.0:*               LISTEN      4261/Xtightvnc
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:6000            0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:6001            0.0.0.0:*               LISTEN      4261/Xtightvnc
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:60888           0.0.0.0:*               LISTEN      -
tcp6       0      0 :::80                   :::*                    LISTEN      -
tcp6       0      0 :::6000                 :::*                    LISTEN      -
tcp6       0      0 :::22                   :::*                    LISTEN      -
tcp6       0      0 ::1:631                 :::*                    LISTEN      -
</code>
Which I presume to mean VNC is listening to port 5901.
Don't know what else to do from here.  Any help would be appreciated.
Answer: OK, so I seem to have resolved this.  The Subversion error was indicating a lack of disk space, which made no sense because I couldn't figure out where all the space was going.
Turns out there was a hidden file that was 110GB. The file was .xsession-errors and was FILLED with lines like such:
11/01/2012 07:38:23 AM Authentication deferred - ignoring client message
It had been outputting about 13000+ per SECOND.  I cleared the file and rebooted and subversion came back to life as did VNC.
While I haven't solved WHY this happened, I am at least temporarily, able to work.


How do I change the size of figures drawn with Matplotlib?

Question: How do I change the size of figure drawn with Matplotlib?
Comment: These questions are similar and may be of interest [Specify figure size in centimeter in matplotlib](https://stackoverflow.com/q/14708695/7758804) and [Specifying and saving a figure with exact size in pixels](https://stackoverflow.com/q/13714454/7758804)
Answer: figure tells you the call signature:
from matplotlib.pyplot import figure

figure(figsize=(8, 6), dpi=80)

figure(figsize=(1,1)) would create an inch-by-inch image, which would be 80-by-80 pixels unless you also give a different dpi argument.
Answer: If you've already got the figure created, you can use figure.set_size_inches to adjust the figure size:
fig = matplotlib.pyplot.gcf()
fig.set_size_inches(18.5, 10.5)
fig.savefig('test2png.png', dpi=100)

To propagate the size change to an existing GUI window, add forward=True:
fig.set_size_inches(18.5, 10.5, forward=True)

Additionally as Erik Shilts mentioned in the comments you can also use figure.set_dpi to "[s]et the resolution of the figure in dots-per-inch"
fig.set_dpi(100)

Answer: Using plt.rcParams
There is also this workaround in case you want to change the size without using the figure environment. So in case you are using plt.plot() for example, you can set a tuple with width and height.
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (20,3)

This is very useful when you plot inline (e.g., with IPython Notebook). As asmaier noticed, it is preferable to not put this statement in the same cell of the imports statements.
To reset the global figure size back to default for subsequent plots:
plt.rcParams["figure.figsize"] = plt.rcParamsDefault["figure.figsize"]

Conversion to cm
The figsize tuple accepts inches, so if you want to set it in centimetres you have to divide them by 2.54. Have a look at this question.
Answer:
Deprecation note:
As per the official Matplotlib guide, usage of the pylab module is no longer recommended. Please consider using the matplotlib.pyplot module instead, as described by this other answer.

The following seems to work:
from pylab import rcParams
rcParams['figure.figsize'] = 5, 10

This makes the figure's width 5 inches, and its height 10 inches.
The Figure class then uses this as the default value for one of its arguments.
Answer: In case you're looking for a way to change the figure size in Pandas, you could do:
df['some_column'].plot(figsize=(10, 5))

where df is a Pandas dataframe. Or, to use an existing figure or axes:
fig, ax = plt.subplots(figsize=(10, 5))
df['some_column'].plot(ax=ax)

If you want to change the default settings, you could do the following:
import matplotlib

matplotlib.rc('figure', figsize=(10, 5))

For more details, check out the docs: pd.DataFrame.plot.
Answer: The first link in Google for 'matplotlib figure size' is AdjustingImageSize (Google cache of the page).
Here's a test script from the above page. It creates test[1-3].png files of different sizes of the same image:
#!/usr/bin/env python
"""
This is a small demo file that helps teach how to adjust figure sizes
for matplotlib

"""

import matplotlib
print "using MPL version:", matplotlib.__version__
matplotlib.use("WXAgg") # do this before pylab so you don'tget the default back end.

import pylab
import numpy as np

# Generate and plot some simple data:
x = np.arange(0, 2*np.pi, 0.1)
y = np.sin(x)

pylab.plot(x,y)
F = pylab.gcf()

# Now check everything with the defaults:
DPI = F.get_dpi()
print "DPI:", DPI
DefaultSize = F.get_size_inches()
print "Default size in Inches", DefaultSize
print "Which should result in a %i x %i Image"%(DPI*DefaultSize[0], DPI*DefaultSize[1])
# the default is 100dpi for savefig:
F.savefig("test1.png")
# this gives me a 797 x 566 pixel image, which is about 100 DPI

# Now make the image twice as big, while keeping the fonts and all the
# same size
F.set_size_inches( (DefaultSize[0]*2, DefaultSize[1]*2) )
Size = F.get_size_inches()
print "Size in Inches", Size
F.savefig("test2.png")
# this results in a 1595x1132 image

# Now make the image twice as big, making all the fonts and lines
# bigger too.

F.set_size_inches( DefaultSize )# resetthe size
Size = F.get_size_inches()
print "Size in Inches", Size
F.savefig("test3.png", dpi = (200)) # change the dpi
# this also results in a 1595x1132 image, but the fonts are larger.

Output:
using MPL version: 0.98.1
DPI: 80
Default size in Inches [ 8.  6.]
Which should result in a 640 x 480 Image
Size in Inches [ 16.  12.]
Size in Inches [ 16.  12.]

Two notes:

The module comments and the actual output differ.

This answer allows easily to combine all three images in one image file to see the difference in sizes.
Answer: Adjust the figsize= parameter in matplotlib.pyplot.figure, which is similar to this answer, but uses the standard plt import alias, and doesn't directly import figure from the pyplot namespace.
import numpy as np
import matplotlib.pyplot as plt

N = 50
np.random.seed(2022)  # creates a repetitive sample data
x = np.random.rand(N)
y = np.random.rand(N)
area = np.pi * (15 * np.random.rand(N))**2

fig = plt.figure(figsize=(10, 10))
plt.scatter(x, y, s=area, alpha=0.5)
plt.show()

Without fig = plt.figure(figsize=(10, 10))

With fig = plt.figure(figsize=(10, 10))
Answer: You can simply use (from matplotlib.figure.Figure):
fig.set_size_inches(width,height)

As of Matplotlib 2.0.0, changes to your canvas will be visible immediately, as the forward keyword defaults to True.
If you want to just change the width or height instead of both, you can use
fig.set_figwidth(val) or fig.set_figheight(val)
These will also immediately update your canvas, but only in Matplotlib 2.2.0 and newer.
For Older Versions
You need to specify forward=True explicitly in order to live-update your canvas in versions older than what is specified above. Note that the set_figwidth and set_figheight functions don't support the forward parameter in versions older than Matplotlib 1.5.0.
Answer: This works well for me:
from matplotlib import pyplot as plt

F = plt.gcf()
Size = F.get_size_inches()
F.set_size_inches(Size[0]*2, Size[1]*2, forward=True) # Set forward to True to resize window along with plot in figure.
plt.show() # Or plt.imshow(z_array) if using an animation, where z_array is a matrix or NumPy array

This forum post might also help: Resizing figure windows
Answer: Comparison of different approaches to set exact image sizes in pixels
This answer will focus on:

savefig: how to save to a file, not just show on screen
setting the size in pixels

Here is a quick comparison of some of the approaches I've tried with images showing what the give.
Summary of current status: things are messy, and I am not sure if it is a fundamental limitation, or if the use case just didn't get enough attention from developers. I couldn't easily find an upstream discussion about this.
Baseline example without trying to set the image dimensions
Just to have a comparison point:
base.py
#!/usr/bin/env python3

import sys

import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl

fig, ax = plt.subplots()
print('fig.dpi = {}'.format(fig.dpi))
print('fig.get_size_inches() = ' + str(fig.get_size_inches())
t = np.arange(-10., 10., 1.)
plt.plot(t, t, '.')
plt.plot(t, t**2, '.')
ax.text(0., 60., 'Hello', fontdict=dict(size=25))
plt.savefig('base.png', format='png')

Run:
./base.py
identify base.png

Outputs:
fig.dpi = 100.0
fig.get_size_inches() = [6.4 4.8]
base.png PNG 640x480 640x480+0+0 8-bit sRGB 13064B 0.000u 0:00.000

My best approach so far: plt.savefig(dpi=h/fig.get_size_inches()[1] height-only control
I think this is what I'll go with most of the time, as it is simple and scales:
get_size.py
#!/usr/bin/env python3

import sys

import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl

height = int(sys.argv[1])
fig, ax = plt.subplots()
t = np.arange(-10., 10., 1.)
plt.plot(t, t, '.')
plt.plot(t, t**2, '.')
ax.text(0., 60., 'Hello', fontdict=dict(size=25))
plt.savefig(
    'get_size.png',
    format='png',
    dpi=height/fig.get_size_inches()[1]
)

Run:
./get_size.py 431

Outputs:
get_size.png PNG 574x431 574x431+0+0 8-bit sRGB 10058B 0.000u 0:00.000

and
./get_size.py 1293

Outputs:
main.png PNG 1724x1293 1724x1293+0+0 8-bit sRGB 46709B 0.000u 0:00.000

I tend to set just the height because I'm usually most concerned about how much vertical space the image is going to take up in the middle of my text.
plt.savefig(bbox_inches='tight' changes image size
I always feel that there is too much white space around images, and tended to add bbox_inches='tight' from:
Removing white space around a saved image
However, that works by cropping the image, and you won't get the desired sizes with it.
Instead, this other approach proposed in the same question seems to work well:
plt.tight_layout(pad=1)
plt.savefig(...

which gives the exact desired height for height equals 431:

Fixed height, set_aspect, automatically sized width and small margins
Ermmm, set_aspect messes things up again and prevents plt.tight_layout from actually removing the margins... this is an important use case that I don't have a great solution for yet.
Asked at: How to obtain a fixed height in pixels, fixed data x/y aspect ratio and automatically remove remove horizontal whitespace margin in Matplotlib?
plt.savefig(dpi=h/fig.get_size_inches()[1] + width control
If you really need a specific width in addition to height, this seems to work OK:
width.py
#!/usr/bin/env python3

import sys

import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl

h = int(sys.argv[1])
w = int(sys.argv[2])
fig, ax = plt.subplots()
wi, hi = fig.get_size_inches()
fig.set_size_inches(hi*(w/h), hi)
t = np.arange(-10., 10., 1.)
plt.plot(t, t, '.')
plt.plot(t, t**2, '.')
ax.text(0., 60., 'Hello', fontdict=dict(size=25))
plt.savefig(
    'width.png',
    format='png',
    dpi=h/hi
)

Run:
./width.py 431 869

Output:
width.png PNG 869x431 869x431+0+0 8-bit sRGB 10965B 0.000u 0:00.000

and for a small width:
./width.py 431 869

Output:
width.png PNG 211x431 211x431+0+0 8-bit sRGB 6949B 0.000u 0:00.000

So it does seem that fonts are scaling correctly, we just get some trouble for very small widths with labels getting cut off, e.g. the 100 on the top left.
I managed to work around those with Removing white space around a saved image
plt.tight_layout(pad=1)

which gives:
width.png PNG 211x431 211x431+0+0 8-bit sRGB 7134B 0.000u 0:00.000

From this, we also see that tight_layout removes a lot of the empty space at the top of the image, so I just generally always use it.
Fixed magic base height, dpi on fig.set_size_inches and plt.savefig(dpi= scaling
I believe that this is equivalent to the approach mentioned at: https://stackoverflow.com/a/13714720/895245
magic.py
#!/usr/bin/env python3

import sys

import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl

magic_height = 300
w = int(sys.argv[1])
h = int(sys.argv[2])
dpi = 80
fig, ax = plt.subplots(dpi=dpi)
fig.set_size_inches(magic_height*w/(h*dpi), magic_height/dpi)
t = np.arange(-10., 10., 1.)
plt.plot(t, t, '.')
plt.plot(t, t**2, '.')
ax.text(0., 60., 'Hello', fontdict=dict(size=25))
plt.savefig(
    'magic.png',
    format='png',
    dpi=h/magic_height*dpi,
)

Run:
./magic.py 431 231

Outputs:
magic.png PNG 431x231 431x231+0+0 8-bit sRGB 7923B 0.000u 0:00.000

And to see if it scales nicely:
./magic.py 1291 693

Outputs:
magic.png PNG 1291x693 1291x693+0+0 8-bit sRGB 25013B 0.000u 0:00.000

So we see that this approach also does work well. The only problem I have with it is that you have to set that magic_height parameter or equivalent.
Fixed DPI + set_size_inches
This approach gave a slightly wrong pixel size, and it makes it is hard to scale everything seamlessly.
set_size_inches.py
#!/usr/bin/env python3

import sys

import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl

w = int(sys.argv[1])
h = int(sys.argv[2])
fig, ax = plt.subplots()
fig.set_size_inches(w/fig.dpi, h/fig.dpi)
t = np.arange(-10., 10., 1.)
plt.plot(t, t, '.')
plt.plot(t, t**2, '.')
ax.text(
    0,
    60.,
    'Hello',
    # Keep font size fixed independently of DPI.
    # https://stackoverflow.com/questions/39395616/matplotlib-change-figsize-but-keep-fontsize-constant
    fontdict=dict(size=10*h/fig.dpi),
)
plt.savefig(
    'set_size_inches.png',
    format='png',
)

Run:
./set_size_inches.py 431 231

Outputs:
set_size_inches.png PNG 430x231 430x231+0+0 8-bit sRGB 8078B 0.000u 0:00.000

So the height is slightly off, and the image:

The pixel sizes are also correct if I make it 3 times larger:
./set_size_inches.py 1291 693

Outputs:
set_size_inches.png PNG 1291x693 1291x693+0+0 8-bit sRGB 19798B 0.000u 0:00.000

We understand from this however that for this approach to scale nicely, you need to make every DPI-dependant setting proportional to the size in inches.
In the previous example, we only made the "Hello" text proportional, and it did retain its height between 60 and 80 as we'd expect. But everything for which we didn't do that, looks tiny, including:

line width of axes
tick labels
point markers

SVG
I could not find how to set it for SVG images, my approaches only worked for PNG, e.g.:
get_size_svg.py
#!/usr/bin/env python3

import sys

import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl

height = int(sys.argv[1])
fig, ax = plt.subplots()
t = np.arange(-10., 10., 1.)
plt.plot(t, t, '.')
plt.plot(t, t**2, '.')
ax.text(0., 60., 'Hello', fontdict=dict(size=25))
plt.savefig(
    'get_size_svg.svg',
    format='svg',
    dpi=height/fig.get_size_inches()[1]
)

Run:
./get_size_svg.py 431

And the generated output contains:
<svg height="345.6pt" version="1.1" viewBox="0 0 460.8 345.6" width="460.8pt"

And identify says:
get_size_svg.svg SVG 614x461 614x461+0+0 8-bit sRGB 17094B 0.000u 0:00.000

And if I open it in Chromium 86 the browser debug tools mouse image hover confirm that height as 460.79.
But of course, since SVG is a vector format, everything should in theory scale, so you can just convert to any fixed sized format without loss of resolution, e.g.:
inkscape -h 431 get_size_svg.svg -b FFF -e get_size_svg.png

gives the exact height:

I use Inkscape instead of ImageMagick's convert here because you need to mess with -density as well to get sharp SVG resizes with ImageMagick:

https://superuser.com/questions/598849/imagemagick-convert-how-to-produce-sharp-resized-png-files-from-svg-files/1602059#1602059
How to convert a SVG to a PNG with ImageMagick?

And setting <img height="" on the HTML should also just work for the browser.
It was tested on matplotlib 3.2.2.
Answer: Generalizing and simplifying psihodelia's answer:
If you want to change the current size of the figure by a factor sizefactor:
import matplotlib.pyplot as plt

# Here goes your code

fig_size = plt.gcf().get_size_inches() # Get current size
sizefactor = 0.8 # Set a zoom factor
# Modify the current size by the factor
plt.gcf().set_size_inches(sizefactor * fig_size)

After changing the current size, it might occur that you have to fine tune the subplot layout. You can do that in the figure window GUI, or by means of the command subplots_adjust
For example,
plt.subplots_adjust(left=0.16, bottom=0.19, top=0.82)

Answer: This resizes the figure immediately even after the figure has been drawn (at least using Qt4Agg/TkAgg - but not Mac OS X - with Matplotlib 1.4.0):
matplotlib.pyplot.get_current_fig_manager().resize(width_px, height_px)

Answer: I usually care more about the relative sizes of height/width rather than the actual values in inches. So, I use plt.figaspect() to set the aspect ratio.
# Make the image 3x as wide as it is tall
fix, ax = plt.subplots(figsize=plt.figaspect(1/3))
plt.title("I'm 3x as wide as I am tall")
plt.show()

Answer: I always use the following pattern:
x_inches = 150*(1/25.4)     # [mm]*constant
y_inches = x_inches*(0.8)
dpi = 96

fig = plt.figure(1, figsize = (x_inches,y_inches), dpi = dpi, constrained_layout = True)

With this example you are able to set figure dimensions in inches or in millimetres. When setting constrained_layout to True, plots fill your figure without borders.
Answer: You can also set the default size of figures in a custom style sheet used with matplotlib.style.use. In your .mplstyle file, include a line setting rcParams['figure.figsize']:
figure.figsize : 8, 6

The space between the numbers is optional, and you can use integers or floating-point.
Then, call use before creating the plot, ex. if your style file is my_style_file.mplstyle in the same directory:
matplotlib.style.use('my_style_file.mplstyle')

The numbers in the style file (8 and 6 in my example) are equivalent to the numbers you'd supply in the figsize argument: plt.figure(... figsize = (8,6) ...), but the behavior will be similar to setting rcParams['figure.figsize'] at the beginnining of the file, i.e., every new figure will be that size without needing to specify the size in every new figure.


Can I find which search terms my photos in Google+ will respond to?

Question: When performing a search in Google Plus, magically queries for "beach, jewelry, etc." show relevant photos from your own library. I'd like to see all of the search terms each of my photos will respond to. Is this possible via the API or using any other means?
Answer: There is not a library for accessing your stream data and content shared with you because some of this data is private and Google+ search only returns public data. If your content is public, you can use the activities.search API to perform searches against Google+ but this cannot be personalized to your particular stream or scoped to a specific user.


Groceries left out on the counter

Question: I accidentally left my groceries out on the counter for an hour. Some frozen fish and frozen fruits and vegetables. Are they still good? Especially the fish?
Comment: Missing information: how long was the time between taking them out of the grocer's fridge and plunking them on the counter?
Comment: Possible duplicate of [How do I know if food left at room temperature is still safe to eat?](http://cooking.stackexchange.com/questions/34670/how-do-i-know-if-food-left-at-room-temperature-is-still-safe-to-eat)
Answer: It's all still safe, given that it was only an hour. Even very perishable food like fish and meat is safe for 2-4 hours in the danger zone (above 40F/5C), so even if it had fully thawed it'd be okay. If it was all still clearly frozen on the surface, you have absolutely nothing to worry about.
If some of it was thawed on the surface, it's still okay, but note that the time limit in the danger zone is cumulative. So in that case, when you do use it, I'd be sure to avoid letting it sit out thawed before cooking, or after cooking. But it would all still be fine.
All you really have to worry about here is quality. If things thawed significantly, and then you refreeze them, the texture will suffer. Things are likely to get mushier, especially vegetables. They'll still be safe, just not as good. So if anything seems to have thawed, I'd try to use it immediately instead of refreezing.
Answer: If every thing is still cold you should be ok. If the fish is still a little frozen you can go ahead and put it in the freezer. If it is completely thawed I would eat it with in a couple of days.
Answer: you don't say how frozen/defrosted the fish is. Here is a guide to shelf life which could help.  Your fruits will, if defrosted and then re-frozen be a bit more mushy and possibly watery when defrosted again.
Your fish however is another matter, if it has de-frosted do not re-freeze.  Here is a statement from the above site. 'Finally, if you thawed the fish fillets on the counter or in hot water, you shouldn't eat them at all. The USDA cautions that it's dangerous to eat any fish that's been thawed under those two methods, as the outer layer of the food would have been allowed to sit between the bacteria-breeding temperatures of 40° F and 140° F for far too long to be safe.'  Also 'Refreezing is not an option, though, if the fish wasn't thawed in the refrigerator to begin with.'.
Answer: During an ice storm, in 2009, we had no electricity for 2 weeks. A friend made it to my house to run a generator for me, to keep my frozen foods from going bad, and I wondered if it was all OK.  I was told by the local farm bureau and food safety people that if it is still COLD, but thawed, it can be refrozen. Look closely for any ice still left- any signs of still being partially frozen. As said above, texture may be not prime, but it is food safety to be concerned about.  If not still very cold, cook immediately, or throw away. Any foods such as fish or meats should then be cooked well done, to add another measure of safety.
I cooked some of my frozen foods in my wood furnace, threw a little away, but most made it.

Groceries left out on the counter