Possible paths of analytic continuation

Question: Let $U\subset \mathbb{C}$ and $U$ open. Let $f:U\rightarrow \mathbb{C}$ and $f$ holomorphic. Let $p\in U$. Let $\gamma$ be path starting from $p$.
definition $f$ can be analytically continued along path $\gamma$ iff there exists an indexed finite set of tuples $(D_i,f_i)_{i\in I}$ where $D_i$ is a an open disc and $f_i$ is a holomorphic function on it such that for all $i,j \in I$ $f_i|_{D_i\cap D_j}=f_j|_{D_i\cap D_j}$ and for all $i\in I$ $f_i|_{D_i\cap U}=f$.
$V(f):=\{q\in \mathbb{C}: \ \exists $ a path $ \gamma $ starting at $p$ and ending at $q $ such that $f$ can be continued along it$\}$
The question is: can we perform analytic continuation along any path in $V$ starting from a point $p$?
So far, I have only encountered functions for which this is possible. For example: meromorphic functions, sections of functions as $z\rightarrow z^n$ and solutions of linear ode's on $\mathbb{C}$.
(edit: I want to stress that the resulting extension of $f$ could be multivalued, so that is not the issue.)
Comment: I think if the path crosses itself you will run into trouble, with e.g. $z\mapsto z^\frac12$ and a path that crosses itself after winding round the origin (or simply returns to its starting point). Then you will end up with different values of $f$ at the crossing point.
Comment: Hi TonyK, thanks, I am aware that an extension may result in a 'multivalued function'. But this is not the point.  The question is really if some other point is 'reachable' by analytic continuation along any path in $V$, without defining an extension on all points in $V$ or on the union of all discs in along the path.
Comment: If that is your question, then I don't understand it :-/
Comment: Consider the case of a local section of $z\mapsto z^2$. Then $V=\mathbb{C}\backslash \{0\}$. We can perform analytic coninuation along any closed path through $V$ and the resulting local section we end up with is one coinciding with one of the two possible local sections. However, maybe there exists a function which can be continued once along a closed path, but not twice, or more.
Comment: I remember having seen an example of function that has a dense set of poles on the unit circle. Then it isn't possible to cross the unit circle.
Comment: md2perpe, I also know that example, but that does not awnser the question in any way. $V$ does not have to be $\mathbb{C}$.
Comment: I see that I misunderstood the question, and now I do not understand the question. Your attempts to clarify unfortunately don't help. What do you mean with "continued once along a closed path, but not twice"?
Comment: md2perpe, I will clarify it what I mean with 'being able to continue a holomorphic function along a path' and write as edit my question in a moment.
Comment: My definition of analytic continuation is by the way precisely the one of S. Lang. You can find it in his book _Complex Analysis_.
Comment: The meaning of "continue a holomorphic function along a path" is not what I do not understand. What do you mean with "once /.../, but not twice"?
Comment: Oh, by concatenating the same path with itself, and continue along it the function would mean continuing twice along the path (in this context you need a closed path).
Comment: If you continue a function along a closed path you might end up on another branch at the starting point. Doing it a second time might result in a third branch.
Comment: Is the problem you see that some paths might not allow for a *finite* number of steps?
Comment: No, a path has compact image.
Answer: Okay, I found a counterexample myself. Define $z\mapsto \log(z)$ as a local inverse around 1 of $z\mapsto e^z$ such that $\log (1)=0$. Define
$$
g(z)=\frac{1}{z-2 \pi i}.
$$
The set of points for which there exists a path starting at 1 along which we can analytically continue the function $g(\log(z))$ is $\mathbb{C}\backslash \{0\}$. However, we cannot analytically continue this along the path $t\mapsto e^{2t\pi i}$, since there $\log(z)$ reaches $2\pi i$ and $g$ explodes on that value.
Answer: I don't have my copy of Lang's "Complex Analysis" handy to see exactly what he wrote, but I suspect that there is a small underlying misunderstanding that makes it harder to address this precisely.
Also, there is a not-so-trivial theorem (perhaps attributable to Weierstrass?) about a condition under which analytic continuation is guaranteed... Probably some version of it is in Lang's book. I believe also in Ahlfors'.
First, I have a suspicion that the desired hypothesis is something in the following direction: for some non-empty open subset $U$ of $\mathbb C$, for every $z_o\in U$ there is an open neighborhood $U_{z_o}\subset U$ of $z_o$ and a holomorphic function $f_{z_o}$ on $U_{z_o}$ (possibly a set of them, or a vector space, or...) ... with some sort of compatibility conditions on non-empty overlaps $U_{z_1}\cap U_{z_2}$.
(Typical instances are that the local bits $f_{z_o}$ are local solutions of an algebraic equation, or of a linear differential equation. But the set-up does admit some abstractions/generalizations.)
Then the theorem asserts the existence of an analytic continuation along any path inside $U$.
No, it does not assert that the analytically continued pointwise value(s) match the starting value, in case the path returns to the beginning point.
In fact, the Monodromy Theorem asserts that the values obtained by analytic continuation depend only on the homotopy class of a closed path (and base point, if the open $U$ is not connected).
Thus, analytic continuation (with a connected open) gives a group homomorphism from the first homotopy group to a Galois group, in the case of an algebraic equation, and to a group of automorphisms of the vector space of solutions to a homogeneous linear differential equation (with analytic coefficients...)
Answer:
The question is: can we perform analytic continuation along any path in $V$ starting from a point $p$?

This question looks clear enough for me to answer it.
Yes, we can perform analytic continuation along any path having enough space around it to allow it. The resulting functions might however differ. These different functions are called branches.
Comment: This does not convince me. The possibility of analytic continuation along a path could also depend on its homotopy type.

Possible paths of analytic continuation


Limiting node access to certain users based on an entity reference field. Which hook to use for when node is viewed?

Question: Scenario:
"Teams" content type has user entity reference field.
"Manager" role can add teams to nodes they have created and the teams will change often.
Members of the team can only view the nodes (and nodes that reference that node through another entity reference field) whenever their team is assigned to them.
For these content types, performance isn't an issue. What I want to do is use a series of views_get_view_result when the node is viewed and redirect away from the node if necessary. That part is easy.
What is the best hook to use for when the node is viewed and I can run my views to find out if the user should view it?
Thanks
Answer: In similar situation I used hook_entity_access. Also there is hook_ENTITY_TYPE_access so you can use the hook_node_access.


Strange behaviour with mysql and tomcat

Question: I have a strange behaviour in my application
The application normally starts in 30 seconds but sometimes it takes 7 minutes to start.
It starts in 30 minutes again only when I restart mysql.
Mysql is installed using

apt-get install mysql-server

and I did not change any of its default settings.
Can anyone please just guide me where to look and what should I suspect here?
Thnx
Comment: Have you shut down things cleanly?
Answer: I believe this might be something to do with uncommited transactions. As I have had something similar to this.
Another option might to look at any dead locking happening.
Im assuming when the application starts it immediately accesses the database.
First will usually be successful, then because of uncommited transactions, the second and subsequent starts of the Application will result in it hanging for a period of time.
Answer: Get your Tomcat's PID with jps and check what your threads do (or waiting for) with jstack.

Strange behaviour with mysql and tomcat


What to do with questions & answers regarding free extensions?

Question: Ref: Is there any free extension available for designing products label or cover in magento?
OP asks specifically for a free extension, but "answers": so far are paid extensions only. I deleted the first answer because it was a link-only answer and to a paid solution (∴ spam). I really, really do not like deleting content, but I really, really do not want this SE site to become a spamhaus.
When should we delete? When should we not?
EDIT: Rules for questions & answers involving paid extensions

Proposed that:

In general, deleting content is not desirable. Deleting relevant content should be avoided altogether. Sometimes, paid extensions provide a great & cost-effective solution to a question, so questions and answers involving paid extensions should be allowed.
When someone asks about a free extension, answers mentioning paid extensions are subject to deletion if there is no attempt to address the lack of availability of a free extension.
Answers which mention a given extension (or single vendor's extensions) should seek to address the question's topic directly. Link-only answers in this context will be deleted.
Answers mentioning extensions - when coming from users with low post counts and/or posts mentioning particular extensions, extension vendors, or using affiliate links - will be subject to deletion.
Questions which seem to be leading or clearly related to promoting a particular extension or set of extensions will be subject to deletion.

Perhaps we should require disclosure when someone mentions a product in which they have a stake, paid or not?
Comment: The reason I'm so tweaked about that question is because the extension requested is so specific to a type of industry. They'll (assumably) make money on the resulting store, and you're already getting a free ecom platform. It's like, what more do you want? Spend some money on the extension that drives your entire business model.
Comment: I hear you on that, and I left a comment as such.
Comment: I think the rules you came up with sound great.  I guess one thought that I have is that asking specifically about free extensions doesn't seem to be a valid question.  People should just ask what extensions are out there to solve *a given problem* and if there are relevant free or paid extensions they should be mentioned.  Asking specifically about free extensions seems weird.  Not that I'm biased or anything.
Comment: Yes, asking about free extensions feels a bit weird, but remember that there are freelancers dealing with small clients and being able to bootstrap their dev with existing free work is legitimate.
Answer: I completely agree with you Ben. I think it OP emphasised that extension has to be "free" promoting a paid extension is not only spam but also absolutely false answer.
The question with commercial extensions was raised more then enough here. We definitely will not be able to find a silver bullet here. Commercial extensions related questions are all different and has to be treated individually. This time I'm absolutely agree with your decision.
Comment: Edited my question - would like to have some standard which we can make public.
Comment: Hey Ben, I absolutely agree with all points. I will contact the SE and will ask if we can add it to FAQ. The only idea is regarding #2. Maybe we disallow linking in general and allow only naming paid extension?
Comment: My preference would be to allow linking if it's relevant. At least the links are `rel="nofollow"` so that should reduce some of the impetus to spam.
Answer: I say just edit the question to remove the word "free".   If there's a good free extension it'll pop-up in the answers regardless, and not limiting the answers to one type of extension creates a better artifact for future internet users who find the page.
Comment: Interesting. If moderators are taking this action consistently, should we not notify users that we are effectively banning requests for free extensions? Of the questions I've seen regarding "free extensions", the users needs were tied explicitly to the extension being free. I think these edits fall under the "changing the original meaning" clause.
Answer: A complex question - but I think what you've proposed is a fair approach. I agree that affiliate links and link only posts which do not adequately address the question should be removed.
A couple of points to add to the discussion:

Similar to what Alan mentioned: Stackexchange answers have two
audiences: the original poster as well as future googlers (who may be
looking for an extension with similar functionality, but not
necessarily only looking at free extensions). What you've proposed in
point 2 sounds like a fair approach to balancing the needs of current
and future audiences
For point 2, it may also be appropriate for answers to refer to paid extensions if the free extension options are limited or would
only partially meet the need outlined in the question
I don't believe that nofollow links stop links being posted. These links would still provide value to the poster through
potential sales, even though they may not count towards google
rankings (from the main SO site this is the highest per visit value
referral traffic for Fooman - mind you none of the links added there
have been added by me)
An unbiased evaluation of a free or paid extension on Stack exchange is usually significantly more credible than potentially untrustworthy reviews posted on other sites. The posts that we want to attract mention a range of extensions and don't simply restate what is in the extension's description, but instead offer advice such as "I have used Y before with X outcome, have dealt with this vendor" etc. Disclosure is something we should encourage but not rely on.

In summary
With so many extensions now available it is unlikely that only one solves the problem and all posts that mention only 1 commercial solution should be scrutinised and are subject to deletion.
Comment: I like everything which you've said here, and it's good to have some perspective from a respected module developer.
Answer: As a module developer (been around for years on magento, but only recently started actively producing commercial modules), I agree with all your points.
I, for one do not want to see this become a spam ridden, module promotion platform. I simply will just go away then, and so would others, I think.
That said, it is a good forum to promote modules (be it my own, or that of another developer).
My own rule, is to first give the OP a solution, that does not require my module, and as a second option, promote the module I have (or know of) that can do the job.
I think this is fair, and a paid for module can be less costly compared to spending time developing a new solution (and frankly re-inventing the wheel)
For me, if the OP asks for a free module, then that is what I will inform them about. If they are to cheap to pay for a module, that could solve their issue quicker, and more effectively, then they should suffer for it. Any paid for module will, and can be found by potential googlers by other means.
just my 2c :)


how do you disconnect an active user logged in to a box?

Question: how do you disconnect an active user logged in to a box? There should be a command line tool that comes with Windows, but I forgot it's name. It lists all the users logged in to a box and you can force disconnect of some, because, for example, you want to Remote Desktop to it and there's too many users
Answer: You are looking for a combination of the rwinsta and qwinsta commands.
first do qwinsta /SERVER:<server_name> to get a list of session ids then do rwinsta <session_id> /SERVER:<server_name>
It should also be noted you can use the /console (rdp client < 6.0 i believe) or /admin (rdp client > 6.0 i believe) to get in onto session 0 or the console session which should allow you to kick people from the gui.


Adgamer interstitial ad doesn't show

Question: I'm trying to implement AdGamer SDK in my Unity game. I'm calling AdGamer.InterstitialAds.Show() but it doesn't show anything. Please help
Comment: Please share your code so we can help you.
Answer: It could be for several reasons:

The interstitial hasn't yet been loaded. So, check AdGamer.InterstitialAd.IsReady() before trying to show an interstitial ad
The SDK hasn't yet been initialized. Make sure to call AdGamer.InitWithGameToken(YOUR_GAME_TOKEN); before calling anything else in the AdGamer SDK. For example, you can do that in Awake() method in a script which you put on some GameObject in the first scene your game loads. Or you could create a static method with the attribute [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
to make it run at game launch before anything else. It can be in any script and there you'd initialize the SDK. The game token you get when you register your game in the AdGamer publisher console.
The initialization of the SDK may take several seconds (e.g. it may need to auto-update), so if you're trying to show an interstitial very early (right at game launch, before the starting screen) the call will likely fail. For such cases you may want to check AdGamer.IsInitialized before doing anything else.

   // in any script

   [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
   public static void InitializeAdGamerBeforeEverything()
   {
       AdGamer.InitWithGameToken(YOUR_GAME_TOKEN);
   }

   // elsewhere in code

   if (AdGamer.IsInitialized && AdGamer.InterstitialAd.IsReady())
   {
       AdGamer.InterstitialAds.Show();
   }

There is no internet connection or some firewall or other settings on your machine prevent the game from connecting with AdGamer servers

Note that the "no_fill" case doesn't exist in AdGamer: it should return at least a cross-promo ad even if no commercial ad is available in your country at the moment.
Also, please be sure to check the SDK documentation (it also comes as a PDF file inside the unitypackage)

Adgamer interstitial ad doesn't show


Ordenar apresentação de ficheiros consoante a extenção

Question: Eu tenho um código onde quero mostrar os ficheiros que estão inseridos.
Os nomes estão contidos num array que vou buscar à base de dados. Eles são apresentados da forma que eu quero mas existe alguma forma de ordenar? Como por exemplo aparecer as imagens primeiro e depois os outros sem extenções? Tenho assim o meu código.
<?php
$count=explode(",", $mos['files']);
foreach($count as $i){
  $ext=substr($i, strpos($i, ".") + 1);
  if($ext=="png" || $ext=="PNG" || $ext=="jpg" || $ext=="JPEG" || $ext=="JPG" || $ext=="jpeg"){
    echo '';
  }else{
    echo '
'.$i.'
';
  }
}
?>

Dou como exemplo o seguinte array: ajax.png,array.pdf,algo.jpg,tres.docx,sentido.doc
Comment: tem um exemplo do `array` ?
Comment: @VirgilioNovic Adicionei informação à pergunta.
Answer: Tem sim, basta usar usort, assim:
<?php

$arquivos = array("semext", "apple.doc", "foo.png", "apple.txt", "foo.png", "banana.jpg", "apple.txt");

function is_image_extension($name) {
     return preg_match('#\.(png|jpeg|jpg|gif|bmp|tiff|ico)$#', $name);
}

usort($arquivos, function ($value) {
    return !is_image_extension($value);
});

foreach ($arquivos as $arq) {
    if (is_image_extension($arq)) { //Verifica se a extensão é imagem
        echo '';
    }else{
        echo '
', $arq, '
';
    }
}

Note que a regex que usei \.(png|jpeg|jpg|gif|bmp|tiff|ico)$ checa todos nomes pelo final, tendo que ser .png, .jpg, etc, e usei o ! na frente para inverter a ordem para que as imagens sejam as primeiras.
Exemplo online no repl.it e no ideone


Vectors in $\mathbb{R}^3$: justify the inequalities $a\cdot b\le |a\cdot b|\le |a| |b|$

Question: Let $a, b$ two non null vectors in $\mathbb{R}^3$. During last calc class we used the inequalities
$$a\cdot b\le |a\cdot b|\le |a| |b|$$,
where $\cdot$ denotes the scalar product in $\mathbb{R}^3$.
The latter inequalities should be clear (it should be Cauchy-Schwarz), but where did the first one come from?
Thank you in advance.
Answer: The first one is trivial and true of any real number: $x \le |x|$ for any $x \in \mathbb{R}$ (including dot products).
This follows immediately by definition of absolute value:
$$|x| := \begin{cases}
x, & x \ge 0 \\
-x, & x < 0 \end{cases}$$
Consider proving the inequality by cases.


How can I solve this question without using calculator and in only 2.5 minuites.

Question:

  This is a math subject GRE exam question, that I know how to solve but in more than 2.5 minuets and using a calculator, may be there is some intuition for solving this question that I do not know that makes its solution quicker, could anyone help me please?
Comment: Eliminate the obvious, first: $\,\cos(t) \ge \cos^2(t) \ge \cos(2t) \ge 0\,$, and $\,\sin(x) \ge \sin(2x) / 2 \ge 0\,$ on $\,[0,\pi/4]\,$. Then you are left with only (A) and (B) to consider, which should be fairly obvious.
Comment: (B): picture graphs of all these functions in your mind.
Comment: Recall that $\sin x \cos x = \frac{1}{2}\sin2x$
Comment: why $cos^2(t) \geq cos(2t)$? @dxiv
Comment: @Intuition Because $\,\cos(2t)=\cos^2(t)-\sin^2(t)\,$.
Answer: $\sin x$ is increasing on the interval, starting at $0$ and ending at $1/\sqrt{2}$. $\cos x$ is decreasing on the interval, starting at $1$ and ending at $1/\sqrt{2}$, so $\cos x$ is bigger. Since $\cos x \leq 1, \cos^2x\leq\cos x$, so $\cos x$ is still bigger. Since $\cos 2x$ is decreasing from $1$ to $0$ on the same interval, it must be decreasing faster, so $\cos x$ is bigger than that. Lastly, since $\sin x \leq 1, \sin x \cos x \leq \cos x$, so yet again, $\cos x$ is bigger. Since $\cos x$ is strictly greater than all of the other functions on the given interval (endpoints notwithstanding), it's integral must be greater as well.
Answer: Compare the values of $\cos t, \sin t, \cos^2 t, \sin^2 t, \cos 2t, \cos t*\sin t$.  On $0 \le t \le \frac {\pi}4$.
$0 \le \sin t \le \frac {\sqrt{2}}2 \le \cos t \le 1$.  So $\cos t > \sin t$.
$\sin t < 1 $ so $sin^2 t < \sin t$.
$\cos t \le 1$ (with equality only holding and $t = 0$) so $\cos^2 t \le \cos t$ with equality only holding for $t= 0$.
$\cos t$ is decreasing for $1$ to $\frac {\sqrt 2}{2}$ and $\cos 2t$ is decreasing faster from $1$ to $0$ so $\cos 2t \le \cos t$ (with equality only holding at $0$.
$\sin t < 1$ so $\sin t*\cos t < \cos t$.  (Also $\cos t \le 1$ so $\sin t *\cos t \le \sin t < \cos t$.
For all points other that $t= 1$, $\cos t$ is the strictly largest function so the values over which the integral are taken are stricly larger so the integral of $\cos t$ is the largest value.
Answer: If $f(t) > g(t)$ whenever $a < t < b,$ then
$$ \int_a^b f(t)\,dt > \int_a^b g(t)\,dt. $$
You can eliminate two of the functions immediately because
$\sin t < 1$ and $\cos t < 1$ when $0 < t < \frac\pi4.$
To figure out which of the other three functions is greatest,
spend a few seconds graphing all three from $0$ to $\frac\pi4$
on the same pair of axes.
Answer: $\cos 2x$ is stretched along the $x-$axis, just like $\sin x \cos x=\dfrac{\sin 2x}{2}$. Thus they are smaller than $\cos$ and $\sin$.
Furthermore squaring numbers less than $1$ gives smaller numbers. So options $c$ to $e$ are out.
Recalling the graph of $\sin$ and $\cos$ is quite easy to answer that the larger is $\cos$.


How to execute a C++ console program in a C++ program?

Question: I've already tried system() and spawnl, but strangely, the .exe program that I've tried to execute within my C++ program didn't work as it should be.
this is my piece of code:
    #include <stdio.h>
    #include <process.h>

    int main(void)
    {
    puts("Executing simpleTest.exe....");
    spawnl( P_WAIT, "C:/simpleTest.exe",
    "C:/simpleTest.exe", "Using spawnl", "Arg1", "Arg2", NULL );
    system("pause");
    return 0;
    }

that simpleTest.exe is actually a C++ console application too, and I want to invoke it within a C++ console application named Invoke.exe....I wonder if that's what my problem is.
If I execute simpleTest.exe by double-clicking it, it works fine....but if I execute it with above code, it exits because it encounters an error...
I wonder where did I do wrong? Is there any other suggestion beside above code?
Oh yeah, I'm using Microsoft Visual Studio 2008 by the way...
Any help will be appreciated, thanks.
Comment: Perhaps the Current Working Directory is not what simpleTest.exe expects?
Answer: The MSVC (Windows actually) way to execute a process is via CreateProcess function. I've never used spawnl however, so I don't know how it works.
Comment: Doubly so since spawnl was deprecated in VS2k5, from memory.
Comment: Deprecated in favor of `_spawnl`. Same function, just prepended with underscore.
Answer: Using native C runtime process-creation functions would eventually call CreateProcess only. They may also create a console window, which may not be desirable.
Therefore, it is recommended to use CreateProcess or ShellExecute family of functions.


About Collatz Conjecture

Question: Please explain to me, what do Terence Tao and other mathematicians who write books about the Collatz Conjecture, what do they want to do in general? Do they want to prove this hypothesis, or disprove it?
What can we generally conclude from these books?
what are the mathematical predictions about this problem ,what is it in general?
Comment: I don't know that there is a clear consensus on the Collatz conjecture.  There are some heuristics which make it plausible, but I don't think anyone would be too terribly shocked by some big counterexample.  At the moment, all we can do is to search for counterexamples, try to prove what we can, and make predictions based on it which we can then test.
Comment: @Student I agree lulu , I also tend to believe that it is true. But to be honest, I would find a counterexample (or just a disprove) more interesting although a proof would be truely sensational.
Comment: Although they may not have solved the problem in question, they generally want to share their learnings and insights, what they conjecture might be approaches to tackle the problem, and perhaps some of the reasons why they believe the problem is difficult.
Comment: @lulu I think most who have studied the problem in any depth would be surprised by any counterexample. The reason is... there can not be some **isolated** counterexample. The smallest counterexample would be the base of a tree which branches at the same rate as the tree known to branch from 1 and its predecessors must occupy the ranges of numbers occupied by the trivial tree.  Furthermore, if it did not terminate in a loop it would also have infinitely many successors which would again have to occupy the same ranges of numbers, every odd successor also having infinitely many other predecessors
Comment: They contain what we currently know about Collatz conjecture. For example, Steiner (1977) proved that there is no 1-cycle other than the trivial (1;2); Simons & de Weger (2003) extended this proof up to 68-cycles: there is no k-cycle up to k = 68. Knowledge of this sort makes finding counter-examples easier.
Comment: @lulu incredible..You say that, maybe there is a counterexample??
Comment: Sure, why not?  I don't see how anyone could claim intuition over a problem like this, and all the trials we conduct are still on very, very small numbers (in the vast scheme of things).  Still, if you asked me to guess I'd say the conjecture is probably true.  But it's just a guess and a big counterexample would not shock me.
Comment: @lulu I appreciate you giving me an answer...
Comment: @Student As long as the Collatz problem is open we cannot rule out a counter-example. If we actually knew there isn't one, we would know that the Collatz-conjecture is true. But we do not know it yet.
Comment: @Peter Answering the question made me happy..thanks.
Comment: @Peter What is your own opinion? lulu already said. Can you ask?.
Comment: @Peter Thank you so much.
Answer: There is The Ultimate Challenge: the 3x+1 Problem by Jeffrey Lagarias (which is a collection of papers by various writers).  There are papers and chapters in books by others.
But generally, the books on the Collatz conjecture seem to be the self-published writings of cranks.
Comment: What is   crank?? Ohh sorry English is not my native language..
Comment: An interesting look at cranks is here: https://www.amazon.com/Mathematical-Cranks-Spectrum-Underwood-Dudley/dp/0883855070/
Comment: Finally...,what is your personal thought about this conjecture? can I ask??

About Collatz Conjecture


For some reason JSP documents output XML instead of HTML

Question: OK, so I am trying to set up a simple JSF application. I'm using NetBeans 6.8, Glassfishv3 and Maven2. I made a JSP document like so:
<?xml version="1.0" encoding="utf-8"?>

<f:view>

        <title><h:outputText value="#{Welcome.title}"/></title>

        <h:outputText value="Welcome"/>

</f:view>

Problem is, if I navigate to this page (http://myHost/myApp/faces/welcome.jspx), it is returned as an XML document, but with the ${Welcome.title} value populated:
<?xml version="1.0" encoding="UTF-8"?>
<title>Gymix - Welcome</title>Welcome

In Internet Explorer this looks like I would have opened an XML document. In Google Chrome the title is printed next to the text Welcome and instead of the title the URL to the page is printed on the tab.
If I change the JSP document to a plain JSP page (taglibs instead of xmlns and so on) it works and I get a proper page returned. Any ideas on what's wrong? Thanks!
Edit: sadly none of the quick fixes fixed this, so I'll look into this more. BTW, my pom.xml has jsf-api and jsf-impl dependencies with the version for both set to 1.2_14
Answer: I think you need to put in a valid doctype.
This would go below your xml declaration:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Comment: Hmm I tried this, but NetBeans is giving me an error (can't open file or something) that looks like a compilation error...
Answer: Aside from the fact that you need to set the proper doctype and content type so that the browser knows what to do with the page, you also should get rid of the old fashioned jspx format and use xhtml format to get the most benefit of Java EE 6-shipped JSF 2.0 and Facelets.
The given code should be changed to:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <h:head>
        <title>#{welcome.title}</title>
    </h:head>
    <h:body>
        Welcome
    </h:body>

Note that the doctype is included and that JSF 2.0 / Facelets will automatically take care about the right content type with help of the <h:head> component. Also note the absence of the <f:view> tag, this isn't needed anymore in Facelets.
You probably also need to reconfigure your webapp to make use of the full powers of JSF 2.0 and Facelets. To learn more about JSF 2.0 and Facelets, I strongly recommend to go through the Java EE 6 tutorial part II chapters 4-9.
Good luck.
Update: as per the comment of bobince: I would add an important note; it is true that the XML declaration (the first line) would mess the rendering mode of some webbrowsers (also see the site behind the doctype link here above), but that's certainly not an issue here. Facelets removes the XML declaration during generating the HTML of the page. The XML declaration is simply there because Facelets needs to parse the page using a XML based tool first. We're talking about a component based MVC framework and XML based templating technology, not about a plain vanilla HTML page ;)
Comment: Hmm NetBeans doesn't recognize h:head and h:body. Am I possibly using an old version of jsf-impl and jsf-api (1.2_14)?
Comment: Glassfish v3 already ships with JSF 2.0. You don't need to include any libraries yourself. Just follow the Java EE 6 and the Netbeans 6.8 tutorials.
Answer: You have to tell the browser what you're sending. I'm not exactly sure of how to do it inside a JSP though, so you'll have to figure out yourself or wait until someone more knowledgeable than me tells you.
You have to send the Content-Type HTTP header indicating your file is a text/html; charset=UTF-8.
Content-Type: text/html, charset=UTF-8
Comment: Oh, and as Darren said, setting a doctype wouldn't hurt either. However, Internet Explorer will still fail at opening the page if you keep sending it as XML.
Comment: You can set the content-type based on the extension of the request (.jspx) with a  element in web.xml
Comment: You'll also want to lose the `` does nothing anyway as those are the default properties of an XML document.
Comment: bobince is entirely correct, but I would add: Facelets **removes** the XML declaration during rendering the page. The XML declaration is simply there because Facelets needs to parse the page using a XML based tool first :)


Using variable_get from DrupalWebTestCase

Question: I would like to pull certain configuration items from settings.php from a DrupalWebTestCase in order to test my module (in this case, a SFTP module).
I want to do it this way so that I don't hardcode my SFTP credentials.
For example, in my DrupalWebTestCase, I have:
  public function test_sftp()
  {
    $this->assertTrue(variable_get('mymodule_test_sftp'));
    // then I would try to connect, etc....
  }

In settings.php:
$conf['mymodule_test_sftp'] = array(
 'host' => 'example.com',
 // etc...
);

When I run the unit testing suite, this unit test fails, the value returned by variable_get is NULL.
Edit:
Running the code below, returns the correct database settings, but I get "Undefined index: mymodule_test_sftp":
  public function test_sftp()
  {
    global $databases, $conf;
    $this->assertTrue($databases);
    $this->assertTrue($conf['mymodule_test_sftp']);
  }

Comment: Simpletest is running on separate Drupal instance witch don't have setting.php edited by you. variable_get() gets you values from system.variable but in your simpletest from simpletestxxxx.system.variable I suposse
Comment: Have you used variables_set('mymodule_test_sftp', $variable); first?
Comment: No, but I do not want to hard code my credentials. That's why I want to use settings.php
Comment: in your simpletest check the db values manually to ensure they are there
Comment: See my edit, it does pull the right databases information. I also tried with global $conf, but this still gives an error.
Comment: Thanks for the explanation, this is helpful! So if I understand correctly there's no good way to achieve this?
Comment: Except you struggle arround to design your test to edit used settings.php like normally admin (you) would do:)
Comment: Do you have an example that would work? Maybe submit it as an answer?
Comment: Unlucky no idea, but anyway I wouldnt test it like this. The Whole application will depend on this credential so if they are not there. you cant do much about it. if the credentials are stored in db anyway, why don't you make config page for your module?
Answer: Just faced a similar issue. What I have found out is that in your DrupalWebTestCase child class you still have access to all variables defined in settings.php before calling parent::setUp(). Which means you can do something like this:
class MymoduleWebTestCase extends DrupalWebTestCase {

  public function setUp() {
    $mymodule_test_sftp = variable_get('mymodule_test_sftp');

    parent::setUp();

    variable_set('mymodule_test_sftp', $mymodule_test_sftp);
  }

}

Answer: In the current Drupal 7, I found that the above is only true the first time the test case setUp() method is called. On subsequent calls, the values from settings.php will either be gone or replaced by what was in the database, which is not always the same. A local development instance of a site, for example, might have a definition for "site_name" that is different from the "site_name" value in the database copied from the live site.
You can catch that first value and use it thereafter:
class MymoduleWebTestCase extends DrupalWebTestCase {

  public function setUp() {
    static $mymodule_test_sftp = NULL;
    if ($mymodule_test_sftp === NULL) {
        // if it's not defined, don't keep checking
        $mymodule_test_sftp = variable_get('mymodule_test_sftp', FALSE);
    }

    parent::setUp();

    if ($mymodule_test_sftp) {
        variable_set('mymodule_test_sftp', $mymodule_test_sftp);
    }
  }

}


Filter out both copies of duplicated files in a vector with dplyr

Question: I'm processing files in a directory to convert a .raw filte to .wav. The output goes in the same folder and I need a way to generate a list of raw files that don't have a corresponding wav.
e.g convert this
files  <- c('2019-09-30_16:29.raw', '2019-09-30_16:29.raw.wav', '2019-10-06_09:13.raw', '2019-10-06_09:13.raw.wav',
'2019-10-06_09:15.raw', '2019-10-06_09:15.raw.wav', '2019-10-11_06:18.raw', '2019-10-11_06:18.raw.wav',
'2019-10-11_08:55.raw', '2019-10-11_17:42.raw', '2019-10-12_05:53.raw', '2019-10-12_07:34.raw',
'2019-10-12_08:43.raw')

to this
unpaired_files <- c('2019-10-11_08:55.raw', '2019-10-11_17:42.raw', '2019-10-12_05:53.raw', '2019-10-12_07:34.raw', '2019-10-12_08:43.raw')

If I strip the file extensions, duplicated or unique will get rid of the duplicates, but keep one copy of each pair. I want to get rid of both copies to just leave the unpaired files.
Answer: This is a pretty straight forward solution using the %in% function
files  <- c('2019-09-30_16:29.raw', '2019-09-30_16:29.raw.wav', '2019-10-06_09:13.raw', '2019-10-06_09:13.raw.wav',
            '2019-10-06_09:15.raw', '2019-10-06_09:15.raw.wav', '2019-10-11_06:18.raw', '2019-10-11_06:18.raw.wav',
            '2019-10-11_08:55.raw', '2019-10-11_17:42.raw', '2019-10-12_05:53.raw', '2019-10-12_07:34.raw',
            '2019-10-12_08:43.raw')

#Strip of the extension
basename<-gsub("\\..+", "", files)

#find duplicated base names
dups<-unique(basename[duplicated(basename)])

#find files which are not on the duplications list
files[!(basename %in% dups)]

#[1] "2019-10-11_08:55.raw" "2019-10-11_17:42.raw" "2019-10-12_05:53.raw" "2019-10-12_07:34.raw" "2019-10-12_08:43.raw"

Answer: You could use regex to "convert" the "wav"s to raws, which yields set "g1". Then identify the "raw"s in a second step and make set "g2". Finally what you want is the setdiff.
g1 <- paste0(unique(gsub("(.*?)\\..*", "\\1", files[grep("wav", files)])), ".raw")
g2 <- files[grep("raw$", files)]
setdiff(g2, g1)
# [1] "2019-10-11_08:55.raw" "2019-10-11_17:42.raw" "2019-10-12_05:53.raw"
# [4] "2019-10-12_07:34.raw" "2019-10-12_08:43.raw"

All in one:
setdiff(files[grep("raw$", files)],
        paste0(unique(gsub("(.*?)\\..*", "\\1", files[grep("wav", files)])), ".raw"))
# [1] "2019-10-11_08:55.raw" "2019-10-11_17:42.raw" "2019-10-12_05:53.raw"
# [4] "2019-10-12_07:34.raw" "2019-10-12_08:43.raw"


What is the best way to keep subversion users and passwords in synch with Linux users?

Question: I'm not sure what is best, keeping subversion users and passwords in synch with linux users and passwords or just having linux somehow provide subversion authentication service.
I'd prefer to just maintain only linux users since I find it easy to add and remove users on ubuntu. I'd like to issue the command "sudo adduser developer" and "developer" immediately have access to subversion repositories.
At the moment, I must first create a linux user then create subversion user with the following:
sudo htpasswd -m /var/lib/svn/mainrepo/conf/htpasswd developer
Is there a better way?
Comment: what protocol would you like to use?  http or svn+ssh protocol
Answer: You might look at just using apache authentication, and authenticating THAT with your centralized authentication scheme:
http://blogs.open.collab.net/svn/2007/03/subversion_ldap.html
Answer: FYI can see this topic: How to use Linux username and password with Subversion?
It uses PAM authentication for SVN accounts.
Are you interested on implement this over apache as the previous link or on a direct way to use SVN client from the command line?
Answer: I'd caution you on doing this ... Subversion caches credentials on UNIX systems in the $HOME/.subversion/servers directory - on systems without gnome-keyring this is unencrypted (although protected by user read-only permissions).
Anyone with a reasonable level of systems knowledge will be able to get round this level of protection and would therefore have the user's account password and be able to do anything as this user. If the user has sudo access they could potentially elevate their access to the root user.
Answer: There's an apache auth_pam_module that you can use.  Be sure to enable https for your repository if you want to do this.  The following site will walk you through it:
http://blog.eval.ca/2007/01/04/pam-authentication-for-apache-trac-and-svn/
I especially like the example for groups:
<Location "/svn/repository">
   AuthPAM_Enabled On
   AuthType Basic
   AuthName "My Repository"
   Require group developers
</Location>

That way you only have to update apache once and can add your new users to the developers group instead.


Median and Mode of a probability density function

Question: Let X be the random variable with probability density function
$$
f_X (x) = \begin{cases}
    \frac{3}{32} (-x^2+2x+3), & x\in(-1,3) \\
    0, & \text{otherwise} \\
\end{cases}.
$$
Let $M_X$ be the median of $X$ and $m_X$ be the mode. Determine $M_X+m_X$.
To calculate the mode of $f_X$, it is the value of x at which $f_X$ attains its maximum. In this case, it is $1$.
I know that generally to calculate the median,
$$
\int_{-\infty}^{M_X} f_X (x) = \frac{1}{2}
$$
But as we have an interval on $x$, should the lower limit be $-1$?
Comment: yes, the integral is $\int_{-1}^{Me} f(x)dx=0.5$
Comment: $\int_{-\infty}^{-1}f(x)dx=0$.
Answer: Yes, you can integrate from $x = -1$ instead of $x = -\infty$. The relevant concept here is the support of the distribution. When working with probability densities, you can generally ignore the parts of the domain where $f_X(x) = 0$. In these portions of the domain, the CDF is unchanged, so they have no effect on probabilities.
In this particular problem, you can split up the integral used to calculate the median into two parts, only one of which is over the support of the distribution:
$$ \int_{-\infty}^{M(x)} {f_X(x) dx} = \int_{-\infty}^{-1} {f_X(x) dx} + \int_{-1}^{M(x)} {f_X(x) dx} . $$
Then, since $f_X(x) = 0$ for $x \in (-\infty, -1)$, we have
$$ \int_{-\infty}^{M(x)} {f_X(x) dx} $$
$$ = \int_{-\infty}^{-1} {0 dx} + \int_{-1}^{M(x)} {f_X(x) dx} $$
$$ = 0 + \int_{-1}^{M(x)} {f_X(x) dx} $$
$$ = \int_{-1}^{M(x)} {f_X(x) dx} $$


Probability: Problem with $30$ books distributed to $3$ libraries

Question:
We have $30$ books. $15$ of them are Literature Books(LB) and the other $15$ are Mathematic Books(MB). We randomly distribute those $30$ books to $3$ libraries, giving to each library $10$ books. What's the probability that the first library gets $10$ LB and the second one gets $5$ LB?

This is a problem from Probability class I am attending. I am a bit confused on this...i know there are $\binom{30}{10}$ ways to distribute $10$ books from $30$ to one library but i have to take into account what's happening to the other $2$ libraries, plus there are $\binom{15}{10}$ ways to give to the first library $10$ LB. And now comes my confusion on finding the rest of these and combining them. Even a small hint may help me solve it so thanks in advance.
Answer: After you give the first library 10 books, you have $\binom{20}{10}$ ways to choose $10$ books of the remaining $20$ to give to the second library.  There no choice for the third library -- it gets whatever's left.  So, there are $$\binom{30}{10}\binom{20}{10}$$ ways to distribute the books.
Now apply the same kind of reasoning to the given distribution.  After giving $10$ LB to the first library, how many ways are there to give the second library $5$ LB?
For this particular problem, there's a shortcut.  What does the third library get?
Answer: First the probability that $10$ literature books are distributed to the first libary and no mathematic books to the second libary:
$$\frac{\binom{15}{10}\cdot \binom{15}{0}}{\binom{30}{10}}$$
Now we can distribute 5 literature books to the second libary. That means that 5 of 15 mathematic books are distributed to the second libary.
$$\frac{\binom{5}{5}\cdot \binom{15}{5}}{\binom{20}{10}}$$
The remaining books can be distributed arbitrarily, since all conditions are fullfilled
Comment: So the answer is $\frac{\binom{15}{10}\cdot \binom{15}{0}}{\binom{30}{10}}\cdot\frac{\binom{5}{5}\cdot \binom{15}{5}}{\binom{20}{10}}$?
Comment: @ΚωνσταντίνοςΚορναράκης Yes, that´s true.


I want download window appear instead of showing my mp4 file

Question: I upload some mp4 files to my private folder and some users can access those files. this is my code for letting them download my mp4 files:
function my_module_file_download($uri) {

  // Get the file record based on the URI. If not in the database just return.
  $files = file_load_multiple(array(), array('uri' => $uri));
  if (count($files)) {
    foreach ($files as $item) {
      // Since some database servers sometimes use a case-insensitive comparison
      // by default, double check that the filename is an exact match.
      if ($item->uri === $uri) {
        $file = $item;
        break;
      }
    }
  }

  if (!isset($file)) {
    return;
  }

  // Put your permission check code here.

  // When done perform the following code
  if ($can_access_file) {
    $headers = file_get_content_headers($file);
    return $headers;
  }
  return -1;
}

my problem: once my user clicks on the link of the file google chrome starts showing the file! although they can right click on the link of the file and download that, but i want the download window appear from beginning! maybe one solution is to zip the file but what about mp4 without zipping?
Answer: You can do this using htaccess, Open your .htaccess file and add the following...
<FilesMatch "\.(mp4)$">
  ForceType application/octet-stream
  Header set Content-Disposition attachment
</FilesMatch>

This should force the browser to do a left click download, rather than play the content. You can do it for multiple files types as well. After the mp4 just add |mp3, so it would look like <FilesMatch ".(?i:(mp4|mp3|pdf))$">
Comment: i added that code to the htaccess file of my localhost but did not work!
Comment: Did you flush your cache?
Comment: yeah but fruitless! Is there any difference between server and localhost? do i have to add the code at any spacial part of the file?
Comment: Try adding it to the head of the document. Or try adding just this line "AddType application/octet-stream .mp4" without the quotation marks to the head without the rest.
Comment: Please see edited answer and try that instead, it just worked for me.


How to debug users geting automatically logged out for unknown reasons?

Question: For our Drupal 6 site, we've experienced such issue that logged-in users are getting logged out for around one week or several days.
Firstly I thought this might happen with Boost module, but it seems this issue happens as our test site that runs without boost enabled. We have already set cookie time long as following in settings.php
<code>ini_set('session.cookie_lifetime',  2147483647);
ini_set('session.gc_maxlifetime',   200000);
</code>
This site is pretty big and includes a lot of custom modules/code, which make it difficult to debug what's going on. I greb the code, and no luck to find session_destroy code, or user logout code. Maybe I need to set session.gc_maxlifetime as large as session.cookie_lifetime?
Is there some way to debug this issue when users are logged out?
Answer: This issue is solved by updating this setting
ini_set('session.cookie_lifetime',  21474836); The original value '2147483647' is too big for some reason.


C++: virtual void functions error "explicit type is missing (int assumed)"

Question: This program includes a class called collection, which contains virtual void functions. The dynamic array I am making in my main should be able to accept any amount of integers from a file with each line having one number of the file. It allows the user to specify the file name they want to read. Here is the header file:
#ifndef Collection_H
#define Collection_H
class collection{
public:
    collection(); //constructor
    virtual void add(int value) = 0; //adds the value to the array
    virtual void remove(int index) = 0; //removes and item from the appropriate index location
    virtual void print() = 0; //prints item of the array comma seperated.
    virtual int get(int index) = 0; //gets item at a particular index.
    virtual int sum() = 0; //gets the sum of the array
    virtual int size() = 0; //gets the size of the array
};

The first question I have for this program is a bit more conceptual: What does virtual actually do and why would you use it and how do you actually implement it? I do know that since you have to make a derived class in order to implement the virtual functions. Therefore, here is my derived class header:
// this is the derived collection
#include "Collection.h"
#ifndef derivedcollection_H
#define derivedcollection_H
class derivedcollection: public collection
{
public:
    collection(); //constructor (error is at this line)
    virtual void add(int value) = 0; //adds the value to the array
    virtual void remove(int index) = 0; //removes and item from the appropriate index location
    virtual void print() = 0; //prints item of the array comma seperated.
    virtual int get(int index) = 0; //gets item at a particular index.
    virtual int sum() = 0; //gets the sum of the array
    virtual int size() = 0; //gets the size of the array
};
#endif

My next and final question is more of a simple error I am getting that I don't understand. For the line where collection(); is declared in my derived class derivedcollection, I am getting an error that states "explicit type is missing ('int' assumed)". While this is usually a simple error to fix, it honestly is a bit confusing as to why it gives me this error. How does it gives me this error for my default constructor when I declare it in my derived class header but not my base class header?
Comment: Constructors have the same name as the classes they're within. `derivedcollection`'s constructor must be called `derivedcollection`.
Answer: There's a ton of literature and YouTube videos out there about virtual methods. Regarding the error, your constructor should be derivedcollection(), not collection().
Answer: Virtual functions that help in implementing the dynamic polymorphism(a pillar of OOP) are explained in many tutorials in the web.
One of them is explained here
virtual void add(int value) = 0; means it is a pure virtual function that may not have any definition. The deriving class must implement its definition.
Please, note that the collection isn't a constructor for the derived class derivedcollection.
Thus, the compiler assumes its return type as integer. i.e. its a plain method.
The construct must be derivedcollection() instead of collection().
Comment: A pure virtual function can (optionally) have a definition.    However, it must be overridden by a derived class.


C# foreach statement

Question: I need some help with a for each statement, basically what happens is when a user edits a value within a cell, my foreach will apply this to all cells within the datagrid and change the value of them all, i need my foreach statement to work by iterating through the datagrid but only change the selected row that has been edited
try
{
    //loop through each of the rows in the dgv
    foreach  (DataGridViewRow row in dgvDetials.SelectedRows)
    {
        int intQtyInsp = 0;

        //if quantity inspected is empty:
        if (row.Cells[2].Value.ToString() == "")
        {
            //quantity inspected is 0. Prevents null value errors:
            intQtyInsp = 0;
        }

        intQtyInsp =
            Int32.Parse(dgvDetials.CurrentRow.Cells[2].Value.ToString());

        if (intQtyInsp < 0)   // checks the cell for a negative value
        {
            intQtyInsp = 0;   // if cells is negative submits value as Zero
        }
        else
        {
            //sets quantity inspected to value entered
            intQtyInsp = Int32.Parse(row.Cells[2].Value.ToString());
        }

        if (intQtyInsp == 0) //if quantity inspected is 0. Ignore row.
        {

        }
        else //else gather details and insert row as production.
        {
            area = dtArea2.Rows[0]["area_code"].ToString();
            inspDate = dtpInspectionDate.Value.ToString("MM/dd/yyyy");
            inspShift = cbShift.Text;
            partNo = row.Cells[0].Value.ToString();
            // dieCode = row.Cells[0].Value.ToString();
            dieCode = "";
            machine = "";
            qtyInsp = intQtyInsp;
            qtyInspRecorded = Int32.Parse(row.Cells[5].Value.ToString());
            comment = "";
            //machine = row.Cells[3].Value.ToString();

            if (qtyInspRecorded == 0)
            {
                SQLMethods.insertProduction(area,
                                            inspDate,
                                            inspShift,
                                            partNo,
                                            dieCode,
                                            qtyInsp,
                                            comment,
                                            machine);
            }
            else
            {
                SQLMethods.updateProduction(area,
                                            inspDate,
                                            inspShift,
                                            partNo,
                                            dieCode,
                                            (qtyInspRecorded + qtyInsp),
                                            comment,
                                            machine);
            }
        }
    }
    retrieveData(); //reset values
}
catch (Exception ex)
{
    MessageBox.Show(
        "Error instering production values. Processed with error: "
        + ex.Message);
}

Comment: That's a lot of code, and no question.  What's the problem with the code you've posted?
Comment: The question that is being asked here is quite clear he needs to have only one cell updating not them all.
Comment: can't see anything wrong either
Comment: use `Linq` to get only this row which you need to change. Guys question is how to update only 1 changed row not all in `DataGrid`
Comment: if i edit a cell in my datgrid view, it will update all the cells, and i only want it to update the current cell
Comment: @CHRISTOPHERMCCONVILLE select currentcell then only edit and update it.
Comment: @anonymous can you elaborate more ?
Answer: First of all, I would simplify the code here a little by splitting it into several methods that may be called from the For-loop. That would make it easier to read, and thereby easier to help you too. Just to provide an example, the following:
if (intQtyInsp < 0)   // checks the cell for a negative value
{
    intQtyInsp = 0;   // if cells is negative submits value as Zero
}
else
{
    //sets quantity inspected to value entered
    intQtyInsp = Int32.Parse(row.Cells[2].Value.ToString());
}

could be replaced with something like:
int intQtyInsp = SetQuantityInspected();

Then that method could contain the if-structure. Repeat this for other parts of the code in the loop too. Trust me, this will make your life easier.
Also, it seems as if the result of this section is never used; the value of intQtyInsp is overwritten right afterwards!:
if (row.Cells[2].Value.ToString() == "")
{
    //quantity inspected is 0. Prevents null value errors:
    intQtyInsp = 0;
}

As for your question: I'm not sure how you would get the id of the row that is currently being edited. (If possible (?), it might be getter to loop through the table / data source behind the datagrid?).
In any case, what you need to do is something like the following inside your loop:
if(IsCurrentlyEditedRow(row)){
    ...

    // (all the stuff currently in the body of your loop goes here)
    ...
}

Now you can implement the method IsCurrentlyEditedRow() to return True or False depending on whether or not the id of the current row is the the same as that of the one you are editing.
Sorry if this is not a very specific and detailed answer, hope it is of some use anyway.
Comment: see it does edit a current row the first time around when i input a value for the first time, but it is when i re-edit that same row is when all the rows update

C# foreach statement


Beating 'Blank Page Syndrome' and Projecting Intent

Question: I posted a question earlier, which a number of people pointed out was coming off too broad to make for a good post, and it was suggested I boil it down to a smaller bite, so here goes.
I have been a music nut for my whole life, more passionate about music than probably even some musicians - but always only as an obsessive consumer, never a creator. Over and over throughout my life, I've come at creating my own music from various angles, and I never succeed, always hitting the same wall.
That wall is notes.
Background:
I have a good amount of experience with DJing/controllerism, an absolutely extreme 14+ year rhythm game hobby, have taken lessons for piano/guitar/bass (1yr ea. back in high school), have played with and extensively studied the use of various DAWs and VSTs, and took part of a music theory course at community college before life circumstances forced me to move - I've also watched tens of hours of music theory lectures and tutorials. From all this, I'd like to think I have a pretty good understanding of how music 'works' and is structured. Not the kind of innate understanding one gains through practice, but I know the vocabulary and basic concepts.
Whenever I've pursued an instrument, the best I could ever do was play other peoples' music by rote memorization - and while I'm good at DJing/controllerism, that's, again, other peoples' music.
The Problem: When I try and compose my own tracks, I never even begin to feel as though I have traction. I come from a motion graphic design and programming background, so I'm used to having a pretty concrete and clear methodology for accomplishing certain things.
I'll use one specific inspiration as an example here: Let's say I'm inspired by this track, and trying to make something similar in feel: Djunya - Ites (Picks up around 1 minute in)
The best I can manage is laying down some basic, fittingly sparse rhythm, with a similar structure - slap some dub delay on there, etc. - whatever isn't right about it, I'd tune later. Then, I hit the wall - notes.
That inspiration track has a few layers of notes to consider - the bassline, the dub guitar in the middle, and the higher pitched flourishes of melody. When I listen to it, even just one little flourish of six or so notes can punch me in the heartstrings and fill me with euphoria - even the hyper-simple dub guitar ticking away behind it transports me to a whole new place...
...but when I try to do that in my own projects, nothing. I screw around on the keys, and if I manage a sequence that sounds okay, it usually clashes with the mood I want to create, and doesn't lead me into ideas for the other layers - and the notes I play sound like the stuff I was playing in my early piano lessons - all the impact and depth of Hot Cross Buns, no matter how I process, voice or tweak them. They feel like a random selection of tones, not a coherent musical phrase.
The Question: So I have the desire to create something in that vein, roughly. I have a DAW I know how to operate (Maschine Mk2) loaded to the gills with quick-access sketch tools (almost every Maschine expansion) and oodles of more complex stuff should I want it (Komplete 9 + a few other NI products). I'm staring at a blank project file, or maybe I've created a pattern or two of basic percussion.
How would you proceed from this point? How would you find a collection of notes that worked, that didn't just sound like a kid poking a piano? How do you get that initial sketch down that can be fleshed out into more?
In short: How do I notes?
Comment: I think the biggest problem here is that you don't actually realize how little you know about music theory. *Tens of hours* doesn't cut it. I've spent *thousands* of hours with music theory; as a result, notes are never a problem. You have spent most of your time with the tech, so it's reflexive / easy for you. You **need** knowledge. The idea that musicians don't need to know how to read or any training is a toxic one that is becoming more and more popular in our culture, because those are the types of musicians we see / listen to. Get some workbooks; learn an instrument; it will change you.
Comment: You may find something useful in the answers to this question as well: http://music.stackexchange.com/questions/20395/learning-to-create-melodies
Comment: And also this one (by the same poster), though neither has a selected answer: http://music.stackexchange.com/questions/23048/techniques-for-creating-melodies
Comment: @jjmusicnotes: You can manage without formal theory in many fields of music. You need to spend the time and absorb the idioms in some way though, be it by studying books or by listening/imitating. I'm certainly not against people learning theory, I've done so myself, but this comment is a bit theory-centric, I think.
Comment: I never meant to imply I can really speak on theory - just that I have the basic groundwork and vocabulary. In the disciplines where I consider myself skilled, I have indeed thousands of hours, and I know music will be no different. I mostly point out my preexisting theory knowledge so it can be safely assumed I know what scales, chords, bars, time signatures, flats and sharps, triplets, cadence etc. etc. are - also, while I personally do intend to study theory, there are countless genius musicians dating back decades who can't read sheet music or tell you what key their song is in.
Comment: @user1002617 what if you try playing around with the keys you are already familiar with. Then modulate from one to another to get a stronger mood. For emotional, sad songs, use minor keys. And i wouldn't underestimate the "kid poking a piano" playing style, my hubby who doesn't read music has actually composed a number of BEAUTIFUL songs this way. Pressing random notes and choosing the ones that sound right. Do not set a very high goal first, start small and be persistent. GOOD LUCK ☺
Comment: Inspiration can come form unlikely places. :) https://www.youtube.com/watch?v=M7yZwp77gMA
Answer: I agree largely with the other posted answer, but from the perspective of someone who has messed around with electronic music to at least a modest degree.  I have a lot of VST synthesizers (enough that I definitely stay directionless most of the time) but when I feel inspired to write . . . 'something' . . .I find it very helpful to start extremely simple.
First I find a synthesizer that I like the idea of (whatever that means at the time), then I play around until I have found a sound that I like.  Then, I will play with that sound until it essentially seems to write its own melody.  With a little concentration this can result in a melody of 4, 8, 16 bars, or a 10 minute directionless jam in the vein of countless indie acts touring college towns.
Now take this small form and copy/paste it a few times, probably with some gaps in between at least a few iterations.
Repeat this process with a bassline, or harmonies to your original part.  Keep filling in things as inspiration strikes.  If there is no inspiration for a while, start deleting things.  Or just start over, a hundred times.
There is no magic solution but the trick is in viewing the process itself as the ends you seek.  Most importantly, throw out all the rules of what you think music composition is 'supposed' to be like.
Comment: Thanks for that process outline idea.

Regarding being overwhelmed, that can definitely happen with all the stuff Komplete gives me (so sometimes I disable all of it) - but the Maschine Expansions are worth a look, you might find their concept interesting. They provide themed packs of sounds, kits, samples, presets etc, set up in such a way as to make that kind of sound-finding and sketching very easy and quick. I quite like them, even if I struggle still with notes. It allows for grab-and-go sound kits to work with, or rapid assembly of your own. Once you like what you have, you can customize
Answer:
How would you find a collection of notes that worked, that didn't just sound like a kid poking a piano?

That's just it. My field is slightly different (classical), but the way I force inspiration is roughly equivalent to "poking a piano". I have never actually worked at a piano (not even for piano pieces - I check them when I'm done), but the method is similar: I lay out notes and see what they imply, sort of "Nope, that rhythm isn't right - I need some faster passing notes to make it work"; "If I take the melody to that note, it loses tension. What happens if I take it there?"; or "The theme seems to be pushing towards this key. If I let it go there... Bingo!"
It's not unlike modelling in clay: start with an almost amorphous lump, then add clay, squeeze it in a few spots, scrape some off, and then, after a bit, you start to get a really good idea of what that lump of clay wants to be. Play with your materials, the way the kid at the piano would, but do it with a critical ear, the kind that demands "But what if I...?"
Comment: Kid poking a piano: a composition evolved in 2 minutes: https://youtu.be/IHztGoYZ3rg?t=240 :)
Answer: I am going to answer your "in short" "how do I do notes?" with a much more simplistic approach - one that works for me when I compose melodies for songs I write lyrics for.
Start by deciding what key you want to use.  Your choice of key could be influenced by the feel you want to create.  Many composers will use major keys for happy songs, minor keys for sad songs for example.
Within whatever key you choose, you have a basic set of parameters for a chord progression.  I play around with the available chords for that key (based on I,ii, iii, IV, V, vi etc.) until I arrive at a chord progression that seems to fit the vibe I am looking for.
If, as your question states, you are inspired by a particular track and want to create something with the same feel, find the chords that could be played over the notes in that track.  From there you can notate the chord progression (ie. I V IV ii I etc.) in case you want to transpose to a different key.
Once I have my chord progression down - I am ready to select the notes for the melody.  Within each chord there are three or four notes with possible octaves of each. Those notes will all work well over that particular chord in the progression.  To expand the palate of potential notes to play over that chord, I would select from the notes in the pentatonic scale corresponding to the chord I'm playing at that point in the progression.
Sticking with the pentatonic scale notes will diminish the chance of creating a sequence of notes that clash. Of course you can play around with any note in the scale for the chord you are playing over if you choose - but for me that would be more of a trial and error process than if I limit my selection to the pentatonic notes.
If you prefer that your composition not sound chord based - then after you construct the melody from notes, just take the chords out.
Comment: Loved the pentatonic scale suggestion:)
Comment: Thanks @mey  I try to keep my melodies reasonably simple - for the relatively simple songs that I write.  Plus as a hobbyist song writer, I don't have time to think about it in great depth.
Comment: and simple songs often sound good & leave lasting impression in the listener's mind.
Answer: I thought I'd pull my comments from your other question & ramble on in here, in a more answer-form…
It depends what I'm aiming for, of course…
If I'm doing sound to picture, I will start by watching the film through once, not touching anything; then back through again with a straight piano sound on record. No stopping, I'll just play left-handed, 4-note chords, as & when I feel. [almost always 4 note groups, because otherwise there is structure, but no 'flavour']
I'm a lousy player so that can sometimes generate surprises & mistakes (as I'm playing without watching what I'm doing, too busy actually watching the film & my main keyboard is to my left), which I go back & either embellish or fix later.
A 3rd pass to listen to what I did & start tweaking the basic ideas.
It's not a very disciplined method, but my head tends to be quite 'butterfly' at the best of times, so rather than have a start point, I just 'guess for a bit' then listen back to see if any of my incoherent ramblings make sense on playback.
After that I get my 'toolbox' out & start orchestrating some parts, 'synthing' others, to try pull a coherent piece from the jumble. This can be very simple to start with & I don't do full arrangements until after I get the director's go-ahead.
I would usually submit those early ideas to get some feedback on how the director feels it is going. Some people can't extrapolate from small arrangements to how it will sound with an orchestra, but fortunately a lot now can.
Makes the early stages far easier - there's nothing quite so disheartening as a full-blown score that someone wants 'happier' or "I need to feel the butterflies when she says that" [that was a real comment from one director]
It's come to be known as "I need to hear more yellow" when discussing how directors try to explain their thoughts to musicians.
If I'm doing anything more dance/pop based, quite often I'll start by running through the presets, see what jumps out, but I would usually already have a soundscape in mind, if not an actual song.
Not always, though - sometimes if I'm uninspired I'll just bang on some notes whilst flitting through presets & see what might make a nice noise. That way, I'll rarely arrive at what I thought I was trying to achieve, so it's no good if I'm writing to a brief.
If I have a tight brief but no clue as to how to get there, I'll start with the rhythm track - get a groove going & see if it suggests something. If not, it's back to the presets & bang at things to something makes even the smallest amount of sense.
If I'm writing actual songs with lyrics, I write the lyrics first & mumble a melody as I'm writing them, then find the chords to go with what I'm mumbling.
With songs+lyrics, I often tend to start setting the accompaniment out on guitar, rather than synths, but it depends what genre I'm working in.
I think, whichever way you do it, the 'magic' doesn't happen at the early stages. It's more what you do with the original ideas than those ideas themselves. Somewhere between that first fumbling pass at a new piece & the final arrangement, something gets added [more than just more notes] that can make the final thing more 'special'.
Unfortunately, that 'magic fairy dust' doesn't have a recipe, otherwise everybody would just stir it into their product & sell it;-)
Answer: I don't believe there is some magical trick you can use to get past the wall you're facing. Unfortunately, you just need to write a lot of music, and your first songs aren't going to be very good.
Writing good music is hard, and it takes experience. I'm a programmer myself, and I can tell you it's comparable in difficulty to programming. When you started writing computer programs, you had to write countless poorly formatted, rather hacky toy programs before you could move on to even moderately-sized programs. This wasn't because you weren't smart, but rather because programming just takes a lot of practice. Writing music is very similar: your first songs will not be very good because you need to get some experience under your belt.
Because of this, the only way for you to get past the wall you're facing is to force yourself to write music, even if you're not satisfied with the results at first. Once you've gone through the entire process of writing some songs, you'll have a much better sense of how to pick out the right notes, and you'll quickly see the quality of the music you write improve.
I do have some good news for your particular situation. Since you have a lot of experienceplaying music, listening critically to music, and music theory, I suspect you'll improve as a producer much more quickly than most people. However, you're still going to need to force yourself to write a few songs you're not happy with before you're able to really take advantage of everything else you've learned.
Comment: Agreed with Kevin ' s ssuggestion. @user1002617, my first composition was a crap, and i wasn't able to play any musical instrument at that time. Except the recorder flute many years ago ☺. But i kept trying and now have written more than 20 songs. (And i study music theory along the way, though i was lucky to know enough basics from my school days ). My songs tend to be simple, 16-32 bars each. Not the level of Bach or Handel☺


Mongodb | Check if any other key exist in object field other than given key in object field | length of object field type

Question: We have one use case. Let's suppose I have two documents as given below.
{
  "_id": ObjectID('123'),
  "test": {
     "a":1,
      "b":1
   }
},
{
  "_id": ObjectID('456'),
  "test": {
     "a":1
   }

Now I want those result whose "test" field has property other than "a" or in another way, I want those objects which have multiple keys/properties in a "test" field or to check the size of an object greater than 1
So, the result will be:
{
   "_id": ObjectID('123'),
   "test": {
      "a":1,
       "b":1
    }
}

I tried to make a query for the above output as shown below and it working as expected
db.col.find({"test": {"$gt": {"a": 1} }})
So, is that the right thing to do? Any downside of doing it? We want to lever-age indexes as well
Please let me know your inputs on this.
Thanks.
Answer: Demo - https://mongoplayground.net/p/bluMAU_0Dre
Use $objectToArray { "$objectToArray": "$test" } convert to array
get the size $size os array
$gt check if it's more than 1
db.collection.find({
  $expr: {
    $gt: [ { $size: { "$objectToArray": "$test" } }, 1 ]
  }
})

$expr

Allows the use of aggregation expressions within the query language.
Comment: Thanks. Is this the right way to do this? is there any downside to do this? we want to  leaver-age indexes as well
Comment: @beginner `db.col.find({"test": {"$gt": {"a": 1} }})` query can use index `db.collection.createIndex({ test: 1 })` which will be faster.


What is the meaning of an IIS http status code 404.503?

Question: Microsoft lists the IIS http status codes including the substatus codes here.
In the 404 section there are substatus codes between 0 and 20, but in my logs I get a 503 as sc-substatus
I can't find any information about it. Don't confuse this with the standard http 503 (Service unavailable) status.
Answer: A quick review of the site in question solved this question. It was setup with IP Address Restrictions, the 404.503 is logged for every request that is not from an allowed IP address.
Normally a 403 (Forbidden) status is sent, but in IIS 7+ you can specify which status to return. In the
'Edit Feature Settings' for IP restrictions choose the 'Deny Action Type':
Unauthorized - results in a 401 Unauthorized - IIS-Logs:  401.503
Forbidden    - results in a 403 Forbidden    - IIS-Logs:  403.503
NotFound     - results in a 404 Not Found    - IIS-Logs:  404.503
AbortRequest - results in a Aborted          - IIS-Logs:  not logged

Comment: More info can be found at http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-dynamic-ip-address-restrictions
Comment: which one is recommended? AbortRequest or Forbidden?
Comment: @juFo - I would actually use a 404 NotFound, otherwise you tell a potential attacker that the resource is there but not accessible to him. A 404 is just: "nothing to see here, move along"


Usar "text-overflow" com "height"

Question: Suponhamos que eu tenha uma div, eu apliquei a essa div text-overflow, para ela respeita o width da div e adicionar as reticencias(...), mas até então, ela só respeita o width, e eu queria que esse elemento do css, respeitasse o width e o height, ou seja, ele desse quebra de linha até chegar no limite do height, e quando chegar no final da ultima linha, com o limite do height, ele aplicasse as reticencias, alguém sabe como fazer?
Código css:
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
word-wrap: break-word;
width:100%;
height: 35px;
color:#FF8000;

Comment: Talvez [essa pergunta](http://stackoverflow.com/questions/6572330/) ajude.
Comment: Esse efeito não funciona no firefox, será que tem algum jeito de fazer isso?
Answer: É possível adicionar reticências em um elemento de bloco quando o texto tiver apenas uma linha. De outra forma, somente com um pouco de programação, como é mostrado em outra resposta.
Para setar essa propriedade em CSS, o código básico é esse:
.reticencias{
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

Answer: Resposta tardia mas funcional. O CSS abaixo aplicado na div (ou parágrafo) onde o texto está, limita a exibição em número de linhas, e não em altura (height).
display: -webkit-box;
-webkit-line-clamp: 3; /** número de linhas que você quer exibir */
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;

Créditos: https://stackoverflow.com/a/34559614/13185945
Answer: Não há como exibir apenas uma parte do texto e ainda adicionar reticências ao final com as propriedades CSS. Você precisaria usar comandos nativos da linguagem que estiver utilizando (PHP, ASP, etc...), porém elas apenas cortariam o texto, sem adicionar as reticências.
Para fazer o que você quer, corretamente, é preciso criar a função:
<?php
function tamanho_texto($str, $length) {
     return substr($str, 0, $length)."...";
}
?>

E depois, quando for escrever o texto, definir quantos caracteres deseja que ele tenha, de acordo com o tamanho da sua div.
<?php
echo tamanho_texto("TESTE DE TEXTO", 8);
?>

E o seu retorno seria: TESTE DE...

Usar "text-overflow" com "height"


Why two of my onClick() buttons crashes app

Question: I am teaching myself coding by making an app.
I have a minimal functioning snake game in one project https://github.com/byn3/BynSnake
My goal is to put that working snake app into an onClick() button of my app that I'm making to learn stuff https://github.com/byn3/BryanLeungApp.
My question is, how do I get the last button (the onClick "Play Snake" to stop crashing the app?
The blue "Play Snake" button that I have crashes the app when clicked. I copied over the two classes, "SnakeActivity" and "SnakeView" and modified some other stuff. My suspect is that there is something wrong with my call to start activity
public void SnakeActivity(View view) {
    Intent i = new Intent(this, SnakeActivity.class);
    startActivity(i);
}

Or that my AndroidManifest folder is incorrect in making the activity
<activity
    android:name=".SnakeActivity"
    android:screenOrientation="landscape"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

I've been doing side by side code comparisons in both projects but I finally decided to make an account and ask for help because I have been stuck on this for too long and the answer might probably be something out of my scope of knowledge.
Comment: We can't tell you how to stop the crash because we don't know what caused it and we can't know that because you have shown us no error message or logs. We can't fix a problem if we don't know what the problem is. "_The blue 'Play Snake' button that I have crashes the app when clicked_" That seems like relevant code to show us then...
Comment: put logcat here to better help
Comment: as you said Why two of my onClick() buttons crashes app but where is the code of onclick button
Answer: The reason is in your AndroidManifest.xml file. SnakeActivity should use AppComat theme. Try using Theme.AppCompat.Light.NoActionBar instead of @android:style/Theme.NoTitleBar.Fullscreen
And here is the log:
Process: com.example.android.bryanleung, PID: 2832
                                                 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.bryanleung/com.example.android.bryanleung.SnakeActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2684)
                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2751)
                                                     at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1496)
                                                     at android.os.Handler.dispatchMessage(Handler.java:102)
                                                     at android.os.Looper.loop(Looper.java:154)
                                                     at android.app.ActivityThread.main(ActivityThread.java:6186)
                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
                                                  Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
                                                     at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:359)
                                                     at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:328)
                                                     at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:280)
                                                     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:145)
                                                     at com.example.android.bryanleung.SnakeActivity.onCreate(SnakeActivity.java:37)
                                                     at android.app.Activity.performCreate(Activity.java:6684)
                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2637)

Comment: Can you please explain what _exactly_ is the problem with using `@android:style/Theme.NoTitleBar.Fullscreen` in this case?
Comment: Sure. Activity is using AppCompatActivity witch prohibits any non-appcompat themes
Comment: YOU GOT IT!! Thanks this is the right answer. I was getting the debug logs as the others requested and found that the problem was exactly this. Followed your instructions, replaced. Now it works fine and as intended. Thank you


Solarwinds Network Performance Monitor Service possibly corrupt

Question: I have a laptop running server 2003 with Solar winds software installed. This laptop is used to probe a customers network while we setup a proper server.
When the laptop is powered on and you try to run Solarwinds Network Performance monitor, it freezes until you open Task Manager, end the process, then open Services, stop the service, refresh a couple of times so it shows as stopped, and then restart the service.
Once this is done the Network Performance Monitor works fine, up until the next time the laptop is turned off and/or restarted. I have tried adding a startup script via gpedit but that didn't work. I have tried making a batch file on the desktop to be run before hand but the service just sticks in stopping. I have also tried adding a registry entry to restart the service without success, anyone any idea how I can fix this?
Comment: On the Service itself - have you tried going to the Recovery tab and setting the First, Second and Subsequent failures to "Restart the Service"? Also, you could try to do "Automatic Startup (Delayed)" as it sounds like the service gets hung waiting on a dependency.
Comment: yes I have tried all of that with the same results :-(
Answer: Investigate the resources available and performance. You haven't described your setup at all, but I'm guessing that you put the SQL server and the polling engine and the web server all on the same machine. Which is running a 10-year old OS, and is on a laptop with a drive that probably can't push a lot of IOPS. Check the CPU and memory of course, but also check the disk queue. I bet it runs pretty high.
/Edit - And  I am assuming you've checked the Windows Event Viewer and there's no clues in there, right?
Comment: I am not to certain on the setup to be fair, my manager set it up went on holiday as left me to fix the issues, yes the SQL server and the polling engine are on the laptop which only has a 120gb harddrive and 2gb RAM, there is still 76gb of hdd space left available RAM is being used at 40 - 72% I don't think there is a webserver installed @mfinni
Comment: So check the other performance stats. Use perfmon, not task manager.
Comment: using performance monitor, 0 - 100 up the left and line graphs being drawn, avg disk queue length peaks at 28 steady at 0, processor time fluctuating between 48 and 56, mem pages per sec steady at 16 peaking to 20 every 27 seconds
Comment: what's the average of the avg disk queue length?
Comment: The average is showing as 0 flatlining along the bottom with an occasional spike to 28


IIS Application Pool recycle after appsettings.config change

Question: Is the application pool automatically recycled after the appsettings.config file has been changed (and saved)? I'm asking because I want to know whether I should recycle manually or not.
Thanks!
Answer: Yes. Modifying the appconfig.config file or pushing out a fresh copy of any DLL files will trigger a refresh of the app pool for your application.
Comment: I have trouble believing this. Wouldn't an app pool refresh kill my Session? I am able to update appSettings.config without doing so.
Comment: It depends on what was in your session. If you're using SQL Server based sessions, or have some  way in your code to start up the session again based on a cookie, then you'll be fine. Otherwise you may have some of your session details (form fields, login name, etc.), but behind the scenes a new session has started.


Piano beginner - Practicing duple time with metronome - 2 clicks or 4?

Question: So, for example, the following piece - should I play it as 2 clicks per bar (say at 60 bpm) and count "1 & 2 &" to play the quavers, thereby trying to get the off beat right (and making the playing difficult)?
Or should I play to 4 clicks per bar (at twice the tempo i.e. 120 bpm) and play the 4 quavers as 4 crotchets? That will spare me trying to time the off beats and make the playing smoother.
Aurally, it seems exactly the same. So what is advisable?
P.S. - I am playing more advance LH-RH pieces than this one, but this was handy to illustrate. :-)
Answer: Use either, and both. It depends how good/bad your timing is! As a beginner, I'd start with one click for each of the shortest duration notes. Or even use two clicks per single note.
At a later stage, I might use only one click per bar, or for a bit of fun, use two clicks per bar in 4/4 time, and treat them as the beats 2 and 4 - the off beats. There are lots of imaginative ways a metronome can be used - don't just stick to the mind-numbing one-click-to-a-beat.
And you are right - this could have been written out as 4/4, using crotchets, and it would play the same.
Comment: "At a later stage, I might use only one click per bar, or for a bit of fun, use two clicks per bar in 4/4 time, and treat them as the beats 2 and 4 - the off beats. There are lots of imaginative ways a metronome can be used - don't just stick to the mind-numbing one-click-to-a-beat."

Fabulous! Will try those ahead on the road. Thank you.
Comment: +1 for the suggestion of offbeats. That's a practice method that needs all the publicity it can get.
Answer: I'd go with 2 clicks per bar.
The metronome should keep a steady tempo and optionally help with accenting but not necessarily guide you for every note. And learning to fit 2 eighth notes into the space of a quarter (or whatever subdivision is called for) is something you'll need to learn anyway without hacking the metronome clicks to use as a guide. But use what helps you because that's why you're practicing in the first place.
And there are use cases for such metronome hacking. Jazz players sometimes do the opposite in that they use less precision so that the metronome is half as fast as the actual tempo. Then they use the clicks as the 2 & 4 beats (in 4/4). Some people say it better matches the jazz feel where you might have hihat/ride accents on those beats and some say it helps you develop better time by having to fill in the beats. Personally I just think it's nicer at really fast tempos where a click every beat is too much noise and more information than I need.
Answer: I only either count or use the metronome. But as @Tim mentioned, a metronome, even though there is the agogic component in music and notation, is not aware of these...
I deliberately sometimes set the metronome to three fours to practise even meters, or vice versa, which strengthens my inner timing even more, altough metronomes I find counter-intuitive for inner rhythm development, just a tool to get you started, and fixate your mind on the multi-faceted aspects of meter and rhythm.
But I do always set the metronome first to the indicated meter. It may sound the same, but you'll find it doesn't feel the same. If you want to view these as quarter-notes, it'll only serve you to practice it technique -wise, but more complex pieces require correct interpretation of the meter.
So, to summarize, metronome doesn't have anything to do with indicated notation, and you are free to use it anyway you want, but don't overuse it, or deprive your senses of the agogical aspects of music.
Answer: Doing it right and well from the beginning will not only strengthen your foundation but enable you to progress effectively.
However, using a fast tempo may not really help you; your focus should rather be on the accuracy of the sounds you play, consistency (strength of the sound) in the sounds you are making, their actual duration (with reference to a moderate speed you will use to play them).
You should go step by steps, practice often so as to improve with time.
As a beginner, having reached that stage, you stick to the first option and proceed upward, facing and braving the challenge; that's how you actually learn if you really want to make it far.
Concentration is key.
Difficult, no. Challenging, yes; but do not be discouraged. True gold is only refined through fire.
With time, your performance will surely get better provided you do well your assignments.
I wouldn't recommend you go the other way, at a very slow pace.
It is true most often beginners want the easy way out but that's not the best in my humble opinion.
Step up your game and move out of your comfort zone. If not, you will accumulate lots of lacunae with time, thereby making it difficult for you to progress effectively and tackle advance pieces in future.
Comment: While I understand your emphasis on practice and perseverance, my question was more on number of metronome clicks.
Comment: I understand @SubirNag. I omitted that in my response. You should use the number of metronome clicks you are comfortable with, and this, with respect to the actual timing of the piece.


Uncorrelation of multivariate standard normal

Question: I have a question that probably will sound stupid, but I am approaching myself to statistic concepts. I saw that the multivariate standard normal has a distribution characterized by the parameters $0$ (that is, a vector of 0s) and $I$ as a matrix of variance-covariance. I understand the fact that each marginal has mean 0 and variance 1 (because they are standard normal) but why they are uncorrelated? I saw that 2 standard normal can have an association. Is there any way to prove it?
Comment: They are uncorrelated because here the identity matrix is the covariance matrix whose $(i,j)$th entry denotes the covariance $\mathbb{C}\text{ov}(X_i,X_j)$. In fact for multivariate normals, they are independent not just uncorrelated, a fact that is an exercise in most mathematical statistics books.
Comment: Because "multinomial" and "multivariate" have very different meanings, may we presume you are asking about a *multivariate standard Normal* distribution?  As far as your question goes, if by "uncorrelated" you mean "have zero correlation coefficient," then observe that the correlation coefficients are proportional to the off-diagonal entries in the variance-covariance matrix (by their very definition), which in the matrix $I$ are all zeros (by the definition of $I$).  Do you perhaps mean something a little different by "uncorrelated," then?
Answer: It follows pretty directly from the various definitions of the terms.
The off-diagonal elements of the variance-covariance matrix are the covariances and the diagonal elements are variances. When the diagonal elements are all 1's, the off-diagonal elements are then correlations (see the definition of correlation in terms of covariance and variances.)
With an identity variance-covariance matrix, $I$, the diagonals are indeed 1, and the off-diagonals (which are all 0) will then be correlations. i.e. if the variance-covariance matrix is $I$, all the variables are uncorrelated. With a standard multivariate normal, the variance-covariance matrix is defined to be $I$. That's the whole thing, in effect, just looking at two definitions.
If any off the off diagonal elements were not-zero, then the distribution will be multivariate normal, but the variance-covariance matrix won't be $I$ and then it's not multivariate standard normal. Further, if all the off-diagonals are 0 but not all the diagonals are 1, then the variance-covariance matrix is again not $I$ (it is multivariate normal and uncorrelated but the margins are not standard normal) and it's therefore not multivariate standard normal.
[It's also possible to have a distribution where the margins are standard normal and the variables are all uncorrelated but the distribution is not multivariate normal -- that is, to have the variables related by some non-Gaussian copula that leaves the variables uncorrelated but not independent.]