Visitor that changes the structure of the objects it visits

Question: Brief summary:
The vanilla GoF visitor is great for altering items within a tree of elements, but when the visitor visits an element it can only change the children of that element not the element itself. For example, a visitor altering the DOM of a webpage could search for everything that contains an image and replace it with an ascii art version of that image. However, <dim>s can contains images,
s can contain images, paragraphs (
) can contain images. When the visitor is visiting the node for <image> tag itself it cannot change the type of the image node, though you could change the content of the image node - this is just how visitors work. Instead you would have to find everything that could conceivably contain an image and then visit that - and on top of that anytime W3C added another item that could contain an image you would have to update your visitor.
This isn't a perfect example - there a lots of tools for altering webpage DOMs - but hopefully it is an intuitive one.
Sorry - there is a wall of text in the more complete description below. I'm trying to walk the line between brevity and fully explaining everything, but it looks like this post same out quite wordy.
What I have:
I have a class hierarchy that can be represented by the simplified classes below:

Element is the abstract base class for all visitable classes, and has an Accept method.
LeafElementA and LeafElementB are concretes that are extremely simple. They don't do anything, but just represent that there can be different types of leaves.
MultiCompositeElement and BinaryCompositeElement are also concretes that can contain other Elements - either a collection, or a Left and Right (respectively). The Accept method overrides handle recursing to the contained Elements.
I also have some Visitors that visit each of the Elements. All vanilla GoF visitor so far...
(I'm not looking for feedback on this class hierarchy, I'm just setting the scene with a simplified version of the real classes that I am working with).
What I want:
I would like to use a visitor to alter the structure of the Element tree. For example, in this toy example I might want to append a LeafElementA to each composite element, and if the composite element is a BinaryCompositeElement to convert it to a MultiCompositeElement before (and also recursively visit all the children of each composite element too...).

The vanilla visitor does not cope with this well. When you visit an Element you can alter the content of that Element but not return a completely different Element.
I could check the children of each MultiCompositeElement and BinaryCompositeElement as I visit them to see if any of the children need to be transformed from a BinaryCompositeElement to a MultiCompositeElement. However, this would violate the DRY principle as the check would have to be in both visit methods. This would be compounded by the fact that in the 'real' implementation there are many composite type elements - not just 2.
Finally the code:
DotNetFiddle (sorry for the terrible ToString implementation on this one) or download csproj/zip from dropbox (no terrible ToString, just put a breakpoint in the the end of the main method).
I have left out some "clutter" bits of code from the snippets below. There is no error checking or null checking.
Base classes (I've not included IVisitor as it would also increase clutter. All of the methods on VisitorBase are on IVisitor):
// Element base class
public abstract class Element   {
  // I am returning an Element here (different from a "normal" GoF implementation)
  internal abstract Element Accept(IVisitor visitor);
}

// Visitor base class
public abstract class VisitorBase: IVisitor
{
  // Again, return an Element
  // This is so that each visitor can choose to return a different type
  // than the visited Element
  public virtual Element Visit(Element element)
  {
    element = element.Accept(this);
    return element;
  }

  // Another departure from vanilla visitor: Visit just this element
  // (and don't recurse)
  public virtual Element VisitNonRecursive(Element element)
  {
    return element;
  }

  // These can be individually overridden, and I have added these for transforming
  // one type of Element into another
  public virtual Element VisitNonRecursive(LeafElementA leafElementA)
  {
    return VisitNonRecursive(leafElementA as Element);
  }

  public virtual Element VisitNonRecursive(LeafElementB leafElementB)
  {
    return VisitNonRecursive(leafElementB as Element);
  }

  // ...similar methods for the other elements (removed to reduce clutter in the snippet)
}

Some concrete elements (I'm not including LeafElementB as it is virtually identical to LeafElementA):
public class LeafElementA : Element
{
  internal override Element Accept(IVisitor visitor)
  {
    return visitor.VisitNonRecursive(this);
  }
}

// Implementation of Element that contains multiple other Elements
public class CompositeElement : Element
{
  public CompositeElement(params Element[] containedElements)
  {
    ContainedElements = containedElements.ToList();
  }

  public ICollection<Element> ContainedElements { get; private set; }

  internal override Element Accept(IVisitor visitor)
  {
    ContainedElements = ContainedElements
      // Recursively visit each child
      .Select(visitor.Visit)
      .ToList();

    // And non-recursively visit this
    return visitor.VisitNonRecursive(this);
  }
}

// Implementation of Element that contains exactly two other Elements
public class BinaryElement : Element
{
  public BinaryElement(Element left, Element right)
  {
    Left = left;
    Right = right;
  }

  public Element Left { get; private set; }

  public Element Right { get; private set; }

  internal override Element Accept(IVisitor visitor)
  {
    // Recursively visit the children
    Left = visitor.Visit(Left);
    Right = visitor.Visit(Right);

    // And non-recursively visit this
    return visitor.VisitNonRecursive(this);
  }
}

And the concrete visitor:
// Implementation of Visitor that adds a LeafElementA to any composite element
public class AddOneMoreVisitor : VisitorBase
{
  public override Element VisitNonRecursive(MultiCompositeElement multiCompositeElement)
  {
    multiCompositeElement.ContainedElements.Add(new LeafElementA());
    return multiCompositeElement;
  }

  public override Element VisitNonRecursive(BinaryCompositeElement binaryCompositeElement)
  {
    // Here we are able to change the returned type from the visitor
    var result = new MultiCompositeElement(
      binaryCompositeElement.Left,
      binaryCompositeElement.Right,
      new LeafElementA()
    );
    return result;
  }

  // The rest of the recursion-based visiting can be delegated to the base
}

So, did you actually have a question?
Yes, I did.
Firstly, is there a name for this variant of the visitor pattern? I assume that I will not be the first person in the whole world to think of or implement this. And I assume that with the collective wisdom of all those who have gone before that this class can be done better.
Secondly, if this is not the case, then is there a way I can do this better? Doubling up the visit methods seems wasteful, but I always get stack overflow exceptions when I try an implementation without it.
Thirdly, I am concerned about type safety. In the toy example all the composites contain base Elements. In the real-life code most Elements that contain another hold a derived type. Is there a way of making the visitor type safe so that no upcasting is needed? I couldn't find one - but that does not mean that it doesn't exists. And if not, is there a way to make it easier for a developer to write correct code. This looks like a powerful pattern and as Uncle Ben* said: "With great power comes great responsibility". If it is not possible to make it provably typesafe according to the compiler, then the code should not get in the way of writing correct code.

*The Spiderman uncle, not the rice uncle
Comment: I feel like a preschooler reading Einstein. Is there any way you could simply the explanation of what is going on and what you are wanting done?
Comment: @BKSpurgeon I've added a paragraph at the top. Does that ground what I am attempting to do with a real(ish) exmple?
Answer: Review

Firstly, is there a name for this variant of the visitor pattern?

You have made what I like to call the inviting visitor pattern. I'm not sure this pattern is common, but I have seen it before, disguised and usually involves 3 (types of) classes instead of 2, each with their own concern.

inviter: let visitee invite visitor
visitee: let visitor accept me
visitor: visit reference

As in contrast of the visitor pattern as we all know it:

visitee: let visitor accept me
visitor: visit visitee

Your visitor is also the (self-)inviter. This part is what I would rename if using the augmented visitor pattern. However, your problem is solvable with a regular visitor pattern.

 public virtual Element Visit(Element element)
 {
    element = element.Accept(this);
    return element;
 }

 public virtual Element Invite(Element element)
 {
    element = element.Accept(this);
    return element;
 }

Secondly, if this is not the case, then is there a way I can do this
  better? Doubling up the visit methods seems wasteful.

Since you never override Visit(Element element), I don't see its purpose. If you would have a situation where you could override, consider moving this functionality to another class. You shouldn't let the visitor decide both (A) how the reference can accept the visitor and (B) how to visit the reference, these are two different concerns.

Proposed Solution
Your situation allows for a regular visitor pattern.
Change the flow in the reference:

internal override Element Accept(IVisitor visitor)
{
    // Recursively visit the children
    Left = visitor.Visit(Left);
    Right = visitor.Visit(Right);

    // And non-recursively visit this
    return visitor.VisitNonRecursive(this);
}

internal override Element Accept(IVisitor visitor)
{
    Left = Left.Accept(visitor);
    Right = Right.Accept(visitor);

    return visitor.Visit(this);
}

Change the flow in the visitor and renameVisitNonRecursive to Visit.

public virtual Element Visit(Element element)
{
    element = element.Accept(this);
    return element;
}

public virtual Element Visit(Element element)
{
     if (element is LeafElementA) return Visit(element as LeafElementA);
     if (element is LeafElementB) return Visit(element as LeafElementB);
     // ..
     return element;
}

Answer: You can improve naming. Names like IVisitor are good to illustrate the pattern, but in production code I would rather have a name that tells me the purpose of the interface, not which pattern it represents. For example, this looks a lot better, IMHO:
internal abstract Element Transform(ITransformer transformer);

It looks like you assume that BinaryElement.Left and BinaryElement.Right are not null. Yet nothing stops me from executing this line of code:
new BinaryElement(null, null).Accept(...)

You should validate constructor parameters to catch such mistakes early.

VisitorBase.Visit makes no sense. Why would Visit method call Accept internally? Shouldn't it be the other way around? Shouldn't Accept method call Visit instead? Those methods calling each other is the reason stack overflows. You can remove Visit method, and call Left.Accept(visitor) instead of visitor.Visit(Left). It will work just fine.

I think there are two main ways to implement visitor pattern.

You either provide a method for every concrete implementation:
interface IVisitor
{
   //removed from interface
   //(you can still have this method as `protected virtual` in base implementation)
   //Element Visit(Element element);

   Element Visit(BinaryElement element);
   Element Visit(CompositeElement element);
   //etc...
}

Note, that there is no Visit method, that takes base Element, only concrete implementations are included. This gives you some sort of type safety at compilation time, making sure that you do not forget to modify your visitors as you add new elements. But it also bloats the interface as the number of elements grow.
Or you keep your interface simple by only including base type:
interface IVisitor
{
   Element Visit(Element element);

   //removed from interface
   //(you can still have those methods as `protected virtual` in base implementation)
   //Element Visit(BinaryElement element);
   //Element Visit(CompositeElement element);
}

This prevents visitor interface from bloating, but you lose type safety.

My point is that there is always some sort of trade-off, and one approach might be better than the other depending on use case. However, by combining those two approaches, as you do, you are likely to get the downsides of them both AND gain non of the benefits. So I suggest you pick one or the other, and stick to it.

AddOneMoreVisitor has inconsistent behavior. Sometimes it creates new elements, and sometimes it does not. This can produce all sorts of weird side effects associated with shallow cloning. Modifications that are done to transformed tree in some cases will affect the initial tree. To avoid that you will have to do deep cloning during transformation. However, if initial tree is always discarded after transformation, then it does not matter, I guess.


MacOS: Add browser tab (i.e. Gmail) to application switcher?

Question: I use Gmail for email in my Google Chrome browser. Is there a way to make Gmail appear as an application that I can choose using the application switcher invoked with Cmd + Tab?
Answer: Use Fluid:

Fluid lets you create a Real Mac App (or "Fluid App") out of any website or web application, effectively turning your favorite web apps into OS X desktop apps...your chosen website has a permanent home on your Mac as a real Mac application that appears in your Dock.

Gmail is even one of the examples they show in the video, and it supports features like badging the application icon when you have new messages.
Answer: Browser tabs cannot be added to the application switcher; only running applications can. However, there are various native wrappers around Gmail (by Googling, I found Kiwi and Mailplane for traditional Gmail and Boxy for Inbox by Gmail, although there are plenty others out there) and services that will simply construct a native app that is merely a web view containing a specified website (i.e., Gmail) (these include Fluid and Applicationize, though, once again, there are many others). These native apps (or those generated by these services) can and will appear in the application switcher when active.
Note that I am not affiliated with, and have never used, any of the services mentioned herein.
Comment: Thanks for the variety of tools. I did some research but probably could have used better search terms.


How to Animate Drawing in HTML5 Canvas

Question: I am new to HTML5. I have an animated sequence inside a canvas that shows a pencil writing different letters like ABC etc. I would like to have this saved and available for playback as a tutorial for the user who would then try and write ABC on the canvas themselves.
Answer: Check here -- this topic has been touched on before on SO.
It might also be worth considering using an SVG library like raphaelJS instead of canvas -- this would greatly simply your life if you were planning on including any interactivity with these tutorials, and they would certainly make glyph rendering especially easy (using Cufon).

How to Animate Drawing in HTML5 Canvas


Best way to fix the 'Dear [display_name} problem

Question: When supporters are emailed it would be more personal to start 'Dear Joanna Smith' rather than 'Dear Supporter'.  Of course, sometimes we don't have a first name, and sometimes only an initial so using the tokens is tricky.  How do people handle this in a) traditional bulk emails and b) Mosaico?  Some examples would be useful
Answer: Greeting tokens can use smarty. You can set your default email greeting token at civicrm/admin/options/email_greeting?reset=1, and then in your mail use the greeting token {contact.email_greeting_display}.
So then you can make the greeting token something like Dear {if "{contact.first_name}" != ""}{contact.first_name}{else}Supporter{/if}
To update existing contacts you'd need to first change their pref to the new one you've created, using something like UPDATE civicrm_contact SET email_greeting_id=5 where contact_type='Individual', where 5 is the id of the new greeting, then run the scheduled job "Update Greetings" to update the greeting.
Comment: This works but only for new contacts.  If I update existing contacts with no first name it doesn't work - I checked the database table & these do appear to be blank.  Also this won't work with Mosaico?  The extension Pete mention is this https://github.com/systopia/de.systopia.moregreetings
Comment: It should work with mosaico but yes you're right for existing contacts you'd also have to run a little script since their pref format would already be set to the previous pref. Will update answer.
Comment: Excellent, thanks.  The greeting works in Mosaico too.
Comment: thought i saw a post recently about a new extension to help with this


Reversing the resolution of a minor key's tritone

Question: The tritone is between ^2 and ^6 in minor but from what I understand, if resolved inward to scale degreees ^3 and ^5 it will sound like the mediant chord is now the new tonic. But what about if you resolve it outward. Is this some kind of modulation to A major since neither of the notes would be part of that scale? In Cm for example the D and Ab could resolve to Db/C# and to A natural.
Answer:
^2 and ^6 in minor [...] from what I understand, if resolved inward to scale degreees ^3 and ^5 it will sound like the mediant chord is now the new tonic.

When played in isolation, perhaps, but in the context of a full realization of the harmony, I have serious misgivings about that hypothesis. For a counterexample, what about when ♮vii°7 resolves to i? I think despite the tritone notes moving towards the mediant chord's root and third, the minor tonic note's presence should easily prevail over the parallel major sound.

Is this some kind of modulation to A major since neither of the notes would be part of that scale?

Well, it could be. Those two notes at face value are pretty convincing for an A major change-up, but composers have the ability to use those notes to set up a lot of different ideas, not necessarily only modulations to A major.
Yes, it is possible to resolve the 2nd and 6th in a minor key to the flat supertonic and raised submediant, although perhaps a bit contrived of a solution to the ostensibly ambiguous 2-3, 6-5 resolution pattern. This resolves the tritone in the opposite direction; if previously the tritone in the minor key was going to an interval of a major third, now it will end up a sixth instead. Neither note is in the former key, so a modulation or temporary tonicization is one possible use for this idea.
Note that A major is the relative major of F# minor, which is the key exactly a tritone away from C minor. Any tritone can be reinterpreted as the same tritone relative to the key a tritone away. In this case, the interval between D and Ab (diminished fifth) was reinterpreted as being between D and G# (augmented fourth). This is an artifact of the tritone splitting the octave exactly in half (thus being its own inversion), and it is also the driving principle behind the tritone substitution in jazz theory.
Answer: Keep in mind that the scale degree functions change when that tritone is in the major or minor position.
In major the degrees are ^7 and ^4 associated with the dominant chord, but in minor they are ^2 and ^6 associated with the subdominant.
In major the ^7 would move up to ^1 like in V6 I, but that ^7 becomes ^2 in minor and it would be held when a subdominant moves to the dominant like in iio6/5 V4/2.
I would say that major and minor are not "reverse" of each other and so when you switch between one key and its major/minor relative the scale degree function, or tendency tone directions, are also not "reserved."
When you "reverse" the movement, what you essentially are doing is inverting the scale degree and voice leading roles. With some enharmonic re-spelling D A♭ (interval d5) to E♭ G is ^7 ^4 to ^1 ^3 in E♭ major, "reversing" it as D G♯ (interval A4) to C♯ A inverts the scales degrees to ^4 ^7 to ^3 ^1 in A major. Both motions are dominant function but the keys are a tritone apart. This is the basic of the tritone substitution in jazz.
It's easier to see the relationships when comparing the two major keys E♭ and A rather than comparing Cm and A major, because the converging motion of D A♭ to E♭ G is really characteristic of E♭ not Cm.
Answer: Yes, you can use the tritone between 2 and 6 of the natural minor scale to lead all sorts of places!  As you can with any tritone.
If we're in the world of functional harmony we must also consider the harmonic minor scale, which contains the same 4-7 tritone as the major scale.  And (as mentioned in your other thread about the picardy 3rd) it can take the classic semitone resolution to a major tonic chord or the in-key resolution to the minor tonic.   Same with the 2-6 tritone in the natural minor scale.  Probably best to let one of the notes act as a leading-note and resolve a semitone up.  But the other can resolve down by either a semitone or a full tone.
Answer: Tritones and diminished 7th chords have this in common-- they divide the octave equally.  Composers VERY often use this fact to do just what you're talking about-- for example modulating to A major instead of resolving to E-flat or c minor.
A nice way to move forward might be something like this:
C minor--> d + a-flat (=g#) --> A major --> d minor --> d-dim7 --> G7 -- c minor
This is one of the main ways that Romantic composers get around to so many keys.  When in doubt, diminished 7th your way out! ;D
Comment: ok so its like the tritone has an enharmonic equivalent on the other side of the circle of fifths and you can be transported far away from the home key this way? I notice A major and Eb are on opposing sides of the circle.
Comment: Because I suppose that every dimished 5th has an equivalent augmented 4th right? So in Cm the D - Ab is a dim 5th but that same interval is an augmented 4th in A major or C#minor  right?
Comment: Yes, you have it exactly right.
Comment: And the jazz way would say `D Ab` is d5 `^7 ^4` in E flat major, while the tritone sub makes it `D G#` A4 `^4 ^7` in A major. The same function is maintained, it's still dominant harmony, but the scale degree roles invert. Compare that to the major/minor relative change and the changing role of dominant v. subdominant for the tritone.
Comment: If we insist on half-step motion only, then that leaves us with 4 keys that it can resolve to: C min, E-flat major, F# minor, A major, depending on what roots we add.  But if we also allow that the "top" note of a tritone can fall a full step (I say top because if you respell it, the top note flips), and we like the sound #2-3, then we can also add A minor, F major, E-flat minor and B.  So the EXACT same tritone could be a kind of hub, modulating pretty easily to all those different keys.


Setting up a Bulletin Board

Question: I want to add a "Community" section (Bulletin Board) to my website so everyone can communicate, but I don't know what I'm doing.
How would I go about adding this and which one offers the most documentation and support?
Answer: Whatever you do, make certain that you read the instructions on configuring your discussion software to protect you and your community for the worst parts of the internet: spam, spoofing, and abuse.
Make certain that you immediately change the admin password from the one that comes with the installation.
If you leave your communities wide open to all kinds of posting, harvesting, and general mis-use, you'll spend your days playing whack-a-mole with thousands of idiots.  Develop your acceptable use policy, configure your boards to support it, then enforce it.
And if the software you are looking at doesn't support things like e-mail verification, moderation, abuse reporting, anti-spamming controls, etc., just keep looking.
Be prepared to spend time managing your community so that it doesn't become another one of the millions of web forums out there full of off topic posts that drive people away from your website.
Answer: I think what you needed is a forum software, there are tones of free and open source ones available on the net. DotNetNuke is a .NET one but can be expensive to host and phpBB is another popular choice and there are a lot of cheap hosting solutions.
Answer: This is what you need.
Edit: They don't offer a hosted version there. You can use this instead. It's hosted on it's own site, free, and doesn't require a download.
Comment: If you're using PHP, sure. If not, no.
Comment: Oh my bad, I thought that site had the service of HOSTED phpBB forums. There are other sites for that: http://www.pro-forums.com/

That way you don't have to download anything and it's free.
Answer: is your site based on php/mysql or asp/sql? Chances are if you do not know where to even find tables, that you are not able to what you actually want.
HOWEVER, if it's php/mysql, i recommend Cool Php Scripts book. It covers creating sort of a community forum/message board.
As i said again, you are probably not going to do it alone, at least, without a long frustrating learning curve.
You can always post a job and someone would be more than willing to bid on it at elance or rentacoder or any other site of your choice
Answer: Wikipedia has a big honking list of forum software. Pick the one that best matches the programming language(s) you're familiar with, the features you need, etc.
Answer: I find Vanilla to be a much better forum application that phpBB for reasons of aesthetics as well as extensibility.  I have not seen/used it in a situation where many sub-forums were required, so depending on your scope it may not be the right choice, but for small-to-medium sized forums I'd suggest trying it first.
Answer: First, you need to choose a forum software that matchs your requirements.
Then, just follow the Installation Guide provided by the software you have choosen.
More information at Forum Software Reviews

Setting up a Bulletin Board


English translation of the Samyutta Nikaya

Question: Looking for suggestions on an English translation of the Samyutta Nikaya in printed book form other than Bhikkhu Bodhi's version.
Answer: SuttaCentral has translations by Ven. Sujato (and other translations).
And there are Piya Tan's translations with his commentaries hosted on a site called "The Minding Centre" (formerly called "The Dharmafarers").
Also (according to this answer), Obo's web site links to several translations if you want to compare them.
And the Buddha Vacana web site is one of my favourites, it only translates some of the suttas but translates in depth, i.e. with the English and Pali in parallel (which you can also get with Ven. Sujato's translations, especially if you enable "Activate Pali word lookup" and "View original text with translation" in the Text settings).
Comment: Perhaps also the Pali Text Society (PTS) have a translation.
Comment: Thanks for you reply. I'll have a look through the links you provided. I'm really in need of an inexspensive paperback print edition. Bhikkhu Bodhi's book is good but it is to heavy and a bit pricey to put it through the paces of a carry-around-book. :D TU  ☸
Comment: Apologies, I missed "in printed book form" in the question. I think his books are online as PDFs, [here](http://lirs.ru/lib/sutra/Connected_Discourses_of_the_Buddha(Samyutta_Nikaya).Vol.I.pdf) and [here](http://lirs.ru/lib/sutra/Connected_Discourses_of_the_Buddha(Samyutta_Nikaya).Vol.II.pdf), if that's any use to you (i.e. if you have a portable digital device already).


What's the use of a dual capacitor?

Question: If the part in this question is indeed a dual capacitor, what's it good for? The only thing I can think of is that it would be smaller than two separate capacitors, so space-saving, but then it supposes that you need the two (identical?) values at the same place on the PCB, and a common pin.
Comment: If one capacitor is good, two must be better.
Comment: Its double the fun <:->. Joke not to be taken seriously
Comment: Yo dawg, I herd u liek capacitors, so...
Answer: Capacitors not only have capacitance but also resistance and inductance.
Sometimes those resistance and inductance are disturbing.
Using two equal capacitors in parallel will double the capacitance but half the unwanted resistance and inductance.
Answer: According to @Jason S, it is so it isn't polarized, saving assembly time to put it in the right way (or also not work if placed the wrong way). That argument is only valid for hand-assembly.
Comment: That's according to the Kemet datasheet on their T396 and T398 capacitors. And they're not dual capacitors, they're just single polarized tantalum capacitors with a third terminal so they have the same function regardless of the direction they are installed.
Comment: @Jason S is right; I removed the statement about them being dual caps.

What's the use of a dual capacitor?


Does the brain need more sleep after heavy load?

Question: Does the brain require more sleep in the following night, if you have used a lot more of its capacity that day than usually?
Comment: I experience not being able to fall asleep then eventually sleeping for 14-15 hours. (after long-therm problem solving)
Answer: After stressful events the brain is energized by various (evil in this case) hormones from the adrenal system like cortisol, epinephrine and norepinephrine. Good luck getting sleep without some medical help after trying to solve some major world, work or personal issues. So while the brain still needs its normal rejuvenation and maybe an extra 30 minutes or hour to deal with the bad stages of sleep but its probably not going to get it. That is to say there are several stages of sleep and the adreno hormones mess with the length and quality of the stages which can be fixed by a longer amount in some situations or just flat out starting over the next night and trying to catch up on the debt over the course of time.

Stress, Arousal, and Sleep
Stress is considered to be an important cause of disrupted sleep and insomnia. However, controlled and experimental studies in rodents indicate that effects of stress on sleep–wake regulation are complex and may strongly depend on the nature of the stressor. While most stressors are associated with at least a brief period of arousal and wakefulness, the subsequent amount and architecture of recovery sleep can vary dramatically across conditions even though classical markers of acute stress such as corticosterone are virtually the same. Sleep after stress appears to be highly influenced by situational variables including whether the stressor was controllable and/or predictable, whether the individual had the possibility to learn and adapt, and by the relative resilience and vulnerability of the individual experiencing stress. There are multiple brain regions and neurochemical systems linking stress and sleep, and the specific balance and interactions between these systems may ultimately determine the alterations in sleep–wake architecture. Factors that appear to play an important role in stress-induced wakefulness and sleep changes include various monominergic neurotransmitters, hypocretins, corticotropin releasing factor, and prolactin. In addition to the brain regions directly involved in stress responses such as the hypothalamus, the locus coeruleus, and the amygdala, differential effects of stressor controllability on behavior and sleep may be mediated by the medial prefrontal cortex. These various brain regions interact and influence each other and in turn affect the activity of sleep–wake controlling centers in the brain. Also, these regions likely play significant roles in memory processes and participate in the way stressful memories may affect arousal and sleep. Finally, stress-induced changes in sleep-architecture may affect sleep-related neuronal plasticity processes and thereby contribute to cognitive dysfunction and psychiatric disorders.
Stress and Neonatal Sleep
Routine circumcision, done without anesthesia in the newborn nursery, was usually followed by prolonged nonrapid eye movement (NREM) sleep. Since this form of sleep has been described as a low point on an arousal continuum, we consider its increase to be consistent with a theory of conservation-withdrawal in response to stressful stimulation.
Comment: +1 for a good answer. I still would like to see some reference to research results. In addition, how does this differ if you load brain with and without stress. Eg. load without stress = chess match with a friend, load with stress = emergency situations at work.
Comment: @devlero Effects of stress on sleep: the moderating role of coping style. http://psycnet.apa.org/journals/hea/23/5/542/ and i will put the relivent citation to you chess and work in the answer


How much does it cost to add a glider rating to a PPL?

Question: In Europe, how much does it cost to learn to fly gliders if you're already a private pilot? I am one, so I already have the medical and theory etc. but what cost can I expect for a GPL on top of a PPL?
Comment: We can't always answer cost questions in a good way because the answer can depend a lot on your personal situation. If you mention your country it might help to get an answer. It would be easier to ask what the requirements (training, hours, exams) are, but of course that's a different question and maybe it wouldn't help you.
Comment: Notice that under EASA rules (Europe), to fly a glider you need a license, not a rating. The licenses are either LAPL(S) or SPL if you want to be fancy.  The transition to EASA rules are is not complete yet, and your local national rules will still be at least partly in place. Best place to ask is your local gliding club. Regarding costs - this will vary, your chosen launch method (winch or tow) being a significant factor.
Answer: If you're in Romania, are a Romanian citizen and are under 23 you can do it for free in the Romanian Airclub.
Otherwise it's 15 eur/winch launch and  25 eur/tow at around 300m.
I'm not sure if there's any deduction from the glider training if you have ppl but I know that if you have the glider licence you get a shorter training plan for motorized aircraft.
Comment: Young Romanians are lucky! Wish we had the same in other countries. Still unable to afford any kind of flying...
Answer: This is going to vary widely depending on circumstances, but I can share my personal experience since I did what you are asking about fairly recently.
I got my PPL back in 2004 but pretty much stopped flying two to three years later for financial reasons.  In 2015, I determined through discussions with the glider club I am a member of that I could afford to start flying again in gliders.  I started working on my rating in August 2015 and did my checkride in July 2016.  My stats during training were:

Flights (which equavlates to to takeoffs and landings): 67
Time: 12 hours, 48 minutes
Cost for instruction: \$0
Cost for hourly rental and tows: \$2626
Club dues: \$500 initiation + \$33 a month = \$396
Misc (Books mostly): \$100

Total: $3122
Notes:

The club I belong to, Skyline Soaring Association (SSA) is in Front Royal, Virginia USA.  I don't know how these numbers would compare to other clubs or doing this through a commercial operation.
Our club does not charge for instruction.  Instead, instruction is one of the duties members (who are qualified) perform as part of their participation in the club.  I would expect that instruction would be an extra charge in a commmercial operation as it is in powered flight schools.
My club's rate sheet is here if you'd like to better understand how these costs break down.

Note: I posted this answer before the edit was made qualifying this question to Europe.  I am curious though how the two would compare.


Am I able to obtain a LHR travel visa at Heathrow airport?

Question: I have a Philippine passport but currently residing in the  United States as a greencard holder. I am travelling to Norway with a Shengen visa but I have a 23 hour layover in London Heathrow. And I plan to meet a friend and do a little bit of sightseeing. I don't have enough time to apply for a Transit visa due to time restraint, is it possible to get one when I arrived at the airport?
Answer: You cannot get a visa at the airport, but you seem to qualify for the landside Transit Without Visa scheme. This is open for you since you hold a valid permanent residence permit issued by the United States, and you leave by air on the next day after you arrive.
To use this scheme, simply join the immigration line for non-EU/EEA/Swiss passports, and explain to the Immigration Officer that you're in transit. You'll want to have your green card ready too.
You'll need to convince the IO that you are "genuinely in transit to another country" and "genuinely intend and [are] able to" take your onward flight the next day. So be prepared that you might have to explain e.g. what you're going to Norway for. But overall that's just the same kind of burden-of-persuasion that visa-free visitors need to meet.
See the formal conditions in paragraphs V7.6 through V7.9 of the Immigration Rules.
Comment: But don't mention your friend and sightseeing at immigration, if you can avoid it, just your 23 hour layover and onward flight.
Comment: @Christine: Neither sightseeing nor meeting a friend are unreasonable ways to pass your time during a long layover, and there's no reason why they'd want you not to do that. I think what Michael Hampton is saying is that you should not give the impression that either of those is your _purpose_ for having the layover in the first place. Unless you're specifically asked how you're going to pass the time, there's no need for you to say anything other than "in transit until my connection leaves tomorrow".
Comment: Should i say i will just be checking in at a hotel?
Comment: Thank you very much for making it clear, I really appreciate your help.
Comment: You can also have trouble boarding your flight in the US if you do not have the correct visa. Although this answer is mostly true, it is up to the airlines to verify your visa and they use Timatic and only it. I showed American Airlines V7.6 through V7.9 of the Immigration Rules and the AA boarding agents DID NOT CARE, they only care about Timatic rules because they can be fined if you are denied entry to the UK. The American Airlines company is not willing to take the risk of allowing passengers to "transit without a visa" in LHR, so good luck finding an airlines in the USA that allows it.


Showing that a sequence is exact

Question: $\newcommand{\coker}{\operatorname{coker}}\newcommand{\img}{\operatorname{img}}$If $F:M \rightarrow N$ is a map, prove that there is an exact sequence
$0 \rightarrow \ker f \rightarrow M \rightarrow N \rightarrow \coker f \rightarrow 0$.
Proof: We need to show that $0 \rightarrow \ker f \rightarrow M$ and $N \rightarrow \coker f \rightarrow 0$ are both exact. Firstly, let $\iota: \ker f \rightarrow M$ be the inclusion. Then $ 0 \rightarrow \ker f \rightarrow M$ is injective since $\ker f $ is exact, i.e. \ker f = \img j = ${0}$ where $j$ sends $0$ to the $\ker f$.Thus exactness follows. Next let $\pi: N \rightarrow \coker f$ be the projection onto the quotient $N/\img (f)$. Then $\coker f $ sends everything in the $\img(f) $ to $0$. So $\img(f) \rightarrow 0$. Thus $N/\img(f) = N/0 \cong N$.
This is where I'm stuck and confused. I'm reading from Rotman's Introduction to Homological Algebra and he doesn't have many problems showing how to deal with these type of problems and in terms of proving, I'm not entirely sure how to approach these problems.
In terms of the above problem I'm confused with whether or not I'm approaching it correctly and if it makes any sense.
Any help or advice would be greatly appreciated.
Comment: This is correct but you also need to show that $\ker(f) \to M \to N$ and $M \to N \to \text{coker}(f)$ is exact.
Comment: I originally thought about doing exactly that but wasn't sure
Answer: For what you did, as stated in the comment, restricting the sequence to the two mentioned and proving that they're exact is not enough.
To solve the problem, go back to the very definition of an exact sequence. Do as you said: you consider the inclusion map $\iota:\ker f\to M$, the map $f:M\to N$, the quotient map $\pi:N\to\text{coker} f$ and the zero map $\text{coker}f\to0$. Then, in this order, prove that the image of one is the kernel of the next.

Showing that a sequence is exact


Bed Heating Failed, Printer Halted, Please Reset

Question: A couple of weeks ago I have successfully built a 3D Printer and Printed an XYZ Calibration Cube with ABS material at bed temperature 80 °C.
Next Day I tried bed heating at bed temperature 80 °C,

Screen is blank

and it's not heating at all and showing Following error.

Bed Heating Failed
Printer Halted
Please Reset

Specification board
I use a RAMPS 1.4 running Marlin 1.1.X
Troubleshooting
I searched on Google and tried possible solutions but they are not working.

I changed the thermistor and nothing happened, the old thermistor is also showing the same temperature.
I connected 12V Supply Positive to SMPS (Switched-Mode Power Supply) and Negative to RAMPS 1.4 and not working
I checked the Voltage at heat bed it's showing zero in spite connecting to SMPS

Please let me know how can I fix the problem?
Comment: What happens if you set Bed Temp to, say,  40 Degrees C? Does it warm at all before throwing an error?
Comment: I have installed Marlin 1.1.x firmware.

When It's powdered it'll display properly but when I select Bed Heating Option It becomes like a shown in the image and after 30 to 50 seconds later it displays message Bed Heating Failed Printer Halted Please Reset

Except Bed heating everything working fine
Comment: No, Warming. The LCD Temperature won't change at all from Room Temperature i.e 25 Degrees Celcius.
Comment: Why not attach your PSU directly to the bed, will it warm up? If it does the bed is working then check cables, connectors of the setup.
Comment: When I connect Heated Bed directly to SMPS it's working but when I connect it to RAMPS board it's not working and the screen is becoming blank
Answer: Check that your heated bed is still working:

Measure the resistance of your heated bed. It depends an the power
rating of the bed, but 12V beds usually have values <3 Ohms. That's
hard to measure for cheap multimeters, but you just need to check
that it's not MOhms which would indicate a broken heated bed.
Your heated bed could also have a short. That's hard to measure, as <3Ohms are already 'almost a short'. You'll only notice because your
bed will not get warm, but the wires, connectors and elements on the
RAMPS will get even hotter. Marlin should detect this and switch off
after a few seconds.
Check your thermistor. Seems you already did that.
Check your RAMPS by measuring the voltage on the bed connector while setting the bed to heat up. You should see 12V, at least in the
frist few seconds.
Comment: Heated Bed is working. when I connect directly to 12V SMPS but it's not working when I connect it to RAMPS 1. 4
Answer: I've just been reading 3D Printing Failures: 2020 Edition by Sean Arandy and David Feeney -- one of the things they really harp on is that the high current connectors on the RAMPS board for the bed heat are grossly under-rated -- that is, they're connectors rated for about 4-5 A, while the bed needs to draw about twice that to heat a rated power level.  Their recommendation is to switch this connector on the RAMPS board for one rated at a minimum of 16 A to ensure it has a safety margin over the most current a 12V bed heater will draw.
If you use an e-reader, you may want to consider downloading this book -- it's only ten dollars for Kindle (also available on Kindle Unlimited), or twenty for a paper copy, and to my eye, it's worth having.


Will I keep the progress for my 3DS games if I delete my Nintendo Network ID?

Question: I recently wanted to go back to my 3DS after a while of not playing it. Though I found out my dumb self put wrong information for my NNID and Im not able to use anything like the eShop for example. I would delete it however I am afraid it would delete the save files for my games. (The Games are physical not digital)
Answer: According to Nintendo, game save data is saved directly to the physical game cartridge. So, deleting anything on your 3DS shouldn't affect the save data stored in the cartridges.
There seems to be some rare exceptions to this rule -- e.g. Super Mario Maker saving both to cartridge and SD card -- but you should be fine deleting your NNID without losing progress data :)
Note: it looks like Pokébank is linked to your NNID, so you may lose any Pokémon you have in the Bank.


How do native speakers say withered or withering in these senses?

Question:
The leaf is soft and drooping due to lack of water, may recover after watering.
The leaf has turned brown and crumbling.
Comment: Are you asking about which to pick? If so, use the continuous tense for the first case (not fully withered) and the past tense for the second.
Answer: For the first meaning there is a specific verb:  "wilt" To droop or become limp and flaccid (as a dying leaf or flower). (wiktionary)
For the second meaning I would use "The leaves turned brown" as the simplest way of expressing this idea.
You might also use "brown" as a verb. For example, a houseplants website mostly uses "turned brown" but also has "Browning leaf tip tips are as common as they are challenging to diagnose." in which "browning" is a gerund.
You could also use "wither" to mean "dry up and die". It is a bit more dramatic in mood.
Answer: First of all just some minor corrections to your original sentences:

The leaf is soft and drooping due to lack of water, but may recover after watering.
The leaf has turned brown and is crumbling.

You could use the words "withered" and "withering" like this:

The leaf is withering due to lack of water, but may recover after watering.
The leaf has withered.

However, the word "withered" in connection with a plant doesn't usually mean the same as "crumbling" which was in your original sentence. I'm no botanist, and perhaps that is the expert meaning, but in general use "withered" means limp or lifeless, whereas "crumbled" means broken to pieces, beyond rescuing.


Stellaris Launchpad, lm4f120h5qr, Timer not functioning as desired, can count down but not up

Question: I'm determined not to use the provided stellarisware functions, and am trying to figure out how to get my Timer to work. At this moment, all I'm attempting to do is have Timer0 A count to a specified value (That stored in TIMER0_TAILR_R).
The program as it is now will count down from the specified value (by having TIMER0_TAMR_R |= 0x1) yet when in count up mode, the LED specified blinks at a constant rate (slowly) regardless of the value stored in TIMER0_TAILR_R.
<code>#include "lm4f120h5qr.h"

int main(void){
    SYSCTL_RCGCGPIO_R |= 0x20; // clock gate to port F
    GPIO_PORTF_DIR_R |= 0x7 << 1; // Set Led's as outputs
    GPIO_PORTF_DEN_R |= 0x7 << 1;// for LED's

    GPIO_PORTF_DEN_R |= 0x1; // For timer
    GPIO_PORTF_PCTL_R |= 0x7; //select T0CCP0
    SYSCTL_RCGC1_R |= 0x1 << 16;
    SYSCTL_RCGCTIMER_R |= 0x1;

    TIMER0_CTL_R = 0;
    TIMER0_CFG_R  = 0;
    TIMER0_CFG_R  |= 0x4;
    TIMER0_TAMR_R |= 0x11; // set mode
    TIMER0_TAPR_R |= 0xF; // prescale
    TIMER0_TAILR_R = 0x1F1; // load value

    while(1){
        GPIO_PORTF_DATA_R |= 0x1 << 2;
        TIMER0_CTL_R |= 0x1;
        while(TIMER0_CTL_R & 0x1);
        GPIO_PORTF_DATA_R &= ~(0x1 << 2);
        TIMER0_CTL_R |= 0x1;
        while(TIMER0_CTL_R & 0x1);

    }
}
</code>
As far as I know I've initialised the Timer correctly and am doing everything correctly (obviously this is incorrect). Any help as to where I'm going wrong is greatly appreciated as I've been racking my brains over this for quite some time and cannot find a solution.
cheers,
Luke.
Answer: according to datasheet 11.3 (p660), the code with up and down count :
<code>   #include "lm4f120h5qr.h"

    int main(void) {
        SYSCTL_RCGCGPIO_R |= 0x20; // clock gate to port F
        GPIO_PORTF_DIR_R |= 0x7 << 1; // Set Led's as outputs
        GPIO_PORTF_DEN_R |= 0x7 << 1; // for LED's

        GPIO_PORTF_DEN_R |= 0x1; // For timer
        GPIO_PORTF_PCTL_R |= 0x7; //select T0CCP0
        SYSCTL_RCGC1_R |= 0x1 << 16;
        SYSCTL_RCGCTIMER_R |= 0x1;

        TIMER0_CTL_R = 0;
        TIMER0_CFG_R = 0;
        TIMER0_CFG_R |= 0x4;

        // up
        TIMER0_TAMR_R = 0x11; // set mode
        TIMER0_TAPR_R = 0xF00; // prescale

        // down
        //TIMER0_TAMR_R = 0x1; // set mode
        //TIMER0_TAPR_R = 0x0F; // prescale

        TIMER0_TAILR_R = 0x1F1; // load value

        while (1) {
            GPIO_PORTF_DATA_R |= 0x1 << 2;
            TIMER0_CTL_R |= 0x1;
            while (TIMER0_CTL_R & 0x1)
                ;
            GPIO_PORTF_DATA_R &= ~(0x1 << 2);
            TIMER0_CTL_R |= 0x1;
            while (TIMER0_CTL_R & 0x1)
                ;

        }
    }
</code>


How can I preview image in html file?

Question: Is there a package to preview an image inserted in the html tag  when hovering the tag with the mouse ?
Answer: I am not aware of any mode that provides this. However, after (quite some) 'investigation' it can easily be obtained using something like the following, which makes use of syntactic font lock because the filenames are (usually) given as strings:
(with-eval-after-load "sgml-mode"
  (defun sgml-font-lock-syntactic-face (state)
    "`font-lock-syntactic-face-function' for `sgml-mode'."

    ;; Show image tooltip on hover. From
    ;; `font-lock-fontify-syntactically-region' and
    ;; `font-lock-syntactic-face-function' we conclude that somehow `nth 3' of
    ;; the state corresponds to `strings'
    (when-let (url (and (nth 3 state) (thing-at-point 'filename)))
      (when (image-supported-file-p url)
        (setq url (string-trim url "file://"))
        (let ((img (create-image url
                                 (image-type url)))
              (bounds (thing-at-point-bounds-of-string-at-point)))
          (put-text-property (car bounds) (cdr bounds)
                             'help-echo (propertize url 'display img)))))

    ;; Don't use string face outside of tags.
    (cond ((and (nth 9 state) (nth 3 state)) font-lock-string-face)
          ((nth 4 state) font-lock-comment-face))))

By default the image shows in the minibuffer, but if you prefer to have in in the tooltip, then you just have to activate tooltip-mode.
However, the code is not compatible with goto-address-(prog-)mode, as the overlays added by that mode overrule the text-properties (in particular, it overrules the help-echo, which could be fixed from that mode by first checking if some help-echo has already been assigned).
Otherwise, I guess the code is quite robust, but I am not sure about that. You might have to make some small adaptations, but then at least it shows the essential steps.
Note that on GNU/linux and OSX systems there might be a bug, so that you additionally have to use:
(setq x-gtk-use-system-tooltips nil)

Additionally, @John Kitchin mentions in 2016, that on OSX the image tooltip does not work when Emacs has been built with 'cocoa' support.

How can I preview image in html file?


Black Scholes informal derivation - question about a term in the equation

Question: I am wondering what the term S means in the equation I have circled? I am not sure how to interpret it.
Answer: From the GBM we have:
$$(S_{t}-S_{t-1}) \approxeq dS_t = \mu \cdot S_t \: dt + \sigma \cdot S_t \: dW_t,$$
where $W_t$ denotes a Brownian motion. Here, the first part, $(S_{t}-S_{t-1})$, can be seen as a discretization of $dS_t$. Now, squaring the GBM, $dS_t^2$, is an informal way of denoting the quadratic variation of the process, that is $[dS_t,dS_t]$. A slightly informal derivation gives us:
\begin{align}
dS_t^2 & = [dS_t,dS_t]\\
&= [\mu \cdot S_t \: dt + \sigma \cdot S_t \: dW_t, \: \mu \cdot S_t \: dt + \sigma \cdot S_t \: dW_t]\\
&= \mu^2 S_t^2 [d_t, d_t] +2\cdot \sigma\mu S_t^2 [dt, dW_t] +\sigma^2 S_t^2 [dW_t,dW_t]\\
&= \sigma^2 S_t^2 \: dt,
\end{align}
where $[dt,dW_t]=[dt,dt]=0$ since any finite/bounded variation process (read deterministic function) has zero quadratic variation (I'm talking about the $dt$ term), and $[dW_t,dW_t]=dt$, since quadratic variation of two Brownian motions equals the time difference (you can also look at Ito's multiplication table for these results). From your above formulation, $S = S_t$, and denotes the spot price, and probably that $dt\approx [t-(t-1)]=1$.
Comment: Thank you so much! Makes complete sense now.
Answer: It's the current spot price, or $S_t$. The "next chapter" might show if/why they drop the subscript for this approximation, but in the end the variable in the black-scholes equation will be the current spot price.
Comment: Thank you for the help!


Detect any connected network

Question: How can I detect if any network adapter is connected? I can only find examples on using NSReachability to detect an internet connection, but I want to detect even a non-internet network connection. Getting the IP-adress on eth0 should work? I'm working on Mac only.
Comment: Are you working on iOS, Mac, or both?
Comment: OK, I've only tried this on iPhone, so my answer might not work on Mac.  I'll see if I can do some more research.
Comment: That would be greatly appreciated.
Comment: You should not rely on particular interface names such as "eth0". On an iMac, "en0" can be the (unconnected) Ethernet interface and "en1" the (connected) WiFi interface. A Mac Pro can have 2 Ethernet interfaces "en0" and "en1".
Answer: Getting a List of All IP Addresses in Apple's Technical Note TN1145 mentions 3 methods for getting the status of the network interfaces:

System Configuration Framework
Open Transport API
BSD sockets

System Configuration Framework: This is Apple's recommended way and there is sample code in the TN1145. The advantage is that it provides a way to get notified of changes in the interface configuration.
Open Transport API: There is also sample code in TN1145, otherwise I cannot say much about it. (There is only "legacy" documentation on the Apple website.)
BSD sockets: This seems to be the easiest way to get the list of interfaces and to determine the connection status (if you don't need dynamic change notifications).
The following code demonstrates how to find all IPv4 and IPv6 interfaces that are "up and running".
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <ifaddrs.h>
#include <net/if.h>
#include <netdb.h>

struct ifaddrs *allInterfaces;

// Get list of all interfaces on the local machine:
if (getifaddrs(&allInterfaces) == 0) {
    struct ifaddrs *interface;

    // For each interface ...
    for (interface = allInterfaces; interface != NULL; interface = interface->ifa_next) {
        unsigned int flags = interface->ifa_flags;
        struct sockaddr *addr = interface->ifa_addr;

        // Check for running IPv4, IPv6 interfaces. Skip the loopback interface.
        if ((flags & (IFF_UP|IFF_RUNNING|IFF_LOOPBACK)) == (IFF_UP|IFF_RUNNING)) {
            if (addr->sa_family == AF_INET || addr->sa_family == AF_INET6) {

                // Convert interface address to a human readable string:
                char host[NI_MAXHOST];
                getnameinfo(addr, addr->sa_len, host, sizeof(host), NULL, 0, NI_NUMERICHOST);

                printf("interface:%s, address:%s\n", interface->ifa_name, host);
            }
        }
    }

    freeifaddrs(allInterfaces);
}

Comment: Thanks a lot, best answer so far. I don't have time to try it right now but unless something better drops in the coming 6 hours I will accept it.
Comment: @AndreasBergström: That is OK. I'm glad if it helped.
Answer: You can use the Reachability code, provided by apple.
Here's the link where you could get the "Reachability" source code:
You can also download this file: TestWifi in Github. It will show you how to implement the Reachability class.
Hope this could help you.
Comment: The reachability link you've provided is for iOS.
Answer: Reachability (I assume you meant Apple's demo class based on the underlying SCNetworkReachability... API) works for any IP-connected host, including on your local network.  You could use the reachabilityForLocalWiFi method, although according to this page it will return YES when the network is active but not routable.  So you may prefer to query reachabilityWithAddress: with a local address.
This is a drop-in replacement for Reachability that some people recommend.

Detect any connected network


Pull data from SharePoint On-Premises to SharePoint Online

Question: I would like to pull data from SharePoint On-Premise (Custom List Data) to SharePoint Online. When searched on Internet most of the posts are suggesting like SQL Azure Connectivity between SharePoint On-Premise and SharePoint Online. I would like to know how to achieve this without using Azure as an interface. Is it Possible? If yes, how to achieve this task?
Answer: Since its pulling the list data and not replicating, you can configure Hybrid federated search between the environments and create a result source specific to on-premises. Use this result source in Content search or Search result WebPart query and show the items.
Comment: Thanks Rajesh,Any step by step Sample to do this?How about data synchronization? Newly added item will be available in SharePoint online if it's added in SharePoint on-premises?
Comment: In that case you can write a event receiver for your on premises list and in item added event., use csom or rest API to create items in SharePoint online list. You need also need take care of update and delete too.


Postgres "missing FROM-clause entry" error on query with WITH clause

Question: I am trying to use this query in Postgres 9.1.3:
WITH stops AS (
    SELECT citation_id,
           rank() OVER (ORDER BY offense_timestamp,
                     defendant_dl,
                     offense_street_number,
                     offense_street_name) AS stop
    FROM   consistent.master
    WHERE  citing_jurisdiction=1
)

UPDATE consistent.master
SET arrest_id = stops.stop
WHERE citing_jurisdiction=1
  AND stops.citation_id = consistent.master.citation_id;

I get this error:
ERROR:  missing FROM-clause entry for table "stops"
LINE 12: SET arrest_id = stops.stop
                         ^

********** Error **********

ERROR: missing FROM-clause entry for table "stops"
SQL state: 42P01
Character: 280

I'm really confused. The WITH clause appears correct per Postgres documentation. If I separately run the query in the WITH clause, I get correct results.
Comment: Whoops! Thanks. I was going to say I tried renamed the **stops** table as a diagnostic step, but that's clearly not the issue.
Answer: From the fine manual:

There are two ways to modify a table using information contained in other tables in the database: using sub-selects, or specifying additional tables in the FROM clause.

So you just need a FROM clause:
WITH stops AS (
    -- ...
)
UPDATE consistent.master
SET arrest_id = stops.stop
FROM stops -- <----------------------------- You missed this
WHERE citing_jurisdiction=1
  AND stops.citation_id = consistent.master.citation_id;

The error message even says as much:

ERROR: missing FROM-clause entry for table "stops"
Comment: You're right! They need to give out "bonehead" points here. I think I just earned one.
Comment: @ArenCambre: I think we'd all have an excess of "bonehead" points if there were such a thing :) Some of the hardest problems to see are the ones right in front of your face.
Comment: Very nice answer. Just a small question: it should be FROM stops instead of FROM stop, right?
Comment: @joragupra Yes, it should have been (and now is) `stops`, thanks.
Answer: This can also happen if you mistype a table name. For example:
UPDATE profiles SET name = ( profile.first_name ) WHERE id = 1

Instead of profiles i incorrectly used profile !! This would work:
UPDATE profiles SET name = ( profiles.first_name ) WHERE id = 1


How to keep contents scrolling under both a navbar and logo image in bootstrap?

Question: I have a logo image for my site in the upper left, and the navbar right below it. The rest of the contents on my page will scroll under those items, but in the area to the right of my image I can see everything scrolling up... so my question is, is there a way to make that area  above the navbar opaque in some way? So as everything below will scroll under it?
My code right now looks like this:

Some text to the right of logo, above navbar
More text

Answer: You seem to be missing some code, but try putting background-color: #FFF; on your #top div.


How to detect if a mob has been hit in minecraft with command blocks?

Question: i am making a boss battle for my minecraft adventure map, and using a mob spawned with commands as the boss. When the mob gets hit, some command blocks will give the player a potion effect, but I can't figure out how to activate the command block when the mob gets hit. I am in the latest snapshot (16w03a). please help me (the person who answers my question will be given credit for it in my map)
Comment: Related: http://gaming.stackexchange.com/questions/226755/detect-when-player-attacks-another-player
Answer: Since automated scoreboard statistics (namely stat.damageTaken) only increments for players, you will need to rely on NBT data for non-player entities.
The HurtTime tag will be set to 10 when a mob is struck, decreasing by 1 per tick until it reaches 0 again.

Adding the label for mobs that were struck.
/scoreboard players tag @e[type=Creeper,tag=!Hurt] add Hurt {HurtTime:10s}

Remove the label when the value is 9.
/scoreboard players tag @e[type=Creeper,tag=Hurt] remove Hurt {HurtTime:9s}

Target the mob based on the "Hurt" tag.
/execute @e[type=Creeper,tag=Hurt] ~ ~ ~ /effect @a minecraft:slowness

Comment: @Segosauras If this answers your question, you should click the green "accept answer" checkmark.
Comment: thankyou! This helped me a lot Skylinerw. I will be sure to include you in my map.
Comment: I would have suggested using two scoreboard objectives, one that is tied to the health of the mob, the other that stores the last known value, and just do a comparison.  This solution is much easier.
Answer: 1.13 Update
The answer in 1.12 and below still applies. Note that commands were overhauled in 1.13. Please note the following:

/scoreboard players tag is now /tag.
/testfor is now a branch of /execute, using the (if|unless) parameters.
The NBT selector has been moved inside the target selector, using the nbt argument.
This answer was written before the entity IDs were changed in 1.11. In this change, we see that ZombieVillager and Creeper are now zombie_villager and creeper.

Here are the old commands that used to work but now don't.
/scoreboard players tag @e[type=Creeper,tag=!Hurt] add Hurt {HurtTime:10s}
/scoreboard players tag @e[type=Creeper,tag=Hurt] remove Hurt {HurtTime:9s}
/execute @e[type=Creeper,tag=Hurt] ~ ~ ~ /effect @a minecraft:slowness

And here are the new 1.13+ commands!
/tag @e[type=creeper,tag=!hurt,nbt={HurtTime:10s}] add hurt
/scoreboard players tag @e[type=creeper,tag=hurt,nbt={HurtTime:9s}] remove hurt
/execute if entity @e[type=creeper,tag=hurt] run say No Hurting Creepers!

Answer: You can use this command to test for the creature's health. To make this work properly, several command blocks connected to redstone circuits will be necessary. /testfor @e[type=Zombie] {Health:19s} Of course, Zombie can be replaced with any mob name (first letter capital) You would also have to have a redstone comparator heading out of the command block(s) to the command block with the command you want executed after the creature is hit. You would have to have 19 command block circuits, one for each number from 1-19 to make a fully functional circuit/system. If you don't want this, then just find out how much damage should result from the zombie being hit with the available weapon (remember, your fist is always available)


Semantic parsing vs Propositional Representation

Question: Propositional representation is explained on Wikipedia.
How is semantic parsing different from propositional representation? Or is propositional representation the next step after you do semantic parsing?
Comment: "Semantic parsing" can mean a lot of things, depending on the speaker's idea of what _semantic_ covers, and what they think _parsing_ includes.
Answer: Most computational parsing methods yield an output that is a propositional representation within the computer. This includes pure syntactic parsers (if one assumes we can have pure syntax) and semantic and also pragmatic parsers. Why? Because parsers in computers always produce discrete output and every discrete output can be converted into a graph representation.
Distributional representations of words (word2vec) would be a representation that is not propositional. But such a representation is (currently) not used as the main structural component of a parser output.
If you think about semantic parsing in the human it is a different story and I would not say that it is clear what kind of processes or representations semantic parsing includes in the human brain.
Answer: Both entail the compositional process of converting natural language into a formal or machine-interpretable language. I believe the difference is that propositional representation is how some psychologists/psycholinguists believe people interpret speech, as a series of discrete symbols much like a formal language. This is related to the idea of 'mentalese', if you're familiar with that. Semantic parsing, on the other hand, is a deliberate process which is carried out to make natural languages into formal meaning representations which can be interpreted by machines. This is a computational idea and has nothing to do with psychology.


check and update an application through code when a new version is available in appstore

Question: Within my application, I want to check if there is any updated version of my application is in the app store. If there is any, then have  to inform the user through an alert message and if he/she opt for upgrade I want to update the new version.I want to do all this through my application. Is this possible?
Comment: Doesn't the phone do that on it's own already?
Answer: You can store the most current application version string on your server. When the app is activated, request this information from the server and compare it to the version string that is contained in your applications Info.plist.
You can get the version in Info.plist like this
<code>[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]
</code>
If the string differs, you can show an alert that a newer version is available in the app store. You can also link directly to the app store from the alert.
Answer: You could do something like this: let's say you just started making an app. You hardcode its version (1.0) inside the app's configuration file or something similar.
Then, you can use an universal xml configuration file, which is read by the app everytime it starts and connects to the internet. Inside that xml, make a field named "lastest_version", where you set that value.
When the app starts you can check the xml. If your hardcoded value is 1.0 and inside the xml you get 1.1, this means you need an update.
This is how we do it and, just like Philippe said, we also use an plist to store the original version value.


Modeling project woes

Question: In our company we have started using VS 2010 to model our systems, in so called modeling projects. These are kept under TFS2010 source control.
It's all good for a single user, but as soon as we introduced this tool to our entire architecture team we ran into a major problem: It handles multiple users extremely badly! Let me run you through a simple scenario.

Architect 1 checks out an existing diagram and works on it for a while
Architect 2 adds a new diagram and works on it for a while
Architect 2 checks in his new diagram
Architect 1 checks in his changes to the modeling project
Architect 2 opens his diagram again, only to find that all the elements in it are missing!

As I have understood this, the problem is that the architecture project is based on several xml files, and in particular one important huge chunk of xml called ModelDefinition/Architecure.uml. It contains a lot of knowledge about the diagrams in the modeling project. When multiple people do multiple changes to this file simultaneously, the tools (TFS, VS) does not handle the required merging automatically, and we're left with huge concurrency issues.
So in my scenario, because the Architecture.uml that architect 1 checked in does not know anything about the elements that architect 2 added, these elements are overwritten or otherwise ruined.
We want to avoid splitting the project into several smaller ones, because that would mean that we'd have to re-define our modeling components (classes, actors, use cases, components, etc) multiple times. By using a single solution, we can define such elements in one place, and re-use them in every other diagram.
So, our current 'solution' is to work using exclusive check outs. So only one architect can work at a time!
I was hoping that someone had come up with a better solution to this, which allows us to work more effectively.
Answer: Try divide & conquer: Is it possible that each architect works on her personal branch & then everything is merged into a 'Trunk'?
Conflicts should get visible during these merges.

EDIT
You could employ an XML-specific tool, like the ones presented here.
By doing so, you should keep the branching-per-architect approach, BUT instead of using a single-step TFS-merge you could:

Perform a directory comparison between your 'branch' folder & your 'trunk' folder. Each found file is a subject to the merge that follows.
Merge each found file into your 'branch' folder, using one of the tools presented in the article. I have used Altova DiffDog, it's very good - but comes at a high prize.
Check that everything is OK, then commit on 'branch'.
Now merge with TFS-merge into 'trunk' which should by now be a trivial merge.
Comment: Thanks for replying. It will ensure that no elements are lost without anyone noticing. However, I was hoping to avoid having to manually merge the file, since it's an xml file. It is my experience that the default merge tool that comes with TFS 2010 is poorly equipped to handle xml files, e.g. a moved element might be identified as coflict although it really isn't; it's just swapped position in a non-ordered list. I do apreciate the input though, and I'll take it to my team for concideration. I'll await accepting it for now, to see if anyone else have encountered and solved this nightmare :)
Comment: I absolutely agree with your "hoping to avoid having to manually merge XML". Do wait for a better way :)
Comment: Thanks for your edit, I believe this might improve the process a bit. Forward integrating the trunk using a proper XML merge tool should be a step in the right direction :)

Modeling project woes


How to properly apply an image sequence texture to an imported alembic file?

Question: I've imported an alembic file of a fluid simulation from Houdini and am trying to apply a sequence of image textures (displacement maps that I have also exported from Houdini for the ocean spectrum, which include the UV attribute), but in the viewport and the render, it only displays the first image of the sequence and on the other frames it displays a block color. I have an incling that the issue is that the alembic file is only UV-unwrapped in the first frame and that the map does not apply for the next frames, especially since the vertex count of the alembic changes per frame, but I'm not sure how to fix this. As far as I know multiple UV maps can not be imported into Blender from Houdini. Any advice would be great!
Answer: For anyone else having this issue, make sure you're creating a UV attribute and keeping 'deform input geometry' deselected in the ocean evaluate node in Houdini, then add an attribute promote node and convert your 'uv' attribute from a point to a vertex attribute, then add the ROP alembic output and export as normal. Upon import into Blender, the image sequence texture should work as expected and the UV mappings will be correct!


Is IBM's "Security and Privacy by Design" practices based on any earlier standard or guideline?

Question: The following process overview schematic is derived from IBM's Security in Development The IBM Secure Engineering Framework, but I think I've seen a very similar process diagram before, though I cannot find it or remember it. Would this IBM Security and Privacy by Design (SPbD) process be based on an existing standard or guideline, e.g., one from NIST or ISO? It is a fairly sensible process so I would not be surprised if a similar process has been drawn before.
Comment: The diagram is not rocket science. Risk assess > design tests for risks > manage tests > manage fixes > release. This is a very basic flow of processes used for, well, anything. From software QA to secure coding to financial risks.
Answer: As it is stated in IBM's site, SPbD is aligned with NIST's Secure Software Development Framework (SSDF). As such, you may find similarities among SPbD and others, that are aligned with NIST's SSDF.


How to boot htc desire ss510e into recovery

Question: I want to install 4.0 ics on my htc desire ss510e, so i want to know how can i boot into recovery in order to install the custom firmware. Please help!!
Answer: Boot up your phone using power button and volume down button together. You'll get something called hboot. Now using your volume buttons, goto Recovery Mode listed on the screen. Press the trackpad button to reach recovery mode.


Lenovo Y50 Subwoofer does no work with Ubuntu 14.04.2 LTS

Question: I could not get my Subwoofer on Lenovo Y50 to work. Googled around and did not find any solutions. Let me know if anybody has any clue. Thanks!
Comment: How is the Subwoofer attached to the computer? You are using a computer, right? What leads you to believe it is not working?
Comment: @waltinator The y50 has a built in subwoofer
Answer: I got my Y50-70 sub-woofer working by doing this:
in /etc/pulse/default.pa add this line at the end:
load-module module-combine channels=3 channel_map=front-left,front-right,lfe

then in /etc/pulse/daemon.conf change ;enable-lfe-remixing = no to enable-lfe-remixing = yes note that you have to remove the ;
then reboot.
Tested and validated on Kubuntu 15.04.
Comment: the daemon.conf file seams to be empty
Comment: Same here. No deamon.conf file. I am using Ubuntu 14.04.2 LTS. Should I update to Ubuntu 15.04?
Comment: if you want to, but it maybe don't be the solution, you can try.  If you do it, don't forget do a back backup... I don't know why the daemon.conf is empty , ¿did you use root privileges when you edit the the daemon.conf ?. Sorry i can't help you more.
Comment: Hmm... this seems not work on Ubuntu 14.04 did anybody test this on Ubuntu 15.04 maybe it will be time for upgrade system ;)
Answer: This is what worked for me:
first, install and run HDA Analyzer:
wget -O run.py http://www.alsa-project.org/hda-analyzer.py
sudo python run.py (root is required)
second, using the gui do this:
•PIN 0x17 -> Widget Control -> Check OUT and Uncheck Mute:

•PIN 0x1a -> VREF -> Set it to 100:

And third, test it by listening to some music.
If it still isn't working, you can follow this thread, maybe someone will find an answer:
(https://superuser.com/questions/945110/how-do-i-make-my-lenovo-y50s-subwoofer-work-on-linux)
HDA Analyzer can be found here: http://www.alsa-project.org/main/index.php/HDA_Analyzer
Comment: Thank You for the useful info. According to similar problems on other laptops [ex. https://www.reddit.com/r/linux/comments/17sov5/howto_beats_audio_hp_laptop_speakers_on/] i tried use hda-jack-retask to mapping this pins as a subwoofer but it's seems to be more complicated there is two pins as one subwoofer... I can't figure out. Not luck for me but maybe You will try. I think Yoou can have some better knowlege / ideas in this case. Cheers!
Comment: Note that run.sh should be executed with python2.
Comment: @ShupingRuan That's Great. Are you running Ubuntu or something else? Also please check the answer as the right one  if it worked and consider upvoting it if it was Informative. Thank you.
Comment: Ohhh, thanks a lot. Since I installed Ubuntu I forgot that this laptop actually has a nice sound system.
Answer: In the referenced Super User question and its recent followup, we managed to get it to work, and you can do it all by:
First installing alsa-tools (which contains hda-verb)
and then executing this shell script as root:
#! /usr/bin/env sh

# Run this script as root!

dev="/dev/snd/hwC1D0"

hda-verb $dev 0x17 SET_POWER 0x0
hda-verb $dev 0x1a SET_POWER 0x0
hda-verb $dev 0x03 0x300 0xa055
hda-verb $dev 0x03 0x300 0x9055
hda-verb $dev 0x17 0x300 0xb000
hda-verb $dev 0x17 0x707 0x40
hda-verb $dev 0x1a 0x707 0x25

Side note: Actually it can also be done without hda-verb, using python alone (which hda analyzer can export), but the code would be considerably more messy.
If you want to do it more manually for some reason, here's how:
Install alsa-tools via apt-get or similar.
Get HDA Analyzer like this:
wget -O run.py http://www.alsa-project.org/hda-analyzer.py
Side note: hda-analyzer will only run correctly on your machine if python is a symlink to python2, which it normally is, but there are exceptions. (Arch linux, at least.)
Run HDA Analyzer:
python run.py
Inside HDA Analyzer, look under card 1.
Changes to node 0x17:
Untick Val[0]: Mute
Tick Out under Widget Control.
Changes to node 0x1a
Set VREF under Widget control to 100 instead of hiz.
Quit hda_analyzer.
Run these two hda-verb commands, again as root:
hda-verb /dev/snd/hwC1D0 0x17 SET_POWER 0x0
hda-verb /dev/snd/hwC1D0 0x1a SET_POWER 0x0

Start hda_analyzer again.
Increase the output volume of node 0x3 (AUD_OUT) on card 1:
In HDA Analyzer under Output amplifier push the Val[0] and Val[1] sliders towards the right. They may need to be almost all the way over to the right before you can hear the difference.
Here's a low frequency audio file you can use for testing.
You can test it by plugging something into the headphone plug, as the subwoofer is unaffected by that being plugged in unlike the normal speakers, at least after the above is changed. That problem is unfortunately not solved by the shell script either.
Comment: after shell scripts executed the output volume set to 100%
this is very annoyng. any ways to fix this?
Answer: Try setting lfe-crossover-freq = 0 in /etc/pulse/daemon.conf
Comment: Never mind, I can see you fixed your problem. I fixed my problem by doing this however.


What is the cause of a dimmer image of a light source in a photo?

Question:
Why does an image of the panel appear to left side of the actual object when the picture is taken if the lamp in a switched on state?
Answer: That is most likely the result of an internal reflection between different elements in your lens. Modern coatings can reduce and/or eliminate a lot of internal reflections, but all bets are off when you have an extremely bright light source in the frame.
Comment: One way to verify this is to place the light source in different parts of the frame, and watch how the orientation of the ghost image changes (or doesn't).
Answer: Modern camera lenses are an array of multiple lenses. Such designs are necessary to mitigate degrading of the image due to aberrations. We are talking about the fact that all lenses suffer from about 7 major distortions. While these aberrations are minimized, they cannot be eliminated. Each of the several lens elements have polished glass surfaces. About 6% of the light that hits a surface is reflected away. This surface reflection is the source of ghost images and flare. We coat each lens surface with a thin transparent mineral overlay. The thickness of this coat and the density of the coat reduces the tendency of surface reflections to about 2%. The coat helps, but does not eliminate ghost images. Also, the imaging chip in the camera has a cover glass for protection, and it also is coated. Ghost images are plagues we must endure.
Comment: Note that 2% of light, 1/50, is less than six stops dimmer.  In Zone System terms, the Zone X+ light source might be reduced to a Zone IV by a single reflection.  If the light source is several stops past Zone X, it might still be above Zone 8 after two, perhaps even three reflections.
Comment: @Zeiss Ikon -- The 2% loss is per individual lens element surface. A tip of the hat to Harald Taylor, who in 1892, observed that old lenses of the same design as new lenses, passed more light. His investigation, revealed that crud from air pollution (coal burning industrial London) deposited a fine film on shelved lenses. To day we bloom (artificially age) lenses to mitigate surface reflections.


Joining Textfile to Shapefile Arc 10 and 10.2 Differences

Question: I am trying to join a textfile generated in stata that includes caoname, caoid, and fips. The fips code should match to a shapefile county map that matches to the cntyidfp category.
In ArcGIS 10.0, doing a straightforward join based on these attributes works. However, in 10.2, ArcGIS only allows for the joining of the cntyidfp to the caoname, which is completely useless.
What's the difference between the two versions that makes this difficult?
I have tried exporting to an excel document first, ensuring both the fips and cntyidfp data have the same number of characters, and creating a new table of the textfile within arcgis, but none of these solutions seem to work.
What am I missing?
Comment: More information about the data and field types would be helpful.
Comment: The data includes the caoname and caoid, which have nothing to do with the shapefile and correspond to utility data. The fips number and cntyidfp correspond and are the same data, which arc 10 recognized, but are listing as one being number and one being text format. I guess that brings me to my next question of how I make them both number?
Answer: The most likely thing without seeing the text file and knowing what field type the shapefile contains.
Is that when you add tabular data (xls, txt) to arcmap it reads the first (or first few) values in a field to determine it's type.
You can only join a type to the same type.
So fips is most likely being converted to text and when you try to join cntyidfips it is numeric.
This answer can be expanded with more information added to the question.
Comment: The fips is saying that it is in numeric format and it's type is "long". The cntyidfp from the shapefile is saying it is in "string" format. Should I convert one of them to the other?
Comment: Yes probably so


How do I complete the "Not a Scratch" challenge?

Question: This Deep Stone Crypt raid challenge seems pretty tough in that we have to preserve ALL the sparrows from each heat bubble to the end -- is there a cheese or easier way to complete this challenge to get the exotic Sparrow?
Comment: Commenting as I'm not 100% sure it works yet and have yet to try; but my team intends to attempt the challenge by leaving the pikes at the beginning, completing it with our sparrows, and then using the transmats at each bubble to send ourselves back to the start where we can more safely drive the pikes to each bubble.
Answer: My team completed this tonight. We used a cheese, so up to you if you want to use it.
If you place a pike outside the heat bubble when you have frostbite debuff, then get onto it from inside the bubble. You are protected from the frost permanently and can slowly sparrow your way to the end.
Update, This cheese has been fixed now
Also worth noting that when a Pike is destroyed it will respawn either at the start or nearby. So be sure to check the first spawn, then Sparrow the route to pickup the Pike again along the route. You can use the Fallen teleporters in each heat bubble to teleport back a bubble.
Here is the route.
Comment: You can actually bring all the sparrows to the end solo, but you still need all 6 players to sit on them for the triumph to trigger.


BDD and TDD, what is the correct workflow?

Question: My understanding is such that:
BDD is the process of evaluating how software needs to behave, and then writing acceptance tests on which to base your code. You would write code using a TDD approach, by writing unit tests for methods and building your classes around the unit tests (code, test, refactor). When the code is written, you test it to see that is satisfies the original acceptance test.
Can anyone with experience of the entire comment on my interpretation and give a walk through of a simple application using these Agile principles? I see there is plenty of text on BDD and TDD in separate publications, but I am looking at how the two processes complement one another in real world development.
Answer: Try thinking of them as examples, rather than tests.
For the whole application, we come up with an example of how a user might use that application. The example is a specific instance of behaviour which illustrates that behaviour. So, for instance, we might say that a till application allows for refunds. A till operator who uses that till will be familiar with the scenario in which Fred brings back a microwave for a refund:

Given Fred bought a microwave for $100
  When he brings the microwave back for a refund
  Then he should get $100 refunded to his credit card.

Now it's easy to think of other scenarios too; for instance, the one where Fred got a discount and only gets $90 back, or the one where Fred had broken the microwave himself and we refuse his refund, etc.
When we actually start coding the till software, we break our code down into small pieces; classes, functions, modules, etc. We can describe the behaviour of a piece of code, and provide an example. So, for instance, we might say that a refund calculator should take discounts into account. This is only a small part of the refund scenario. We have a class, RefundCalculator, and a unit test with a method that says shouldTakeDiscountsIntoAccount.
We might put the steps for our example in comments, for instance:
// Given a microwave was sold at 10% discount for $100

...

// When we calculate the refund due

...

// Then the calculator should tell us it's $90.

...

Then we fill in the code to turn this into a unit test, and write the code that makes it pass.
Normally "BDD" refers to the scenario which describes the whole application, but the ideas actually started at a unit level, and the principles are the same. The only difference is that one is an example of a user using an application, and the other is an example of a class using another class (or function, or what have you). So BDD on the outside of an application is like ATDD (Acceptance-Test-Driven Development) and BDD for classes is like TDD. Hopefully this helps give you an idea of how the concepts hang together.
The only difference is that we got rid of the word "test", because we find it easier to ask people for an example than a test, and it helps keep people thinking about whether they understand the problem, rather than thinking about how to test a solution.
This answer on "top down" (or outside-in) vs. "bottom-up" may also help you.
Answer: Your summary is basically correct. The labels can be misleading: people who call what they do 'BDD' will write acceptance tests and unit tests, people who call what they do 'TDD' will write acceptance tests and unit tests.  To me, the distinction between the two is much ado about nothing.  You will read many people's experiences with different flavors of this basic process.  Try the approaches that seem to make sense in your situation and always be ready to make adjustments based on what works and doesn't work for you - that's the essence of agile.
Comment: It's much ado about the word "test". For devs, that might not mean a lot, especially if we're used to TDD, but it's pretty important if you're talking to business people. "Can you give me an example?" is a lot easier than "Can you give me an acceptance test?"
Answer: There are two approaches to BDD stories, imperative and declarative.  A developer will likely find imperative stories easier to write especially when being used to script unit tests.
However when approaching this from Agile Test First/Test Driven Development approach a declarative approach results in BDD narratives that are cogent with the development stories.  This is because the BDD narrative continues to reflect the domain language of the business rather than programming domain.
How do you capture requirements with declarative acceptance tests?


What type of connector is this?

Question: This connector was removed from my old recessed ceiling lights.  The light socket was wired with this connector at the other end of the lead.  The connector pairs with a female 3-pin/3-hole connector mounted on the socket plate in the recessed light can.   I need to replace a couple of these leads/connectors as they are faulty.  Thanks for any guidance.
Comment: Hello, and welcome to Stack Exchange. My guess is that these are non-standard, and were chosen by the fixture manufacturer for its own reasons. Perhaps now is the time to replace with LEDs...
Comment: Thank you. I am trying to replace with LEDs, however the retrofit LEDs I purchased use an adapter that screws into the existing light socket, however 2 of my sockets aren't working, hence I need to replace the socket and/or socket lead all the way to the socket plate. This connector is on one end of the socket lead...
Answer: That is a molex connector, often used in low voltage DC applications. I've seen them in auto/marine lighting applications but never in residential (but that doesn't necessarily mean it's wrong).
Though I question their use in high voltage receptacles the parts are tooling for them are readily available at any electronics retailer.
Comment: Molex is regularly used in industrial equipment 120v signal connections and for internal connections in HVAC equipment. There are 2 different pin sizes (diameter), and some are gold plated these are standard tin coated copper pins. A pin removal tool can easily push out the old pins so new ones can be installed if the plastic is still in good shape. There are single pin connectors up to 50 or more. I saw a complete set for 2$ by typing 3 pin Molex connector both male and female pins and shells.
Comment: Thanks....my understanding is Molex is a brand, and they make many models of connector.  Do you have any idea which this is?

What type of connector is this?


Guitar, let ring concept confusion

Question: I read guitar tabs recently and was confused by the "let ring" concept. If I'm not using palm mute, shouldn't it be ringed instead? E.g, I change C chord to D chord, 5th string still ringing and shouldn't be played in D chord. Should I mute it before playing D chord?
Comment: If the music is telling you to let that 5th string from the C chord to carry on ringing, it'll be a C note on the 3rd fret. There's a possibility it's on purpose to produce a **D7** chord.
Comment: For a song you can listen to?
Answer: Instruments that have mutiple elements for producing notes, such that those elements keep producing tone after they are activated:sustain—plucked strings, struck blocks and such, support a technique called lasciare suonare ("let ring").  This means that we play the music by initating all the right notes at the right time, but allow them to decay naturally rather than dampening them.
On a piano, music can be played lasciare suonare by holding down the sostenuto pedal.
Under this technique, it doesn't matter that some of the notes don't go together in terms of harmony; the dissonances you hear contribute to the music. The beauty of lasciare suonare is that it makes simple passages sound rich and complicated. It can create a "haunting" feeling.
Every wind-up, plucked-reed music box plays lasciare suonare, which is responsible for the charming sound, and a feeling of reverberation that adds depth to the tiny sound source.
The magic of the harp is also due to lasciare suonare.
Most vibraphone/metallophone/xylophone music is lasciare suonare, too.
Note that even when you do not play lasciare suonare, if you merely play legato, or even just close to the full time value of the individual notes, successive notes that are produced by different strings will still bleed into each other, due to the decay caused by damping not being instantaneous.
On a piano, when the sostenuto pedal is not being used, all notes have a release time: the time required for the second decay that begins when the player lifts the finger from the key, to the time when the note stops.  This means that if you play a quick passage of notes on a piano, they bleed into each other; and the faster you play them, the more it is so. The felt damper which stops the string cannot do its job instantaneously, and it doesn't get any faster with increased tempo. Moreover, it would be odd if it could do so.
People who program  synthesizers understand that a note's amplitude envelope has four stages: attack, sustain, decay, and release.  Decay is the gradual deadening of the note after the initial attack while the note is being sustained. Release is the second decay (usually much faster), when the note is stopped.
On a decently programmable synthesizer, it is possible to tweak the piano patch such that the notes have a release time of zero (the sound stops instantly when the key is released without any additional decay). I tell you, it becomes weirdly choppy sounding, almost not like a piano. All imperfections in technique seem laid bare.
Comment: Not only the sostenuto pedal on pianos. The sustain ('loud') pedal also. In fact, in U.S. and Canada, most pianos have both, along with the 'soft' pedal. The rest of the world isn't so lucky, and often pianos lack that middle - sostenuto - pedal. There's always a sustain (damper) pedal. Some pianos with three pedals have the middle one to make it very quiet, for practising. Although, this question is specifically about guitar, rather than piano.
Answer: It would help to have some better examples.  In the example you gave the 5th string open is A and that's okay to put on a D chord.  However, I can't imaging how that is ringing since the C chord has the 3rd fret of the 5th string fingered.
I am used to seeing "let ring" when they want you to play something arpeggiated.  For example the into to Stairway to Heaven has the guitar playing a series of chords one note at a time, like Amin = (x, x, 7, 5, 5, 5) where x means don't play and the other numbers are fret numbers on the strings 6 through 1.  In this case "let ring" means let each note ring as the others are being played so that the entire chord fills out.
In your case if you are just playing chords one after another it does not make sense to let notes from the previous chord continue as that could conflict.
If the open A is ringing because you released the finger and that naturally acts as an attack then you have a different issue.  In this case I'd say the instructions are trying to tell you to let each chord ring, but you still need to play each with clean technique.  So when one chord is over and the next one starts you do need to control the extra open sting sounds.  This may require you to mute with either hand, at least momentarily.
Lastly, the open A has harmonics that align with those of the D chord.  So it is possible that even with clean technique on an acoustic guitar when you play the D chord the A string starts vibrating.  This is completely nature and, unless you don't like it, should be left alone.  The sympathetic resonances between the open strings help fill the chords out and make the overall sound richer.
Answer: In practice, let your ears decide! In theory, is the note part of the chord you are trying to carve? If not, mute. You'll know when to mute with experience. There are techniques that use either hand for muting, both for finger style and pick.
In your specific example the 5th string is A, which is the 5th of D, part of the major triad, so not muting it sound perfectly fine. The 6th is an E, not part of the triad, so you might want to be a little more careful with it. It's common to do the second fret, which is the major third, part of the triad again. You can strum all string that way. You can also strum all strings by muting the 6th with your left hand's thumb, if the neck is small enough.
But it's mostly your ears and experience. Play with all possibilities, and practice in a way that you can do either muted and not muted whenever you feel like. That E in the 6th string can sound great in the right contexts, same that you'd expect with any note in any harmony. Diatonic second, so not even that big of a leap!
Answer: It is perfectly possible in standard musing notation to explicitly specify how long each note should last and have one note lasting past the start of next one. You see this a lot in piano music.
So since the composer/transcriber could have done that but decided not to the "let it ring" is open to artistic interpretation
I agree with @user1079425 just try it a few ways and do what sounds good.
Also its a license to not mute notes that are awkward to mute :)

Guitar, let ring concept confusion