Multitasking using setjmp, longjmp

Question: is there a way to implement multitasking using setjmp and longjmp functions
Comment: [Tony Finch's picoro(small co-routines)](http://dotat.at/cgi/git?p=picoro.git;a=blob;f=picoro.c;hb=HEAD).  Co-routines are in Knuth's the art of computing and are co-operative multi-tasking.  As well, Simon Tatham has a [co-routines web page](http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html) with nice explanations.
Comment: Also, care should be taken; the `setjmp()` and `longjmp()` are most often/always implemented in assembler and resemble OS context switch code.  However, they may not save some state such as *floating point*, *SIMD state*, etc.  Whether this is an implementation bug or a standards issue, I don't know.  However, this issue will often exist in practice.  Knowing what state to save can be a significant boost to context switch speeds.
Comment: See: [`setjmp()` and fpmode](http://www-personal.umich.edu/~williams/archive/computation/setjmp-fpmode.html) for more on other CPU state.
Answer: You can indeed.  There are a couple of ways to accomplish it.  The difficult part is initially getting the jmpbufs which point to other stacks.  Longjmp is only defined for jmpbuf arguments which were created by setjmp, so there's no way to do this without either using assembly or exploiting undefined behavior.  User level threads are inherently not portable, so portability isn't a strong argument for not doing it really.
step 1
You need a place to store the contexts of different threads, so make a queue of jmpbuf stuctures for however many threads you want.
Step 2
You need to malloc a stack for each of these threads.
Step 3
You need to get some jmpbuf contexts which have stack pointers in the memory locations you just allocated.  You could inspect the jmpbuf structure on your machine, find out where it stores the stack pointer.  Call setjmp and then modify its contents so that the stack pointer is in one of your allocated stacks.  Stacks usually grow down, so you probably want your stack pointer somewhere near the highest memory location.  If you write a basic C program and use a debugger to disassemble it, and then find instructions it executes when you return from a function, you can find out what the offset ought to be.  For example, with system V calling conventions on x86, you'll see that it pops %ebp (the frame pointer) and then calls ret which pops the return address off the stack.  So on entry into a function, it pushes the return address and frame pointer.  Each push moves the stack pointer down by 4 bytes, so you want the stack pointer to start at the high address of the allocated region, -8 bytes (as if you just called a function to get there).  We will fill the 8 bytes next.
The other thing you can do is write some very small (one line) inline assembly to manipulate the stack pointer, and then call setjmp.  This is actually more portable, because in many systems the pointers in a jmpbuf are mangled for security, so you can't easily modify them.
I haven't tried it, but you might be able to avoid the asm by just deliberately overflowing the stack by declaring a very large array and thus moving the stack pointer.
Step 4
You need exiting threads to return the system to some safe state.  If you don't do this, and one of the threads returns, it will take the address right above your allocated stack as a return address and jump to some garbage location and likely segfault.  So first you need a safe place to return to.  Get this by calling setjmp in the main thread and storing the jmpbuf in a globally accessible location.  Define a function which takes no arguments and just calls longjmp with the saved global jmpbuf.  Get the address of that function and copy it to your allocated stacks where you left room for the return address.  You can leave the frame pointer empty.  Now, when a thread returns, it will go to that function which calls longjmp, and jump right back into the main thread where you called setjmp, every time.
Step 5
Right after the main thread's setjmp, you want to have some code that determines which thread to jump to next, pulling the appropriate jmpbuf off the queue and calling longjmp to go there.  When there are no threads left in that queue, the program is done.
Step 6
Write a context switch function which calls setjmp and stores the current state back on the queue, and then longjmp on another jmpbuf from the queue.
Conclusion
That's the basics.  As long as threads keep calling context switch, the queue keeps getting repopulated, and different threads run.  When a thread returns, if there are any left to run, one is chosen by the main thread, and if none are left, the process terminates.  With relatively little code you can have a pretty basic cooperative multitasking setup.  There are more things you probably want to do, like implement a cleanup function to free the stack of a dead thread, etc.  You can also implement preemption using signals, but that is much more difficult because setjmp doesn't save the floating point register state or the flags registers, which are necessary when the program is interrupted asynchronously.
Comment: ...things like C++ exceptions, depending upon how they're implemented, may or may not play nice with even cooperative multitasking.  One would have to research how exceptions are implemented to know what is required of the stacks maintained by the running threads.
Comment: If you use the stack overflow method to adjust the stack pointer, there's no asm, and the approach works for all machines in which the stack grows down and the stack frames begin with RA and FP (need to use sizeof(int*) to get the appropriate size for the offsets).  That covers pretty much all x86/AMD64 machines that use Windows, OSX or Linux.
Comment: A lot of C++ implementations use one or more static variables to control exception handling; trying to switch between threads that use exceptions will require that the task-switcher know about such variables and swap them.  Swapping them isn't hard--making sure there aren't any static variables that one doesn't know about is the hard part.
Comment: Some specific implementations of setjmp/longjmp may work in such a fashion that one can jinx them to behave as desired, and it's possible that some compilers might even *specify* that their implementations work in a particular fashion that would allow such a thing without having to rely upon undocumented/undefined behavior when targeting such compilers, but I'd suggest instead using a few lines of assembly code to do the stack/register switches.  Using setjmp/longjmp is no more portable than assembly code, but might give an illusion of portability.
Comment: That having been said, I think there's a lot to be said for cooperative multi-tasking.  Many compilers expressly document what registers (if any) need to be preserved by external assembly-language modules.  A pre-emptive multitasker would have to preserve all registers that a compiler might be using, which could be a problem if e.g. a compiler takes advantage of a hardware multiply-accelleration acceleration unit the multitasker doesn't know about, but cooperative multitaskers avoid such problems.  That having been said...
Comment: If you use the asm approach for modifying the stack pointer, than this works on any sane setjmp/longjmp implementation.  The only implementation defined part is when you modify the pointers in the jmpbuf yourself, which I mentioned above.  The question specifically asks for setjmp, longjmp implmentation, so that's what is here.
Comment: Preemptive multitasking is easily doable.  I did an implementation which worked on OSX and Linux, with very minimal ifdefs for portability.  Signal context stores all register state, even the floating points (because it must).  You just need to write your own asm to restore all of the state.  It's literally just a bunch of pop instructions, and fxrstor to restore floating point state.  There are very few calling conventions in widespread use so achieving something portable enough is not a hard problem.
Comment: Ah, that's interesting.  I'm not very familiar with C++.
Comment: FYI, Seastar uses setjmp/longjmp for context switches https://github.com/scylladb/seastar/blob/master/src/core/thread.cc#L137-L152, and setups initial stack with setcontext hack https://github.com/scylladb/seastar/blob/master/src/core/thread.cc#L234-L247
Answer: It may be bending the rules a little, but GNU pth does this. It's possible, but you probably shouldn't try it yourself except as an academic proof-of-concept exercise, use the pth implementation if you want to do it seriously and in a remotely portable fashion -- you'll understand why when you read the pth thread creation code.
(Essentially it uses a signal handler to trick the OS into creating a fresh stack, then longjmp's out of there and keeps the stack around. It works, evidently, but it's sketchy as hell.)
In production code, if your OS supports makecontext/swapcontext, use those instead. If it supports CreateFiber/SwitchToFiber, use those instead. And be aware of the disappointing truth that one of the  most compelling use of coroutines -- that is, inverting control by yielding out of event handlers called by foreign code -- is unsafe because the calling module has to be reentrant, and you generally can't prove that. This is why fibers still aren't supported in .NET...
Comment: The Netscape Portable Runtime (NSPR) also appears to define macros for doing this using a simpler but hairier method: they just call setjmp and then change the machine stack pointer and instruction pointer in the buffer. Google "_MD_INIT_CONTEXT" for an entertaining read.
Answer: This is a form of what is known as userspace context switching.
It's possible but error-prone, especially if you use the default implementation of setjmp and longjmp.  One problem with these functions is that in many operating systems they'll only save a subset of 64-bit registers, rather than the entire context.  This is often not enough, e.g. when dealing with system libraries (my experience here is with a custom implementation for amd64/windows, which worked pretty stable all things considered).
That said, if you're not trying to work with complex external codebases or event handlers, and you know what you're doing, and (especially) if you write your own version in assembler that saves more of the current context (if you're using 32-bit windows or linux this might not be necessary, if you use some versions of BSD I imagine it almost definitely is), and you debug it paying careful attention to the disassembly output, then you may be able to achieve what you want.
Answer: I did something like this for studies.
https://github.com/Kraego/STM32L476_MiniOS/blob/main/Usercode/Concurrency/scheduler.c
The context/thread switching is done by setjmp/longjmp. The difficult part was to get the allocated stack correct (see allocateStack()) this depends on your platform.
This is just a demonstration how this could work, I would never use this in production.
Answer: As was already mentioned by Sean Ogden,
longjmp() is not good for multitasking, as
it can only move the stack upward and can't
jump between different stacks. No go with that.
As mentioned by user414736, you can use getcontext/makecontext/swapcontext
functions, but the problem with those is that
they are not fully in user-space. They actually
call the sigprocmask() syscall because they switch
the signal mask as part of the context switching.
This makes swapcontext() much slower than longjmp(),
and you likely don't want the slow co-routines.
To my knowledge there is no POSIX-standard solution to
this problem, so I compiled my own from different
available sources. You can find the context-manipulating
functions extracted from libtask here:
https://github.com/dosemu2/dosemu2/tree/devel/src/base/lib/mcontext

The functions are:
getmcontext(), setmcontext(), makemcontext() and swapmcontext().
They have the similar semantic to the standard functions with similar names,
but they also mimic the setjmp() semantic in that getmcontext()
returns 1 (instead of 0) when jumped to by setmcontext().
On top of that you can use a port of libpcl, the coroutine library:
https://github.com/dosemu2/dosemu2/tree/devel/src/base/lib/libpcl

With this, it is possible to implement the fast cooperative user-space
threading. It works on linux, on i386 and x86_64 arches.

Multitasking using setjmp, longjmp


Difference Between Web and Chain of Trust

Question: I have a basic understanding of the "Web of Trust" used in PGP. I would like to know how the "Web of Trust" differs from the "Chain of Trust" that's used for SSL certificates?
Answer: The primary difference is that PGP does not trust a set of central authorities while SSL does. In SSL the certificate authorities do the required checks and then certify that the identity of the certificate holder is correct for the level of certification. We trust the CA's decisions and trust who they trust.
The different certificate types theoretically correspond to different levels of background checks. For a basic certificate this is as simple as verifying that the requester controls the domain. For an EV this requires significantly more checks (incorporation, place of business etc).
Answer: As I am learning PGP, my understanding is the Web of Trust uses votes of trust by peer group members at the same authority level, but using inconsistent verification methods.  It is a vote of the people (users).
Chain of Trust uses certifications issued by trusted Certificate Authorities if all the required qualifications of a submitted request are strictly verified to meet different levels or categories of trust. It is a certificate of merit.
Certificate Authorities may have lower level or higher level authority, like government or corporate officials. The King verifies the Prince, the Prince verifies the Count, the Count verifies the Sheriff, etc., and the verification certificates are interlinked in sequence, ranked by authority level.
I have noticed there are now Certificate Authorities for PGP keys. I have a Proton Mail account. I signed up for an account, Proton Mail issued the keys for my account, and they now have a Certificate Authority that signs the keys as an endorsement of trust, using their special email address email@example.com.
See Oct 2022 article https://proton.me/blog/why-we-created-protonca
In a similar manner, for my small business, I created special CA email addresses firstname.lastname@example.com and firstname.lastname@example.com to sign keys of employees. This creates a Ladder of Trust from higher authorities, such as the CEO or CISO or Security Officer, rather than a Web of Trust from peers, such as fellow employees or friends or acquaintances at the same trust level.
My business good standing and reputation can be verified for trustworthiness by inspecting the website history for duration, SOS business records, the local BBB directory listing, and a high rating from over 100 customer reviews on Google Maps.
My PGP public key is posted on the business website under Contact Us and on GitHub, both protected by strong passwords and two-factor authentication.


Need help with the logistics of faking a character's death

Question: Okay. I'm writing a fantasy novel about bad faeries (very simplified summary.)
Protagonist is a 24yo who lives with her mother. Her father was murdered a few months before start of book - so she thinks.
For several reasons that connect to the protagonist that I won't get into here, dad was actually kidnapped by the faeries. Mom saw this happen. Dad was injured when he was taken and left a pool of blood in the living room. (or somewhere in the house. Maybe it'll be outside.) Some physical sign that something bad happened.
Mom is having a metal breakdown because faeries took her freaking husband. Faeries. She can't process this. She obviously doesn't want to tell anyone that faeries took her husband because that will make her sound crazy.
So I'm playing with the idea of her passing it off as he was murdered, so the protagonist goes the whole book thinking that her dad is dead, killed by some thug who broke into the house.
What are the logistics of this? Is it possible to pass someone off as murdered instead of kidnapped without a body? Doesn't necessarily have to be a legal route to achieving this, but it does have to be believable - or at least capable of suspending disbelief if done well ;)
To narrow this down a bit, I'm talking the practical stuff: police involvement, death certificate, coroner, whatever else. I've never personally handled the death of someone so I don't even know exactly what happens, legally speaking, after someone dies. Is it possible to pretend someone was murdered when you don't have a body?
I tried to google the answers to this and I must not be googling the right question because I haven't found much that's helpful.
Hopefully this makes sense. My brain is going in ten million different directions right now.
Thanks!
Comment: Welcome to writers SE!  Unfortunately, this is a bit of a "How/what to write" question, which is unfortunately off topic for our site.  We focus on the actual writing process which can be used to help the broad spectrum of writers and not specific content that can only help individuals :)  Please check out our [Site Tour](https://www.writers.stackexchange.com/tour) for more details.
Comment: as far as your actual question... there are many times where people disappear out of murder.  Usually in those situations, someone was killed in the heat of the moment so they try to hide the body somewhere.  So bodies do disappear when murdered.  I would try reading through murder cases/cold cases or watch CSI shows (though CSI isn't exactly accurate with some things either but at least it gives an idea). Since this part seems pretty key to the plot, it's important to learn the ins and outs of murders and criminal investigations that follow.
Comment: watch Sherlock season 2.
Answer: There are two general avenues to achieve what you want:
1) Declare the missing person dead. That would normally take years, and family members would keep wondering if their relative is truly dead.
2) A coroner would conclude that the amount of blood loss is not allowing a victim to survive. In this case, incident would be qualified and investigated as a murder almost from the very beginning, even if the body is never to be found.
Comment: And in this case, the wife would most likely be the prime suspect
Comment: @Thomo that would add some interesting drama on top of it all!
Answer: Yeah, the mom advocating for murder is never a good sign in the eyes of the investigation.  Especially if there is evidence that she was in the room when the blood was spilt.  Putting on my detective deer stalker hat, she'd be obvious (signs of a struggle, she's freaking out, and... I'm presuming she's not lawyering up right away?  If you're ever involved with a crime, even if you did nothing at all, always best to have a lawyer to assist you.  That said, she's freaking out, so a lawyer wouldn't be the first thing to her mind. If that's the case, she could easily say the wrong thing.  And I'm no lawyer, but I know enough about the law to know never lie to the cops like that.).  In a domestic setting, the one who reported the incident is usually the first suspect.  Spouses have plenty of motive, means, and opportunity to murder.  None of these are enough to convict.  Just because I hated the guy, had access to the murder weapon, and was the last person to see him alive doesn't meant I killed him... but I'm sure going to have a fun time explaining all of that to a degree of reasonable doubt.
How do the fairies get in?  The nature of who done it, with relation to the victim, is quick to determine by figuring out if there was forced entry (windows are broken, door is busted, ect.).  If that exists, then the guilty party was not trusted by the victim (they were either known, but he wanted them out of his life or they were unknown to him completely).  No forced entry means that the victim trusted the guilty party enough to give them unrestricted access to his personal house... usually it would be residents.
Mitigating this would be again, lack of murder weapon (which can't exist since he is most certainly going to be found alive), the lack of evidence of his death (which would turn this into a missing persons case, not a murder investigation), and the lack of anything showing ties to the wife beyond she reported the whole incident.  By the stage that the police are requesting help, the family usually has a lawyer (in the United States, there are a lot of lawyers and a case like this will be publicity generating, which can potetntially be more valuable than anything the family could pay... presuming they are of little means to pay... so the family would have a pick of lawyers to defend their interest).  The family lawyer would have no interested in promoting the murder... because the police cannot rule out the father's death at this stage...  Why continue to bring up a crime that the police aren't looking at charging anyone with, without offering evidence that a crime exists?  The only reason a defense attorney would not offer evidence of a murder would be if it violated Attorney Client privilige... which means that the evidence exists, but his client (i.e. the mom) is the guilty party (and he can't reveal that).  Even if his client was to say "I murdered the bastard and I'd do it again" to the lawyer, he's not getting paid to figure out whodunnit... he's getting paid to keep his client out of jail.  It serves no interest of his to turn over the evidence that would get his client charged and in fact, if the lawyer specifically did it, the Bar association would kick have a field day with that lawyer for the violation of Attorney-Client Privilege, have him disbarred, and some new lawyer would likely come in to get the evidence thrown out on grounds that it was illegally obtained because the lawyer was not acting in his clients best interest AND the police would never have found the evidence if the lawyer was acting properly (conversely, the prosectuion has no such rule.  Because innocence is presumed until guilt is proven, the Prosecuter must turn over all evidence to the defense, even if doing so would injure his own case.  Not doing this will get the prosecuter in a lot of trouble with the Bar).  Fruit of the Poison Tree is a legal concept that not only is illegally obtained evidence inadmissible at trial, but any evidence that was obtained that would not have been obtained had that evidence comes into play is now illegally obtained evidence as well and thus, unusable to build a case.  For an example of this in real life, check out "Making A Murderer" on Netflix, where one of the accused recently (after the making of the documentary) had his conviction overturned because (among other things) his appointed lawyer was shown to believe the guy was guilty (despite his plea of not guilty) and was working with the prosecution to provide evidence against his client.
As for the wait period, it depends... Unless the victim is missing in some kind of reasonable event that would lead to death (explosion, fire, flood) the search will still be in rescue mode for some time, though it will eventually get called off.  Cops do not give up easily (there's a recent case that's local to me where a three year old girl was killed after she was caught in the crossfire of a gang drive by shooting... it took three years to find her killer and the case never went cold, according to the police).
Without evidence of the missing father, after a certain number of years, the person can be declared legally dead... This varies in jurisdiction.  In the United States, it's typically 7 years without meeting the criteria.  A few states have lowered this to 5 years and Georgia and Minnesota have it set to 4 years (can be further decreased if the missing person was in imminent danger... i.e. the evidence points to a situation where his life was on the line and his body was not found, such as a plane crash at sea or disaster).  Estate will be dealt with as if the person is dead and deceased will have the right to reclaim his property should he show up alive and well.  Beneficiaries of any Life Insurance are also supposed to return the money if such an event occurs and it can be proven that it was Fraudulent (a hostage or POW declared dead this way would probably not have to pay, as they were not in control of their disappearnece).  This is very very rare in the modern setting (the last known return to life in this fashion was in 1982, and was ruled fraudulent.).  Not sure how "Faeries held me captive" would hold up in a court of law.  Presuming the man's death, the case would be closed and the wife could be free to insist her husband was murdered and they never caught the guy... it has no more legal standing than "OJ Simpson did it" at this stage, but there will likely always be rumor and speculation about to what happened and what the woman did.


What is an atalef?

Question: In Vayikra 11:19, the atalef is listed as an unclean bird. Is it not a bat which is a mammal/rodent? Is this a translation issue?
Answer: It is certainly not a translation issue, as it might be considered a bird by the Torah (by virtue of the fact that it flies), which does not need to follow any modern-day taxonomy, as stated in the comments...
(If we want to get really crazy we can apply the famous rule of Dibra Torah Kelashon Benei Adam, the Torah speaks in man's language, to say that the Torah would call any flying creature a bird even though Hashem knows it is not a bird, so the people living at that time would understand it.  The usage of this term in contexts like this is a subject of much debate, and IIRC it was discussed in the first issues of Dialogue magazine.)
Additionally, here are a few recent blog posts that deal with the identification of the Atalef according to Chazal, some of which suggest that it may not be a bat, and what it might be instead:
Rabbi Meiselman's claim that the Atalef is a platypus, and rebuttal, Part 1
Rabbi Meiselman's claim that the Atalef is a platypus, and rebuttal, Part 2
Rabbi Josh Waxman's claim that the Atalef is a strix

What is an atalef?


What are the components (or radicals) that comprise the character '兼'?

Question: Without the knowledge of a character's components or radicals, I find some difficulty recalling the meaning or pronunciation of that character. I have looked at this poster containing radicals here, but cannot place which radicals comprise it. I'd appreciate any help. Thank you!
Answer: The correct term is just components. Characters aren't comprised of radicals (部首; section header). Radicals are just modern stroke-shapes used as indexing tools to mark the heading (首) of dictionary sections (部), equivalent to the first letter of an English word when you look it up in a dictionary ("A", "B", "C", etc.), and may not be related to the character at all.
Since a character isn't indexed under more than one radical in a dictionary, we also don't speak of characters having multiple radicals, just like English words don't have more than one first letter.

時期字體
字形
參考資料

戰國・楚簡

11曾侯竹簡

篆

秝部說文解字

東漢隸

衡方碑

楷

「兼」 is a picture of a hand 「又」 simultaneously grasping two cereal plants 「禾禾」, indicating the meaning simultaneously, concurrently.
Be wary of the shape changes in 「兼」 over the course of history: 「又」 is still present in the middle of 「兼」 and now looks like 「⋺」, while the top of 「禾禾」 has been reduced to 「䒑」.
Answer: the main radical is 八, and the components are 䒑、⺕、八、丨 as per pleco.
For these types of questions often a dictionary is still the best choice.  I am sure there are probably online ones as well if you prefer to pleco.


how to prove that ${S_N\over E[S_N]}$ converges to an exponential distribution

Question: Suppose that $\{X_1,X_2,\ldots\}$ is a sequence of iid $L^1$-random variables such that $E[X_1]\neq 0$. Define for every $n$,
$$
S_n=X_1+\cdots+X_n.
$$
Let $N$ be a geometric random variable such that
$$
P(N=k) = q^{k-1}p,\quad k=1,2,\ldots,
$$
where $q=1-p$ and $p\in(0,1)$. Assume that $N$ and $\{X_1,X_2,\ldots\}$ are all independent. Show that as $p\to0$,
$$
{S_N\over E[S_N]}
$$
converges in distribution to an exponential distribution with some rate $\lambda$, and identify $\lambda$.
Comment: I have no ideas of addressing this kind of problem. Using characteristic function or in any other ways?
Comment: I think the starting point will be to  use Wald's lemma which states that $\mathsf{E}(S_N)=\mathsf{E}(X_1)\mathsf{E}(N)=\frac{\mathsf{E}(X_1)}{p}$ (since $X_1,\ldots, X_n$ are $IID$. Hence
\begin{align}
\frac{S_N}{\mathsf{E}(S_N)}=\frac{p}{\mathsf{E}(X_1)}S_N
\end{align}
Comment: @ShahidMShah This can also be shown directly with condition expectations (nested). I am not sure how to continue after that, but this seems a good start (conditional expectations should help you "decouple" the $N$ from the $X_k$'s in the expectations).
Comment: suppose the moment generating function of X is $\psi$, then the mgf of left hand side is $[\psi({pt\over m_1})]^N$, where $m_1=E(X_1)$. So we need to show that $[\psi({pt\over m_1})]^N\to {\lambda\over \lambda-t}$ as $p\to0$.
Comment: The exponent $N$ is a geometric random variable related to $p$, and the mgf function also contains $p$. So the problem remains to be: how could we get the limit of the above formula in this kind of form. I tried to expand the mgf, however I really have no idea how to handle the random variable $N$.
Answer: You are already on the right track and I complete the latter part for you.
Let $\mu = E[X_1]$ be the common mean and
$ \varphi(t) = E[e^{itX_1}]$ be the common characteristic function
As stated above,
$$ E[S_N] = E[E[S_N|N]] = E[N\mu] = \frac {\mu} {p} $$
Now consider the characteristic function of $\displaystyle Z = \frac {S_N} {E[S_N]} = \frac {pS_N} {\mu}$:
$$ \begin{align*} \varphi_Z(t) & = E\left[e^{it\frac {pS_N} {\mu}}\right] \\
& = E\left[E\left[e^{it\frac {pS_N} {\mu}}|N\right]\right] \\
& = E\left[E\left[e^{i\frac {tp} {\mu} X_1}\right]^N\right] \\
& = E\left[\varphi\left(\frac {tp} {\mu} \right)^N\right] \\
& = \sum_{k=1}^{+\infty} \varphi\left(\frac {tp} {\mu} \right)^k (1 - p)^{k-1}p \\
& = p\varphi\left(\frac {tp} {\mu} \right) \sum_{k=1}^{+\infty}
\left[\varphi\left(\frac {tp} {\mu} \right) (1 - p)\right]^{k-1} \\
& = \frac {\displaystyle p\varphi\left(\frac {tp} {\mu}\right)}
{\displaystyle 1 - \varphi\left(\frac {tp} {\mu} \right) (1 - p) }
\end{align*}$$
Note the infinite geometric series converges as the characteristic function is bounded by 1. Since $X_1 \in \mathcal{L}^1$, $\varphi$ is differentiable and thus we can evaluate the limit via L'Hopital Rule:
$$ \begin{align*}
\lim_{p\to 0} \varphi_Z(t) &= \lim_{p\to 0}
\frac {\displaystyle p\varphi\left(\frac {tp} {\mu}\right)}
{\displaystyle 1 - \varphi\left(\frac {tp} {\mu} \right) (1 - p) } \\
& = \lim_{p\to 0} \frac {\displaystyle \varphi\left(\frac {tp} {\mu}\right) + p\varphi'\left(\frac {tp} {\mu}\right)\frac {t} {\mu}}
{\displaystyle  \varphi\left(\frac {tp} {\mu} \right) - (1 - p)\varphi'\left(\frac {tp} {\mu}\right)\frac {t} {\mu} } \\
& = \frac {\varphi(0) + 0} {\displaystyle \varphi(0) - \varphi'(0)\frac {t} {\mu}} \\
& = \frac {1} {\displaystyle 1 - i\mu \frac {t} {\mu}} \\
& = \frac {1} {1 - it}
\end{align*}$$
which is the characteristic function of $\text{Exp}(\lambda = 1)$
Comment: impressive! Thank you very much!


"We hear only the questions to which we are capable of finding an answer"(Friedrich Nietzsche, The Gay Science, aphorism 196) What's his proof?

Question: I have a paper due and it is about critiquing one of Nietzsche's statements. I have to provide an example for my reason and defense for his.
Comment: @another_name can you further explain that?
Comment: Do you have a source for the quote? This may help someone search its context for an answer. By source I mean, title of the book Nietzsche wrote, chapter and/or page number. Welcome!
Comment: The Gay Science, section 196
Comment: This is what psychologists call [confirmation bias](https://en.wikipedia.org/wiki/Confirmation_bias):"*people tend to test hypotheses... by searching for evidence consistent with their current hypothesis*". Why? Because otherwise it may be wide open what to search for, and unclear how. Wittgenstein made a similar point about mathematics in PR:"*We may only put a question in mathematics (or make a
conjecture) where the answer runs: "I must work it out"*". Because it is an idea of how to work it out that gives meaning to a question or conjecture, otherwise it has no use, and hence no meaning.
Comment: Nietzsche is not big on proofs. This joins his over-arching belief that Truth is but a stabilized Interpretation. It is because we see the red color but not the infra-red that we will ask "why is tomato red?" but not "why is that rock infra-red?". In other words, we filter out Reality, our question are about what we can see, and since our perception is biased, we will only ask some specific questions; our answers are in some sense confirmation to our questions, any fundamental underlying to all of it might just turn out to be a game of mirrors reflecting each other.
Answer: Preliminaries
First of all, having a paper due means researching sources and reading a lot in the first place. It has to be your original effort, otherwise, you can fail the module. Considering the question, commentaries and papers that involve aphorism 196 are to be found. In the light of this, I deliberately refer to a single source here, a source which can be used but should be weighed against other, preferably more recent publications. We cannot and should not make this work for you.
First step: Understanding the aphorism
You cannot critique or defend something well if you do not fully understand the content. Thus, you have to identify the point he is trying to make.
Monika Langer in her book Nietzsche's Gay Science: Dancing Coherence (Springer:2010) has the following to say (p. 158):

Unfree spirits also tend to follow anybody running in front
  of them – even someone actually fleeing them. Nietzsche declares unfree
  spirits are thoroughly "herd". We saw earlier such adherents ironically
  pride themselves on being more virtuous than the one they are following. In unmasking various facets of such alleged virtue, Nietzsche tacitly
  urges us to question ourselves and our age. However, he observes we
  hear solely questions we can answer. Rushing through life renders us
  incapable of finding answers requiring reflection.
Nietzsche advises caution in interacting with unfree spirits. They are
  deaf to numerous questions and happily communicate secrets they
  claim to conceal.

Thus, her commentary suggests that "we" is alluding to the common man, the unfree spirit incapable of true reflection. They will prise themselves for the mainstream (i.e. "herd") knowledge they are able to reproduce and simply ignore questions that are out of the box and truly questioning the status quo. Thus, one can say that "we" - common humans - "do not hear" - i.e. deliberately ignore - "questions to which we are [in]capable of finding an answer".
Second step: Critique
Critique always includes consideration of arguments in favour of the position or point if it is to be well-graded. Thus, you should try your best to think of - and find sources for - straightforward arguments for and against such a view. I will give some hints which obviously need work and references put into them - since this is what you get your grade for.
First of all, the aphorism cannot be literally true since otherwise, we would not be able to develop new knowledge, either individually or culturally. Nietzsche was aware of that, but critical towards what he conceived to be a sheepish and repetitive culture without any true progress.
What are the possible merits of the aphorism? Some have already been discussed in comments or answers:

Confirmation bias is a psychological fact, people tend to ignore input that does not sit well with their already established knowledge and worldviews.
The inability to understand something that cannot be framed in one's conceptual framework is an epistemological argument. There are plenty of authors defending such a view.

One might want to add the social dimension Nietzsche is often suggesting as well: People thinking out of the box and genuinely questioning the norms and common knowledge tend to be pariahs. Nobody really likes them either because they are so much beyond our own abilities and understanding (genius, Übermensch - envy) or because they make us feel bad for adhering to what they can show us to be wrong (projected self-hatred).
Thus, indeed only few people want to be confronted with these kinds of questions - and so they are commonly ignored by "not hearing" them.
A word on Nietzsche and the kind of philosophy he offers
Given that all this analysis is correct, why didn't he just write that and gave proper arguments? Mainly because he (just as e.g. Schopenhauer) deemed this to be exactly the style so typical for "the herd" and thus beneath his dignity. He thought the argumentative, structured philosophy of Kant to be the epitome of abhorrence (see only two aphorisms earlier). He wrote against such technical, yet herdish philosophy. Accordingly,  Nietzsche writes in aphorisms, which are a literary form, a form of the art of writing. Asking him for proofs is misplaced.
Answer: Defense for his statement:
We rely on incoming sense data to formulate a model of the world and act according to that model. But our formulation of the world is heavily constrained by our five senses.
We only see through a tiny slit of reality because of this limitation, therefore our model of the world is simply a rough approximation, which has been developed through the process of evolution for us to survive.
Since our perception of reality exists in this rough approximation of the world that we have conjured, our rationality is also confined within this box. We are incapable of conceiving questions beyond what we are "capable of finding answers to", because the act of asking a question implies one "knows what he does not know".
One cannot ask a question which lies outside the bounds of his conception of reality, because he does not know what he does not know.
Comment: Asking questions is not impeded by what "what we don't know", it does not imply one "knows what he does not know", because that would mean it is impossible and useless. Rather, we can have a very clear idea of what we do not know. Also, we are perfectly capable of asking after things that are unknowable, or even impossible - after things that lie beyond our conception of reality - because imagination is not limited by reality.
Comment: I take your point that imagination is not limited by reality. My point is that our conception of reality itself is limited by our senses. It is impossible for us to imagine outside of our reality. The act of imagination implies concepts of space, time and rationality. How about a reality outside these boundaries? How do we imagine that?
Comment: Care to cite Nietzsche on any of this? This doesn't sound particularly Nietzschean to me, with talk about sense data and world models.
Answer: The complete aphorism 196 from Nietzsche's The Gay Science is what the OP quoted:

We hear only the questions to which we are capable of finding an answer.

The OP wants to know what Nietzsche's justification for this aphorism might be.
A literal reading of this aphorism suggests that it is not true. One can find questions in a textbook on a subject that we have not studied and actually hear those questions without having any idea of how to answer them. So we can literally hear questions we cannot answer.
What we are not able to do is understand those questions, or at least understand them well enough to suggest how we might try to provide an answer if we wanted one. What Nietzsche may have intended by the word "hear" is "understand". Given that, it still does not seem true. We may be able to understand the question whether an unsolved mathematical conjecture is true or not without being able to find a proof of, or counter-model for, the conjecture.
Perhaps Nietzsche means completely understand a question defining complete understanding as actually being able to find an answer if we wanted to? If that is the case we might be able to rephrase the aphorism as

We completely understand only the questions to which we are capable of finding an answer.

However, that does not sound very profound. It just repeats our definition of "completely understand".
We could then go back to the original aphorism and suggest that Nietzsche's justification for stating the aphorism at all was to get us to think about the relationship between questions, answers and our hearing or understanding them without providing an answer.
Comment: If we are in the realm of conjecture anyways,  wouldn't it be more fitting to understand it as "We (tend to) ignore (i.e. not listen to) questions to which we are not capable of finding an answer"? Mind,  this is a translation and there is an ambiguity in the German "hören" which does not exist in English because it is clear-cut between to hear and to listen to.
Comment: A cognitive/rational approach to Nietzsche fails in general, it's more so in the case of this aphorism. His statement is a metaphore to the boundries we contend with when wresling with the world, he wish to suggest that we are structured in some very specific manner, one which directs our questions.
Answer:
What then is truth? A movable host of metaphors, metonymies, and
  anthropomorphisms: in short, a sum of human relations which have been
  poetically and rhetorically intensified, transferred, and embellished

For me implies we can only answer a question by making sense of its metaphorical structure, and metaphors are rich verbal expressions that leave most things implicit

A sentence metaphor typically likens many things or kinds to many
  other things or kinds at a single verbal stroke. Benjamin's terse
  little aphorism manages to liken works to death masks, conceptions to
  living human beings, the changes a conception undergoes before being
  incorporated into a finished work to life, the stabilization and
  stultification it allegedly undergoes after such incorporation to
  death—and so on.

Because of Nietzche's anti-essentialist "perspectivism", the truth is a matter of subjective attitudes, and given the ubermensch ideal has no human limits, we may find that the metaphorical structure of question, at least about value, is limitless and un-grounded. Our attempt to understand it will be a reflection of our own triviality or concern

if you gaze long enough into an abyss, the abyss will gaze back into
  you
Comment: not sure, but does my answer make sense iff every aspect of a question has a corresponding (true) answer?


Some questions about posts that I've edited

Question: I have some questions about posts that I've edited.

How can I get a list of all posts that I've edited?
Can I get the count of all posts that I've edited?
How can I discard my edited post?
Comment: Please, don't use one post for multiple questions. Also, these are all answered by other, pre-existing posts on Meta.
Answer:
You'll find these on your activity tab in your profile.

Click 'Users' at the top, then 'Editors' on the right, then select 'All' just below that, then filter by your own name on that page.

You can't, unless you mean 'delete the post', which you can only do in certain circumstances (always your own answers, only your own questions if there are no upvoted answers).
You can 'undo' an edit by using the 'rollback' link, which copies the previous version of a post back on top as a new edit.
Answer:
Your user page > Activity > revisions.
It tells you the number of Revisions to the left of "Revisions" on the same page.
You can Rollback to a previous version of an edit by clicking on the link that is the relative time that you edited the post when you view the post.

If you are referring to Suggested Edits, exchange "suggestions" for "revisions" above, except for (3) where I don't recall if you can recall a suggested edit when you don't have the rep to edit the question directly.
Answer: Your Profile contains all these details.
<code>1. How can I get posts that edited by me already ?
</code>
Go to your profile, select Activity tab, select "suggestions" option. It will show you the edit suggestion you did. you can choose any particular from there.
<code> 2. Can I get number of edited post by me until now ?
</code>
You have edited only 1 post till now. In the "suggestion" option when you click on the "suggested edit" link it will show you the suggestion history, where you can find the total number of edits you done at the botton, along with the user who approved/reject your suggest edit.
<code> 3. How can I discard my edited post ?
</code>
There is a roll back link with every edit you made. Just click on it to discard the modification you did.


Change url of angular-ui-router without reloading page

Question: I'd like for changes in the URL to drive my application, and for changes in the application to change the URL, but not actually change state.
I have a route like this. The country/city example is a bit contrived, hopefully that doesn't confuse things. The relationship in the real application is somewhat hierarchical. Child views don't seem a fit though because there's no need for nested views.
$stateProvider.state( 'viewMap', {
  url: '/viewMap/:country/:city',
  templateUrl: 'pages/viewMap/viewMap.html',
  controller: 'ViewMapController'
};

In ViewMapController, I can construct the page based on $stateParams.country and .city. As these values change, my application reacts and I want the url to stay in sync. I don't want to reload the whole page, however. I just want to update the url and push a history state on to the stack.
I understand I could manually construct a string:
updateUrl = function() {
 window.location.hash = '#/viewMap/'+ $stateParams.country +'/'+ $stateParams.city
}

This feels fragile, as the way I build the string is separate from the way the framework parses it. I would prefer for the framework to build me a string based on the current params, but $state.href('.') describes the current route, which doesn't include $stateParams that haven't yet been activated/navigated to.
I've also looked at reloadOnSearch, but I think it only applies to query params.
Is there a better way to model this? It feels like I'm fighting the framework over something simple.
Answer: You can pass state params to $state.href function to get the complete URL
$state.href('.', $stateParams)

To generate arbitrary urls you can pass non-current params and/or configuration:
$state.href('.', {country:'usa',city:'sf'}, {absolute:true})


How can I have a modelformset with inline modelform?

Question: Say I have a model like:
class Team(models.Model):
    name = models.CharField(max_length=20)

class Game(models.Model):
    title = models.CharField(ma_length=20)
    home_team = models.ForeignKey(Team)
    away_team = models.ForeignKey(Team)

Then in my view I have:
def manage_games(request):
     GameFormSet = modelformset_factory(Game, extra=1)
     game_forms = GameFormSet(request.POST or None,
                                 queryset=Game.objects.all())
     if request.method == "POST":
         if game_forms.is_valid():
            game_forms.save()
            game_forms = GameFormSet(queryset=Game.objects.all())

     return render(request, "admin_dashboard/manage_games.html", locals())

This works okay except that I'd like to be able to turn the home_team and away_team into CharFields (rather than the dropdown it currently is) while also keeping them separate models. How can I add an inline model formset into a model formset to make this possible?
Comment: For me it is completely unclear, why you think you need an inline model formset (which is by the way with your models not possible anyway)? Why do you want to have char fields instead of the dropdowns? This does not seem to be logical to me, so I am afraid I miss some information or I misunderstand the provided information.
Comment: @schacki Client wants to supply the team name in the same form as he edits or creates a game. It seems perfectly fine to me that he should be able to create/update the team on the same screen as the game. :)
Comment: Understand, I personally would prefer an nice and easy drop down instead of typing, but that is a matter of taste. Just be aware that you will create a new team now for every type. And  again: this is not an inline model formset :-).
Answer: An inlinemodelformset wouldn't work because Game has the foreignkeys Team.
An inlinemodelformset can show a list of forms for models which are connected to another via a ForeignKey. For example if A.b is an FK to B, then it is possible to make an inlinemodelformset of A for B.
However, you could still add a couple of fields to change the home/away team names:
from django import forms

from models import Team, Game

class GameUpdateForm(forms.ModelForm):
    home_team_name = forms.CharField(max_length=20)
    away_team_name = forms.CharField(max_length=20)

    def save(self):
        obj = super(GameForm, self).save()

        if not obj.home_team_id:
            obj.home_team = Team()
        obj.home_team.name = self.cleaned_data.get('home_team_name')
        obj.home_team.save()

        if not obj.away_team_id:
            obj.away_team = Team()
        obj.away_team.name = self.cleaned_data.get('away_team_name')
        obj.away_team.save()

        return obj
    class Meta:
        model = Game
        exclude = ('home_team', 'away_team')

And make the modelformset use it:
GameFormSet = modelformset_factory(Game, form=GameForm, extra=1)

You might also want to add CharField autocompletion.
Comment: I like this and would accept it if my `name` field was unique, but I can't make them unique. :(


accdr runtime error, missing references?

Question: so I have an access 2010 application and am trying to run it on a pc with just MS office and access 2010 runtime installed. when I open the accdr file on the other pc, I get a runtime error as soon as it opens up and then I click ok and then it closes. I've tried the accdr file on my pc and it works fine. I'm guess the other PC has some missing references and thats whats causing it? How do I check to see what references are missing on the other pc?
Answer: Since the other computer has MS Office installed you can do the following:

Make note of the references in your full version of MS Access
Open Excel on the other computer
Press Alt + F11 to open VBA
Go to Tools --> References...
Attempt to find the references you noted in the first step above

Any references you are unable to find in Excel VBA will also not be available in the Access runtime.
Comment: so in excel I'll see the same ones as I do in access? I did find some on my side that was not on the other pc, how can I install the ones that are not on the list?
Comment: The References dialog is a generic VBA dialog, so it will be the same whether you are looking at it from Excel or Access (or Word or Outlook, etc.)  With regard to installing missing references, that depends entirely on which ones are not on the list.  If you post the names of the missing references we may be able to point you in the right direction.  Also, keep in mind there may be licensing considerations that restrict distribution of the missing libraries.
Comment: I'm seeing "ctv OLE Control module", "Microsoft forms 2.0 Object Library", "Microsoft Windows Common Controls 6.0 (SP6)", "Microsoft Office 14.0 Object Library", "Microsoft AtiveX Data Objects 6.1 Library"


Mercurial and Word or PDF documents

Question: is it possible to use Mercurial version control to track Word or PDF files?
Is there any limitation or problem?
Answer: Yes.
You will be able to do meaningful diffs for MS Word documents.

If you have TortoiseHg installed and
you have set up a repository,
right-click the file for which you
want to check the diffs.
On the context menu, click TortoiseHg > Visual Diffs.
In the Visual Diffs dialog, select
docdiff, instead of kdiff3.
Double-click the file in the Visual
Diffs dialog.

MS Word will open a Compare Result Word document, which will show the differences between the current version of the document and the previous version as Tracked Changes.
Comment: Very cool! One question: I can only do a visual diff if I have changes that are not committed and it only compares my current changes with the last commit. Is there a way to specify which two revisions to compare?
Comment: You can right click on any revision and do a "Diff to Local" @JasonDown to compare with the current working directory.
Answer: Yes, but of course you won't be able to diff in any meaningful way. The files will therefore be treated as binary during merges.
Mercurial is perfectly capable of tracking binary files:

Mercurial generally makes no
  assumptions about file contents. Thus,
  most things in Mercurial work fine
  with any type of file.

Mercurial stores a binary diff regardless of the file type. The problem with PDF/Word files is that a little change to them usually causes a huge difference in their binary representation on disk. .docx Documents are stored as a zipped xml, due to the zipping a single flipped bit inside the archive can cause the zip archive to look completely different.
If you don't grow your repository too large, you probably won't experience any issues using Mercurial.
Comment: and if I save the word file in XML with "Save as"... ?
Comment: except if the binary is such that small changes to the document make large binary changes  then the binary diff will be about the same size as the file for each version. i'd use words xml format rather than the binary ones
Comment: @jk: You're right, in fact I assumed he used the office 2007 format, only problem is it is zipped internally AFAIK. But people tend to blame the VCS for not handling binaries correct all too often.
Comment: then you will get efficient storage in hg, and could conceivably use normal text merge to merge docs, there do appear to be special word merge tools available which may (or may not) be better though
Answer: Beware the suggested
cmd.pdfdiff = [\path\to\diffpdf.exe]
opts.pdfdiff= -a $local $other

$local and $other have no meaning in the extdiff context. The literal strings "$local" and "$other", not the file names, will be passed to "diffpdf.exe". I found this the hard way.
cmd.pdfdiff = [\path\to\diffpdf.exe]
opts.pdfdiff= -a

will work and the two files will be passed as parameters following the "-a". c.f. https://www.mercurial-scm.org/wiki/ExtdiffExtension where it is stated:

Each custom diff commands can have two parts: a 'cmd' and an 'opts' part. The cmd.xxx option defines the name of an executable program that will be run, and opts.xxx defines a set of command-line options which will be inserted to the command between the program name and the files/directories to diff
Answer: For Pdf files, I was able to get the GPL licensed DiffPDF hooked up to do comparisons between revisions of pdf files.
I added the following to my mercurial.ini file:
[extdiff]
cmd.pdfdiff = [\path\to\diffpdf.exe]
opts.pdfdiff= -a $local $other

[diff-patterns]
**.pdf=pdfdiff

Now when I click on the pdf file in tortoisehg (or use hg pdfdiff at the cmd line), it opens the two files for comparison. Since my pdf's tend to contain images, I use the appearance comparer (-a in opts). If you have mostly text, you can use -w instead.
It defaults to highlighting to show the diffs. I prefer the Src Xor Dest option for displaying the differences, but I don't think there is a cmd line option for that.
Comment: DiffPDF is NOT GPL licensed:  "DiffPDF is a commercial Windows graphical user interface (GUI) application ..."

Mercurial and Word or PDF documents


Different tmux configs for different sessions?

Question: We have a centos 7 machine that many developers use with tmux 1.8 under the same user. Is it possible for us to have personal configs for each tmux session, while also leaving the default config intact for new (default) sessions?
Answer: As @asmodean correctly mentioned, the way to use multiple tmux instances on the same machine (with the same user) is to use two different sockets. A socket name can be given using -L option.
Usage
Create tmux instances

first session:

tmux -L userA -f ~/.tmux-userA.conf

second session:

tmux -L userB -f ~/.tmux-userB.conf

Join instances

tmux -L userA attach
tmux -L userB attach

Other tmux commands
Other commands work with -L option. For example, to list userA and userB sessions:

tmux -L userA list-sessions
tmux -L userB list-sessions

Answer: Here is what I did to achieve per session configuration in tmux.
set-hook -g after-new-session 'if -F "#{==:#{session_name},emacs}" "source ~/.tmux/.tmux.conf.emacs" "source ~/.tmux/.tmux.conf.amos"'
set-hook -g after-new-window 'if -F "#{==:#{session_name},emacs}" "source ~/.tmux/.tmux.conf.emacs" "source ~/.tmux/.tmux.conf.amos"'

Answer: tmux can be invoked as tmux -f /path/to/tmux.conf.  Since everyone is logging in as the same user, you could create a directory of user configuration files for tmux.  For example /home/username/tmux/userA.tmux.conf.  UserA would then start their tmux session with:
tmux -f ~/tmux/userA.tmux.conf

If you wanted to simplify thing for the users, you could make alias entries for each user in the ~/.bashrc file for example if you are using bash.  Each line would look like:
alias tmuxuserA='tmux -f /home/username/tmux/userA.tmux.conf'

Then userA would invoke their session with the command tmuxuserA.
Comment: If the users don't need to communicate between sessions, you can use the `-L` option to specify a socket name.  A unique server will be started for each socket, which _can_ use different config files.  You can even add it to the alias: `alias tmuxuserA='tmux -L userA -f /home/username/tmux/userA.tmux.conf'`.
Comment: Sadly, I this doesn't seem to work. As per the man page, "tmux loads configuration files once when the server process has started.  The source-file command may be used to load a file later". So `-f` only works if tmux is fresh and has no running session. Using `source` updates the config for all running sessions. I feel what I am asking cannot be done using tmux alone.
Comment: @asmodean, you should add that as it's own answer.  Running independent instances on separate sockets is the solution for the stated problem.


What is the recommended mobile apps that assist in meditation?

Question: I have been meditating for a few years now. I love the ones that deal with breathe control. I have use Headspace, calm, and balanced. All help a little but I have done trials of all three and don't know which is better. Please help
Comment: This is a type of question that would be considered off-topic on other SE sites -- because it's a "product recommendation?" question. It doesn't even specify what you mean by "better" i.e. what you are looking for.
Answer: The Buddha provided instructions on meditation. Those instructions are the original "app". You can use your phone to read such instruction:

DN22:1.7: "Mendicants, the four kinds of mindfulness meditation are the path to convergence. They are in order to purify sentient beings, to get past sorrow and crying, to make an end of pain and sadness, to discover the system, and to realize extinguishment.

On your phone, you can also listen to the same thing:

https://www.sc-voice.net/#/sutta/dn22/en/sujato

Listening is quite important. All meditation apps focus on listening. Why is that?
The suttas were originally spoken and heard as is, in the moment. In this age of fast looking and grabbing, the art of listening mindfully has sadly slipped into disuse. You may notice that modern meditation apps have an emphasis on sound. Listening mindfully is quite important. The ears must hear what happens in the moment. Eyes tend to grab what glitters. So we tend to use our phones as eyes onto the world, grabbing whatever catches our fancy, leaving us unsatisfied. Meditation apps turn away from the grasping of sight and allow you to explore listening. And if you're going to explore listening, well, try listening to Buddhist suttas, especially the ones on meditation itself.

MN143:5.1: "That's why, householder, you should train like this:
MN143:5.2: 'I shall not grasp the eye, and there shall be no consciousness of mine dependent on the eye.'


Wood Trim that has Come Loose

Question: I have a thin strip of wood trim on the inside of a bedroom door frame that needs repairing (it's loose). What should I try first?
Comment: What tools do you have access to and/or feel comfortable with?
Comment: I am comfortable with using hammers, wood nails, wood glue and can learn and acquire needed tools and techniques if necessary to ensure the repair is performed adequately.
Comment: Thanks for everyone's response. I'm comfortable using hand tools. The thin strip looks like it was secured by small narrow staples. I will try some of your suggestions.
Comment: As an aside, I asked this question for @tamera...when she finishes the job, I will mark one of the answers based off what she had success with. Thanks everyone!
Answer: My best suggestion from personal experience and opinion, is to stay away from adhesives. Mechanical fasteners (nearly) always have a method of removal that doesn't destroy the things it's fastening. You can pull a common nail, back out a screw, or punch through a finish screw.
In my house I've had similar things happen, and it's usually due to the wood expanding or contracting in such a way that the finish nail has pulled through the wood and is no longer mechanically squeezing the top piece to the substrate.
A few (2-3) well placed, ringed finish nails would go a long way. I prefer "panel nails" for this kind of work, so long as they aren't too long. Their ringed shanks tend to hold well.
If you can locate studs or other timber behind your trim, I especially like specialty "finishing screws" with counter threaded shanks near the head to minimize that "swollen" area around the head.
Answer: If the piece has been attached to the wall with fasteners try tapping it back in place and adding 1 or 2 6 penny finish nails. If that isn't possible than try using wood glue by applying glue to each of the damaged pieces. Bring the pieces together and if possible clamp the piece in place while the glue is drying and/or fasten to wall with finish nails. Wipe up any oozed-out glue with a damp rag before it dries. After a few hours lightly sand and paint.
Answer: Based on your description it sounds like it's the door stop molding. It's a thin piece of trim that goes around the sides and top inside of the door frame that the door presses against when closed so it doesn't swing all the way through. Common size is about 1-1/4" wide by 3/8 to 1/2" thick.
It's common for these to come loose over time especially if it's installed so that the door hits it when it's latched closed. Also if someone falls against it or kicks the door from the inside when closed.
Close the door so it latches, press the trim back in place and hold it. Make sure the door continues to open, close and latch properly. Should be about a 1/16" gap between the closed door and door stop. Take a pencil and mark the door jamb (the wider board that the door stop sits on) where the door stop trim rests up against it. That way you won't push it too forward to interfere with the latch or leave it too far back to create a gap.
Grab a hammer and some 2d finish nails (or 1" long 16 or 18 gauge nails if you have a finish or brad nailer or smallest size it takes around that size) and use them to attach the trim to the door jamb. You don't need very big or long nails. The only thing you're nailing into is the 3/4" thick door jamb behind the door stop.

Wood Trim that has Come Loose


How would I go about vectorizing this image?

Question: I'm working on vectorizing (in Illustrator CS6) the atrocity below. I've finished almost everything except for the teeth. What is the best way to vectorize the mouth and teeth? Should each grey tooth be its own shape, or is there a better way to draw all the black outlines?
Comment: Personal pet peeve: we use the term 'vectorizing' instead of 'converting to a vector format'. I know all the kids are using it these days, but It just drives me crazy. AND GET OFF MY LAWN!
Comment: Are you using image trace in Illustrator for the entire image?
Comment: To provide some help, though, I'd actually suggest you just manually redraw it as a vector image. Most of it is extremely geometric so you'll end up with a much more accurate rendering by hand tracing rather than relying on an auto-trace tool.
Answer: Depends on the teeth. Are the lines between each tooth going to be a t-junction to the top & bottom edge, or are they going to be more of a y-junction where each tooth has rounded or angled corners?
If a t-junction (like human teeth), it is easy to make one large shape for all the upper (or lower) teeth and just add the vertical lines after to define each tooth.
If you want more detail, rounded corners or sharp pointed teeth, it is easier to create them separately. Trying to add the saw-tooth details for the top/bottom edge in a single vector line will be more difficult to accomplish.
The mouth would be one big circular shape layered underneath the teeth.
Answer: The mouth is actually "general" 3 shapes - upper jaw, lower jaw, and mouth opening itself (it should be lower in the layers if you want the teeth to be curved, or on top to "strait" the teeth borders).
I'd create outlines for these 3 shapes by pen tool and after that I'd divide the jaws shapes by lines to teeth - via pathfinder or creating compound path again via pathfinder.
Finally - if you want different hues - live paint filling.
There are a lot of ways to perform the task, however. I described the one, others will give others.


Vertical and Horizontal three dots icon button usage

Question: Despite the Material Design has great guideline documentation, I'm confused about vertical/horizontal dots icon for a Web App since for mobile, the vertical solution is a stablished pattern.
I found a post that says that vertical dots are for secondary options menu but I see some examples that show that the horizontal can be also used for that.

I'm redesigning a table list that have option menus but some are linked with option pages. Is okey to use the horizontal dot icon also as link for a option page instead of vertical menu?
Comment: I think either are acceptable and have identical meaning. Although I prefer the horizontal version because it literally can be interpreted as an ellipses (i.e. there's more here.)
Comment: @UXfrom12 If he needs to add 3 more options next week he wouldn't want that to involve a design change
Comment: If there are only two actions, why wouldn't you just put the two options?
Answer: The Material HIG recommends using the vertical menu icon on the web and on Android, the horizontal one on iOS:

If you're following these guidelines in general, it's best to use the vertical icon.
As for Spotify, LinkedIn, and Jira, none of those are following the material design guidelines. In fact, if you look across various applications and platforms, you'll see that the "menu overflow" functionality doesn't have one consistent icon: Microsoft uses horizontal dots, Firefox and Gnome use the hamburger icon (which is used for navigation only on Android), and some iOS apps use a gear or a tool icon.
Comment: As for whether you can use the icon for linking to an "Options" page instead of a menu, I wouldn't recommend it, as I haven't seen it used that way anywhere. There's a settings icon in the Material icon set that you can use instead: https://material.io/icons/#ic_settings .
Answer: This is a really interesting question, luxo. The difference between horizontal and vertical should be based on design shape, space, and/or fit.
For instance, let's take a mobile app with a navigation menu that has icons (like the pic below). A vertical ellipsis fits better in the space and provides continuity within the design. A horizontal ellipsis just wouldn't provide as nice of a touch.
It's not always about looks, but sometimes it just 'looks/feels right' for a reason that you might not be able to come up with. But if you dig deeper, there is a reason for why it looks/feels better – in this case it's because of the continuity and harmony between the other elements that it possesses.
Comment: "fits better in the space" - A good point! "...in this case it's because of the continuity and harmony between the other elements" - needs more evidence/explanation.
Answer: Be aware of alternate usage for three horizontal dots:
In addition to their being a hamburger icon dialect, I have seen horizontal three dots used on a button as a prompt to browse for a file whose pathname is to be entered into a field.
Comment: In material design, the hamburger and the "More" icon have distinct meanings. The hamburger triggers the *navigation drawer*, whereas the three dot icon shows additional items.
Answer: You can go both ways as the icons have the same meaning and there is no consensus on which one to use. There are even multiple other solutions (I'm not proclaiming that they're better).
As an idea (depending on your context):

It might be valuable to show primary actions directly in the table and hide only the secondary ones in a submenu.
In case the table is quite full of date you can unclutter the view a bit by showing the actions only on mouse-over and selection of the row.
Answer: For consistency reasons it's better to stick to one selected guideline instead of mixing. You need to be consistent across the interface, but also consider the device it was build for.
So, you mentioned Material Design, so I will assume that you are following that guideline and maybe are creating Android/Web apps. In that case, you should use the vertical icon. You can see example images with the icon in the Components > Contextual Menus

Now if you were to design for Apple devices, their guidelines use the horizontal icon, see System Icons, especially the More icon.
I prefer the horizontal icon, since it's reminiscent of the typographic ellipsis which was intended to suggest "more" items, so it has a more common interpretation in the user's minds, but above preferences, I would go for consistency.


Would it be haraam if I killed a spider on night of Qadr (Laylat al-Qadr)?

Question: Would it be haraam if I killed a spider on the night of Qadr?
I have no idea about this but i become very scared when i see it so killed it ...Please tell me for this reason my dua and other things i do will be lose or not please help me
Answer: There is no special prohibition in night of qadr.
If you're expecting a fear from a spider, no problem in killing it
Comment: Thanks for replying ....
Answer: It is not permitted to kill any life that Allah has made scared, whether it is on the night of Qadr or not.
Say: "Come I will rehearse what Allah hath (really) prohibited you from": join not anything with Him; Be good to your parents: kill not your children on a plea of want;― provide sustenance for you and for them;― come not nigh to shameful deeds, whether open or secret; take not life, which Allah hath made sacred, except by way of justice and law: thus doth He command you, that ye may learn wisdom. (6:151)


How do cycling moltant salt reactors do nuclear fission?

Question: I only have an understand of how PWR's do nuclear fission, looking at the diagram for the  salt reactors it's a bit confusing. Where is the fission taking place if the salt is cycling throughout the entire plant? How is flux controlled? How is neutron capture handled while cycling is taking place?
Comment: I thought the 'salt'  used is a mix of salt and plutonium and was being used as a replacement for the fuel rods. Your saying they use standard aluminum/uranium fuel rods for fission with the salt as a moderator and heat transfer?
Comment: There are 3 main types of molten salt reactors. One type uses the salt as a coolant. https://en.m.wikipedia.org/wiki/Molten_salt_reactor
Comment: I'm specifically asking about the cycling reactors.
Answer: The fission is happening everywhere there is salt with fuel in it. Most of the fissions are occurring in the "main" part of the core, where the geometry is favorable for neutron multiplication, but there are fissions occurring everywhere in the primary loop.  This is one of the challenges of molten salt reactors.
In addition to the prompt neutrons, some fissions will produce a "neutron precursor" that will eventually release a neutron after a slight delay.  These neutron precursors are generated in the main part of the core, then transported into the primary loop, where they release their neutron and produce additional fissions in the primary loop.  It gets interesting....
To account for the (very) radioactive primary loop, there is an intermediate coolant loop that will isolate the primary loop from the final coolant loop.


If outside a cylindrical solenoid exist an electrical field what does that mean to the Aharonov-Bohm Effect?

Question: To the question "What is the electric field outside a cylindrical solenoid when inside is turned on a magnetic field" the answer is that outside exists a electric field. Does that mean that the fringes shift in the double slit experiment with electrons could be explained with electromagnetic fields and it is not necessary (but of course possible) to explain it with quantum mechanics?
Answer: This is what the author of http://arxiv.org/abs/1407.4826 seems to imply. I have no idea if this is correct or not, sorry.
Comment: That is not the answer to my question. your answer to my last question was high satisfying. Thanks
Answer: The issue here isn't quantum mechanics but whether a description using only local fields is possible. Quantum mechanics is essential as you are considering an interference phenomenon. The alternative would be to consder a charged classical field that corresponds to the electrons in a superposition of the two paths, but then you are simply considering the trivial limit of large numbers of particles.
Lev Vaidman has argued here that the non-local effect in the AB-effect is an artifact of describing the solenoid classically. In reality, everything is quantum mechanical including the solenoid. It is then the electric field of the electron that exerts a force on the charges in the solenoid, the momentum transfer leads to the wavefunction of the solenoid to pick up a phase which is different for the two paths and that difference is precisely given by the AB formula involving the flux.


How do I move content from one business unit to another within the same org?

Question: We have 3 business units in Marketing Cloud and all of our content resides in the Parent BU. I need a way to transfer all of the content.  I know I can share from one to the next but there are over 1500 items. It has been suggested that I could use AMPScript to achieve this, I have found some functions that allude to this possibility and I have the handbook however I don't know where to begin or if its even possible. Any help / insight would be greatly appreciated.
Answer: AMPScript won't help you in this situation.  You can either:

Utilize Shared folders -- if they're enabled in your account
Build a utility with the SFMC API to move the objects.  Some assets you cannot move via API (e.g. Import Definitions, Data Extracts, etc).
Move the assets manually.


Why do larger animals need bigger brains?

Question: For example, we can assume that the average house cat is equally intelligent as the average tiger. The average tiger is about 100 times heavier than the average house cat. But its brain is also bigger than the house cat's brain. Since the tiger isn't any more intelligent than the average house cat, why does it need a bigger brain?
Answer: Brain size isn't necessarily a determinant of intelligence. That notion was a  assumption of neuroscientists of the past, a speculation that lead to many problematic socio-psychological projections.
The size difference of brains might simply match the morphology of the species, but sometimes it doesn't scale so evenly, as with crocodiles, whose brains remain roughly the same size their whole lives even as their bodies grow. I personally wonder if this relates to the hypothesis that brains evolved to meet the need for movement (the "moving hypothesis").
Often larger animals have larger brains to fit their morphology, but they don't necessarily have more neurons. Having more neurons might be the reason for the greater intelligence (or, perhaps a better phrasing, greater cognitive flexibility) of species like Homo sapiens. This hypothesis is explained in detail in Suzana Herculano-Houzel's paper "Brains matter, bodies maybe not: The case for examining neuron numbers irrespective of body size" http://www.suzanaherculanohouzel.com/herculano-houzel-2011-anyas/


How to create a bootable Windows usb from Linux Mint?

Question: I have a Windows 7 iso file which I wish to burn into a usb to make it bootable. I tried with the Disks utility "Restore Disk Image" and it copied the iso files into the drive but it didn't make it bootable. I tried using Etcher but when I selected the Windows iso file I got a message saying that Windows iso files required a special burning process to make them bootable and that I had to use a tool such as Rufus which isn't available for Linux and Wine couldn't run it properly.
Answer: I always use dd for this, and it has never failed. Yes, it works for Windows ISO's too.
Here's how I normally go about it (as root -or use sudo):
dd if=/path/to/your/iso of=/dev/sdX bs=4M;

The X in sdX is the where your USB device is connected. Be very careful tho choose the right one! Otherwise you might overwrite the wrong disk/partition.
One way to find out the right device is to issue ls -l /dev/disk/by-id/.
Below is an example, where you see that the USB device is located on /dev/sdb:
ls -l /dev/disk/by-id/
totalt 0
lrwxrwxrwx 1 root root  9 11 okt 12.36 ata-MATSHITADVD-RAM_UJ-842S -> ../../sr0
lrwxrwxrwx 1 root root  9 11 okt 12.37 ata-TOSHIBA_MK8009GAH_Z8A1W9THW -> ../../sda
lrwxrwxrwx 1 root root 10 11 okt 12.37 ata-TOSHIBA_MK8009GAH_Z8A1W9THW-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 11 okt 12.37 ata-TOSHIBA_MK8009GAH_Z8A1W9THW-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 11 okt 12.37 ata-TOSHIBA_MK8009GAH_Z8A1W9THW-part3 -> ../../sda3
lrwxrwxrwx 1 root root  9 11 okt 12.41 usb-SanDisk_U3_Cruzer_Micro_3512330F5580ED45-0:0 -> ../../sdb
lrwxrwxrwx 1 root root 10 11 okt 12.41 usb-SanDisk_U3_Cruzer_Micro_3512330F5580ED45-0:0-part1 -> ../../sdb1
lrwxrwxrwx 1 root root  9 11 okt 12.41 usb-SanDisk_U3_Cruzer_Micro_3512330F5580ED45-0:1 -> ../../sr1
Edit: The Arch Wiki has a good guide for this.
Comment: You can also use the /dev/disk/by-id/ names directly with dd. So just do `dd if=/path/to/your/iso of=/dev/disk/by-id/usb-SanDisk_U3_Cruzer_Micro_3512330F5580ED45-0:0 bs=4M`
Comment: @masgo Thanks buddy, you taught me something new!
Comment: the `/disk/by-id/` is really great. Also for things like software RAID systems, fstab, etc. You always get exactly the drive you expect. If the drive is not there you will get a decent error message. While using /dev/sdX causes a lot of trouble if you replace the drive, or if you re-wire your drives. - The only real drawback is: if you clone your drive and replace it with the clone it will not work until you changed your config - but I like this sort of explicit handling.


Install guest additions with Dockerfile

Question: Right now I'm using docker to build a personalized virtual environment for tensor flow development.
I will install fluxbox and guest additions ontop of an existing tensor flow Ubuntu Docker...
here is my Dockerfile
FROM b.gcr.io/tensorflow/tensorflow:latest-devel
RUN apt-get update && apt-get upgrade -y

RUN apt-get install -y build-essential module-assistant
RUN m-a prepare
RUN m-a update
RUN sh /media/cdrom/VBoxLinuxAdditions.run

RUN apt-get -y install xorg openbox
RUN apt-get -y install fluxbox
RUN apt-get -y install gedit

RUN apt-get update
RUN apt-get upgrade -y

Unfortunately RUN m-a prepare exits with code 101 expecting me to Click on Install Guest Additions… from the VirtualBox Devices menu.
I am thinking that this is the same type of issue you get if you try to apt-get install without the -y option, the docker file results in a indeterminate state requiring user input and the whole thing crashes.
Now I have been looking for a couple hours now and I can't figure how to install guest additions in with my Dockerfile...
Any input would be awesome!
I also posted this question here : https://superuser.com/questions/1067118/install-guest-additions-in-dockerfile
Answer: You can install virtualbox-guest-dkms package instead, it contains the same guest drivers.
sudo apt-get install virtualbox-guest-dkms

Install guest additions with Dockerfile


What size to save if we're going to sell our photo?

Question: My question is similar to the original poster's question, except for that I'm trying to understand what size to save a photo in if you're uploading it as a high resolution photo for print. Would you still save it on the low-end resolution as "8" in Photoshop or up it to the highest resolution as "12"?
Comment: Welcome to Photo.SE.  You refer to "the original poster's question" which doesn't make sense here.  It would help if you could indicate "where" you're thinking of selling your image.  I assume your reference to "8" or "12" is to JPEG compression.  Output settings in Photoshop would really depend on where you are getting it printed; your print shop should be able to provide advice.  In terms of storing the original photo, shooting raw would be best; if not, then saving your image in a lossless format (e.g. TIFF) would be good.
Comment: See also: [Why does JPEG quality go up to twelve?](http://photo.stackexchange.com/questions/11544/why-does-jpeg-quality-go-up-to-twelve)
Answer: Always use the highest (native) resolution on your camera, and after editing keep the photo at its native original resolution.
You do not need to, and should not, reduce the resolution simply because you plan to sell the image in future.  Most people who buy the image would want it in its original resolution, and if they don't, they can do the resizing themselves.
Only when you are told you need to reduce the image to a specific resolution for a specific purpose should you create a separate copy of the image in that resolution.
As for file format, firstly, always keep the source image, as it came from your camera, unmodified.  That way if you screw up you have something to go back to.  When storing an image for your own use and editing, use a lossless format - it might be a good idea to use the native format of your editing software, eg PSD for photoshop.  When delivering the image to someone they may specify which format they like, or you can use JPEG with a high quality setting.  For long term archival use something lossless but well-established like TIFF, though PSD is established enough to be supported for a long time too.
Answer: Generally, save always the best possible resolution, and prefer always a lossless format.
Once data is lost, it is lost, and cannot be gained back. Don't skimp on some megabytes, unless you are forced to by the print provider.


Why does making a pasta require more yolks than whites?

Question: I have looked up numerous pasta recipes and all of them suggest adding a certain number of whole eggs and a certain number of additional egg yolks. I am just curious why we need only yolks? How would the pasta be different if I added a total number of whole eggs instead? Is it a matter of colour, or texture, or both? And more importantly how
Comment: Hi, and welcome! Nice first question. We are a bit specific about what questions we take, and the one about pasta fits quite well. The last paragraph about generically deciding on extra yolks was not only a different question, it would have needed a full book to answer. We not only don't take more than one question per post, but also don't take questions whose answer would be so voluminous. You would need to know the role of both the egg white and the egg yolk in the exact recipe which you are working with, and whether they are already well balanced or not, before you can start deciding.
Answer: It's about what properties you're looking for in the pasta.  Serious Eats had a primer on fresh pasta a couple of years ago, and they discussed some of the differences:
https://www.seriouseats.com/best-easy-all-purpose-fresh-pasta-dough-recipe-instructions

Egg Whites, Egg Yolks, Water: Identifying the Best Source of Hydration
With my flour selected, it was time to test different sources of moisture. My first step was to make three doughs, keeping the hydration level as consistent as possible across the board. I used three equal measurements of all-purpose flour as my baseline; one batch got water, one batch got egg whites, and the third got egg yolks.** I added just as much as I needed to make the dough come together. This is what I wound up with; you can probably tell which is which.
** I stuck with large eggs for all my tests, and even weighed them to make sure that I was adding consistent amounts of water, protein, and fat to each dough.
(image)
The water-only pasta (right) was a total bust—the noodles were bland, mushy, and...well...watery. And the egg white pasta (center) wasn't much better: Whites are almost 90% water, so, while the noodles weren't quite as bad as the water-based version, which literally fell apart and stuck to each other in a big, gluey mass, they definitely weren't winners. The yolks, on the other hand, made a beautiful, golden dough (left). Yolks contain about 48% water, 17% protein, and around 33% fat. More yolks will deliver more color, more egg flavor, and silkier noodles.
Unfortunately, that high fat content complicates things a little bit. Though it's not exactly scientifically accurate, you can think of that fat as making the gluten proteins all slippery, preventing them from building a strong network—when I tested this using different amounts of olive oil, I found that, sure enough, more oil made for softer, mushier, less elastic noodles. And, to complicate matters even further, I had a really hard time getting the flour and yolks to come together. It was a dry, tough dough that was difficult to mix and knead—not exactly beginner-friendly.
Difficulty aside, an all-yolk pasta may make great noodles, but it's not sufficiently elastic to use for stuffed pastas, which require a dough that can be rolled more thinly and is, quite simply, bendier. I needed to strike a better balance.
At this point, I knew there was no point in adding water—if I wanted additional moisture, egg whites were definitely a better bet. It seemed clear that my dough was going to require a combination of whole eggs and additional yolks. I ultimately settled on three yolks for every egg white.
What's that? You like softer, mushier noodles? Good for you. Add a teaspoon of oil to my basic recipe. Want a richer, eggier flavor and a more golden hue? Throw in an extra yolk and add a little more flour. This is your dough.
Answer: It is not actually required. I have never seen an egg pasta recipe which uses extra yolks, and Ruhlmann, a cook who wrote a book with prototypical recipe ratios, also uses whole eggs only. So you can certainly make (good) pasta without the extra yolks, and using extra yolks is just one possible variation. You simply have happened to come across recipes written that way.
If you use more yolks, you can expect a stronger eggy taste and a slightly gooier texture than with whole eggs. Possibly also a color difference, if you have dark yolks and use a lot of them, but you can't rely on that. If you need colored pasta, you should simply color it.
Comment: I know I just thought it was curious that you've never seen a recipe with extra yolks. It seems like most of the recipes I see use them. No idea why it's more popular in some circles than others.
Comment: Funny, one of my favorite chefs on Youtube makes all his pasta with WAY more yolks than whole eggs. His ravioli dough calls for 2 whole eggs plus SIX yolks. They are darn good though and I've never had a problem rolling it out or shaping it.
Comment: @PeterMoore ah, I see now, thanks for clarifying! Indeed, I have no idea why there is such a difference between recipes.
Comment: @PeterMoore I never said that you cannot make pasta with (extra) yolks, or that pasta with extra yolks isn't good. The claim was the opposite: that you can make good pasta *without* extra yolks.
Comment: @rumtscho possibly older/historical recipes had to use more yolks as there was imbalance between available whites and yolks -  https://cooking.stackexchange.com/questions/113540/what-did-european-american-historical-cooks-do-with-the-egg-whites
Comment: downvoted for implying egg pasta recipes with extra yolks are uncommon, which would be easy to verify it's actually quite common with tons of counterexamples. OP was not making claims, they were asking why extra yolks make a difference.


Logging the Instruction Pointer Register

Question: Is there a tool that logs the value the IP register of a specific process running?
I am trying to compare the instruction excution before and after a file modification.
Answer: Depending on the CPU architecture the process targets, there are many dynamic instrumentation tools that can perform this function. However, you have not specified the environment the process of interest runs in.
Architecture-specific examples:

Intel's pintool. Someone on stackoverflow has already asked about how to use pintool to print all executed instructions
PANDA. This framework includes a plugin called PANDA_CB_INSN_TRANSLATE which is triggered prior to instruction translation and can be paired with PANDA_CB_INSN_EXEC
The DynamoRIO-based tool instrace. "instrace" is short for "instruction trace".


power to outlet until something is plugged in

Question: I have a single item on the line.  I have power on that line until I plug something in and then I lose power to that outlet.  I replaced both the circuit breaker and outlet.  Suggestions please.
Comment: Welcome to StackExchange. If you lose power when you plug something in, *how do you know there was power there before?* What is your testing method that shows power?  Is it a voltmeter, and if so what voltage does it show?
Comment: Does the breaker trip or does the outlet just stop working?
Comment: Have you tried plugging different things into the outlet? The item that you're plugging in might have an issue. Also, is there a GFCI or AFCI in use?
Comment: Sounds like a failed back stab , if using a non contact tester and with a load there is no power it's a damaged splice or backstab. If a non contact tester says there is power but a load is plugged in and it doesn't work it's the neutral.
Answer: Assuming the breaker doesn't trip and there isn't a GFCI involved, this would generally indicate a poor, high resistance, connection somewhere in the line. Your voltmeter pulls so little current that you see the full voltage but when you connect a real load, the poor connection drops the voltage.
Since you replaced the breaker and outlet, the problem must be elsewhere. Wires generally don't just fail, unless someone drove a nail through it. So you are looking for a junction box somewhere with splices. At least hopefully, the person who wires it followed code and didn't just splice it in a wall.


Random distribution of objects over a plane

Question: I'm making a game which involves the player walking around a forest, and so I need to randomly distribute trees from the sapling tree generator all over it. The plane is huge so I can't simply place them manually.
It would also be ideal to change the seed of the tree for each tree created. I'm familiar with python so a script would be acceptable.
Thanks!
Comment: Particles are what you're looking for, I think
Comment: @GiantCowFilms how would I use this to do it?
Comment: I'm not entirely sure, since I don't work in the game engine much
Comment: @GiantCowFilms Okay, well I'll see if it works
Comment: @GiantCowFilms oh it seems I can't use particles in the game engine
Comment: @GiantCowFilms actually the particles worked eventually so if you put that solution as an answer I'll make it the accepted answer
Answer: I'd recommend the Asset Sketcher commercial addon on CG Cookie Market. Perhaps you can modify it to randomize the Sapling seed value.
Answer: Another way to do it is with particles. The particle system would duplicate a specific tree object and distribute it. There is a button in the modifiers tab (if a particle system is present for the object) that makes all the particles into individual oobjects. I won't provide specific step by step instructions on how to set up the particle system, but I hope that works.
However, on most cases Python script would be preferable for what you want. You'll probably to distribute multiple tree models to provide variations, and you'd need a Python script for that.
EDIT: well now I see the comments under the question. This is probably useless. XD
Comment: Actually it's still useful, the modifiers tab part helps @TheMinecraftMan757
Answer: Use Python. Get the list of verts in the terrain then iterate through them and randomly assign each coordinate as covered or empty. Covered ones get a tree or bush object or the like. I built exactly this a while back. Let me know if you'd like an example script.


Updating without Composer

Question: I've previously used Drush to update my Drupal-installations. They are installed without using Composer, and currently on version 8.7.3. However, when I try to use Drush (drush v8.1.15, using drush up) to install the currently newest version the update fails when untarring the new core. When googling I see conflicting answers about what to do - among suggestions are Drush9, updating using composer (which I tested - does not work since the page is not installed using Composer) and others. What would be the simplest, least likely way to destroy the page while being able to update (with regards to security updates)?
Comment: Rebuild your site locally using Composer. Then update locally using Composer. Then upload the updated packages to your live site and run database updates.
Comment: Latest releases of Drupal 8 work with Drush 9 only. There is a project out there that will convert your site to be composer controlled if that's what you desire.
Comment: I would prefer to not go the composer-route if it is not needed - but if that is what I have to do to get security updates I guess I will. Looks like updating Drush could work though.
Answer: The latest releases of Drupal 8 are "supported but not recommended" on Drush 8. Drush 8 is still necessary if you are not using Composer to build your site. Composer is recommended for all Drupal 8 sites because sooner or later you are likely to need a module that requires Composer. If your site does not yet need such a module, though, then it is possible to continue to use Drush 8 and the pm-update command.
A few months back drupal.org changed all of the URLs used to download Drupal images; in order to continue to use Drush 8, you need the latest version, which has been updated to use the new URL scheme. Please update to Drush 8.3.0, and you should be fine.
Comment: Thanks for this! I updated drush to 8.3.0 now - but still get the error. However, looks like the initial failed download is cached, but I can't seem to find a way to clear the cache?
Comment: Nevermind - cleared the cache manually - still got an error. That error was caused since the droplet had ran out of Inodes. 8.3.0 worked like a charm. :)
Answer: I am sure many expert users will consider this heretical advice. It may or may not work for you depending on your hosting arrangements.
I'm with a shared hosting provider using a cpanel interface. Their cpanel has the Softaculous installer.
I have found that I can simply update drupal core using their scripts in 1 click.
No drush. No Composer. No fuss.
Of course it does not update contrib modules (which can still be updated using the admin/modules/update interface) or libraries (which would need to be updated manually) but I have found this route way less stressful and complex with the relatively simple sites I am working with.
Pro developers of course need more sophisticated tools and more time efficient ways of updating multiple sites, and the manual route does take longer if you are updating multiple libraries.
I hope those developers so enamored with Composer don't kill off that functionality once they hear of this! (Please don't :-))

Updating without Composer