Yet another Gamma function approximation

Question: I know I have asked a similar question a couple of days, ago, but I still have a problem. I need a upper bound for:
$$ \ln\frac{\Gamma\left(\frac{x}{3}+1\right)}{\Gamma\left(\frac{x}{4}\right)\Gamma\left(\frac{x}{12}\right)} $$
Similar to this bound:
$$ \ln\left(\frac{\Gamma\left(\frac{x}{3}\right)}{\Gamma\left(\frac{x}{4}+1\right)\Gamma\left(\frac{x}{12}+1\right)}\right)\leq \left(\frac{\ln 4}{3}-\frac{\ln 3}{4}\right)x $$
I tried - as I was adviced in my previous post - applying Stirling's approximation ($ \Gamma(x)\approx\sqrt{\frac{2 \pi}{x}}{\left( \frac{x}{e} \right)}^x  $) and using the fact that $ \ln\Gamma(x) $ is a convex function and the Bohr-Mollerup theorem. After much computations, I derived:
$$ \ln\frac{\Gamma\left(\frac{x}{3}+1\right)}{\Gamma\left(\frac{x}{4}\right)\Gamma\left(\frac{x}{12}\right)}\le\ln{x}+x\left(\frac{\ln{4}}{4}-\frac{\ln{3}}{3}+\frac{\ln{12}}{12}\right) $$
But I made error somewhere (and I am not able to find it), because this inequality fails for example for $ x=4567 $... So could someone compute the upper bound for me and maybe trace when I could make the mistake? I really need these bounds. Thank you in advance... Hope someone will help me!
Comment: Given the answer to your previous question, you could use $\Gamma(t+1)=t \Gamma(t)$
Comment: Yes, I USED IT, but it yielded the result I have written. And you should read my question more carefully, as I have written also, that I used the Bohr-Mollerup theorem, which is exactly $ \Gamma(t+1)=t\Gamma(t) $.
Answer: We have the estimates
$$
0\le\log(\Gamma(x))-\left[x\log(x)-x+\frac12\log(2\pi)-\frac12\log(x)\right]\le\frac1{12x}
$$
and
$$
-\frac1{360x^3}\le\log(\Gamma(x))-\left[x\log(x)-x+\frac12\log(2\pi)-\frac12\log(x)+\frac1{12x}\right]\le0
$$
Using these, along with the fact that $\log\left(\frac{\Gamma\left(\frac x3+1\right)}{\Gamma\left(\frac x4\right)\Gamma\left(\frac x{12}\right)}\right)\sim\log\left(\frac{x^2}{48}\right)$ for $x$ near $0$,
$$
\begin{align}
\log\left(\frac{\Gamma\left(\frac x3+1\right)}{\Gamma\left(\frac x4\right)\Gamma\left(\frac x{12}\right)}\right)
&\le\left(\frac14\log(4)+\frac1{12}\log(12)-\frac13\log(3)\right)x+\frac32\log(x)-\log(12\sqrt{2\pi})
\end{align}
$$
Comment: Thank you so much, you saved my thesis!


Change post featured image

Question: I would like to you ask you. I changed the dimensions of the thumbnail size in my theme. But in the categories, it looks stretched (I mean the images associate with a post in the category view). Problem is that some pictures are in landscape and others are in portrait format. The picture is not visible in full resolution. Is there any CSS command which can help me? What do you recommend?
Answer: Using background-size: cover instead of  background-size: contain with a custom background-position ? It will cut images but preserve the same format/size for all.

Change post featured image


Changing zoom level of d3 SVG canvas?

Question: I have a test site where I am building a d3-based force-directed network graph from my own data.
If I pick about five or six genes, the nodes in my graph start to get drawn outside the canvas.
What parts of the d3 API do I need to call to control zoom level, so that nodes do not disappear off the edge of the canvas?
If available, I would definitely appreciate any code snippets that briefly explain the concept, unless the implementation is fairly simple. Thanks for your advice.
Comment: possible duplicate of [Is there a way to zoom into a graph layout done using D3?](http://stackoverflow.com/questions/7871425/is-there-a-way-to-zoom-into-a-graph-layout-done-using-d3)
Answer: D3 allows to use zoom and it's fairly easy to implement. You'll only need to wrap your graph inside a "g" element that I'll call "viewport". Then you'll assign to the zoom event of the svg element:
svg.call(d3.behavior.zoom().on("zoom", redraw))

the following function:
function redraw() {
    d3.select("#viewport").attr("transform",
        "translate(" + d3.event.translate + ")"
        + " scale(" + d3.event.scale + ")");
}

Answer: var x, y, k;
            if (d && centered !== d) {
                var centroid = path.centroid(d);
                x = centroid[0];
                y = centroid[1];
                k = 4;
                centered = d;
            } else {
                x = w / 2;
                y = h / 2;
                k = 1;
                centered = null;
            }

write the following code in zoom function
svg.attr("transform", "translate(" + w / 2 + "," + h / 2 + ")scale(" + k + ")translate(" + -x + "," + -y + ")");
for absolute scale you cann use this code
this will be helpfull for maps zooming and panning

Changing zoom level of d3 SVG canvas?


What can i do against cobblestone getting stuck in my recycler output?

Question: I have a recycler that gets fed cobblestone to the top by buildcraft pipes. Directly adjacent, i put an automatic crafting table to produce scrap boxes. However, sometimes the cobblestone gets fed in the output slot of the recycler. I think it happens when a cobblestone comes in during the operation?! Can anyone give me a tip how i can avoid this problem? Would putting a chest on top of the recycler work?
Comment: Have you tried putting the pipe on the side. This always works for my.
Answer: I think i figured it out. I accidentally had one of the pipes connected to the side, and cobblestone would get input in the output slot (although this can't be done manually, feels buggy to me). I changed the pipes to avoid that, and it solved the problem.


Conceptual question on differentiation in calculus?

Question: In Calc class, my teacher told us that the only solution to $y' = y$ is $y = ce^x$, with $c$ being a real number. I am having difficulty understanding the only part. Is there a proof of this? Or am I missing something obvious?
Comment: If $f$ is such a function, then $f(x)/e^x$ will have derivative zero.
Comment: Is there a rigorous proof that a function whose derivative is everywhere zero must be a constant? Use mean value theorem?
Answer: We have $y'=\frac{dy}{dx}=y$ where $y$ is a function of $x$. Therefore, by rearranging the equation,
\begin{align}
\frac{dy}{y}=dx\,.
\end{align}
Integrating with respect to $x$ on each side,
\begin{align}
\int\frac{dy}{y}=\int dx\implies \ln(y)=x+C\,,
\end{align}
where $C$ is an integration constant. Exponentiating both sides,
\begin{align}
e^{\ln(y)}=e^{x+C}=e^Ce^x\,.
\end{align}
As $e^C$ is just a constant, we will re-label it $c$. Also note $e^{\ln(y)}=y$. Thus $y=ce^x$.
There's probably a more formal way to see why $y=ce^x$, but I hope this explanation helps.
Answer: Expanding on Matthew's comment
Let $g(x)=f(x)/e^x$. Then, $g'(x)=\frac{f'(x)e^x-f(x)e^x}{e^{2x}}=0$ Therefore, $g(x)$ is a constant say $C$.
Then,
$f(x)=Ce^x$
Answer: The book Calculus by Tom Apostol defines ln(y) as $\ln(y) =\int \frac{1}{y} dy$. Using this definition the answer is clear as $\int \frac{dy}{y}= \int dx \implies \ln(y) = x+C $.
Following is a part of how $\ln(y)$ is defined.
Consider an equation such that $f(xy)=f(x)+f(y)$
We can see that only solution valid for entire real line is $f(x)=0$
Now consider a function which is not defined at $0$.
The domain contains 1
Then $f(xy)=f(x)+f(y) \implies f(1)=2f(1)$ so $f(1)=0$
$f(1)=f(-1*-1)=2f(-1)=0$
So $f(-x)=f(x)+f(-1)=f(x)$, so the function is even.
Now consider $ f'(xy)$ for a fixed $x$
By chain rule:   $y f'(xy)=f'(x)$ as y is treated as a constant
When $x=1$ this gives us $y f'(y)=f'(1)$
So, $f'(y)=f'(1)\frac{1}{y}$
Here we may notice that $f'$ is monotonic and hence integrable on every closed interval not containing $0$.
$f(x)-f(c)=\int_c^xf'(t) dt=f'(1)\int_c^x\frac{1}{t}dt$
This equation holds if $x$ and $c$ are both graeter than $0$ or are both less than $0$.
For a positive $x$ setting $c=1$
$f(x)=f'(1)\int_1^x \frac{1}{t}dt$
AS $f(x)$ is an even function we can have the definition
$f(x)=f'(1)\int_1^{|x|}\frac{1}{t}dt$
Therefore solution to this equation is of form $f(x)=C\int_1^{|x|}\frac{1}{t}dt$ where $c \neq 0$
The definition of $\ln$ takes $C=1$ but any solution would be of the form given above i.e. of the form $C \ln(x)$.
In this way $\ln$ is defined as $\int_1^{|x|}\frac{1}{t}dt$ such that it is consistent with its definition as inverse of exponent. Note that the inverse of exponent definition is not easily explained for irrational values of $\ln (x)$ In this sense this function is a continuous function which is an extension of the usual definition.


Hide Shared Site From Site Selector Options in SXA

Question: Hopefully, a quick question. Can you hide a shared site from the 'Site Selector' component in SXA? The site is flagged as shared and has no host name but still it shows as a selection. I assume there is a check box somewhere? Maybe I missed it.
Thanks!
Answer: As per my understanding, there is no option in Sitecore to hide a site. If you check the logic for the Site Selector, it is trying to get the children of the current Tenant like this.
  protected virtual IEnumerable<Item> GetSites() => (IEnumerable<Item>) this.MultisiteContext.TenantItem.Children;

And there is no property indicating that they are using it to mark a site as hidden.
I hope anyone has done something else to do this, but this is just my understanding.
Hope this makes sense.


Look for Android USB driver for mag tablet

Question: I can't find my tablet device on the eclipse android device manager,
after a research I found out that the problem is that the android usb device is missing.
I am looking for Android USB driver for MAG Innovision MP973G, can someone help ?
Answer: You may not need specific driver for your device, you could use drivers provided with android sdk.
You need to locate installed android <sdk> path on your machine and follow 8 steps listed here (for windows)


Do you need to dispose of objects and set them to null?

Question: Do you need to dispose of objects and set them to null, or will the garbage collector clean them up when they go out of scope?
Comment: @peter: Don't use "using" blocks with WCF client proxies: http://msdn.microsoft.com/en-us/library/aa355056.aspx
Comment: My advice is always dispose if an object implements IDisposable. Use a using block every time. Don't make assumptions, don't leave it up to chance. You don't have to set things to null though. An object just has go go out of scope.
Comment: **HOWEVER, YOU MAY** want to set some references to null inside your `Dispose()` method! This is a subtle variation on this question, but important because the object being disposed can't know if it is "going out of scope" (calling `Dispose()` is no guarantee). More here: http://stackoverflow.com/questions/6757048/msdn-dispose-example-erroneous-when-to-set-managed-references-to-null
Comment: There appears to be a consensus that you don't need to set the object to null, but do you need to do Dispose()?
Comment: as Jeff said: http://www.codinghorror.com/blog/2009/01/die-you-gravy-sucking-pig-dog.html
Comment: Yes, that's about right.
Answer: Objects will be cleaned up when they are no longer being used and when the garbage collector sees fit.  Sometimes, you may need to set an object to null in order to make it go out of scope (such as a static field whose value you no longer need), but overall there is usually no need to set to null.
Regarding disposing objects, I agree with @Andre.  If the object is IDisposable it is a good idea to dispose it when you no longer need it, especially if the object uses unmanaged resources. Not disposing unmanaged resources will lead to memory leaks.
You can use the using statement to automatically dispose an object once your program leaves the scope of the using statement.
using (MyIDisposableObject obj = new MyIDisposableObject())
{
    // use the object here
} // the object is disposed here

Which is functionally equivalent to:
MyIDisposableObject obj;
try
{
    obj = new MyIDisposableObject();
}
finally
{
    if (obj != null)
    {
        ((IDisposable)obj).Dispose();
    }
}

Comment: One remark regarding `IDisposable`. Failing to Dispose an object will generally **not cause a memory leak** on any well designed class. When working with unmanaged resources in C# you should have a finalizer that will still release the unmanaged resources. This means that instead of deallocating the resources when it should be done, it will be deferred to when the garbage collector finalizes the managed object. It can still cause many other issues though (such as unreleased locks). You should Dispose an `IDisposable` though!
Comment: @RandyLevy Do you have a reference for that? Thanks
Comment: But my question is Dispose() needs to implement any logic? Does it have to do something? Or internally when Dispose() is called signals GC that is good to go? I checked the source code for the TextWriter for example and   Dispose has no implementation.
Comment: @Mihail I haven't been doing C# lately so I could be a bit rusty, but IIRC there's nothing special about Dispose and the garbage collector, it's just a pattern in C# to release resources before the garbage collector gets around to finalizing your object. If you have a finalizer, make sure to call GC.SuppressFinalize(this) inside dispose so GC doesn't have to do more work than necessary.

See https://msdn.microsoft.com/library/b1yfkh5e(v=vs.100).aspx
Comment: @ZachJohnson thank you for your answer. Yes I know Microsoft's pattern , I know that the destructor aka finalizer is used to to get rid of unmanaged  resoures , and Dispose() is used to do both using Microsoft's pattern, but I was wondering if we acually NEED to do something about the managed resources , we all know , if a reference is out of scope the object is good to go and GC will collect it at some time. I am a bit confused , do I have to nullify the references or something , does that even help at all? I am a bit confused. Thank you again.
Comment: @Mihail you shouldn't need to worry about managed resources, or nulling things out (unless they're being referenced directly or indirectly via a static field - a memory profiler can help out here)
Comment: @ZachJohnson makes sense! Thank you very much sir! Cheers!
Answer: Objects never go out of scope in C# as they do in C++. They are dealt with by the Garbage Collector automatically when they are not used anymore. This is a more complicated approach than C++ where the scope of a variable is entirely deterministic. CLR garbage collector actively goes through all objects that have been created and works out if they are being used.
An object can go "out of scope" in one function but if its value is returned, then GC would look at whether or not the calling function holds onto the return value.
Setting object references to null is unnecessary as garbage collection works by working out which objects are being referenced by other objects.
In practice, you don't have to worry about destruction, it just works and it's great :)
Dispose must be called on all objects that implement IDisposable when you are finished working with them. Normally you would use a using block with those objects like so:
using (var ms = new MemoryStream()) {
  //...
}

EDIT On variable scope. Craig has asked whether the variable scope has any effect on the object lifetime. To properly explain that aspect of CLR, I'll need to explain a few concepts from C++ and C#.
Actual variable scope
In both languages the variable can only be used in the same scope as it was defined - class, function or a statement block enclosed by braces. The subtle difference, however, is that in C#, variables cannot be redefined in a nested block.
In C++, this is perfectly legal:
int iVal = 8;
//iVal == 8
if (iVal == 8){
    int iVal = 5;
    //iVal == 5
}
//iVal == 8

In C#, however you get a a compiler error:
int iVal = 8;
if(iVal == 8) {
    int iVal = 5; //error CS0136: A local variable named 'iVal' cannot be declared in this scope because it would give a different meaning to 'iVal', which is already used in a 'parent or current' scope to denote something else
}

This makes sense if you look at generated MSIL - all the variables used by the function are defined at the start of the function. Take a look at this function:
public static void Scope() {
    int iVal = 8;
    if(iVal == 8) {
        int iVal2 = 5;
    }
}

Below is the generated IL. Note that iVal2, which is defined inside the if block is actually defined at function level. Effectively this means that C# only has class and function level scope as far as variable lifetime is concerned.
.method public hidebysig static void  Scope() cil managed
{
  // Code size       19 (0x13)
  .maxstack  2
  .locals init ([0] int32 iVal,
           [1] int32 iVal2,
           [2] bool CS$4$0000)

//Function IL - omitted
} // end of method Test2::Scope

C++ scope and object lifetime
Whenever a C++ variable, allocated on the stack, goes out of scope it gets destructed. Remember that in C++ you can create objects on the stack or on the heap. When you create them on the stack, once execution leaves the scope, they get popped off the stack and gets destroyed.
if (true) {
  MyClass stackObj; //created on the stack
  MyClass heapObj = new MyClass(); //created on the heap
  obj.doSomething();
} //<-- stackObj is destroyed
//heapObj still lives

When C++ objects are created on the heap, they must be explicitly destroyed, otherwise it is a memory leak. No such problem with stack variables though.
C# Object Lifetime
In CLR, objects (i.e. reference types) are always created on the managed heap. This is further reinforced by object creation syntax. Consider this code snippet.
MyClass stackObj;

In C++ this would create an instance on MyClass on the stack and call its default constructor. In C# it would create a reference to class MyClass that doesn't point to anything. The only way to create an instance of a class is by using new operator:
MyClass stackObj = new MyClass();

In a way, C# objects are a lot like objects that are created using new syntax in C++ - they are created on the heap but unlike C++ objects, they are managed by the runtime, so you don't have to worry about destructing them.
Since the objects are always on the heap the fact that object references (i.e. pointers) go out of scope becomes moot. There are more factors involved in determining if an object is to be collected than simply presence of references to the object.
C# Object references
Jon Skeet compared object references in Java to pieces of string that are attached to the balloon, which is the object. Same analogy applies to C# object references. They simply point to a location of the heap that contains the object. Thus, setting it to null has no immediate effect on the object lifetime, the balloon continues to exist, until the GC "pops" it.
Continuing down the balloon analogy, it would seem logical that once the balloon has no strings attached to it, it can be destroyed. In fact this is exactly how reference counted objects work in non-managed languages. Except this approach doesn't work for circular references very well. Imagine two balloons that are attached together by a string but neither balloon has a string to anything else. Under simple ref counting rules, they both continue to exist, even though the whole balloon group is "orphaned".
.NET objects are a lot like helium balloons under a roof. When the roof opens (GC runs) - the unused balloons float away, even though there might be groups of balloons that are tethered together.
.NET GC uses a combination of generational GC and mark and sweep. Generational approach involves the runtime favouring to inspect objects that have been allocated most recently, as they are more likely to be unused and mark and sweep involves runtime going through the whole object graph and working out if there are object groups that are unused. This adequately deals with circular dependency problem.
Also, .NET GC runs on another thread(so called finalizer thread) as it has quite a bit to do and doing that on the main thread would interrupt your program.
Comment: @Igor: By going 'out of scope' I mean that the object reference is out of context and cannot be referred to in the current scope.  Surely this still happens in C#.
Comment: @Craig Johnston: See http://blogs.msdn.com/b/ericgu/archive/2004/07/23/192842.aspx : "there is no guarantee that a local variable will remain live until the end of a scope if it isn't used. The runtime is free to analyze the code that it has and determine what there are no further usages of a variable beyond a certain point, and therefore not keep that variable live beyond that point (ie not treat it as a root for the purposes of GC)."
Comment: @Tuzo: True.  That's what GC.KeepAlive is for.
Comment: @Craig Johnston: No and Yes.  No because the .NET runtime manages that for you and does a good job.  Yes because the job of the programmer is not to write code that (just) compiles but to write code that *runs*.  Sometimes it helps to know what the runtime is doing under the covers (e.g. troubleshooting).  One could argue that it's the type of knowledge that helps to separate good programmers from great programmers.
Comment: @Craig Johnston, don't confuse variable scoping used by the compiler with variable lifetime which is determined by the runtime -- they are different.  A local variable may not be "live" even though it is still in scope.
Comment: @Tuzo: you will need to elaborate. The only kind of scoping I am talking about is the scoping that makes a variable local to a function go out of scope when the functions finishes. What is the other kind of scoping?
Comment: @Tuzo: Is the 'life' of a variable of any relevance to the programmer?  It sounds like something that happens well after the programmer has written and compiled the code.
Comment: Well, just like the rest of the program, variable lifetime is inherently a run-time characteristic of a program. Yes it happens after the programmer wrote the code, but just like any code, the programmer has some control over the runtime behaviour.
Answer: As others have said you definitely want to call Dispose if the class implements IDisposable. I take a fairly rigid position on this. Some might claim that calling Dispose on DataSet, for example, is pointless because they disassembled it and saw that it did not do anything meaningful. But, I think there are fallacies abound in that argument.
Read this for an interesting debate by respected individuals on the subject. Then read my reasoning here why I think Jeffery Richter is in the wrong camp.
Now, on to whether or not you should set a reference to null. The answer is no. Let me illustrate my point with the following code.
public static void Main()
{
  Object a = new Object();
  Console.WriteLine("object created");
  DoSomething(a);
  Console.WriteLine("object used");
  a = null;
  Console.WriteLine("reference set to null");
}

So when do you think the object referenced by a is eligible for collection? If you said after the call to a = null then you are wrong. If you said after the Main method completes then you are also wrong. The correct answer is that it is eligible for collection sometime during the call to DoSomething. That is right. It is eligible before the reference is set to null and perhaps even before the call to DoSomething completes. That is because the JIT compiler can recognize when object references are no longer dereferenced even if they are still rooted.
Comment: @Kevin: Correct. If `a` were a class member and the class containing `a` was still rooted and in-use then it too would hang around. That is one scenario where setting it to `null` could be beneficial.
Comment: What if `a` is a private member field in a class? If `a` is not set to null the GC has no way of knowing if `a` will be used again in some method, right? Thus `a` will not be collected until the entire containing class is collected. No?
Comment: Your point ties in with a reason why `Dispose` is important--it's not possible to invoke `Dispose` (or any other non-inlineable method) on an object without a rooted reference to it; calling `Dispose` after one is done using an object will ensure that a rooted reference will continue to exist throughout the duration of the last action performed on it.  Abandoning all references to an object without calling `Dispose` may ironically have the effect of causing the object's resources to occasionally get released *too early*.
Comment: This example and explanation doesn't seem definitive on the hard suggestion to never set references to null.  I mean, except for Kevin's comment, a reference set to null **after it is disposed** seems pretty _benign_, so what is the harm? Am I missing something?
Comment: @dathompson setting it to null twice would also be "benign" but that isn't a reason to do so. (ad absurdum...)
Comment: Is there any code analyzer that goes through the code and warns when things that should have been disposed aren't disposed?
Answer: You never need to set objects to null in C#. The compiler and runtime will take care of figuring out when they are no longer in scope.
Yes, you should dispose of objects that implement IDisposable.
Comment: If you're ever "done with it" it shouldn't be static. If it's not static, but "long-lived" then it should still go out of scope soon after you're done with it. The need to set references to null indicates a problem with the structure of the code.
Comment: You avoid it by storing the raw data in a local variable in the method that processes it. The method returns the processed data, which you keep, but the local for the raw data goes out of scope when the method exits and is automatically GCed.
Comment: If you have a long-lived (or even static) reference to a large object, you `want` to null it out as soon as you're done with it so that it's free to be reclaimed.
Comment: Then it should not store any raw data in a static field if it's only used temporarily. Sure, you *can* do that, it's just not good practice for exactly this reason: you then have to manage its lifetime manually.
Comment: You can have a static item that you get done with.  Consider:  A static resource that's read from disk in a user-friendly format and then parsed into a format suitable for program use.  You can end up with a private copy of the raw data that serves no further purpose. (Real world example:  The parsing is a two-pass routine and thus can't simply process the data as it's read.)
Comment: How in the world do you avoid it?  You have an object that obtains raw data and processes it.  The processed data persists for the life of the program.  Unless you manually dispose of the raw data the object is still going to retain a reference to it.  Whether the object is static or dynamic is irrelevant.
Comment: "*you never need to set objects to null in C#*" - bit of a wild statement do you have evidence to back that up? If I have a lazily loaded/singleton object and I subsequently call `Dispose` on it there is the potential for me to attempt to use that object after it's been disposed as there is no guarantee that the GC will `null` out the field before it's used again.
Answer: If the object implements IDisposable, then yes, you should dispose it.  The object could be hanging on to native resources (file handles, OS objects) that might not be freed immediately otherwise.  This can lead to resource starvation, file-locking issues, and other subtle bugs that could otherwise be avoided.
See also Implementing a Dispose Method on MSDN.
Comment: GC will never call Dispose(). GC might call a finalizer which by convention should clean up resources.
Comment: @leppie: finalizers are not deterministic and might not be called ( e.g. when the appdomain is unloaded). If you need deterministic finalization you must implement what i think is called a critical handler.  The CLR has special handling of these objects to guarantee that they are finalized (e.g it pre-jits the finalization code to handle low memory)
Comment: But won't the garabage collector call Dispose()?  If so, why would you need to call it?
Comment: Unless you call it explicitly, there is no guarantee that `Dispose` will be called.  Also, if your object is holding on to a scarce resource or is locking some resource (e.g. a file), then you'll want to free it up as soon as possible.  Waiting for the GC to do that is suboptimal.
Comment: @adrianm: Not `might` call, but `will` call.
Comment: @adrianm: I've also found a few odd cases, such as locker objects, where Dispose does things that Finalize does not.
Answer: I agree with the common answer here that yes you should dispose and no you generally shouldn't set the variable to null... but I wanted to point out that dispose is NOT primarily about memory management. Yes, it can help (and sometimes does) with memory management, but it's primary purpose is to give you deterministic releasing of scarce resources.
For example, if you open a hardware port (serial for example), a TCP/IP socket, a file (in exclusive access mode) or even a database connection you have now prevented any other code from using those items until they are released. Dispose generally releases these items (along with GDI and other "os" handles etc. which there are 1000's of available, but are still limited overall). If you don't call dipose on the owner object and explicitly release these resources, then try to open the same resource again in the future (or another program does) that open attempt will fail because your undisposed, uncollected object still has the item open. Of course, when the GC collects the item (if the Dispose pattern has been implemented correctly) the resource will get released... but you don't know when that will be, so you don't know when it's safe to re-open that resource. This is the primary issue Dispose  works around. Of course, releasing these handles often releases memory too, and never releasing them may never release that memory... hence all the talk about memory leaks, or delays in memory clean up.
I have seen real world examples of this causing problems. For instance, I have seen ASP.Net web applications that eventually fail to connect to the database (albeit for short periods of time, or until the web server process is restarted) because the sql server 'connection pool is full'... i.e, so many connections have been created and not explicitly released in so short a period of time that no new connections can be created and many of the connections in the pool, although not active, are still referenced by undiposed and uncollected objects and so can't be reused. Correctly disposing the database connections where necessary ensures this problem doesn't happen (at least not unless you have very high concurrent access).
Answer: If they implement the IDisposable interface then you should dispose them. The garbage collector will take care of the rest.
EDIT: best is to use the using command when working with disposable items:
using(var con = new SqlConnection("..")){ ...

Answer: When an object implements IDisposable you should call Dispose (or Close, in some cases, that will call Dispose for you).
You normally do not have to set objects to null, because the GC will know that an object will not be used anymore.
There is one exception when I set objects to null. When I retrieve a lot of objects (from the database) that I need to work on, and store them in a collection (or array). When the "work" is done, I set the object to null, because the GC does not know I'm finished working with it.
Example:
using (var db = GetDatabase()) {
    // Retrieves array of keys
    var keys = db.GetRecords(mySelection);

    for(int i = 0; i < keys.Length; i++) {
       var record = db.GetRecord(keys[i]);
       record.DoWork();
       keys[i] = null; // GC can dispose of key now
       // The record had gone out of scope automatically,
       // and does not need any special treatment
    }
} // end using => db.Dispose is called

Answer: Always call dispose. It is not worth the risk. Big managed enterprise applications should be treated with respect. No assumptions can be made or else it will come back to bite you.
Don't listen to leppie.
A lot of objects don't actually implement IDisposable, so you don't have to worry about them. If they genuinely go out of scope they will be freed automatically. Also I have never come across the situation where I have had to set something to null.
One thing that can happen is that a lot of objects can be held open. This can greatly increase the memory usage of your application. Sometimes it is hard to work out whether this is actually a memory leak, or whether your application is just doing a lot of stuff.
Memory profile tools can help with things like that, but it can be tricky.
In addition always unsubscribe from events that are not needed. Also be careful with WPF binding and controls. Not a usual situation, but I came across a situation where I had a WPF control that was being bound to an underlying object. The underlying object was large and took up a large amount of memory. The WPF control was being replaced with a new instance, and the old one was still hanging around for some reason. This caused a large memory leak.
In hindsite the code was poorly written, but the point is that you want to make sure that things that are not used go out of scope. That one took a long time to find with a memory profiler as it is hard to know what stuff in memory is valid, and what shouldn't be there.
Answer: Normally, there's no need to set fields to null. I'd always recommend disposing unmanaged resources however.
From experience I'd also advise you to do the following:

Unsubscribe from events if you no longer need them.
Set any field holding a delegate or an expression to null if it's no longer needed.

I've come across some very hard to find issues that were the direct result of not following the advice above.
A good place to do this is in Dispose(), but sooner is usually better.
In general, if a reference exists to an object the garbage collector (GC) may take a couple of generations longer to figure out that an object is no longer in use. All the while the object remains in memory.
That may not be a problem until you find that your app is using a lot more memory than you'd expect. When that happens, hook up a memory profiler to see what objects are not being cleaned up. Setting fields referencing other objects to null and clearing collections on disposal can really help the GC figure out what objects it can remove from memory. The GC will reclaim the used memory faster making your app a lot less memory hungry and faster.
Comment: What do you mean about 'events and delegates' - what should be 'cleaned up' with these?
Comment: @Craig - I edited my answer. Hopefully this clarifies it a bit.
Answer: I have to answer, too.
The JIT generates tables together with the code from it's static analysis of variable usage.
Those table entries are the "GC-Roots" in the current stack frame. As the instruction pointer advances, those table entries become invalid and so ready for garbage collection.
Therefore: If it is a scoped variable, you don't need to set it to null - the GC will collect the object.
If it is a member or a static variable, you have to set it to null
Answer: A little late to the party, but there is one scenario that I don't think has been mentioned here - if class A implements IDisposable, and exposes public properties that are also IDisposable objects, then I think it's good practice for class A not only to dispose of the disposable objects that it has created in its Dispose method, but also to set them to null. The reason for this is that disposing an object and letting it get GCed (because there are no more references to it) are by no means the same thing, although it is pretty definitely a bug if it happens. If a client of Class A does dispose its object of type ClassA, the object still exists. If the client then tries to access one of these public properties (which have also now been disposed) the results can be quite unexpected. If they have been nulled as well as disposed, there will be a null reference exception immediately, which will make the problem easier to diagnose.


Difference between とても and なかなか

Question: I am having difficulty understanding the difference between とても and なかなか.
The English meaning is the same, so are they interchangeable?
Comment: Hi, welcome to Japanese SE. Just some quick tips to help you better understand how our site works. When you post a question or answer, be sure to include as much information as possible, and possibly more importantly, cite your sources. This is a good question, but it could be improved by including some example sentences you have seen or heard from native speakers. Also, you do not need to post thank-you comments. Upvoting and/or accepting helpful answers is the way to go. Happy learning!
Answer: As a native Japanese speaker I think it's weird "とても" and "なかなか" seem to be the same in English.
That's because "とても" suggestion a different degree (either higher or lower) than what I expected and also "なかなか" sounds more or less equal to what I expected.
When the amount or value compared with what you expected is high, you should use "とても" but when the amount or value almost equals or is a little more or less than what you expected, you should use "なかなか".
I think like this. This explanation is based on my life in Japan for more than 35 years.
Answer: As a supplement to the existing answers, I would say なかなか would be closer to the English words 'pretty', 'rather', or 'quite' than 'very' which とても matches.
I have an example that may make this difference clearer, though it may be an odd example; in the forging minigame in Dragon Quest XI, a well-made item can turn out ちょっといい which is +1, なかなかいい which is +2, or とてもいい which is +3.
Comment: `なかなかいい which is +2, or とてもいい which is +3.` -- Oh, that's a とてもいい example!
Comment: @Chocolate  その通りです。「very」は「とても」や「すごく」に近いと思います。「fairly」も「pretty」も「quite」も「結構」とか「なかなか」とかとほぼ同じくらいですが、「quite」と「fairly」のほうが「pretty」よりもう少しフォーマルな感じです。
Comment: very well と fairly well (と pretty well, quite well ?) はどのくらい違います? すごく・とてもいい、結構・なかなかいい、みたいな感じですかね?
Answer: First, they are not of the same language level, とても is polite, なかなか is casual.
とても is "very".
なかなか is "very" with the nuance of "not bad".
If you say とても美味しい to someone who cooked something, they're pleased. If you say なかなか美味しい, they'll be mad because it'll be taken as if you're looking down on them - "Not too bad for somebody like you" kinda thing.

Difference between とても and なかなか


What is the difference between 'want camping' and 'I want to camp'?

Question: I want to learn the difference between 'I want camping' and 'I want to camp'.
Please, somebody tell me the difference~
Comment: "I want camping" doesn't make any sense. It does not mean "I want to camp".
Comment: I can think of contexts in which "I want camping" makes sense.  Please explain your context.
Answer: "I want camping" doesn't make sense. "Camping" is an activity, not an object. You can say, "I want to go camping" -- or "I want to camp", your other example. (Similarly, you can't say, "I want eating." You could say "I want to eat" or "I wish I was eating.")
Perhaps you heard or read, "I went camping", that is, "went", not "want". That is a common way of saying that I was camping at some time in the past.
"I want to camp" means that I desire to go camping at some time in the future.
Comment: I agree with pretty much everything you said.  Maybe, *maybe*, you could say "I want camping" in the sense of "I desire there to be the activity of 'camping'", but it's really hard to come up with a reasonable use for it.
Comment: I was drafting an answer, but yours is just right. +1
Comment: @stangdon - +1 for your dual maybes. That said, it's not hard to imagine why an English novice might think "I want camping" is a legitimate way to say "I want to go camping."
Comment: @stangdon Good point. Like, Person A: "What activities should we have for the youth group this year? Boating? Camping? A concert?" Person B: "Oh, I want camping." Unusual, but certainly possible.


Each Two—Singular or Plural?

Question: There are 4 students and 2 textbooks, so each two students share one textbook. Is it share or shares here? My apologies for this easy question, but please let me double check.
Comment: plural --------
Comment: The subject noun is "two", so the verb must be plural. I question your choice of "each", though. A commoner way to say it in English is "Every two students share".
Comment: Thanks for your explanation, but I made the toy example to review my understanding. If it should be "every" as "two students" are plural, then should I also avoid "each sunglasses" or "each scissors" for the same reason as well? "There are 4 papers and 2 scissors, so each scissors cut 2 papers," for example. Though it seems it's cut rather than cuts, is it every scissors rather than each scissors?
Answer: "Each" is always singular, therefore the grammatically correct sentence is "each two students shares one textbook."
This becomes obvious if you replace "two" with its synonym "pair of": "each pair of students share" is clearly incorrect.
Comment: -1 This is wrong because the subject is plural (even though the choice of "each" rather than "every" is not idiomatic). Your argument involving "pair of" is misleading and bogus because a pair is a single thing (even though it contains two items).
Comment: How in the world can *students* ever be singular?
Comment: Stepping back, I realize now that the use of "each" here is not idiomatic. As you say, "every" is better; but I guess ditching each/every and going with "Two students share one textbook" would be better still. All the same, though, "each" and "every" indicate a singular subject, so I don't consider my "pair of" argument to be bogus. Just as a pair is a single thing, so is "each" and "every."
Comment: I am not asserting that _students_ can be singular. But if  _students_ is used with a collective noun, then there can be no grammar-based objection to using the third person singular verb with it, e.g., "There's a couple of students in the lounge", "There's a dozen students on the team."

Each Two—Singular or Plural?


Looking for a replacement of the old Murray main breaker

Question: Evening all. I've got an old-late 70s era fuse panel that has a failing main breaker. I've tried to cross reference the numbers on the breaker and the best I can come up with is Murray type md breaker, but the "issue LC-880" is throwing me for a loop. Can't find that reference in any of the charts I've found online for Siemens equivalents. The breaker has a sticker that reads "style md, 2 pole issue lc-880. Interrupting rating: 10,000 amp, 120/240vac cu/al a-h murray mount on vertical surface only"
Comment: Can you post photos of the breaker in question please?  There's a bit of a subtlety with the Murray/Siemens double-frame breakers that can trip one up without careful attention
Comment: Please take the [tour] so you can learn about how we work here. You've posted the pics (very helpful) in the box labeled "Your answer". They're not answers, so they go in the question. Simply [edit] the question and paste the pics in there. No need for the random key presses, either.
Comment: Not a solution, just an observation: Often, many houses in the same town were wired using the same equipment. A local supplier  may have a stock of "old new" replacement parts that are otherwise hard to find. (An electrician finally found a breaker we needed at the local hardware store after his usual wholesalers were unable to provide it. Since then I've replaced that panel entirely; realistically, it was reaching end of useful life.
Answer: The correct replacement is a QN2200H...
The correct replacement breaker for your Murray MD is a Siemens QN "double frame"; for a 200A breaker, this would be a QN2200H.
...but you'll probably need to have your PoCo "pull the meter" to do the replacement
That said, from the looks of things, said Murray MD appears to be mounted in a multiple-main-disconnect Class 320 meter main, which means that you (or your electrician if you're hiring one to do this work) need to call the power company and have them disconnect your power for the duration of the swap.  Fortunately, with the rise of smart meters, most utilities can and will do it for free if you call during business hours, as they no longer have to roll a truck out to your house to physically yank the meter out of its socket, but can tell the meter to disconnect its internal cutoff switch instead.


Did the author of Colossians know Paul's Epistle to Philemon?

Question: The majority of critical scholars now believe that Colossians was written in Paul's name decades after his death.  Are the parallels between Colossians 4:14-17 and Philemon 23-24 sufficient evidence that Colossians' author knew the Epistle to Philemon?
Answer: John Barclay says (Colossians and Philemon, page 24) a comparison of the greetings in Colossians 4:7-17 with the names listed in Philemon 23-24 reveals both a close matching and a wide variation in order and style. That suggests either that Colossians was written by Paul at the same time and in the same circumstances as Philemon or that it was written by a Pauline imitator who knew Philemon and was capable of very skilful adaptation of its names to make Colossians look authentic.  He says (page 22) that Colossians is now routinely bracketed as 'deutero-Pauline'.
In Colossians 4:14, the reference to Luke is, by itself, evidence that, if Paul was not the author of Colossians, its author knew Philemon, which is  the only undisputed Pauline epistle to mention Luke (Philemon 24). True, Luke is also mentioned in 2 Timothy 4:11, but it is the almost universal consensus of scholars that 2 Timothy was not written by Paul.
Demas sends his greetings in Colossians 4:14, just as Demas sends his greetings in Philemon 24.  Philemon is, once again, the only undisputed Pauline epistle to mention Demas, although 2 Timothy 4:10 also mentions Demas. This is further, strong evidence that the author of Colossians knew Paul's Epistle to Philemon.
Philemon and Colossians both contain salutations by Epaphras and Aristarchus, but Colossians strangely reverses their roles, possibly as a result of confusion by the author:

Philemon 23: There salute thee Epaphras, my fellowprisoner in Christ Jesus
  Philemon 24: Marcus, Aristarchus, Demas, Lucas, my fellowlabourers.
Colossians 4:12: Epaphras, who is one of you, a servant of Christ, saluteth you
  Colossians 4:10: Aristarchus my fellowprisoner saluteth you

If, as Barclay suggests as one explanation, Colossians was written by Paul at the same time and in the same circumstances as Philemon, then Epaphras was at that time a fellow-prisoner and Aristarchus was not. On this ground alone, Paul could not have written both epistles at the same time and in the same circumstances. It is implausible that at some time other than when Paul wrote Philemon, Paul was in prison, Aristarchus was in prison with Paul and Epaphras was free, and that Paul wrote an epistle in which Aristarchus and Epaphras should include their greetings. Whether our author reversed the situations of Aristarchus and Epaphras because of some confusion on his part, or for some other reason, this reversal is strong evidence, first to confirm that Paul did not write Colossians, and second that our author learnt these names from Philemon.
In summary, the author of Colossians must have learnt the names of Luke, Demas, Aristarchus and Epaphras from Philemon. There is no other extant source that was written before Colossians and contains all four names. Even if another source mentioning the names  Aristarchus and Epaphras existed at that time, it is most unlikely that it would have described Aristarchus as a fellowprisoner and Epaphras as a free servant of Christ, in reversal of Philemon's description of them.
Comment: You might want to add that Colossians agrees to a very large extent (in content and even in wording) with Ephesians. On the whole, Colossians is a kind of pastiche of Ephesians and Philimon.

Did the author of Colossians know Paul’s Epistle to Philemon?


Shrink volume of Primary Partition

Question: I currently run windows 8.0 and have 4 partitions. I will like to shrink the volume of my primary partition containing the win 8 OS so I can have more space to install ubuntu 14.04. My question is will it delete everything in that partition while shrinking the volume and how do I go about installing it on the new partition created.
Comment: Is this pre-installed Windows with UEFI or your install in BIOS mode with MBR partitioning and the 4 primary partition limit? http://askubuntu.com/questions/6328/how-do-i-install-ubuntu and: http://askubuntu.com/questions/343268/how-to-use-manual-partitioning-during-installation
Comment: It's BIOS installed. Partition 1 containing win 8 has 44Gb free space, partition 2 (recovery disk) has 2.33Gb free space, partition 3 & 4 have 90Mb and 161Mb free space respectively.
Comment: With MBR you can only have 4 primary partitions. You have to delete one primary can convert to an extended partition. The extended then is like a container for as many logical partitions as you want. http://askubuntu.com/questions/149821/my-laptop-already-has-4-primary-partitions-how-can-i-install-ubuntu
Answer: I have done this from an application in the Windows 7. It should be in win 8 also.
We can shrink the size. Afterwards "Ubuntu"can be installed with C.D. This C.D can be created by down-loading an Image file(nrg)and running a virtual drive/burning Disc. 'How to create a virtual drive' may be known from Internet.But we should be careful not to lose Windows after the installation of "UBUNTU" by deleting any partition and leaving the space without DOS partition.If space is not there we can delete unwanted files and then shrink.

Shrink volume of Primary Partition


How do I cap off a pipe below by hot water heater's cutoff valve?

Question: I live in Texas and am dealing with a destroyed external tankless hot water heater. When I restore water to my house via the street valve I have water gushing out of the pipe below my hot water heater as it appears to have multiple cracks. I would like to at least use water to the rest of my house while I wait who knows how long for a plumber. What would be the easiest way to cap off this blue pipe or the pipe coming out of my house?
Answer: Absent the presence of any valves...go to hardware store plumbing dept. And get a 3/4" sharkbite or tectite end stop. You just shove this on to the end of the (cut or removed)  blue pex pipe. Get a 1/2" one in case I'm wrong judging size from the pic...be sure to buy the same size removal tool as well. It is cheap.
I keep these in my emergency preparedness kit...
If you post a pic of the top of this valve, we can help with temporary plumbing. Good luck with your recovery!
Answer: If the tankless heater was installed properly there will be a valve just before the heater to allow shutting off the cold water to the heater. My indoor tankess WH has a shutoff valve in the cold line and also has a valve on the hot water side. Double valves are recommended, but I believe that a valve on the cold inlet is required by code. Do you have these?
Is the valve in your current pic in the cold water inlet line or the hot water output line? Blue usually used for cold. The insulation on the other line might have been placed on the hot line. If the blue is the cold inlet, then that valve has shut off the cold inlet to the heater.
We need to see pics of the entire setup.
Where is this in Texas?
Comment: Thanks Jim for the reply. We are located in Austin and got hit hard by the recent snow storm. This is the cold inlet, I have it turned off at the unit, but it is leaking below it badly due to cracks from the cold. Finally found a plumber to come out tomorrow but I appreciate the help.
Comment: It would be beneficial to others to document the repair with pics. Does your gas tankless WH have 120 vac powered controls? Did it have an internal heater? Did the heater itself freeze? I helped a neighbor here in Far North Dallas with an outside tankless with an internal electric heater.
Comment: How did this situation resolve? Was the tankless WH wrecked by freezing?
Comment: Hi Jim, amazing still waiting on our WH to be replaced due to difficulty getting a plumber out. We did have an emergency fix done to cut off the leaking below the valve. The plumber found a crack inside the unit so it did get destroyed.


Tool to write LaTeX on the Mac?

Question: I'm looking for a tool that makes it easy to write LaTeX on the Mac. I heard that the there are excellent tools available for the Mac? Which one can you recommend and why?
Comment: vim! (Ignoring the separate issue of a good LaTeX distribution)
Comment: This should be asked at: http://softwarerecs.stackexchange.com/
Answer: I was just about to do this on my os x laptop soon. This is what I have found and heard about:

Texshop is a front end: http://www.uoregon.edu/~koch/texshop/ (Requires TexLive)

Obtaining TeXShop and TeX Live
  The MacTeX Working Group from the Tex User Group (TUG) constructed an install package which installs everything needed to run TeX on Mac OS X in one step. This package is free, and uses Apple's standard installer; installation takes four to eight minutes and is automatic. The package installs TeX Live, the complete reference edition of TeX produced in cooperation by TeX User Groups across the world. It also installs several GUI utilities for TeX including TeXShop, so it is not necessary to get the front end separately. Everything is completely configured and ready to use once the installer finishes its job.
MacTeX is a large download, over a gigabyte. To obtain it, click on the following link: http://mirror.ctan.org/systems/mac/mactex/MacTeX.mpkg.zip

http://www.uoregon.edu/~koch/texshop/obtaining.html (For information to get MacTex which should include almost everything needed)  This is large download.
Comment: Definitely agree that a MacTex base is the way to go, no matter what else you use to make you latex life easier.
Answer: I would recommend TextMate as the best text editor on the Mac. It has wonderful file handling support, great shortcuts, snippets with definable entities within them that can be tabbed between, a set of great colour schemes and wonderful editing bundles. It comes with ones already for things like C, Java, Python, LaTeX, and Subversion.
This page shows some good instructions for setting it up with Fink.
Answer: A very easy tool, especially if you are new to LaTex is Lyx.  It's available as a binary for Mac OS X 10.3.9 and later.  It's is arguably the easiest to use, the downside is that while it is 'LatTex aware', the files it saves are in it's own LyX format, which may be a show stopper for you. Your best bet is to use MacTex as the base LaTeX.  It's huge, even for a LaTex version, but it works and installs easily.
Answer: I recommend a combination of DaveParillo's and Steven Hepting's answers. I agree with DaveParillo about MacTeX. It is probably the best way to get LaTeX installed on your system. It's basically TeX Live, which is much better supported these days than teTeX. You can get the entire install or a minimal install of it. Among other things, it also includes the venerable XeTeX system, which allows you to access system fonts easily and select a multitude of font features. Take a look at the XeTeX examples available at TUG.
As mentioned by Steven Hepting, TextMate is definitely the best text editor for OS X. To see its LaTeX features, take a look at the two screencasts hosted on the MacroMates website (scroll to the very bottom of that page).
Unfortunately, as a new user, I could only post one hyperlink, so I had to be quite choosy and decided that the screencasts list for TextMate was probably the best one as you will see how to very quickly become productive with its shortcuts.
Answer: If you don't want to go through the trouble of installing a full LaTeX distribution, Archimedes is a great editor for casual writing: http://www.mattrajca.com/archimedes
Answer: GNU Emacs works well. Here's the plugin for it:
http://aquamacs.org/
And here are some good tips for using it:
http://aquamacs.org/latex.shtml
Of course, this assumes that you have the nerd-cred to use a basic text editor :)

Tool to write LaTeX on the Mac?


Can we do a Wick rotation by an angle not being $\pi/2$?

Question: If a state obeys  an evolution equation, we can replace $t$ by $-t$. we get another equation and it is interesting to study its solutions.
If we replace $t$ by $it$ (wick rotation) we get again another equation.
The Schrödinger equation becomes a thermal equation.
I wonder if the rotations other than $\pi$ or $\pm \pi/2$ were studied.
Do you know of any examples? I only encountered a $t + i \beta $ in the KMS condition.
Comment: In the [method of steepest descent](https://en.wikipedia.org/wiki/Method_of_steepest_descent) one can in principle rotate an integration contour an arbitrary angle depending on the problem.
Comment: May be [this paper](https://arxiv.org/abs/hep-th/9611043) will be useful
Answer: I found that such rotations occur when we get a partial which path information. Consider the usual two holes Young experiment. Electrons are emitted by a source S at an equal distance of the holes 1 and 2. behind their screen there is (in the middle of 1 and 2) a  source s of photons. when the electron passes thru the holes a photon interact with it.
ccd sensors (l and r) are near each hole and register the photon. Then the electron  hits the second screen at P.
The electron  has two choices for the holes and the photon can hit two ccds.
so we have 4 possible paths each one with an associated amplitude
$\phi_i(ccd) \Psi_i (P)$
To get the probability that the electron hits P we have to add things like $P_i \overline{P _j}$ where $P_i$ is a complex number associated to a given path and $\overline{P _j}$ is the conjugate associated to $P_j$
we have to add 8 terms.Due to the symmetry the sum of the first four terms reads
$$(|\phi_{near}|^2 + |\phi_{far}|^2)(|\Psi_1(P)|^2 + |\Psi_2(P)|^2$$
Here $\phi_{near} = \phi_1(ccd1) = \phi_2(ccd2)$ and $\phi_{far} = \phi_1(ccd2) = \phi_2(ccd1)$
the second sum is
$$(\phi_{near} \overline{ \phi_{far}} + \phi_{far} \overline{ \phi_{near}}) (\Psi_1(P) \overline{ \Psi_2(P)} + \Psi_2(P) \overline{ \Psi_1(P)})$$
we can write $\phi_{near} = r e^{i\theta}$ and $\phi_{far} = r' e^{i\theta'}$
so the second sum reads
$$rr'(e^{i({\theta} - {\theta'}  )} + h.c.) (\Psi_1(P) \overline{ \Psi_2(P)} + \Psi_2(P) \overline{ \Psi_1(P)})$$
This term with interferences cancels if $\theta - \theta' = \pi /2$ and
if $0 \le \theta - \theta' \le \pi $ we have intermediate visibilities of the interferences.


How to Schedule Run all apex tests on daily basis

Question: How to Schedule Run all apex tests on a daily basis?
Currently, we are performing it manually is there any way we can automate it?
Comment: You can write apex scheduler class that will use tooling api service: runTestsAsynchronous. https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/intro_rest_resources.htm
Answer: There are many, many ways to automate it. You can subscribe to an app like GearSet to schedule automations, you can set up a CI/CD (Continuous Integration/Continuous Delivery) system to run tests on a schedule, you can use the basic core features of Windows or Linux systems to run a Windows Task or Cronjob, deploy a container to Heroku or AWS, etc, or you could write Apex code in a scheduled class to run at the desired time. Each solution will have different technical requirements, may require a subscription, etc.


「X」と「Y」と - how does the second と affect the sentence?

Question: I've seen some titles like this, for example an episode of an anime series that was called 敵{てき}と味方{みかた}と, or a manga that was called エルフと少年{しょうねん}と. I'm curious, how does the second と affect those sentences, what would change if they were removed? Would it make any sense to translate them as "X and Y and..." or would that be nonsensical?
Comment: Possible duplicate of [Why is there a と in front of 別?](http://japanese.stackexchange.com/questions/32765/why-is-there-a-%e3%81%a8-in-front-of-%e5%88%a5)
Comment: No, I don't think "And X and Y" is correct. Please see my answer for details.
Comment: I might be wrong here but, Since in Japanese there are no prepositions, と refers to what comes before it. That means that is not X と Y= X and Y, but And X And Y. I do not know if it's like this or If you understood it but, I hope someone can clear this for me too.
Answer: I've seen this usage once in awhile, and haven't felt any difference in the meaning, but I did a search in Japanese to see what I could find.
This (you may need to set EUC encoding to view this properly) is a pretty long treatment on the subject in Japanese, but the summary is that originally this final と was used, but at present this is omitted most of the time. There are some situations where it can be natural to leave it in, and others where it is best to remove it.
Near the end of the post, it is mentioned that in some cases the final と may possibly be used to give a feeling of both parties doing something together or doing something mutually. Though it is acknowledged this is the opinion the author of that post.
Also, there is talk about how sometimes it is better to add と when it helps avoid confusion, as in the phrase "私とあなたの父との関係". Without the last と、technically that can be viewed as "私" and "あなたの父の関係" as opposed to the relationship of "私" and "あなたの父".
I'd be curious to hear the opinion of native speakers, but my feeling is that for people learning Japanese as a second language it's usually best to just omit the final と.
Because of the above interpretation, I would generally translate the pattern as just "X and Y". "X and Y and" would be incorrect.
Edit: I apologize for originally including the improper link. I just fixed it. On my browser (Safari), I had to manually select "EUC" encoding to be able to view it.
Comment: It feels more authentic than the one that uses と only once.
Comment: Your link doesn't appear to work.  Did you accidentally paste the wrong text?  By the way, you can find some literature on this topic by searching for "conjunction doubling", for example [On the Nature of the Repetitive Coordinator *To* in Japanese](http://www.ls-japan.org/modules/documents/LSJpapers/journals/145_forum_asada.pdf).  Also mentioned in Kuno 1973 (p.72 in the Japanese edition).
Comment: snailboat: thanks for pointing that out. I just fixed the link. Also thanks for the reference, will look at it in detail at a later point.


Error Handling in methods that return account

Question: I have an Apex method that receives an Account record as input and returns Account record. What if an error occurs and i want to return it to the user? I cannot return String, since the method returns Account.
Any ideas ?
Comment: Sounds like the concept you're looking for is _exceptions_, but we'll need more details if you want an accurate answer. Probably the most important detail here is _how does the user end up calling this apex method?_ Is it called as part of a trigger, a visualforce page or lightning component, or something else?
Comment: Hi Derek,For example:
    @AuraEnabled
    public static List matchingService(Account acc) {
        try{//Some code here and return acc; } catch (Exception e){ return ('The following exception has occurred: ' + e.getMessage())                                                                 I cannot save this method cause i cannot return a string.
Answer: Based on your comment, you are looking for a way to return custom error message to User in your Lightning Component. One solution would be to use AuraHandledException in your Apex controller. Then you can throw this exception and pass String argument to helper which will display it to the User.
Apex controller:
@AuraEnabled public static List<String> matchingService(Account acc) {
    List<String> returnList = new List<String>();
    try {
    //perform some logic on returnList
    } catch (Exception ex) {
        throw new AuraHandledException('You cannot perform this action, error occured: ' + ex.getMessage);
    }
    return returnList;

}

JS Helper:
myFunction: function (component, account) {
        var action = component.get("c.matchingService");
        var account;

        action.setParams({
            "acc": account,
        });

        action.setCallback(this, function (response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var stringList = response.getReturnValue();
            } else {
                //errorMessage is the String argument of AuraHandledException
                var errorMessage = response.getError()[0].message;
                console.log('Error in matchingService : ' + errorMessage);

                //Handle error - for example show toast with message from Apex controller
                helper.showToast(component, errorMessage);
            }

        });
        $A.enqueueAction(action);
    }


Prototyping a GUI with a customer

Question: When prototyping initial GUI functionality with a customer is it better to use a pen/paper drawing or to mock something up using a tool and show them that ?
The argument against a tool generated design being that the customer can sometimes focus on the low-level specifics of the mock-up rather than taking a higher level functional view of the GUI overall.
Answer: Always start with paper or paper-like mock-ups first.  You do not want to fall into a trap of giving the impression of completeness when the back-end is completely hollow.
A polished prototype or pixel-perfect example puts too much emphasis on the design.  With an obvious sketch, you have a better shot of discussing desired functionality and content rather than colors, photos, and other stylistic matters.  There will be time for that discussion later in the project.
Jeff discusses paper prototyping in his Coding Horror article UI-First Software Development
Click the "Watch a video!" link at twitter.com to see an interesting take on the idea from Common Craft.
Answer: The "Napkin Look & Feel" for Java is really cool for prototyping. An actual, functioning, clickable app that looks like it was drawn on a napkin. Check out this screenshot:

Seriously, how cool is that?
Answer: I would suggest you sit down with your client and use a tool like Mockupscreens and develop the UI interactively. A benefit it has over Napkin LAF is that it does not require coding, or indeed development tools of any kind
Answer: Check out Balsamiq
It does the "THIS IS NOT A FUNCTIONAL APP" napkin view very well and is easy to use.
Has a full featured demo you can try out online and as an added bonus you can email your XML to your client and they can tweak it and play with it and email it back to you without having to have a license.
Answer: There is a book called Paper Prototyping which details pen and paper drawing and what you can gain from it.  I think it has a lot of benefits, particularly that you can, very early on (and easily), modify what the end result will be without much effort, and then start off on the right foot.
Answer: A basic paper version is the way to go for an initial mock-up.  It's been my experience that if you do a "real" mock-up, even if you explain to the customer that it's a non-functional mock-up, they are confused when things don't work.
Bottom line: keep it as simple as possible.  If it's on paper, there is no way the customer will confuse it with a working product.
Answer: For the first draft, I prefer to use graph paper (the stuff with a grid printed on it) and a pencil.  The graph paper is great for helping to maintain proportions.  Once the client and I have come to a conclusion I'll usually fill in the drawing with pen since pencil is prone to fading.
When I actually get around to building the digital prototype, I'll scan in the hand-drawn one and use it as a background template.  Seems to work pretty well for me.
Answer: WireframeSketcher is a tool that helps quickly create wireframes, mockups and prototypes for desktop, web and mobile applications. It comes both as a standalone version and as a plug-in for Eclipse IDEs. It has some distinctive features like storyboards, components, linking and vector PDF export. Among supported IDEs are are Aptana, Flash Builder, Zend Studio and Rational Application Developer.

(source: wireframesketcher.com)
Answer: I think it is best to start with Paper/Whiteboards/White walls.
Once you have the basic structure, you can move it to Visio with the wireframe stencils

(Download a Stencil Kit)
(Visio Stencils for Information Architects).

Or you could use Denim (An Informal Tool For Early Stage Web Site and UI Design) with a tablet PC or Wacom tablets to design the GUI and run it as HTML website.
Answer: I've recenly used a windows App to prototype an application to a customer (the final interface has to be integrated into a website).
At first people thought that it would be the last version and they started to make very heavy criticism from the way controls were displayed to the words I had used (terminology and stuff) and the meeting time ended before we could even discuss the functionality itself.
That discussion dragged on for days and days until I told them that, being a mock (and not a final application) all input is welcome but we had to focus on the functionalities first and then we could move on to look and feel as well as terminology issues.
From thay meeting on I am always terrified of prototypes and mock-ups... Perhaps I should just have given them something made in visio instead.
Answer: You can try out ForeUI, it allow prototyping with different styles, what's more, it can make interactive prototype and run it in browser.
Answer: For a non-installation browser based tool you can try draft-it
It's free - and if you have a gmail account - no registration is needed.
Makes interactive/Step by Step Or Slide Show- prototypes. You can share your protoype with anyone you choose by just sending a link.
Works for us ...

Prototyping a GUI with a customer


When is the word *LEV* לב first mentioned in the Torah?

Question: I was not able to find this information anywhere, so am positing the question here. Thank you in advance.
Answer: Just checking a non-vowelized page of Chumash like mechon-mamre and doing Ctrl+F, we get Genesis 6:5

וירא ה', כי רבה רעת האדם בארץ, וכל-יצר מחשבת לבו, רק רע כל-היום

God saw that ... all the plans of man's heart were constantly bad.
Of course that's conjugated "libo", "his heart." If you want just "lev", fast-forward to the end of the Flood story, 8:21:

כי יצר לב האדם רע מנעריו

The inclination of man's heart his evil from his youth

Afraid those may not be the uplifting ones you had in mind ... but early Genesis has a lot of human failure ...
Comment: Thank you. I did try Mechon-Memre but for some odd reason the browser was alerting me to coding errors. Ironically.

Re; Ki Yatzar Lev Ha-Adam Ra Meneurav - I read this to mean *He CREATED man's heart to be evil from the (point) of his youth.* This, perhaps to give us the starting point of return via discernment.

Todah rabbah :)
Comment: @AdamaTova vowelization -- it's yetzer = "nature", not yatzar.
Comment: One could find this information in the concordance about any word.
Comment: One could read YATZAR and also to read YETZER. @Shalom. And if not, why?


How to stop the programming language part from updating?

Question: I am using the latest Raspbian and I am not a programmer. Therefore, I don't want the programming part of Raspbian. Does this part get updated every time Raspbian updates? How can I stop the programming module from updating, so that I can save precious mobile data usage? It should not affect the other software after the programming section is removed or prevented from updating.
Comment: I think you are making a big mistake looking at things this way.  If you are not a programmer, it will be too easy to confuse things that may appear to be "just for programming" with things that are in fact crucial to some normal user functionality.  Remember, it is *all programs and programming* that make it go.  The base install does not include much clutter this way as it is intended that programmers have to do the work of installing the tools they want, not that normal users need do the work of uninstalling them.
Answer: It is not safe to remove programming languages and stop future updates without disrupting current applications and opening your device to future unexpected failures.
Languages like python are implicitly used by a significant number of applications, also, many packages are distributed (partially) in source code form that need compile to installation on your device (gcc, g++) .
What you can do is to do check what is available for 'upgrade' and manually update modules that you consider important (at your own 'risk'):
$ apt-get update
...
Ign http://mirrordirector.raspbian.org wheezy/rpi Translation-en
Fetched 7,015 kB in 43s (160 kB/s)
Reading package lists... Done

now, request the 'upgrade' but answer n on Do you want to continue [Y/n]?
$ apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
  firmware-atheros firmware-brcm80211 firmware-libertas firmware-ralink firmware-realtek
  libxapian22 libxml2 locales multiarch-support php5 php5-cli php5-common php5-mysql samba-common smbclient tzdata
xx upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 38.9 MB of archives.
After this operation, 4,692 kB of additional disk space will be used.
Do you want to continue [Y/n]? n
Abort.

Assume you want just to 'upgrade' the module tzdata
$ apt-get install tzdata
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
   tzdata
1 upgraded, 0 newly installed, 0 to remove and 32 not upgraded.
Need to get 453 kB of archives.
After this operation, 13.3 kB of additional disk space will be used.
Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main tzdata all 2016d-0+deb7u1 [453 kB]
Fetched 453 kB in 1s (315 kB/s)
...

pd: sudo required, omitted for brevity
Comment: You will definitely FUBAR the system without python and perl, but I think using proper "uninstall/purge" methods should make that very clear (I think `apt` itself has a perl and/or python dependency).  Put another way **Do not remove perl or python or prevent upgrades on them.**  A C/C++ compiler is a little less necessary but will barely take any space (their primary libs have to be there anyway) and don't do anything when not in use.  AFAIK there aren't any programming interfaces worth removing from stock Raspbian except that Wolfram math thing (if it is still stock).
Answer: Your best option is to remove any packages that you do not require with the command sudo apt-get purge <PackageName>. The system should then offer to remove other packages that will not be needed.
It is not adviseable to only update some packages that are installed and not others since most packages depend on other packages being at a certain version date.
Answer: Your question is misguided. "Programming" actually contributes very little to upgrades which, in any event, are quite modest in size.
The other answers have pointed out the folly of selective updates. If you want to minimise the size of your image un-install unwanted applications (there are quite a few in Raspbian which would fall into this category). This will prevent the upgrades from installing. Python and perl do NOT fall into this category.
The simplest answer, if you are concerned about data usage, is DO NOT UPDATE/UPGRADE. There is no need to do so - your system will continue to operate. Upgrades tend to add new features and fix bugs, but unless you have a problem DO NOTHING.


How can I remove these blue lines without losing the color?

Question: I need to learn how to remove these blue lines without changing anything else.
Comment: If you'd ask me, it'd be *way* faster to recreate the pattern from scratch in Illustrator that it'd be to try and edit out the raster in a photo editing program.
Answer: Too much work to remove the line pattern. Make a new yourself.
It seems to be a big piece of chipwood with half transparent white overlay pattern. That pattern is easy to do in Illustrator (measurements only approximate)

have a triangle, say 6 degrees angle in the sharpest corner, one long side is horizontal, grey fill, no stroke
rotate the triangle 0,5 degrees
rotate the triangle making 11 more copies in 7,5 degrees steps
align all 12 triangles down & left to get the sharp corners to the same point
copy twice with reflect to have a fan that covers full 360 degrees
scale horizontally to smaller size to have elliptical pattern
change the fill color to white
add a clipping mask to have rectangular shape
copy to photoshop to insert it over a photo of chipwood

I hadn't a good photo, so I used a flat color fill.
Photoshop is in theory not necessary at all for this job, but coloring is there easier.
Addendum: If you want to stay in Photoshop and want something fast, then:

select all
goto Filter > Blur > Radial Blur > Zoom, good quality, radius=60px
fix (=clone) the middle area manually, if needed.
add some grainy texture, if needed


Density of states in irregularly-shaped volumes

Question: A very common result is that the density of momentum states in a cubic volume is $\displaystyle\frac{V}{(2\pi\hbar)^3}$ in momentum space. How does this result extend to arbitrary volumes? Are there any nice examples of volumes that are endowed with an interesting set of a momentum eigenstates?
Comment: You might be interested to read about Weyl's formula: https://en.wikipedia.org/wiki/Weyl_law . This is basically the name by which this result for density of states is known for mathematicians.
Comment: An interesting result from 1982  [*Density of states on fractals : "fractons"*](https://hal.archives-ouvertes.fr/jpa-00232103/document) by S. Alexander & R. Orbach.
Comment: Semiclassically, it works for an arbitrary finite volume $V$ with a sufficiently nice boundary. Are you asking about exact quantum mechanical results?
Comment: @AleksandrArtemev that's perfect, thanks!
Answer: Okay, so, for a free particle, with the hamiltonian
$$
H = - \frac{\hbar^2}{2m} \Delta
$$
living in a cavity of volume $V$ (for any shape of the cavity) number of energy eigenstates with energy less than $E$ has the following asymptotic
$$
N(E) \sim \frac{V}{(2\pi \hbar)^d} \omega(\sqrt{2mE}),\, E \gg \frac{\hbar^2}{2ma^2}
$$
Here $\omega(R)$ is a volume of $d$-dimensional ball of radius $R$, $a$ is a characteristic size of a cavity. This is a property of Laplacian eigenvalues called asymptotic Weyl formula, or "Weyl law": https://en.wikipedia.org/wiki/Weyl_law .
By assuming $E=p^2/2m$, one gets the usually used density of states in momentum space $\frac{V}{(2\pi \hbar)^d}$. The formula is valid in any dimension.
Although in the formulated problem one assumes Dirichlet boundary condition (with wavefunction equal to zero on the boundary), the leading asymptotic is independent of them (which is why people usually use periodic boundary conditions for simplicity and the result is right).
This property can also be generalized for nonzero external potential in a pretty natural way (see Wiki article for the result).
The fact that this result is an asymptotic for large $E$ motivates this result being called "semiclassical". Unfortunately, I wasn't able to find any kind of "quantum-mechanical proof" to this formula that would derive it using semi-classical approximation; in physical literature it sometimes is loosely referred to as multidimensional analogue of Bohr-Sommerfeld rule, although I don't really feel this is the case, as Bohr-Sommerfeld rule speaks of a contour integral, rather than an integral over volume in momentum space.
The specifics of a cavity shape and boundary conditions become important for energies $E \sim \frac{\hbar^2}{2ma^2}$; the first correction term is proportional to the area of boundary of a cavity and has different signs for Dirichlet or Neumann b.c. . Maybe this correction term could be interpreted as some kind of "boundary states", though I am not sure about that.


ORA-01031 Insufficient Privileges Raised From Within Function

Question: When I run a CREATE USER statement within Sql Developer, the user is created just fine.  When I try to call a function which performs CREATE USER (followed by a bunch of other statements) I get the ORA-01031 error when that statement is executed.  On another machine this function is apparently completing successfully.  I have checked all the roles and system privileges but nothing stands out.  What could it be?
Answer: When you have permission to perform an action at the command line but not within a definer's rights stored procedure (and I hope you're using a stored procedure here, not a stored function), the problem is almost certainly that the privilege you need has been granted through a role, not directly to the user that owns the procedure.  Inside a definer's rights stored procedure, only privileges that have been granted directly to the owner of the procedure can be used-- privileges granted through a role (such as DBA) cannot be used.
You can verify that the problem is, in fact, that the privilege is granted through a role by disabling roles and then trying to create the user, i.e.
SQL> set role none;
SQL> create user ...

Assuming that fails, as I expect it will, you would need to grant the owner of the function the CREATE USER privilege directly
SQL> grant create user to <<owner of procedure>>

Then, you should be able to create users even with roles disabled and the stored procedure should work.
Comment: I am going to go bang my head against a sufficiently thick block of concrete.  I just had the owner of the procedure incorrect ... I was assuming it was someone else.  Granting to the correct user solved my problem.  Thanks.
Comment: I got bit by this for a different reason (different situation) but similar... I had granted UPDATE and READ to a table in the procedure that it was updating, but changed the  privilege from READ to SELECT and the error went away.  I suppose due to READ not having `SELECT ... FOR UPDATE` abilities.


Can I delay a while signing an official postdoc offer letter

Question: I have got an official postdoc offer letter. The HR now is requesting my signature and then return the letter back asap. But I haven't made a final decision to sign it or not, because there may be another offer coming very soon, which seems better to me. I wonder if it is appropriate to delay the received offer a little bit. After that accept or turn it down.
Answer: Sitting on an offer (e.g. ignoring emails from HR, taking forever to answer or other delay tactics) is generally not appropriate in my opinion. I would suggest honesty and transparency.
Let your prospective postdoc advisor that you'd like a bit of time to consider your options (they will likely get the hint that you're considering other positions, no need to be too blunt). In addition, talk to your alternative option ASAP and let them know the situation. It is absolutely acceptable to tell them that you have another offer who's waiting for your reply, and you'd appreciate an answer from them soon.
Whether either party would agree really depends on them. I would be careful of losing both options: if you wait for too long then your potential host might get annoyed and just rescind the offer. They could be holding off on other good applicants thinking that you are about to sign, and you waffling might result in them going ahead with other applicants.
Your other option might not be getting back to you because they actually don't have an open position right now, or they themselves are waiting for some other applicant's final answer (if they say yes, you're out).
These are all considerations that you should weigh out for yourself, and I cannot offer any concrete advice on. Just to reiterate - lying/misrepresenting your status/using delay tactics is probably a bad idea.
Answer:
I would definitely delay in this case.   (If you truly might have another, better written offer soon.)  HR is in the business of getting selected candidates hired.  You need to look out for yourself when comparing competing offers (or about to) as your interests are not 100% aligned.  There is nothing odious about this.  It's a normal part of hiring and recruiting.  The same applies if you are negotiating salary, after a formal offer (the only time you should negotiate or discuss salary).
The actual mechanics of how you delay (ignore the letter, say "I'm looking at it, request more time, etc.) depend on the situation.  For example, did the letter have an offer time period?  How long has it already been?  Etc.  Without knowing more, I would say ignoring an email from HR (not the principal) for a handful of days is not completely off the table as an option.  But again I don't know the specifics and that is not your only option to delay.
Things are a little delicate now, but you really don't want to commit to one if about to get another, formal offer.  And of course you don't want to blow what you have, now.  But you will never have as much power as you do now (or shortly).  With two offers in hand, you can pick the best or negotiate terms (with some power).  It should be the normal objective of any job searcher to get competing offers.  Employers know this and try to push after the offer or have short consideration periods.  You need to to try to get that second offer though.
Reach out to the other possibility (email AND phone) and let them know you have a formal offer and need their letter ASAP.  Give a hard date for how long you can delay the other offer, during discussions--if you don't know, estimate, but not more than 1 week.  Of course, make it 100% clear you need a fornal offer letter with terms (salaray, etc.) of the new offer.  Knowing you are in demand and will be off the market makes you look good.  If they are leaning to you, it will often shift the balance AND make them hurry up their red tape and send you a letter.  If they don't, then they weren't a serious possibility.  (You may not have been top of their list.  Or even if so, if they don't care enough to walk an offer through, then they don't love you that much.)

P.s.  You don't need to share any details (place or salary) of the letter on hand with the place that you are pushing to send a letter.  Probably better for you if you don't "put a price on your head" and just see what they offer.  Once you have two offers, some light negotiation is normal (and informed by comparing the terms).  You want to seem graceful, but at the same time, you really do want to create an auction. You won't have any power to negotiate later.
P.s.s.  Read What Color is Your Parachute. You should know more about how to manage the mating dance of job searching.
Comment: I suggest the OP _not_ take this advice. Seems a bit dangerous.
Comment: Thank you for the detailed comments and suggestions, which are very helpful to me!!


How can I prevent water from flowing into my carport under the wall plate?

Question: The carport was enclosed but no additional concrete was poured. The sill was screwed directly into the concrete. As a result of being so close to to ground, water has come in under it about 2-3 inches. I was wondering what would be the most cost efficient method to remedy this problem? Could we put water proofing membrane  around the sill and bottom of the framing studs then pour concrete or cinder block on the exterior, making the foundation higher (as it should have been prior to construction) even though it's only the perimeter that is higher? Please help.
Comment: Hello, and welcome to Stack Exchange. Where are you located? Could you post some photos? (Edit this into your original question.)
Comment: It sounds like the carport was not originally designed to be enclosed. If you pour on the exterior you may trap water in side the wall. the best way might be to put in temporary supports and pull the wall and install a small stem wall on top of the pad. this would be a large job for a DIY project but would fix the problem for good.
Comment: What's the source of the water?  Guttering ($$$) and/or a French Drain System ($$$$-$$$$$) might be cheaper, or better, than mud-jacking (guaranteed $$$$$) the building....
Answer: I would consiter putting in a temporary wall a foot back. Remove the existing wall Or at least the rotted  wood cut it off at the bottom and pour a new stem wall that is taller. With the best method being to dig a new footing and put some perf pipe in a sock at the edge of the footing for drainage (Basicly a French drain). With a new stem wall the water won't be able to rot out the sill plate, with drainage the wall should not weep.
Answer: I had this same issue when I built a workshop on-grade on an existing slab. The solution I used was to take a piece of 1" x 4" L-flashing, lay down a thick bead of asphalt emulsion sealant on the concrete pad at the exterior, and tuck the tall leg under the siding of the structure, and the short leg was set into the 'bed' of asphalt emulsion sealant. I then put more sealant over the edge of the metal and troweled it smooth.
Answer: 2-3 inch deep water that could run out the garage door, that is unbelievable.  Dig a sloping trench around the perimeter.  Can be as simple as that, or the full monty.
Comment: I think they're saying that water intrudes 2-3 inches from the enclosure wall (which indicates the carpet is wicking water), not that the water is 2-3 inches deep
Comment: carPORT, not carPET.


What Does It Mean When 过来 Indicates A Return To Normal State?

Question: I saw 他随后明白过来 as a clause. Does the 过来 imply that it took like some effort or some extra time so that they could return to this normal state of understanding? Like it was a discovrery?
Answer: Quote:- Indicates a return to normal state?
It actually means a transformation to a new state. In this case, a "new state of  understanding"
Let me elaborate.
When you tell someone to 过来, it means to tell that person to "come here or come over here" to where you are.
Why 过来? It means to tell that person to "traverse", 过, (to pass through) the physical space between where he was originally to "come", 来, to the space where you are. So, "come", (traverse from where he was), to "here", (where you are)
So, how does all these metaphysical reasoning has to do with the 过来 in 他随后明白过来?
The sentence, in English, means "He then, (afterwards), understood" But there is no past tense in Chinese, so how to say he now understands what he had not understood before?
Following from our metaphysical reasoning above, he now understands because he had traversed the "old space / state", from ignorance, (where he originally was), to the "new space / state" of understanding, (where he is now), that is, he now 明白过来.
Actually, the more usual way in Chinese to indicate a "past tense marker" is to use 了, as in 明白了, and 明白过来 is just a more formal expression.
Answer: 过来, when used after the verb, means "can" or "manage".

他随后明白过来 - He (soon) later managed to realize.

他终于醒过来了 - He managed to wake up in the end.

活儿不多, 我一个人干得过来 - There is not much of a workload, I myself can manage it.
Answer: The words 来 and 去 are like the English words this and that, or here and there. They have extended meanings in Chinese. Basically, 来 indicates something as wished and welcomed, and 去 means not very good. For example,
(1) 这些年生活好起来了。= The livelihood became better in those years.
(2) 钱都被他花出去了。= He spent all of the money.
(3) 在家休息了几天,他的体力恢复过来了。= After a couple of days relaxing at home, he feels that he is revived.
(4) 他的病,好转了几天,怎么又变回去了?= He feels better for some days but now it goes back.
Answer: Since 来 means "to come", using 过来 feels like that person comes to the same state as the speaker.
Think about the following examples:

他醒过来了。
他睡过去了。
他晕过去了。
他死去了。


Why is Pondicherry divided into so many names and exists in so many states?

Question: In Tamil Nadu it is called Punducheery. Yanam is in Andhra Pradesh and again I guess there is another territory where it exists. A slightly detailed insight into this will be most welcome.
Comment: Actually, Puducherry does *not* include all of French India, Chandernagor/Chandannagar merged with West Bengal before the remaining territory merged with India. Puducherry was treated differently (including by granting French citizenship to its residents) so it's an interesting question and brings up many other: why merge some bits with larger states and not do that with the others, why adminster them all as one territory, why keep the statu quo long after the colonial period, etc. Details would be interesting (+1)
Comment: I guess it (originally French India) got assimilated to India as a whole entity rather than being distributed into the existing Indian states.  see https://en.wikipedia.org/wiki/French_India#History - look at the tail end of that link
Comment: @ItalianPhilosophers4Monica Alright but why is it called Pondicherry everywhere. It should be aa unique place isn't it?
Comment: all of the widely separated French colony spots had the same name.  look at the map on the right. *French India, formally the Établissements français dans l'Inde[a] (English: French Settlements in India), was a French colony comprising five geographically separated enclaves on the Indian Subcontinent*
Comment: I am not going to put this as an answer though.  I don't know enough about Indian history to be sure I am correct.  but it looks like a reasonable guess that that territory decided to "stick together" under one name when they joined.
Answer: Consider the USA.  This is composed of several places that are not connected.  There is the main part of the USA "the lower 48", and Alaska, and Hawaii.  But they are all politically united and they are all "USA"
In India the former French colonies of  Pondichéry, Karikal, Mahé and Yanaon chose to become a politically united Union territory, even though they are not connected. This Union territory needs a name.  It could have been called anything, but as Pondichéry was the largest part, that name stuck (albeit with a corrected spelling "Puducherry")
Historically the city of Puducherry was the first to join the Republic of India, and other French territories joined later and merged with the existing Union Territory and the existing name.
So: It is not unusual for a political united territory to be disconnected geographically.  It is normal for such a territory to have a single name. And the name is Puducherry for reasons of size, dominance and history.


Is there a way for the code on a site to detect whether or not someone accessed it through a QR code?

Question: I want to make a site that uses QR codes, and for user analytics I want to see how many people access it through the code, but I don't want a GET parameter for this because I don't want any URL guessing giving me incorrect stuff.  Any way to detect QR code access?
Answer: No.
Besides something in the URL, you only really have the headers. For example, if you assume all mobile traffic to the URL is from a QR code reader, you could sniff for a mobile User-Agent header. Doesn't seem very robust, tho.
Answer: Not really, but you can use a URL shortener such as bit.ly to collect analytics.


For a physical pendulum, why do you use an angular coordinate system when the centre of mass translates too?

Question: I am trying to understand why you can use $F=ma$ for a simple pendulum, yet need the rotational equivalent for a physical pendulum.  I understand it is because the rigid body can rotate too, whereas you don't consider that for a simple pendulum and consider just the mass under translational motion.  I just don't understand why you don't have to consider translational motion with the physical pendulum?  My understanding was kinetic energy is the sum of the translational kinetic energy of the centre of mass and rotational kinetic energy where it is rotating about the centre of mass?  I'm not sure how to use this information though for a physical pendulum when it is rotating about a different axis?
Comment: The formula $\tau= I_{support}\alpha$ (which uses an angular coordinate system) can also be used on a simple pendulum. You will have to assume a point mass "rotating" about the hinge.
Answer: With any extended object such as a physical pendulum, you are considering not the force on a single particle but on all of the particle (atoms, molecules, whatever) that make up the object: right off the bat, you're considering the positions of $10^\text{something}$ particles.
But that's not the whole story, because these particles exert forces on each other, and you need to keep track of that too. These forces are not fixed beforehand like gravity: they are whatever is needed to keep the body rigid, which adds more complication since we have to calculate them too. So if you want to analyze the physical pendulum the same way you would the point-mass one, you can.
The whole point of the rotational equations, however, is that they take care of all of this for us. They are nothing more than a convenient way to simplify the problem using that we don't actually need to write down one equation per particle, since the fact that the body is rigid makes everything a whole lot simpler: we actually only care about a single number, the angle of the pendulum.
So to answer your question: we do have to consider the translational motion, since that's the only kind of motion there is in reality. But doing it directly would be too complicated, which is why we have the equations of rotational motion, that help us simplify the whole thing down to a single variable.
Comment: That makes sense that it is just a simplification.  My only other question is when you can treat a rigid body as a point mass at the centre of mass, and when you can't?  I understand you can't when the body can rotate about it's centre of mass.  But I don't understand why if something rotates about a point other than the centre of mass you can't treat it as a point mass in this case (as in the physical pendulum), as then surely you could just use F=ma etc like you do for a simple pendulum?  As you can treat a rigid body as a point mass in other situations?