Checking for Continuous function

Question: I have the below question, i understand how to check for continuity for individual equations in a piecewise function but i dont understand how to find continuity for the whole function with only 1 inequalitygiven, could someone explain
Answer: The functions $f(x)=400x$ and $g(x)=600x-0.2x^2$ are continuous functions because they are polynomial functions (polynomial functions are continuous everywhere). So, the function $P(x)$ is continuous everywhere on its domain except that we should check the point where those two functions, $f(x)$ and $g(x)$, meet (if they don't meet, there will be some sort of gap or hole at the point where they're supposed to meet). If they meet at the point $x=1000$ (the only point in the domain of $P(x)$ that's most likely to make it discontinuous), then the function $P(x)$ is going to be continuous at that point and thus everywhere on its domain. So, if the following equality is true, $P(x)$ is continuous over $[500,2000]$ (otherwise it's going to be discontinuous over $[500,2000]$):
$$
f(1000)=g(1000)\implies\\
400\cdot 1000 = 600 \cdot 1000 - 0.2 \cdot 1000^2\implies\\
400000=400000\implies true
$$
Therefore, $P(x)$ is continuous over $[500,2000]$.
Answer: How is this different from the piece-wise functions you know how to check?
$P(x)$ is continuous over the interval $(500,1000)$ because polynomials are continuous.
Same thing for the interval $(1000,2000)$
That leaves one point left to check.
$P(x)$ is continuous if
$\lim_\limits{x\to 1000^-} P(x) = \lim_\limits{x\to 1000^+} P(x) = P(1000)$
Answer: It is indeed, continuous.
It is easy to check that the function is continous for each of the partitions [500,1000] and (1000, 2000). The "trouble" part is where x = 1000. You can see that  400(1000) = 400,000 = 600*(1000) - .2(1000)^2. The RHS of that expression is precisely the limit of the second part when iot approaches 1000 by the right. (sorry for not posting in LateX).

Checking for Continuous function


Do I need to keep twisted pair ethernet wires consistent down the entire cable?

Question: I have an ethernet cable that is hooked up to a 20 foot long 24 AWG twisted pair cable. The twisted pairs are not twisted to the same wires like in the ethernet cable. Would this be a problem? I imagine that it could be, considering that the signal between the wires is differential.
Edit: Both the number of twists, and the wires aren't twisted with the same wire on each cable. I will take both as an answer.
Additionally, there are 6 different breaks in the cable connected by terminal blocks. I am unsure if this will cause significant reflections or differences in resistance?
Comment: Some answers assume you mean that the amount of twist for each pairs isnt the same as the ethernet cable, while others assume you mean that one wire from one ethernet pair is twisted with another wire from another ethernet pair - which is it?
Comment: It may be a problem or not. It fully depends on for what you use it for. It definitely is not a good idea though. What do you use the cable for?
Answer: Three things to check:

(1) Are the pairs done up as... pairs?
(2) Are the characteristics of your 24AWG twisted-pair consistent with Cat5e (same differential impedance, reasonable loss / crosstalk, etc.)
(3) Do the pairs in your 24AWG cable have differing twist rates to reduce inter-pair crosstalk?

For (1), pair-wise connection is essential. Fix this first: make the wiring pair-to-pair. It will not work otherwise. If your cable uses punch-down connection this should be easy to fix.
For (2), this will depend on your required cable run length. The longer the run, the more important this will be owing to losses in the cable. While 20' is pretty long, 10/100 is pretty forgiving. 24 AWG twisted-pair is typically in the 100 ohm range anyway, even if it's not specified as impedance controlled. Toss-up.
For (3), this is again length-dependent. And again, 20' is kind of on the long side. Also a toss-up.
This all said, is it a big problem to secure an actual by-dog Cat5e cable for your run, lest there be any question of your link signal integrity? Cat5e wire is cheap; downtime not so much.
If you're facing pushback on getting the right Cat5e cable for the 20' run, get access to a network cable tester to evaluate the quality of the overall cable plant. This rules out any guesswork on your part.
Comment: For (1), it most likely *will* work otherwise -- but it won't enumerate at 1Gbps, and probably won't even do 100.  10 is robust enough to run on wet string (literally), I would be shocked if it doesn't work at all. It's tricky, because just getting a light on the port, and a connection on the network, can make it seem successful, but the proof comes when testing the actual link quality (bandwidth).  This also affects immunity to ambient noise, and testing in a quiet location (the usual case) can be similarly misleading.
Comment: Almost no one uses 10M anymore. OP didn't provide details, but I'm guessing they're trying to repurpose some as-is existing plant wiring (maybe old telco wire or suchlike.) Getting the pairs right is an easy problem to solve. That said, the mere threat of getting a tester would be enough motivation to get the electrical contractor to do their job and provision a correct Ethernet wire pull.
Comment: Unless 10M has been widely deprecated and I'm not aware (which is possible--I don't work in networking), it's possible they get a connection, and don't realize possible issues until they're later uncovered (at which point this question will be long forgotten). That's all I was thinking. Definitely, it needs to be done right.
Answer: AFAIK, the amount of twist isn't specified anywhere, other than all four pairs should have different rates of twist.  The big problem would be the impedance mismatch, assuming your 24 AWG cable is not 100-ohm or not specified; and the step change in impedance at the junction between the two.  10/100 can be surprisingly forgiving though so you might be able to make it work but I wouldn't trust it to anything critical.
Edit: and yes, as @BeB00 says, if the wires aren't twisted to the same pairs (e.g. Rx+ twisted to Tx+) then I wouldn't even bother trying.
Answer: Yes, that is a big problem - being untwisted would be very bad, but being twisted with the wrong pairs is extremely bad. The signals are differential to each other - there are 4 pairs of signals, and each pair has a plus and a minus. When the plus switches, the minus switches in the opposite direction, to cancel out emi and reduce interference. If you twist the plus from one pair to a signal from another pair, you remove all the benefits of the twisting, and add extra problems, like the wires interfering with each other. I wouldn't be surprised if this is a big problem for even the slowest common type of Ethernet.
Answer:
The twisted pairs are not twisted to the same wires like in the
ethernet cable. Would this be a problem?

The bigger question is whether the cable characteristic impedances are the same.
If they are the same then having a different twist length isn't going to be a significant problem. If the cable characteristic impedances are different then you might hit significant problems.
Answer: Depends on how long the cable is untwisted for. I had a prototype that I bought a female ethernet extension cable to use for the already made female termination on one end and it had straight wire in it! I used the straight wire for 2 feet. It worked fine but I would not use this in a normal product.
That being said, CAT 5 runs at 100MHz, which is a wavelength of ~120in or 3m. So a small fraction of this is probably not going to create an issue because if you create a stub that is a small fraction (like 1/5th) it's probably not going to create reflections. You'll also get some attenuation and the wire will be more succeptable to noise because you are making the loop area between wires larger.
Comment: the question says 20 feet, but I think that it also means that the wrong pairs are twisted - waiting on clarification from OP though
Comment: It says 2o feet so yeah, waiting on clarification


Our company needs to conduct an audit of a large ASP.NET solution that was developed for us by a development company.

Question: What professional standards and practices are recommended for guiding such an effort?
Comment: Hire someone who knows what they are doing.
Comment: If we're going to go the route of suggesting hiring someone, I think it would be useful to post qualities to look for in a company you're going to hire to do the audit.
Answer: As mentioned in the comments, likely for this the best option would be to get in an external company with expertise in this area, if it's something your organisation doesn't have experience of.  That said there's several things you could consider in terms of what you want to get from the review which could help you get the right company and commission the right piece of work, some things to consider :-

Are there any specific concerns you have with the application?  Are you worried about back door code, or is it more that you're interested in general security good practice.  Reviewing for back doors is pretty tricky as it can be very hard for automated tools to find them and manual review of large codebases is expensive.
Have you reviewed the processes that the development company used to write the application?  For ASP.NET a common approach would be to follow Microsoft SDL.  If the company used something like this there should be documentation they can provide you around the output of their internal code reviews, threat(risk) modelling and the like.  It's not a guarantee but if they've got a good internal process it's more likely that the application will have a decent level of security.
Do you want the 3rd party review company to do a code review (white-box) assessment, or a more traditional web application test which is usually more of a black-box affair?
Are there any regulatory concerns (eg, PCI).  Things like that can help frame a minimum level of security that the application should have and focus the assessment.
Answer: Good place to start is OWASP project. In this case I think that OWASP ASVS may come in handy. You can verify your application on L2A or L2B level since you have access to source code.
Unfortunately you probably won't be able to properly test your application if you don't have any experience in this area, so hiring someone is really good move. Of course even if you hire someone you need to specify the goal of this test (saying "I want by application to be secure" is not a good idea), and again - in my opinion - using ASVS as a checklist is really good choice.
Comment: Anyone who accepts a contract with the terms of "I want the application to be secure" isn't anyone worth hiring.
Comment: Unfortunately clients often cannot provide more specific requirements, at least at the beginning of the project. Especially if it is the first security assessment of theirs application. I agree that good consulting company should help the client to define assessment's goals, that's why I've mentioned about OWASP ASVS.


Computing the dual change of coordinate matrix $[T^t]^{\beta *}_{\gamma *}$

Question: I am trying to understand the computation of $[T^t]^{\beta *}_{\gamma *}$ from Friedberg linear algebra.
$T:P_1(R)→ R^2$ and $T(p(x))=(p(0),p(2))$
$\beta$ and $\gamma$ are the standard ordered bases for $P_1(R)$ and $R^2$ respectively and the asterisk denotes their dual bases, and $T^t$ denotes the transpose of the linear transformation $T$.
We are to compute $[T^t]^{\beta *}_{\gamma *}$ directly without using the fact that $[T^t]^{\beta *}_{\gamma *}=([T]^{\gamma}_{\beta})^t$.

First we let $[T^t]^{\beta ^*}_{\gamma ^*}=\left( \begin{matrix}
    a & b \\
    c & d \\
   \end{matrix} \right )$
Then we see that $T^t(g_1)=af_1+cf_2$ where $\beta ^*=\{f_1,f_2\}$ and $\gamma ^*=\{g_1,g_2\}$

Friedberg goes on to show that $T^t(g_1)(1)=(af_1+cf_2)(1)=af_1(1)+cf_2(1)=a(1)+c(0)=a$
My question is why did he choose $1$? Is it so that $a$ could be isolated from this equation and how would one know that? Also, why is $f_1(1)=1$ and $f_2(1)=0$. I know $f_{i}(x_j)=\delta _{ij}$ but I cannot put these two facts together since I cannot see how $1$ is $x_j$ where $x_j$ is the jth vector of a basis.
Then Friedberg goes on to show  $(T^t(g_1))(1)=g(1)(T(1))=g_1(1,1)=1$ and that proves that $a=1$.
I don't understand why $g_1(1,1)=1$, and I'm not really sure what $g_1(1,1)$ even means.
Then using similar computations not provided in the book, $b,c,$ and $d$ are found. How is this done? Is it by performing the above with $g_2$ and $1$ and $0$?Any guidance or explanation of the proof is greatly appreciated.
Answer: I believe that your main issue is that you are used to think of bases in an abstract fashion. That is, if $\beta:=\{x_1, \ldots, x_n\}$ is a basis for a vector space $X$ then the dual basis $\beta^*=\{f_1, \ldots, f_n\}$ are linear functionals such that $f_{i}(x_j)=\delta_{i,j}$. However, for this question you have some concrete vector spaces and some well known bases for each of them.
First of all since $\beta$ is the standard ordered bases for $P_1(\Bbb{R})$ we actually have $\beta=\{1, x\}$. Thus, the dual basis is $\beta^*=\{f_1, f_2\}$, where $f_1, f_2 : P_1(\Bbb{R}) \to \Bbb{R}$ are such $f_1(1)=1$, $f_1(x)=0$, $f_2(1)=0$ and $f_2(x)=1$ (think of $1$ as $x_1$ and $x$ as $x_2$ in the abstract fashion above). Hopefully this answers one of your questions.
Similarly, $\gamma=\{(1,0), (0,1)\}$ is the standard basis for $\Bbb{R}^r$ and therefore the dual basis is $\gamma^*:=\{ g_1 ,g_2\}$ where $g_1, g_2: \Bbb{R}^2 \to \Bbb{R}$ are such that $g_1(1,0)=1$, $g_1(0,1)=0$, $g_2(1,0)=0$ and $g_2(0,1)=1$ (think of $(1,0)$ as $x_1$ and $(0,1)$ as $x_2$ in the abstract fashion above). Therefore, since $g_1$ is linear
$$
g_1(1,1)=g_1( (1,0)+(0,1) ) = g_1(1,0)+g_1(0,1)=1+0=1
$$
This should answer what $g(1,1)$ is and why is it equal to $1$.
Finally your main goal is to find the entries $a,b,c$ and $d$ for the matrix of the linear transformation $T^t$ with respect to the bases $\gamma^*$ and $\beta
^*$. To do this you have to use that there are two ways to compute $T^t(g_1)(1)$, namely

Using the matrix: $T^t(g_1)(1)=(af_1+cf_2)(1)=a+0=a$
By definition of $T^t$: $T^t(g_1)(1)=g_1(T(1))= g_1(1,1) = 1$

This gives you the value of $a$. Analogously there are two ways to compute $T^t(g_1)(x)$, namely

Using the matrix: $T^t(g_1)(x)=(af_1+cf_2)(x)=c$ (because $f_1(x)=0$ and $f_2(x)=1$)
By definition of $T^t$: $T^t(g_1)(x)=g_1(T(x))= g_1(0,2) = 2g_1(0,1)= 0$

This now gives the value of $c$. Similarly, when computing both $T^t(g_2)(1)$ and $T^t(g_2)(x)$ using matrix way and the definition way you should be able to find the values for $b$ and $d$.
Do you think you can take it from here now?
I hope this is helpful.
Answer: Above they already showed you the reasoning, but I want to show you another way of doing it. I will first observe one thing in "abstract".

If $V$ is a finite-dimensional vector space, $\alpha = \{v_1,\dots,v_n\}$ is a basis for $V$, and $\alpha^* = \{\phi_1,\dots,\phi_n\}$ the corresponding dual basis, then any $f \in V^*$ can be written as $f = f(v_1)\phi_1 + \cdots + f(v_n) \phi_n$.

This is easy to see, for if $v \in V$, then $v = \phi_1(v)v_1 + \cdots + \phi_n(v)v_n$, and then
$$f(v) = \phi_1(v)f(v_1) + \cdots + \phi_n(v)f(v_n) = \big( f(v_1)\phi_1 + \cdots + f(v_n) \phi_n \big)(v).$$
So, in this concrete example we have to write the linear functionals $T^t(g_1)$ and $T^t(g_2)$ as a linear combination of $f_1$ and $f_2$, and because $\{f_1,f_2\}$ is the dual basis of $\{1,x\}$ we have:
\begin{align}
T^t(g_1) &= T^t(g_1)(1)f_1 + T^t(g_1)(x)f_2 \\
&= g_1(T(1))f_1 + g_1(T(x))f_2 \\
&= g_1(1,1)f_1 + g_1(0,2)f_2 \\
&= 1f_1 + 0f_2
\end{align}
and similarly, $T^t(g_2) = g_2(1,1)f_1 + g_2(0,2)f_2 = 1f_1 + 2f_2$.


Matomo one click solution GDPR compliant settings

Question: I'm using the latest Matomo self-hosted version. Is there a one click solution to set all settings to be GDPR compliant? (like import default settings for GDPR)
Answer: GDPR can be a complex process, there is this guide that goes over the 12 steps: https://matomo.org/blog/2018/04/how-to-make-matomo-gdpr-compliant-in-12-steps/
The easiest way to be compliant with GDPR easily is to not collect any personal data with Matomo, learn how at: https://matomo.org/blog/2018/04/how-to-not-process-any-personal-data-with-matomo-and-what-it-means-for-you/
Answer: @mattab is completely right. I just wanted to add a bit more detail.
The GDPR covers the processing of "personal data". If what you collect is not "personal data", you can consider yourself to be compliant with the GDPR. But that requires a bit of sacrifice: You will obtain less detailed, less precise information. The most immediate example is IP addresses and GeoIP results from those addresses. Full IP addresses are considered "personal data" because a natural person can theoretically be identified from it. And GeoIP information from full IP addresses are also very likely to be considered personal data. matomo has options to deliberately reduce the information in IP addreses and location data from it, so that it can be considered "anonymous" (and therefore not "personal data")
If you cannot stomach that, you will be processing personal data. And then being "GDPR compliant" requires a lot of consent management, privacy policies, data deletion policies etc. etc. As someone running a site on a no-personal-data basis, I can say that you still get a lot of interesting and useful data without it being personal.
The matomo guide linked to by @mattab is helpful if a bit sparse on the whys and wherefores. (selfpromotion) I have written a more detailed guide to matomo without "personal information" if you would like to know more than just what buttons to press and what it means for the quality of your data (/selfpromotion).


How do I block people from intentionally re-submitting a form?

Question: I'm building a website using Ubuntu, Apache, and Django. I'd like to block people from filling out and submitting a particular form on my site more than once. I know it's pretty much impossible to block a determined user from changing his IP address, deleting his cookies, and so on; all I'm looking for is something that will deter the casual user from re-submitting.
It seems to me that blocking multiple form submissions from the same IP address is the best way to achieve what I'm looking for. However, I'm unsure how I should do this, and whether I should be doing this from Apache or from Django. Any tips?
Edit: I'm looking to prevent intentional re-submission, not just unintentional double submission. e.g. I have a survey that I want to discourage people from voting multiple times on.
Answer: If your main concern is to prevent someone writes a script and automatically submit the form many times, you may want to use CAPTCHA with your form.
Answer: Several whole countries are NAT'ed, and some (most?) large multinational corporations too, many with several hundred thousand users each. Blocking anything by IP is a bad idea.
Go for a cookie instead, which is as good as it's going to get. You could also make the user login in, in which case you'd know if the form was submitted repeatedly for that login.
Comment: Thanks krosenvold. So if a country is NAT'ed, then all visits from that country show the same IP address? Where can I find info on which countries/areas are NAT'ed?
Comment: Well they won't be sharing a *single* IP address, which would probably be too limited. Expect something like a one or more  class C networks for a whole country. To my knowledge at least Singapore and Thailand are NAT'ed. I don't know if there is any coordinated source of this information; and things may change too ;)
Answer: I would use the session id, and store form submissions in a table with session id, timestamp, and optionally some sort of form identifier. Then, when a form is submitted, you could check the table to make sure that it had not happened within a certain period of time.
Answer: Filtering on IP address and/or cookies are both easy to get around, but they will prevent the casual user from accidentally submitting the same stuff multiple times due to browser hick-ups, impatience and so on.
If you want something better than that you could implement login, but of course that prevents a lot of users from responding.
Answer: Add to the form a monotonically increasing id number in a hidden field.
As each form is submitted, record the id in a "used" list/map (or mark it used, or whatever, implementation detail).
If you get the same id a second time (if it's already in your used map) inform the user they double-submitted.
Answer: While nothing is fool proof, I would suggest something like this: When a user loads the page with your form on, a cookie is set and the value of the cookie is appended with a fixed secret string and the md5 value of this is written to a hidden field on the form. Ensure that a new value is generated each time the user access the form.
When the user submits the form, you check that the cookie value and form value match, that the cookie the user was given has not been used to submit the form before and that the referrer id match the URL of the form. Optionally you make sure that there has been no attempts to post from that IP in the last 2 minutes (fast enough that it wont matter to most people, but slow enough to slow down bots).
To fix this the user has to make a script that loads the page, store the cookies and submit the correct values. This is much more difficult than if the user could just submit the form.
Added Based on edit: I would block the users in the Django framework. This allows you to present a much better error message to the user and you only block them from that form.
Comment: Thanks tomjen for the thoughtful reply. Would I block IP addresses from my Django code, or from Apache?
Answer: This is a question of authentication and authorisation, which are related but not the same. In order to manage authorisation you must first authenticate (reliably identify) the user.
If you want to make this resist intentional misuse then you are going to end up with not only usernames and passwords but demands for information that personally identifies your users, along the lines of the stuff a bank asks for when you want to open an account. The bleeding hearts and lefties will snivel endlessly about invasion of privacy but in fact you are doing exactly the same as a bank and for exactly the same reasons.
It's a lot of work and may be affected by law. Do you really want to do it?
Answer: The following methods are all relatively simple, both to implement and to hack around.  Anyone with Firebug and a little knowledge won't even blink.
The following JavaScript uses Mootools, and I haven't checked it to be bug free. I understand that JQ syntax is almost identical, and raw JS is similar enough, so the point should be clear.
1) If the form is being submitted via AJAX, you can check before submitting (sorry if I'm just stating the obvious).
<code>var sent = 0;
$('myForm').addEvent('submit', function(){
    if(!sent) this.send();
})
</code>
This is really simple, and surprisingly effective until they reload the page.
2) Add a JavaScript cookie. Again, with Mootools:
<code>$('myForm').addEvent('submit', function(){
     if(Cookie.read('submitted')){ alert('once only'); return false;}
     else{ Cookie.write('submitted', 1); return true; }
})
</code>
This will work even if the user reloads the page.
3) Add a Python session cookie. I am not familiar with Python, but if it is like PHP, this will have no advantage over method 2.  In either case, the user can delete the cookie with FireCookie or WebDeveloper Toolbar (or their equiv's on other browsers) and reload the page.
4) Add a Flash cookie (use Flex).  This is ideal - Flash cookies are stored in a different location, are not obvious, and are very difficult to remove.  The only downside is that you need to create and embed a tiny swf.
5) Store a value in a hidden field, and check for the value.
A hash can be added to the internal links to insure that the value remains filled in even if the page is navigated away from.
6) Other games can be played incrementing a URL (or a custom URL using htaccess) for each visitor.
An swf cookie is the best idea of the above, though it can be combined with the others.


A question about the rotation number of homeomorphisms of the circle

Question: Let $f: S^1 \rightarrow S^1$ be an orientation-preserving homeomorphism of the circle and let $F: \mathbb{R} \rightarrow \mathbb{R}$ be any lift of $f$. Usually one defines the rotation number $\rho(x,F)$ of $F$ for a point $x \in \mathbb{R}$ as the limit
$$
\rho(x,F) = \lim_{n \mapsto \infty} \frac{F^n(x) - x}{n}.
$$
This limit exists always and is independent of the point $x$. Hence we can just write $\rho(F)$. It makes sense to me that the rotation number respects the composition of homeomorphisms, i.e.
$$
\rho(G \circ F) = \rho(G) + \rho(F),
$$
but I seem to be unable to prove it. Is it true at all? Any hints on how to prove it?
Comment: Even if $G$ does not commute with $F$?
Answer: It is not true.
Let the universal covering map $\mathbb{R} \to S^1$ be $t \mapsto e^{2 \pi i t}$.
Let $f : S^1 \to S^1$ fix $1+0i$, and let $f$ act on $S^1 - \{1+0i\}$ by moving each point a little bit in the counterclockwise direction. Lift $f$ to $F$ so that it fixes each integer $n$ and displaces every other point a little bit to the right.
Let $g : S^1 \to S^1$ fix $-1+0i$ and let $g$ act on $S^1 - \{-1+0i\}$ by moving each point a little bit in the counterclockwise direction. Lift $g$ to $G$ so that it fixes each half integer $n+\frac{1}{2}$ and displaces every other point a little bit to the right.
Then $F \circ G$ displaces each point to the right by an amount bounded away from zero and so $\rho(F \circ G) > 0$. But $\rho(F) + \rho(G) = 0 + 0 = 0$.
Comment: Thank you, your example is very helpful indeed! Any idea if it is true if $F$ and $G$ commute?
Comment: See the answer of Tomas.
Answer: If $F$ and $G$ commutes then, the result is true. Indeed, note that
$$\frac{(G\circ F)^n(x)-x}{n}=\frac{G^n\circ F^n(x)-F^n(x)}{n}+\frac{F^n(x)-x}{n}$$
Comment: okay, I see that the first term on the right hand side converges. But why is $\lim_{n \mapsto \infty} \frac{G^n \circ F^n (x) - F^n(x)}{n} = \rho(G)$?
Answer: We define the mean rotation vector of F is an element of $R^{2}$ by :
$$\rho_{\mu}(F) = \int \rho(F,x) d\mu$$
This $\rho_{\mu}(F)$ in $R^{1}$ is equal to $\rho(F)$ ; thus:
$$\rho_{\mu}(GoF)=\int \rho(GoF,x) d\mu = \int \lim_{n} {(GoF)^{n}(x)-x \over n} d\mu$$
$$=\int \lim_{n} {G^{n}(F^{n}(x))-x \over n} d\mu =\int \lim_{n} {G^{n}(F^{n}(x))-F^{n}(x) + F^{n}(x) - x \over n} d\mu$$
$$=\int \lim_{n} {G^{n}(F^{n}(x))-F^{n}(x)\over n}d\mu + \int \lim_{n}{F^{n}(x) - x \over n} d\mu$$
$$=\int \rho(G,x) d\mu + \int \rho(F,x) d\mu$$
$$=\rho_{\mu}(G) + \rho_{\mu}(F)$$
Thus in $R^{1}$ , we have:
$$\rho(GoF)=\rho(G)+\rho(F).$$


Exposing Member Objects As Properties or Methods in .NET

Question: In .NET, if a class contains a member that is a class object, should that member be exposed as a property or with a method?
Answer: You should use properties for anything that conceptually represents the object's state, so long as its retrieval isn't an expensive enough operation that you should avoid using it repeatedly.
From MSDN:

Class library designers often must decide between implementing a class member as a property or a method. In general, methods represent actions and properties represent data. Use the following guidelines to help you choose between these options.

Use a property when the member is a logical data member. In the following member declarations, Name is a property because it is a logical member of the class.
public string Name
get
{
    return name;
}
set
{
    name = value;
}

Use a method when:

The operation is a conversion, such as Object.ToString.
The operation is expensive enough that you want to communicate to the user that they should consider caching the result.
Obtaining a property value using the get accessor would have an observable side effect.
Calling the member twice in succession produces different results.
The order of execution is important. Note that a type's properties should be able to be set and retrieved in any order.
The member is static but returns a value that can be changed.
The member returns an array. Properties that return arrays can be very misleading. Usually it is necessary to return a copy of the internal array so that the user cannot change internal state. This, coupled with the fact that a user can easily assume it is an indexed property, leads to inefficient code. In the following code example, each call to the Methods property creates a copy of the array. As a result, 2n+1 copies of the array will be created in the following loop.
Type type = // Get a type.
for (int i = 0; i < type.Methods.Length; i++)
{
   if (type.Methods[i].Name.Equals ("text"))
   {
      // Perform some operation.
   }
}

The following example illustrates the correct use of properties and methods.
    class Connection
    {
       // The following three members should be properties
       // because they can be set in any order.
       string DNSName {get{};set{};}
       string UserName {get{};set{};}
       string Password {get{};set{};}

       // The following member should be a method
       // because the order of execution is important.
       // This method cannot be executed until after the
       // properties have been set.
       bool Execute ();
    }

Answer: If all you are doing is exposing an object instance that is relevant to the state of the current object you should use a property.
A method should be used when you have some logic that is doing more than accessing an in memory object and returning that value or when you are performing an action that has a broad affect on the state of the current object.
Comment: What is the benefit of using a method, rather than a property, when you have some logic that is doing more than accessing an in memory object and returning that value or when you are performing an action that has a broad affect on the state of the current object?
Answer: That is irrelevant to the matter.
It should be a Property if the value is some detail about the state of the object.
It should be Method if it performs some action on the object.
Answer: Property. A Property is basically just a 'cheap' method. Getting or setting a reference to an object is pretty cheap.
Just to clarify, properties are usually supposed to represent the internal state of an object. However, the implementation of a member as a property or method tells the user how expensive the call is likely to be.
Comment: You're right in that a property can do anything since it's just syntatic sugar for a couple of methods. I meant to say that a property *should* be cheap. If it's not then make it an explicit method.
Comment: Huh? A property set can trigger the object serialization and cause a database update or a web service call. How's that for a cheap?
Answer: Properties read and assign values to instances within a class.
Methods do something with the data assigned to the class.
Answer: Overview
Generally, properties store data for an object, such as Name, and methods are actions an object can be asked to perform, such as Move or Show. Sometimes it is not obvious which class members should be properties and which should be methods - the Item method of a collection class (VB) stores and retrieves data and can be implemented as an indexed property. On the other hand, it would also be reasonable to implement Item as a method.
Syntax
How a class member is going to be used could also be a determining factor in whether it should be represented as a property or a method. The syntax for retrieving information from a parameterized property is almost identical to the syntax used for a method implemented as a function. However, the syntax for modifying such a value is slightly different.
If you implement the member of a class as a property, you must modify it's value this way:
 ThisObject.ThisProperty(Index) = NewValue
if the class member is implemented as a method, the value being modified must be modified using an arguement:
ThisObject.ThisProperty(Index, NewValue)
Errors
An attempt to assign a value to a read-only property will return a different error message than a similar call to a method. Correctly implemented class members return error messages that are easier to interpret.
Answer: I  confused about the using property and method before. But now I am using this rule according to MSDN Guideline:
methods represent actions and properties represent data. Properties are meant to be used like fields, meaning that properties should not be computationally complex or produce side effects. When it does not violate the following guidelines, consider using a property, rather than a method, because less experienced developers find properties easier to use.


Proper method to measure the magnification of a reversed lens

Question: I have a 50mm prime lens and a 18-55mm standard lens at my disposal. How do I measure the magnification of a reversed lens when used with a reverse mount. What are the factors that come into play to calculate the magnification?
Answer: Photograph a normal ruler, mm scale preferred.  Then if your sensor is 24 mm wide (camera specs should say), and if the image shows say 20mm of that ruler, then the magnification is 24/20 or 1.2x  (larger than 1:1 life size).
Normally lenses show smaller than life size, like showing 40 mm on a 24mm sensor would be 24/40 = 0.6x magnification.
Comment: Note that the ruler photo has to be taken at the smallest possible focal distance from the ruler.
Comment: Ruler will show actual magnification at any distance you choose to use (if macro setup offers any choice of focus distance).  Only the Maximum magnification needs to be at closest distance.
Comment: This seems to be a great explanation. Thanks for the answer!


Setting up proxy VM with VirtualBox DNS problems

Question: Using VirtualBox on Ubuntu, I want to connect two Linux (debian 9) VMs together, so that the first one acts as a router for the second one (VM2), whose traffic is completely routed through the first one (VM1). The VM1 (gateway) is connected to a VPN service and thus all traffic from VM2 is connected to the VPN.
I have managed to have the VM2 successfully ping external IPs such as 188.8.131.52. But all other networking fails. I think the issue is the DNS resolution, which for some reason unknown to me is not resolved by the VM1.
Here is what I have done so far:
On VirtualBox, VM1 is connected to a NAT interface, and a second interface, which is an internal network named "testvpn". VM2 is only connected to this internal network, not to the NAT.
VM1 has the following /etc/network/interfaces configuration:
auto lo
iface lo inet loopback

allow-hotplug enp0s3
iface enp0s3 inet dhcp

allow-hotplug enp0s8
iface enp0s8 inet static
      address 10.152.152.10
      netmask 255.255.192.0

VM2 has the following /etc/network/interfaces configruation:
auto lo
iface lo inet loopback

allow-hotplug enp0s3
iface enp0s3 inet static
    address 10.152.152.15
    gateway 10.152.152.10
    netmask 255.255.255.0
    dns-nameservers 10.152.152.10

VM2's /etc/resolv.conf points to VM1:
nameserver 10.152.152.10

With this simple configuration, VM2 can ping VM1, but has no access to external internet. For this I must allow ip forwarding and configure iptables on VM1:
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
iptables -A FORWARD -i tun0 -o enp0s8 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i enp0s8 -o tun0 -j ACCEPT

Note that I use on purpose tun0 for the VPN network interface, but the results are exactly the same with enp0s3 instead of tun0 without the VPN tunnel activated. Now I can ping external addresses on VM2, but all other network connections fail:
  $ curl google.com
    curl: (6) Could not resolve host: google.com

After some online reading, I tried to add supposedly DNS related iptables rules on the first gateway VM:
iptables -t nat -A PREROUTING -i enp0s8 -p udp --dport 53 -j REDIRECT
iptables -t nat -A PREROUTING -i enp0s8 -p tcp --dport 53 -j REDIRECT

It doesn't work. Note that networking works fine on the VM1, with or without VPN.
I am not very experimented with iptables and I really don't know what to do next. I tried searching online hours for solutions but couldn't find a solution. I would not like to use dhcp/dnsmasq solutions as I am quite sure iptables should be enough.
T
Answer: EDIT: I had it working by changing the PREROUTING rules as follows:
iptables -t nat -A PREROUTING -i enp0s8 -p udp --dport 53 -j DNAT --to-destination 10.4.0.1
iptables -t nat -A PREROUTING -i enp0s8 -p tcp --dport 53 -j DNAT --to-destination 10.4.0.1

10.4.0.1 being the default DNS nameserver of the VPN (AirVPN) as in /etc/resolv.conf.
I am not sure if this is the correct way of doing it, but it works...
So now my entire iptables rules look as follows:
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
iptables -A FORWARD -i tun0 -o enp0s8 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i enp0s8 -o tun0 -j ACCEPT
iptables -t nat -A PREROUTING -i enp0s8 -p udp --dport 53 -j DNAT --to-destination 10.4.0.1
iptables -t nat -A PREROUTING -i enp0s8 -p tcp --dport 53 -j DNAT --to-destination 10.4.0.1


Measuring viscosity with tools other than viscometer

Question: I would like to measure viscosity, but do not have access to a viscometer. If possible, I would like to avoid having to purchase one. I have access to many other  flow measuring devices, including flowmeters, pressure sensors, and a turbidimeter, and was wondering if taking measurements with these would somehow allow me to make, at the very least a proportional measurement to viscosity (I only need relative measurements between different fluids, exact specifications are not necessary). I dont have reason to believe these liquids would behave significantly non-newtonian, and they would likely all be water with additives such as salt and detergents.
Answer: A long glass tube and a steel ball which matches the internal diameter closely - then measure the different times compared to some known liquids for the ball to drop a given distance.
Comment: Actually it is easier to get consistent results when the tube is much *larger* diameter than the ball. If the ball is a close fit, the fluid has to move *up* through the narrow gap between the ball and the tube, *faster* than the ball is descending. This can cause turbulence and instability ("the ball "wobbles" as if falls) and correcting for those effects is hard!
Comment: @alephzero but if the clearance is too great then for somewhat similar liquids there may be very little time difference...
Answer: punch a small hole in the bottom of a plastic container. measure the time it takes for the container to empty through the hole. experiment with different hole diameters to "scale" the effect appropriately for your expected viscosity values, and calibrate it against a standard.
Comment: For small holes, the different surface tension of different liquids may cause significant errors.
Comment: this technique is used in the petroleum industry, where the liquids involved have about the same surface tension.
Comment: And in spray painting, where the important feature is to get repeatable viscosity when you're spraying.


MAC address of source in RDP session

Question: In a forensic analysis I analyzed the event logs of the affected machine and saw various RDP sessions from XYZ IP address. However to prove that the source IP was not spoofed is it possible that I could find the MAC address of the PC from where the RDP session was initiated?
Answer: No.

There is no guarantee the other machine has a MAC address at all.
Following the IP over everything principle, the connecting partd may be sitting in a tree using IP over avian carriers - and pidgins do not have MAC addresses.

You may only get a MAC address of an IP in your local network at the time the connection in done, as the mapping can change over time by assigning a new IP to that interface and is only available to your local network. If you want to do this, it's
  arp -an

Please keep in mind that:

If the IP address is spoofed, a TCP handshake will fail. No no actual connection can be made.
Comment: Key point: **if the RDP** was working, **then** the IP address wasn't spoofed.
Comment: The TCP threeway handshake. It cannot be completed with a spoofed packet.
Comment: What about network interface mac address?
Comment: My question is if the network interface has a MAC address then? And we are in a local network. E.g. IP 192.168.2.1 has a0:cc:0f:ab:20 then will I be able to get it in any way possible?
Comment: The `arp -an` is of little use outside of an attack *in progress*.
Comment: @danielAzuelos, but how is this achieved? What auth mechanism provides authenticity of RDP client and prevents spoofing?
Answer: If the IP address of the suspected RDP source is within your managed network,
and if within your network, all your IP addresses are attributed through a correctly tracked process of IP managment: DHCP or radius or 802.1X,
and if this IP address attribution mechanism is correctly logged on a protected log server: through syslog,
then you can get a valid MAC address of the suspected RDP source
and most probably the physical Ethernet socket or the physical 802.11* access point through which it was connected,
else you can't get any MAC address.
For example, to focus on a possible reply to your question,
if the IP address of the suspected source of the RDP attack is outside of your managed network, then you can't get any MAC address.
Be aware that if the attacker was aware of your policy of IP address managment, then the valid MAC address of the attacking PC might have been changed so as to get an access to your network with a registered MAC address.
Answer:
However to prove that the source IP was not spoofed is it possible that I could find the MAC address of the PC from where the RDP session was initiated?

An IP address is at the network layer while the MAC is at the data link layer (see OSI model). The IP address is the same when the data travel through the various networks while the MAC address changes on each network boundary. Thus if the IP address belongs to a different network it will have the MAC address of the router which provided connectivity between these networks.
Even if the IP address belongs to the local network it does not mean that the RDP session originated there. It might just be a system used as the endpoint of some SSH or SOCKS tunnel and the RDP session originated at the other side of this tunnel.

MAC address of source in RDP session


Is it possible to spread malware through Minecraft Servers? How likely is it?

Question: Is it possible to spread malware through minecraft, thus making it dangerous to join? Are any safety checks of incoming traffic made, is it necessary for the server to have malware or is it also possible for a user that joins to infect others that joined the server? I couldn't find any information about it after Googling it, which could be because it's unlikely, but why? What is done to make the multiplayer safe?
Comment: Install an anti-malware plugin like [this](https://www.spigotmc.org/resources/spigot-anti-malware-detects-over-100-malicious-plugins.64982/) one for extra security. I don't know if such software can spread onto other computers through packets but it could certainly do damage to your server.
Answer: I asked an expert on this and many more Minecraft related topics (Pokechu22) and this is what they answered:
Answer: No, excluding resources downloaded (resource packs and skins),
  which still will not be executed without the user manually doing
  something stupid (in which case, you can just as easily pwn them by
  making them download some other malicious executable).  Vague link to
  https://wiki.vg/Protocol.
Java makes it unlikely for buffer overflows leading to arbitrary code
  execution or similar issues to cause problems; if there was a problem
  then it would affect far more than just MC.
The link about malicious plugins is a thing, but that's more the
  server owner installing arbitrary plugins that do bad stuff to that
  server than harming clients
I can't speak for bedrock.  That could have buffer overflows or
  similar issues for all I know.
(and, in case it matters, I give permission for you to quote these
  comments there and apply the needed license for stackexchange posts,
  etc)
Oh.  And since that question was about one user spreading stuff to
  other users, the only venue is skins (which now have a lot of filters
  on them to prevent embedding files after the PNG data, but in the past
  didn't, leading to a scare -- though again that was NOT executed by
  the game.  Such attacks shouldn't be possible/would be much harder
  now, since skins are recompressed and sanitized by Mojang)
The only other venue through which malware could spread is chat, since
  chat gets sent between players and is logged.  So you could put
  something into chat, but that still wouldn't be executed.  Or you
  could put a malicious link in chat, but that'd require naïve players
  anyways.
You could send the EICAR test
  file in a chat
  message, but that wouldn't be executed (and isn't considered a threat
  if it's a substring, only if that's the file's whole contents; after
  all, it's not executable as-is)
And it's not like that's limited to MC's chat; I can send it right
  here too:
  X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*
Comment: And does the client verify that the code coming in from multiplayer is not some malicious stuff to be executed? By that I mean why buffer overflows are necessary to execute other code than game related code. Otherwise I guess someone could just modify some files to send malware instead of the normal Minecraft traffic, so what prevents that from happening?
Comment: All traffic except for resource packs is in specific packets for specific tasks, like block updates, player movement, etc. Those are all interpreted by the game. If there was a way to do something harmful, it would be a bug in the game. And then, sure, you can probably make a client crash for example by making it believe that there are a million entities nearby.
Comment: So I understand that the game does take measures to prevent that? This makes me think of MW2 where one could modify the game to send malicious packets and take control of someone's desktop if I remember correctly... Just wondering why it's not possible in Minecraft...
Comment: I don't know what "MW2" is, but the packets that Minecraft clients receive are never executed as programs and never saved to file, so it can't execute malicious code.
Comment: Only now I fully realise what you mean with "code": No, no executable code is sent in the regular usage of Minecraft, only data that gets interpreted by the program that you have already installed. And even if an executable file was sent, Minecraft would not know how to handle it and would just discard it. I know of no program that normally receives executable files and saves them, except for those made for downloading (browsers, wget, …) and those have lots of safety measures built in. No game should ever just download and save arbitrary files without user confirmation.


class interaction design

Question: Lets say i have something like this coded
class Normal_Mode;
class Fast_Mode;
class File_Control; //handles all operations with reading/writing in file
class Main_Control {
 private:
 some_class *root; //all other classes need access to root pointer since there is all the data(binary tree)
 File_Control *c_file_control;
 Fast_Mode *c_fast_mode;
...
}

Main_Control::Main_Control ( int argc, char* argv[]) {
  ...
  if ( argc > 1 ) {
   c_fast_mode = new Fast_Mode(argc, argv[]);
  } else {
   c_normal_mode = new Normal_Mode();
  };
  ...
};

int main (int argc, char* argv[]) {
 Main_Control c_main_control(argc,argv);
 return 0;
}

Lets say user input had argc > 1 and i am happy doing stuff with users input in Fast_Mode class but when i am finished and want to write stuff to file or read something from file while in Fast_Mode.
How do people in real world access File_control class?
Do they make some global array full with pointers to these kinda of classes who need only 1 instance.
Do they pass pointers to Fast_Mode and other classes so it can have it stored in private members for access.
or they construct/destruct such classes all the time depending on when it is needed.
And what do they do with such *root pointer where all the actual data is stored and lot of other classes needs to access it
Or my design ideas are completely wrong and people in real world do it some other way?
Answer: I don't really know what you are trying to achieve with this: if possible make you goal more clear but what I would say is that people would ususally create an abstract interface called 'Mode' and then have both Normal_Mode and Fast_Mode implement it. That way you could write the following code:
class Main_Control {
    private:
       some_class *root; //all other classes need access to root pointer since there is all the data(binary tree)
       File_Control *c_file_control;
       Mode *c_mode;
       ...
};

And then you could set it like:
if ( argc > 1 ) {
   c_mode = new Fast_Mode(argc, argv[]);
} else {
   c_mode = new Normal_Mode();
};

So you just put the common functions in the Mode interface so that they behave the same way but can be placed inside the same mode variable. To learn more about class inheritance and polymorphism look here. I hope that this answers your question.

class interaction design


How to invest 10000 a week for 36 weeks

Question: How would you invest $10,000 USD in the USA a week for 36 weeks. After that point the entire amount has to be returned. Meaning $360,000 I'm assuming treasury bonds but could you do a short term treasury bond?
Comment: Country? Risk-profile acceptable (does "entire amount has to be returned" just mean you want to liquidate your position in 36 weeks' time, even if there are losses, or that there must not be any losses?)
Comment: @BobBaerker Just for info re. your first comment: at the time of Hilmar's comment, the question just had **10000** with no indication of currency or country.
Comment: @Hilmar - I would assume that $10,000 USD  is kind of self explanatory
Comment: If you want a guaranteed return of  principal after 36 weeks plus  some gain then you're limited to MM, CD's, and any other fixed income of short duration (35 weeks).
Comment: Depends on what recourse is behind the repayment of the principal.
Comment: Better to buy and sell / flip a property with the same money in the same time...
Answer: Sure, you can buy treasury bills in $100 increments with terms of 4, 13, 26, and 52 weeks. You could also reinvest bills that are kept to maturity so that you get as much interest as possible.  For example, you could buy a 26-week (6-month) bill with the first 10,000, then reinvest it with another 4-week bill at week 27, then reinvest that at week 31.
Note that technically you buy t-bills at a discount, so you might not be able to invest all $10,000 each week. Since you might spend, say, $9,910 for $10,000 in bills, you won't be able to invest every penny, but it shouldn't make a huge difference.
I also wouldn't expect much in terms of return for this. Since your average investment horizon is 18 weeks (.346 years), and the current t-bill rates for 13 and 26 week bills are 1.85% and 2.05%, you can expect an annualized  return of about 1.95%, or about 0.6% for your investment, which would be about $2k.

How to invest 10000 a week for 36 weeks


What is known about this product?

Question: I bet the product
$$
\prod_{n=2}^\infty\frac 1 {1-n^{-s}},
$$
which is convergent for ${\rm Re}(s)>1$, has been studied before. Can it be analytically extended across the line ${\rm Re}(s)=1$? If so, is there a functional equation?
Answer: Yes, the inverse of it, $\prod_{n=2}^{\infty} \frac{n^s-1}{n^s}$
 has been studied in connection with the  so-called $k$-almost prime zeta functions of the second  kind.
It can be evaluated to
$$
\prod_{n=2}^{\infty} \frac{n^s-1}{n^s}=\prod_{n=1}^{\infty} \frac{(n+1)^s-1}{(n+1)^s}=
\frac{1}{\prod_{j=1}^{s-1}\Gamma (2-e^{2\pi ij/s})}.
$$
Then one can use the properties for the $\Gamma$-function.
A reference is the paper by Richard J Mathar, on HARDY-LITTLEWOOD CONSTANTS EMBEDDED INTO
INFINITE PRODUCTS OVER ALL POSITIVE INTEGERS, and the references therein. The connection with the $k$-almost prime zeta function is given by
$$
\prod_{n=2}^{\infty}\left(1-\frac{1}{n^s}\right)=\prod_{k=1}^{\infty}\frac{1}{\zeta_k(s)}
.$$
Edit: I apologize, but $s$ is assumed to be an integer above. But the question has been discussed already, see
Values where infinite products of primes and composites are equal.
Comment: @Dietrich: thanks for the answer. However, this is for integral $s$ only. I would be interested in complex $s$ and analytic continuation.
Comment: @Anton: yes, I am sorry. I found the above discussion on your product, called $T(s)$, but I am not sure if this gives you an answer, i.e., how to extend $T(s)$ meromorphically to $\mathbb{C}$.
Answer: Yes, It can be analytically extended across the line Re$(s)=1$. Taking the logarithm of the function and using the series expansion of $\log(1+x)$ gives you the sum
$$
 \sum_{k=1}^\infty \frac{\zeta(ks)-1} k
$$
which has a meromorphic continuation up to the line Re$(s)=0$, with poles at $s=1/k$. There is some speculation on the other page on the problem Values where infinite products of primes and composites are equal whether the continuation should go beyond the line Re$(s)=0$ but I agree with Greg Martin's comment that this is not clear. However you asked about the line Re$(s)=1$ and that follows from the above. Note though that the logarithm of the function has meromorphic continuation and this means that your function does not have meromorphic continuation since the singularity at Re$(s)=1$ will not be a pole. I doubt that the function has a functional equation.

What is known about this product?


How to prevent "sweating" chocolate covered strawberries?

Question: Last year for Valentines day, I decided I was going to be romantic and make some chocolate covered strawberries for someone special. I melted and tempered some milk chocolate. Then dipped the washed and thoroughly dried strawberries into the chocolate and put them on a plate in the refrigerator to quickly "set" the chocolate.
Later that night as my special someone and I were eating the chocolate covered strawberries, we noticed that there was condensation both on the outside and in between the chocolate and strawberry. It was delicious nonetheless, but I was curious as to why it was "sweating" and if there is anything I can do to prevent this if I decide to ever be romantic again.
Comment: I'm wondering if the strawberries should be room temperature when dipped.
Answer: Very simple: don't store your chocolate in the fridge. The ideal temperature for setting chocolate is 20°C. You can store it at less or more than that, but not too much. Setting in the fridge results in bad chocolate. Remember, when you work with chocolate, exact temperatures are extremely important.
Here a loose translation from a good article on chocolate/couverture coating:

This is the usual case. You only want a temperature difference of 12° to 13° between the chocolate and its environment as well as between the chocolate and the confect interior.

If the interior is colder than the room, the setting will happen "inside out". The cocoa butter film which gives a confect its shine will build on the inside, leaving the outside looking dull.

This is a really good case for some types of confect, but you can't do it with most types of filling (definitely not with strawberries). Cooling from the outside gives you a beautiful shine.

If you want to achieve a good shine, it is possible to put the confects in the fridge for a short time, but only after they have cooled to 20°C at room temperature. Don't let them fall to fridge temperature, take them out at 15°C. The continued cooling from the outside is beneficial.

This shouldn't happen. The temperature difference is too small, and the confect doesn't set quick enough. In this case, cocoa butter pools on the surface and creates a yellowish layer after it hardens.
When you make your confect, you should time the first piece. The setting should need 10 minutes. If it is less, you don't get all the possible shine. If it needs more, it will get grey or whitish yellow.
Comment: @Mien, I live in a very old house with bad insulation with 4 other college students. If we want to keep the house above 50 degrees, we would need to each pay about $50-$75 more per month(on top of the already expensive gas bill).
Comment: So if your kitchen is at 10 degrees you're out of luck?
Comment: Looks like it, yes. Chocolate is very finicky when it comes to temperature. Unless you can live with dull, wet chocolate. I know people who don't mind that.
Comment: Valentine's day is around February which is still winter and it is still pretty cold here so it might be a problem. I guess i can always just make it some other time of the year. Like a picnic at the park during spring.
Comment: @Jay, I can't believe your kitchen is (in winter) only 10 degrees C (50 F).
Comment: Brrrr. Move! :P You could place the strawberries somewhere else? ;)
Answer: Chocolate will 'sweat' in the fridge if it cools too quickly, particularly if your fridge happens to be quite moist, which can quite often happen especially with lots of uncovered fruit and vegetables. Also if you think that a strawberry is around 90% percent water it is hardly surprising that water forms (possibly from condensation as it goes from a warm to cool temperature) on the strawberry.
The best place to store chocolate is somewhere cool and dry. I keep mine wrapped in foil, in a sandwich bag, in the 'larder'. In any case the best way to store chocolate dipped strawberries according to this website is by keeping them in the fridge then before serving while still cold, whips of the condensation as not to damage the chocolate.
Another website with tips on storing chocolate is http://candy.about.com/od/workingwithchocolate/a/storechocolate.htm.
Comment: @jay The refrigerator is filled with normal air from outside. But at the low temperatures, air can't hold much water vapor, so the humidity from the air in the refrigerator condenses on whatever surfaces there are in the refridgerator, including your chocolate, while the air itself gets drier.
Comment: Isn't the refrigerator suppose to have very dry air?
Comment: @Jay Supposedly but at the back of my fridge you can see beads of condensation running down!
Answer: Common Belgian wisdom: if you want to prevent chocolate from "sweating", you need to store it at around 15-19 °C, and certainly never ever store it in a fridge...
I suppose to some degree @rumtscho's explanation might explain why.
Answer: We served these at a fancy restaurant I worked in and we simply didn't cover them in the fridge.  Leave them uncovered and they don't sweat.
Comment: I'm not sure that this actually works (someone suggested elsewhere that Jay's strawberries were actually uncovered anyway). Maybe it does with some kinds of chocolate, but in general, it's going to sweat in the fridge, faster than the dry air in the fridge can carry away moisture.


How can I install Gphoto2?

Question: I'm new to (K)ubuntu. Does anybody know how to install the gphoto2 software?
Comment: Possible duplicate of [How do I install applications in Ubuntu?](https://askubuntu.com/questions/307280/how-do-i-install-applications-in-ubuntu)
Answer: Wow, how is the documentation for this so terrible? At the time of writing, the documentation on the official site literally says:
5.3. Configuring, building, and installing
WRITEME :-P (PKG_CONFIG_PATH, ./configure, make, make install, /etc/ld.so.conf, LD_LIBRARY_PATH, PATH, yadda yadda)

Here's how I installed it (on Ubuntu 18.04 LTS) after lots of trial and error. Keep in mind that gphoto2 is simply the CLI for libgphoto2. Simply installing gphoto2 won't do much for you.
Easy method
Use apt (or apt-get)
$ sudo apt install gphoto2
$ sudo apt install libgphoto2-6

You may be wondering why it's libgphoto2-6 and not just libgphoto2. When you're typing sudo apt install libgphoto2 press tab and see what it completes. You can also view what the latest packages are for each ubuntu build. Launchpad and packages.ubuntu.com.
After that you should be able to use gphoto2 in Terminal.
$ gphoto2 -v

should show you something meaningful.
Advanced build
If you go to the gphoto2 website, you'll notice that they've released updates to libgphoto2 since Ubuntu 18.04's latest package (2.5.16). Specifically, I want to have support for Sony Alpha A9, which requires libgphoto2 v2.5.22. You can download it from the source, but now what?
cd to the tar.bz2 file.
unzip it: autocomplete the file name by pressing tab
$ tar -xjf libgphoto2-2.5.22.tar.bz2

configure, make, make install Go into the directory. Each of these commands will take time, so enter one line at a time.
$ cd libgphoto2-2.5.22

$ autoreconf -is
$ sudo ./configure
$ sudo make
$ sudo make install

If at any point it says it looks like something went wrong, it's likely you're missing a package. I had to install: libtool, libpopt-dev, libsub-dev, libexif-dev, libjpeg-dev, autoconf, autopoint, libcdk5-dev
The github repo has an additional step of
autoreconf -is

which for me, required apt installing the autoconf and autopoint packages.
This updates libgphoto2. To update gphoto2, which I needed to do in order to use libgphoto2-2.5.22, you have to go through the same steps. Read the README.md. I had to install libpopt-dev. Running ./configure alerted me to this problem.
You may need to restart Terminal or your machine to see changes.
After that, check your version using gphoto2 -v.
Comment: I believe "libsub-dev" should be "libusb-dev"
Answer: Open a terminal and type
sudo apt install gphoto2 libgphoto2*

This should do it.
Comment: It works, GPhoto2 is downloaded, but how to open it? (Sorry for my stupidness) (sorry for my english too) Thanks #Cheese129
Comment: What exactly do you want to do? I learned that without libgphoto2, Ubuntu does not recognize SD cards with photos on it. I have never tried to control a camera through gphoto2, though.
Comment: I want to try to control a camera with gphoto2. But when i search for gphoto2 in the pc, there is no program called that. When i tries to install it again, it says it is downloaded. What to do? Thanks #Cheese129
Comment: I suggest opening another question here on askubuntu, because that's a different topic. Another idea is asking on https://photo.stackexchange.com .
Comment: I have now opened a new topic:  https://askubuntu.com/questions/905453/have-installedd-gphoto2-but-how-to-open-it
Answer: gphoto2-updater (https://github.com/gonzalo/gphoto2-updater) compiles from the latest github source of gphoto2.
Comment: brilliant shortcut!

How can I install Gphoto2?


Spanning tree whose sum of edge weights are between two boundries

Question: I saw this problem:
$\langle G,w,k_1,k_2 \rangle \in L$ iff Graph $G$ has a spanning tree whose  sum of edge wights are less than $k_2$ and greater than $k_1$. The problem says that we can prove this problem is NP-complete with reduction from Subset-Sum problem. First i cant see how is that possible. Second i know that we can solve Minimum Spanning Tree with kruskal , and i saw that we can compute Maximum Spanning Tree by negating the weights for each edge and applying Kruskal's algorithm. So both of these problems can be solved in polynomial-time. But how this problem could not solved in polynomial-time ?
Comment: https://cs.stackexchange.com/q/142528/755
Comment: @D.W. I can not open this page in your comment.
Comment: Should be back visible again.
Comment: @D.W. Thank you, but i ask this question earlier, probably he/she is one of my classmates :)
Answer: Let $\langle S, t\rangle$ be an instance of subset sum, where $S = \{x_1, \dots, x_n\}$, and $t, x_1, \dots, x_n \in \mathbb{N}^+$.
Create a graph $G = (V,E)$ where $V = \{u,v\} \cup S$ and $E$ contains:

The edge $(u,v)$ of weight $0$.
For  each $x_i \in S$, an edge $(u, x_i)$  of weight $x_i$.
For  each $x_i \in S$, an edge $(v, x_i)$  of weight $0$.

There exists a spanning tree of $G$ of total weight between $k_1 = t$ and $k_2 = t$ (i.e., exactly $t$) if and only if $\langle S, t \rangle$ is a yes-instance of subset sum.
To see this let $M$ be the edges in a spanning tree $T$ of $G$ of weight $w(T)=t$ and define $X = \{ x_i \mid (u, x_i) \in M \}$. Clearly $X \subseteq S$ and $\sum_{x_i \in X} x_i = w(T) = t$.
Consider now a set $X \subseteq S$ such that $\sum_{x_i \in X} x_i = t$ and consider the set of edges $M = \{ (u,x_i) \mid x_i \in S \} \cup \{ (v,x_i) \mid x_i \not\in S \} \cup \{(u,v)\}$. It is easy to see that $M$ induces a tree of total cost $t$.
Answer: First of all, when we reduce problem $A$ to $B$ in polynomial time, we display it by $A\le_p B$, it's means that complexity of any algorithm for solving problem $B$ is at least hard as  problem $A$. From this we act as follow:
Suppose you are Given un-dircted weighted graph $G=(V,E,M,\omega)$  with weight function $\omega:E\to \mathbb{R}$, and $k_1=k_2=M$. Then reduce finding spanning tree $T$ of $G$  to Integer programming as follow:
$$x_{ij} = \begin{cases}
  1 & \text{if edge $(i,j)$ in } T,
   \\
   0 & \text{otherwise.}\\
\end{cases}$$
$$\min 1$$
$$\text{S.t }\sum_{(i,j)\in T}x_{ij}=n-1$$
$$ \sum_{(i,j)\in T}x_{ij}\omega(i,j)=M$$
$$ x_{i,j}\in\{0,1\}$$
Now we formulate Subset-sum with  problem as Integer programming as follow:
Suppose given numbers $S=\{a_1,a_2,\dots,a_n\}$, and target value $M$, the goal is to find a $S'\subseteq S$ :
$$x_{i} = \begin{cases}
  1 & \text{if  } a_i\text{ appear in solution},
   \\
   0 & \text{otherwise.}\\
\end{cases}$$
$$\min 1$$
$$ \text{S.t }\sum_{i\in S'}a_ix_i=M$$
$$ x_{i}\in\{0,1\}$$
So, if we look at the above formulation of the two problems  there are some relation between them.
Now, i try to convert an instance of Subset-sum to spanning tree problem, to show that finding spanning tree at least hard as subset-sum.
Construct a graph $G'$ with $n+1$ vertices,and weight function $\omega:E\to \mathbb{R}$, and un-dircted edge set $E$ as follow:
$$V=\{s,a_1,a_2,\dots,a_n\}$$
$$E=\{(s,a_1),(s,a_2),\dots,(s,a_n)\}\cup\{(a_1,a_2),(a_2,a_3),\dots,(a_{n-1},a_n)\}.
$$
Finally assign  weight  to each edge as follow
$$\forall i\in\{1,2,\dots,n\} $$
$$\omega((s,a_i))=0,\omega((a_i,a_{i+1}))=a_i.$$
Clearly our reduction can be done in polynomial time in size of the input size. So if there is a algorithm $\mathbb{A}$ to find a spanning tree $T$ in $G'$ with
$$\sum_{e\in T}\omega(e)=M$$ in polynomial time of the input size, then we solve
subset-sum problem in poly time. As a result your mentioned problem is NP-complete.
Answer: Try to think what happens when $k_1=k_2$. It makes the question much more difficult.
In fact, consider the following reduction from subset sum: Say we have a set of numbers $S=\{a_1,\dots,a_n\}$ and a target value $t$. Let us choose $k_1=k_2=t$, and build the following graph $G$:
$G$ will have $n+1$ nodes: a special node will be called $v$, and another node $u_i$ for every $1\le i\le n$. We will put an edge between $v$ and $u_i$ with the cost of $a_i$, and another edge between $v$ and $u_i$ with a $0$ cost.
Finding a spanning tree $T$ in this case would be the same as choosing a subset $A$ of $S$, and the sum of the weights of $T$ will be the sum of the values in $A$. Hence, finding a spanning tree $T$ with weight sum equal to $k_1=k_2=t$ is equivalent to finding a subset $A\subseteq S$ with sum $t$.
Note: its not hard to do a similar reduction if you want the graph to be simple (i.e, every two nodes have at most one edge between them).


How to link ibOutlet from subview to custom UIView Class in storyboard xcode

Question: I think this image explains it all. I have a subclass of UIView that I've entered into the class field. I'm trying to connect ibOutlets between the storyboard and class implementation. It's not giving me an error, but it's not working either. Is this another xcode bug, or am I expecting this to work in a way that it won't?
Answer: Here is a solution:
1) Type an IBOutlet by hands in your header file, example:
@property (strong, nonatomic) IBOutlet ProgressBarElementView *targetProgressElement;

2) Drag the pin from the code to the element in document outline zone
Comment: Make sure the view has been set as the custom class otherwise this won't work.
Answer: I have the same problem.. I saw that if you add the custom class to the root view in the view controller, it will work.. In your case this is the initial View, listed under Bottom Layout Guide
But there must be a better way
Answer: To overcome XCode stubborness, especially when you need to hook up different enums from UIControlEvent than UIControlEventTouchUpInside, I'd rather use code directly from within the custom view class:
SWIFT
button.addTarget(self, action:#selector(ClassName.handleRegister(sender:)),
                          for: .touchDragExit)

OBJECTIVE-C
[self.button addTarget:self
                action: @selector(buttonTouchDragExitAction:)
      forControlEvents:UIControlEventTouchDragExit];

One might include such code in awakeFromNib or viewDidLoad or where it best suits.
Answer: write the outlet inside your custom UIView
    @IBOutlet weak var imageView: UIImageView!

then drag it into the storyboard on the view


Is it unprofessional to send meeting invites on weekends/holidays?

Question: I had to schedule meeting for Monday but for some reason or the other it I couldn't finish work on Friday and therefore I wasn't sure if I should schedule meeting on Monday. But on weekend I worked and was able to finish the work and ready to host the meeting on Monday. But I am not sure if I should wait till Monday morning to send them invite for the meeting or it's okay to send it on Weekends?
Comment: Are your concerns about others to see the time you sent the invitation? If you "should" work on weekends then why not send emails on weekends. If management doesn't like you to work on weekends then you better don't.
Comment: @Fattie In my own experience, showing some flexibility on this can have some benefits when needing flexility the other way around though. I know some employers will abuse the situation, but some others are really fair play on this. Some weeks I put 45 hours, some other weeks I need more personnal time and only put 35 hours... life will be life, as long as I don't feel exploited I'm good with it. Note that I don't expect this from others and fully understand colleagues not doing it.
Comment: Note that this question also applies to evenings... I usually start shortly before 9 but am keen on accepting meetings earlier some days as long as I can organize myself. But if you send an invite on Monday evening for a meeting at 8 on Tuesday, don't expect me to be there... and if the meeting is set at 9 don't expect me to be fully prepared.
Comment: Are you emailing the invite?
Comment: @Kilisi Yes, it's a virtual meeting.
Comment: The overwhelming problem here is that you **worked on the weekend**.  life has one simple rule: **never, ever, ever work after 5.00.00PM**  work your official 35.0000 hours (or whatever it is) and: leave.
Answer: You can send the meeting invite over the weekend. Nobody will see it anyway … at least that is the assumption you should make.
Most calendar / meeting apps have the ability to set "quiet time". For example, I have both Outlook and Teams set to not send any notifications between 8pm and 8am, as well as on weekends and bank holidays, and during my vacation time, and I have my company phone and laptop turned off during those times. So, you could send me a meeting invite on Sunday morning 4am, and it would not disturb me because I wouldn't even know about it.
However, you should plan the meeting under the assumption that the invite will have been received no earlier than Monday 9am local time, and you should be mindful of the fact that people generally receive a large backlog of emails, messages, and meeting invites on Monday morning, so they might not be able to deal with the invite immediately.
Especially if you consider that in some parts of the world, Thursday was a bank holiday, and a lot of people will have taken Friday off as well. So, if there's anybody in your list of invitees that deals with international partners, they may be flooded with a backlog of emails from a 4–5 day period.
Some of my colleagues don't even have the possibility of receiving work-related emails, messages, or notifications when they are not at their desk.
So, in short: yes, you can send the invite, but you should treat it as if you had sent it at start-of-business on Monday morning, and you should be prepared that invitees might not be able to attend at such short notice.
Personally, I always plan in such a way as-if nobody was working after lunch on Friday and before lunch on Monday, simply because during those times, people will generally be busy finishing off tasks that need to be finished before the end of the week, and catching up on stuff that happened over the weekend.
Comment: "you should plan the meeting under the assumption that the invite will have been received no earlier than Monday 9am local time"  You've really hit the nail on the head there Jörg.  Good one.
Comment: And in some other parts of the world (I'm working with India) Friday was a bankholliday...
Answer: It doesn't matter if you send the invite on the weekend or Monday. Sending it on the weekend guarantees it will be available on Monday without any obligation for people to reply or even read it on the weekend.
Answer: Send the invite as soon as you know, otherwise the closer to the time the more chance they have planned something else.
Also, since the notice you give is short don't be surprised if they cannot attend. It is not their fault the notice period is short.
Answer: Since you shouldn't expect the message to be read until Monday morning, you would, in effect, be scheduling a same-day meeting. In some orgs, this is likely enough to be impractical that it isn't even attempted. Exception being if everyone expects it and you are just finalizing some details.
Regarding the after-hours email type communications, nobody will think it is inappropriate. However I personally would be concerned that it opens the door to others who may be much more enthusiastic about this habit than I am.
In a "normal" situation, I'd consider (possibly getting up early and) sending it out Monday 6am, unless there are time zone reasons against this. If you are getting close to a big deadline and making a final push as a group, send it as soon as you have it.


invalid content length while importing 2.6 GByte xml in solr

Question: I am getting java.lang.IllegalArgumentException: invalid content length error while importing 2.6 GByte xml in solr . command i used is java -Durl=http://solrserver.local:8080/solr/solr1/update -jar post.jar dssolrprice.xml . the maxHttpHeaderSize is 10485760 in tomcat server.xml. what could be the reason
Comment: Can you write detailed error and format it at your question?
Answer: Use DataImportHandler instead, it works in a streaming fashion. You should not be sending files that big over an internet connection.
Answer: There are some limit when you post something via HTTP. i.e. I think that default size for HTTP post at Tomcat is 2 MB.
1) So maybe you can consider DataImportHandler for such kind of purposes.
2) On the other hand you can use a SolrJ client and split your data into chunks(if you can) and send them to index.


Can A 1-Bit Computer have more than 2 Registers?

Question: I was thinking about making my own minimalist TTL CPU for fun and knowledge, when this question came to mind. Basically, if a 1-Bit Computer can only recognize 2 numbers, 0 and 1, doesn't that mean that the computer could only have 2 registers or instructions? Then, I found the Motorola MC14500B, which is a 1-bit computer that has 16 instructions, with 4 pins for opcodes. Is the MC14500B considered a "true" 1-bit computer, since it has more than 2 instructions, and if so, could I apply the same concept to internel registers where there are more than just 2, but the actual logic going on in the CPU and the memory works on 1-bit? This is a simple question that I need some clarification on, so thank you for your help!
Comment: The width of the instruction word and the width of the computational data path do not necessarily need to match, and in many practical designs do not.
Comment: Thiis is somewhat reminiscent of bit slice processor architectures: https://en.wikipedia.org/wiki/Bit_slicing
Comment: Not answering your question but I would recommend using more bits. Using a 1 bit data path means a lot of control logic to serialize and deserialize all information. If you use 7400 series ICs instead of discrete transitors then there are many ICs with 4 or 8 bit data width and you might actually get something that works before you are old.
Comment: How big is the address space, just out of interest?
Comment: It's confusing to categorize computers into "bits" since there are so many bits in a computer: instruction word width, data word width, memory address space width, which one do you want it be one bit?
Answer: Yes, you can have many more than 2 internal registers and still have a 1-bit datapath and data register width.
So yes, the Motorola MC14500B is considered a true 1-bit microprocessor.
Like most processors, its instructions are wider than its data.
From your description, it sounds like you would need instructions wider than MC14500B instructions so those instructions would have room for the operand specifiers; each operand specifier wide enough to pick one register.
The Wikipedia "1-bit architecture" says

A 1-bit computer architecture is an instruction set architecture for a
  processor that has datapath widths and data register widths of 1 bit
  wide.

You might also consider a serial computer architecture, like every computer built before 1951, which relaxes one requirement and allowing data register widths much wider than 1 bit, but keeps the datapath widths 1 bit wide.
Those computers were necessarily very minimalistic because of the high cost of tubes, relays, and transistors at the time.
Good luck on your TTL CPU.
Answer: Many 8-bit CPU architectures have instructions that consist of more than one byte. I see no reason why a 1-bit CPU could not similarly have some instructions that consist of multiple bits.
At a more general level: The "bit-ness" of a CPU typically only reflects the size of its registers. It's perfectly possible (and, indeed, quite common) for instructions, the address bus, and/or even the data bus to be different widths from registers.


Broken database trigger in postgresql

Question: I have a database with a bunch of insert triggers (5) that fire pg_notify events.
These have all been working happily for about a year until 12:00 today where one of them seems to have come to a grinding hault.
I'm struggling to debug the issue.
The notification is picked up by a queue in rabbitMQ and my clients listen to that. As I said its been working fine for ages now, but went live last week and of course broke today.
I can't see the data hitting rabbitMQ, but at this stage can't work out if its a problem with the trigger not publishing the notification, or a problem with rabbit.
I can't find anything that tells me if the trigger has fired.
The code for the trigger is this
create or replace function public.notify_predl()
returns trigger
language plpgsql
as $function$
declare
my_record record;
begin
select
            to_char(NEW.datetime, 'YYYY-MM-DD HH24:MI:SS') as datetime,
            NEW.duid,
            NEW.agcstatus,
            NEW.availability,
            NEW.connectionpointid,
            NEW.dispatchmode,
            NEW.initialmw,
            NEW.intervention,
            to_char(NEW.lastchanged, 'YYYY-MM-DD HH24:MI:SS') as lastchanged,
            NEW.lower5min,
            NEW.lower5minactualavailability,
            NEW.lower5minflags,
            NEW.lower60sec,
            NEW.lower60secactualavailability,
            NEW.lower60secflags,
            NEW.lower6sec,
            NEW.lower6secactualavailability,
            NEW.lower6secflags,
            NEW.lowerreg,
            NEW.lowerregactualavailability,
            NEW.lowerregflags,
            NEW.periodid,
            NEW.predispatchseqno,
            NEW.raise5min,
            NEW.raise5minactualavailability,
            NEW.raise5minflags,
            NEW.raise60sec,
            NEW.raise60secactualavailability,
            NEW.raise60secflags,
            NEW.raise6sec,
            NEW.raise6secactualavailability,
            NEW.raise6secflags,
            NEW.raisereg,
            NEW.raiseregactualavailability,
            NEW.raiseregflags,
            NEW.rampdownrate,
            NEW.rampuprate,
            NEW.runno,
            NEW.totalcleared,
            NEW.semidispatchcap
            into my_record;
            perform pg_notify('proddl',row_to_json(my_record)::text);
            return NEW;
        end;
    $function$
    ;

===== trigger
drop trigger if exists notify_predl
on pdl;
create trigger notify_pdl
after insert on pdl
for each row
when (new.duid = 'BLAH')
execute procedure notify_pdl();

This really has me tossed at the moment.
I forgot to ask a question.  How do you debug this. For more information I have now restarted the entire client setup, have restarted the database, reinstalled the trigger function and the trigger and still this particular one is not running.
select * from pg_notification_query_usage()

returns 0.
listening for the event in psql shows that it is not infact firing at all (I listened to one that is working as well, and did get that notification).
Data is definitely hitting this table with the duid set correctly. How do I work out why this is not firing now?
I changed the trigger to after insert or update and still nothing fires.
Nope, my mistake. I didn't see the notifications in my session for some reason, but they did make it into the queue, so it seems to be working now. No idea why it needs the 'on update' now when its been working fine for months, but it seems to be working.
Comment: In particular, if you start a session and say `LISTEN proddl;`, do you get notifications? What does the function ` pg_notification_queue_usage()` return?
Comment: Sorry to hear about your troubles, but I don't see a question in your question. Are you asking how to debug triggers?
Answer: The addition of the on update stanza seems to have fixed this issue. I still have no clue why it stopped triggering on just insert but there you have it.

Broken database trigger in postgresql


Is there any benefit to lighting the torches in the game?

Question: You are given a torch that you can then use to light your way and also light torch stands spread throughout the world. I have not yet seen any real game benefit to lighting the stands though. I would even say a majority are not really in areas I even really care to light at all. Is there any mechanical benefit to lighting them up?
Answer: There are four main benefits to using the torch.

Lighting areas

The torch can be used to light areas in the game that are dark. In addition you can light the stands as you go through the game so you do not have to travel back to a bonfire or use a Flame Butterfly

Changing Enemy Reactions

Certain enemies will react differently if the player has the torch lit and equipped.

NPC Interactions

 Certain NPC's dialogs will change based on use of the torch. Blacksmith McDuff is found sitting on a chest, if the player uses the torch to light the stand on the other side of the room and reloads at the bonfire, the blacksmith will have moved to the other side and the chest will be free to open.

Environment Interaction

 Certain boss fights can be made easier with the torch. Using a torch to light certain environmental objects will change both the Lost Sinner and Baneful Queen Mytha fights.
Comment: @Maslow If you light a stand and unequip your torch you can re-light it at said stand instead of having to run back to the Bonfire. This is especially helpful in No-Man's Wharf.
Comment: `you can light the stand as you go through so you don't have to travel back`, you mean you can light torches at the already lit places? or is there some hidden save mechanic of some sort you are referring to?
Answer: In early trailers of the game, some areas were completely dark and it was necessary to hold a torch in one hand and your weapon in the other in order to battle enemies in that area. In the end it seems that From Software backed off from that game mechanic but left the torch and sconces in, but as far as I can tell no such areas remain. The sconces would certainly have been very useful in such cases.
Comment: There is a short section in the Forest of Giants where you have to go through a corridor with skeletons. It's behind a door opened with the soldier key. It's quite short, but it's completely dark.
Answer: There is at least one NPC whose behavior changes after you light the stationary torch near them.
Comment: Can you add which one in a spoiler?
Comment: @Mondrianaire covers the one one I am thinking of :)
Answer: Torches also increase the range you can see and therefore lock on distance.
Answer: In Scholar of the First Sin lighting all the torches in Things Betwixt actually does have an effect on the game, and now requires a Fragrant Branch of Yore to accomplish.
Spoily things ahead:

 A Greatsword-armed red phantom will invade you.


How to play multiple audio files in a row with AVAudioPlayer?

Question: I have 5 songs in my app that I would like to play one after the other with AVAudioPlayer.
Are there any examples of this? How can I accomplish this?
Any example code would be greatly appreciated!
Thanks!
Comment: It's very hard to find any information about this...
Answer: AVQueuePlayer work for this situation.
AVQueuePlayer is a subclass of AVPlayer you use to play a number of items in sequence.
Answer: Instead of AVAudioPlayer you can use AVQueuePlayer which suits this use case better as suggested by Ken.
Here is a bit of code you can use:
@interface AVSound : NSObject

@property (nonatomic, retain) AVQueuePlayer* queuePlayer;

- (void)addToPlaylist:(NSString*)pathForResource ofType:(NSString*)ofType;
- (void)playQueue;

@end

@implementation AVSound
- (void)addToPlaylist:(NSString*)pathForResource ofType:(NSString*)ofType
{
    // Path to the audio file
    NSString *path = [[NSBundle mainBundle] pathForResource:pathForResource ofType:ofType];

    // If we can access the file...
    if ([[NSFileManager defaultManager] fileExistsAtPath:path])
    {

        AVPlayerItem *item = [[AVPlayerItem alloc] initWithURL:[NSURL fileURLWithPath:path]];

        if (_queuePlayer == nil) {
            _queuePlayer = [[AVQueuePlayer alloc] initWithPlayerItem:item];
        }else{
            [_queuePlayer insertItem:item afterItem:nil];
        }
    }

}

- (void)playQueue
{
    [_queuePlayer play];
}
@end

Then to use it:
In your interface file:
@property (strong, nonatomic) AVSound *pageSound;

In your implementation file:
- (void)addAudio:(Book*)book pageNum:(int)pageNum
{

    NSString *soundFileEven = [NSString stringWithFormat:@"%02d", pageNum-1];
    NSString *soundPathEven = [NSString stringWithFormat:@"%@_%@", book.productId,     soundFileEven];
    NSString *soundFileOdd = [NSString stringWithFormat:@"%02d", pageNum];
    NSString *soundPathOdd = [NSString stringWithFormat:@"%@_%@", book.productId, soundFileOdd];

    if (_pageSound == nil) {
        _pageSound = [[AVSound alloc]init];
        _pageSound.player.volume = 0.5;
    }

    [_pageSound clearQueue];

    [_pageSound addToPlaylist:soundPathEven ofType:@"mp3"];
    [_pageSound addToPlaylist:soundPathOdd ofType:@"mp3"];
    [_pageSound playQueue];
}

HTH
Answer: For every song you want to make make a single AVPlayer.
NSURL *url = [NSURL URLWithString:pathToYourFile];
AVPlayer *audioPlayer = [[AVPlayer alloc] initWithURL:url];

[audioPlayer play];
You can get a Notification when the player ends. Check AVPlayerItemDidPlayToEndTimeNotification when setting up the player:
  audioPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;

  [[NSNotificationCenter defaultCenter] addObserver:self
                                           selector:@selector(playerItemDidReachEnd:)
                                               name:AVPlayerItemDidPlayToEndTimeNotification
                                             object:[audioPlayer currentItem]];

this will prevent the player to pause at the end.
in the notification:
- (void)playerItemDidReachEnd:(NSNotification *)notification
{
    // start your next song here
}

You can start your next song as soon as you get a notification that the current playing song is done. Maintain some counter which is persistent across selector calls. That way using counter % [songs count] will give you an infinite looping playlist :)
Don't forget un unregister the notification when releasing the player.
Comment: what do i put in playerItemDidReachEnd? audioPlayer2 play? what if I have 5 songs?
Comment: yeah you could do that. The code i put above is theoretical. It could would but not guaranteed. But the idea seems workable...
Answer: Unfortunately, AVAudioPlayer can only play one file. To play two files, you have to kill the first instance of the AVAudioPlayer and recreate it a second time (it can be initiated using - (id)initWithContentsOfURL:(NSURL *)url error:(NSError **)outError). The problem with this approach is that there is a slight delay between when the first file finishes playing and when the second file starts playing. If you want to get rid of this delay you have to dig into Core Audio and come up with a much more complex solution.
Comment: i think there is a way. check out my answer. `AVPlayer` has a notification selector which tells us when a currently playing song is over. That way we can play our next song as soon as current is done. That could work.
Comment: I actually made a radio app for the iPhone and iPad. I know as of iOS 4.2 there was still a delay when trying to play two files in a row using AVAudioPlayer. I even tried to prep a separate AVAudioPlayer using the `prepareToPlay` method and have the second one start playing as soon as the first one was done, but there was still a slight delay. If you don't mind a slight delay between the sounds it's no big deal, but if you want completely continuous playback between the two files I don't think AVAudioPlayer is the way to go.
Comment: cant imagine having a noticeable gap when trying to use notification unless the audio file itself has white noise or some blank noise at the end. That way `AVAudioPlayer` would still play but the user thinks there is gap. Still curious to know why this is so...
Comment: the gap comes from the AVAudioPlayer prepping to play the audio file