How can a parent actor track status of a sub tasks performed by child actors

Question: I have an actor system that parses a large data, the way I implemented is the parent actor divide the task to multiple child actors that run in parallel. This part works fine. My question is how can the parent actor get the status of each child so that it knows the sub tasks are completed?
Comment: I think you're on the right track. See also [this post](http://stackoverflow.com/a/32433259/1138552) (and the link in that post) which covers a question very similar to what you want to do, which is basically the "aggregator pattern". If you google for "aggregator pattern" you'll find more material you may find useful! :)
Comment: @easuter I was just about to answer with the aggregator pattern here before I saw your comment.  Should really be an answer I think, it's the correct thing to do.
Comment: Why not simply have the child actors message their parent when they complete their work using `Context.Parent.Tell()`? Doesn't sound like you need anything more complicated than that.
Comment: @easuter Looks like my approach was close enough , although the link you shared  creating a an actor for aggregating result is much more cleaner .
Comment: well that is what i am doing . when the parent receives a message ImportCustomerData , it dispatches 4 child actors ImportData, the parent then waits for ImportComplet message from all 4 child actors then the task is complete. the way i am doing it now is the parent maintains list dictionary of CustomerId and flag for the for data items being processed by child actors.   i was asking if there was a better way.
Comment: @PatrickAllwood yeah, I should probably have put that comment in an answer, will do, thanks :)
Answer: Make the child actors tell the parent actor when they are finished, they could also tell updates etc.
Edit: If you want the results of an aggregate of responses ... then use an actor to aggregate the responses? Alternatively just use a count. However the answer is perfectly valid and correct if you apply even 20 seconds of thought. If you want a child actor to provide update its parent of its progress - no matter the complexity of the solution - you have to tell the parent its progress. If you want to insert actors into the middle or use a count in the parent actor to figure out how far through the complete process you are the answer is STILL tell the parent upon completion.
You will get answers to what you ask. If you ask the wrong question then just because the answers don't answer the question you wanted doesn't mean they are wrong (especially given they are still the right answer)
People answering questions on here are not required - nor should be expected - to read the comments on a question - the asker is however required to update the question. Not being funny, but i am fairly busy and you shouldn't be making me work to help you.
This question should be closed as its a duplicate /  vague / incorrect.
When you get responses like this to legitimately answering questions it makes the aggression of SO answerers towards askers feel justified.
Comment: @easuter crazy isn't it. I think the moral is don't go near or post questions with a c# tag  ... If its a dupe question then imo linking to another question is entirely appropriate especially if you do not have flag privileges. I kind of stopped helping people on here. Amusing observation - the linked question is one i asked.
Comment: well i am bitter whenever i try and answer something on here. Its not you its the community. I spent most of my time on here trying to reopen and edit questions so they can get useful answers. When you do answer you get downvoted with no explanations. If i helped you im happy, thats all that matters.
Comment: if you see my my comment up there, just sending message to parent does not solve my problem , i was mostly concerned with how to better aggregate the results of child actor to determine whether the task as whole is complete or not.
Comment: @John Nicholas, you're right and I don't know why you were downvoted. I also tried adding an answer based on my comments on the OP and immediately got 2 downvotes with a moderator/reviewer chastising me for providing a link to another answer - here on SO - that satisfies the question. Apparently I'm to copy over someone else's answer here or maybe implement the solution myself?...SO is going downhill with crap like this. (edit: I don't think it was OP doing the downvoting as he takes some time between replies).
Comment: @JohnNicholas i want to accept your edited version as an answer but you have unnecessary lecturing that is not relevant to to the question frankly belongs to on FAQ/how to page of stackoverflow , you sounded bitter there , not sure what i did wrong.


Create symbolic links with wildcards

Question: I have multiple hard drives with the same directory hierarchy, for example:
/media/sda/dir1
/media/sda/dir2
...
/media/sdb/dir1
/media/sdb/dir2

Two hard drives with similar names and similar directory names.
I want to create separate symbolic links to dir1 and dir2 on every hard drive.
The easiest way I have found is to use cp -sR:
cp -sR /media/sd*/dir1 /somedir/dir1
cp -sR /media/sd*/dir2 /somedir/dir2

However, this creates new directories in /somedir which has various side effects, for example, the directory timestamps are useless.
How can I create symbolic links named dir1 and dir2 which link to /media/sd*/dir1 and /media/sd*/dir2? Files are regularly added to the hard drives so I would need to run these commands on a regular basis.
Comment: When you say "symbolic link named dir1 which link to /media/sd*/dir1" that sounds like a link pointing to multiple places which is not possible: a link can only point from one place to one place. Maybe you want all the files under /media/sda/dir1/* and /media/sdb/dir1/* to be linked to from /somedir/dir1/* ? It would seem to me that unionfs over the two disks would better serve your purpose then symlinks.
Answer: This will create symlinks /somedir/dir1/* pointing to /media/sd*/dir1/*.
mkdir /somedir/dir1
ln -sf /media/sd*/dir1 /somedir/dir1

If a file or directory exists in more than one /media/sd*/dir1/ then the link will point to the last one, for example if you have:
/media/sda1/dir1/Movies
/media/sda1/dir1/Pictures
/media/sdb1/dir1/Movies
/media/sdb1/dir1/Data

you will get:
/somedir/dir1/Movies -> /media/sdb1/dir1/Movies
/somedir/dir1/Pictures -> /media/sda1/dir1/Pictures
/somedir/dir1/Data -> /media/sdb1/dir1/Data

Not sure if this is what you want though.
It seems to me that unionfs mounting over /media/sd* would better serve your purpose than symlinks.
Comment: Thanks but this is not what I wanted to do. Sorry if I wasn't clear enough.
Comment: It was what I wanted to do though. Thanks!
Answer: You might want to do that:
for dir in dir1 dir2
do
  [[ ! -d /somedir/$dir ]] && mkdir /somedir/$dir
  find /media/sd*/$dir -type f -exec bash -c \
    '[[ ! -f /somedir/'$dir'/$(basename $1) ]] && ln -s $1 /somedir/'$dir'/' foo {} \;
done

This create symbolic links in /somedir/dir1/ (resp. dir2) pointing to all files present under /media/sd*/dir1 (resp. dir2). This script doesn't preserve hierarchy that might be present under the source directories.
Edit: Should you want all the links to be placed in a single directory, here is a slightly modified version:
[[ ! -d /somedir/data ]] && mkdir /somedir/data
find /media/sd*/dir[12] -type f -exec bash -c \
    '[[ ! -f /somedir/data/$(basename $1) ]] && ln -s $1 /somedir/data/' foo {} \;
done

Comment: I tried this but it didn't work as expected. It essentially copied the hierarchy of /media: it resulted in /somedir/media/a/..., /somedir/media/b/..., etc instead of creating /somedir/data as one folder.
Comment: Sorry, there was a bug in my script. Answer edited.

Create symbolic links with wildcards


Short Time Fourier Transform analysis of newborn baby cry signal

Question: I am working on analysis of baby cry signal. fundamental frequency(Fo) of signal is already estimated using auto correlation and cepstrum analysis. cry signal is inputted in .wav format. now i want to do short time fourier transform analysis of same signal inorder to find variations in fundamental frequency over the time and plot its "pitch contour". i.e. Fo v/s t. its like finding Fo value for each small interval and plotting over time to see the variability. pls, can anybody help me with the matlab code?
Comment: What kind of help are you expecting if you don't share your code? This is no code-request forum.
Answer: Have a look at SAaC from LabROSA. You also might be interested in delta pitch without explicit pitch tracking.
Comment: sir thank you for reply. it is helping me. but i am getting some errors in code which i tried from above site.
Comment: Make sure you've installed all dependencies and can run their examples first. Then try with your data. If it doesn't work post  new question with details and code as Matt says. Cheers.
Comment: sir @ruoho ruotsi , am using matlab 7.1 version. In one of the above code function "logfsgram(d,256,sr)" is used. here it gives error as "Undefined function 'logfsgram' for input arguments of type 'double' ". how to install these functions in my version?
Comment: check this out: https://github.com/dpwe/alignmidi/blob/master/logfsgram.m


Seismic question

Question: For a 3 stories building, in terms of seismic vertical instability which one is worse: a higher mass on Level 2 or, higher mass on the roof? Both are compared to L1 mass.
Answer: The one with the higher mass on level three is worse.
Assuming the building as an SDF vibration for simplicity:
The period of the building will moderately increase due to the reduction of K,
$$K=P/\delta $$ By moving mas from 2nd floor to 3rd floor we increase deflection by roughly 1.2 hence decreasing the K by 1/5.
Natural frquency $ \ \omega_n=\sqrt\frac{K}{m} \\ \tau= 2\pi/\omega_n \ $ decreases moderately (0.04) which is good but it can not make up for the increase in the additional overturning moment by 150% and extra shear due to triangular sheer distribution.
Comment: I see. I was confused because per ASCE: weight  irregularity occurs where the effective mass of one story is greater than 150% of that of an ADJACENT story.
Comment: then why don't you accept my answer so it will be used by others? thanks.

Seismic question


How can I get my turtle to pull liquid from a tank?

Question: I've tried turtle.place() with a bucket selected, which I assume would emulate a right-click, but it didn't work. What can I do?
Comment: If you choose Squirtle, you will have a turtle who is a tank and shoots _out_ liquid. Hope this helps.
Answer: I don't believe a normal turtle will, however, Thermal Expansion adds a bucket turtle.  http://thermalexpansion.wikispaces.com/Bucket+Turtle
Answer: You can use the MiscPeripherals bucket turtle for older Minecraft versions. Get it here. For newer versions, use mods like Peripherals++
 to help you.
Peripherals++ Bucket Turtle wiki page.


Understanding Prevention, Detection, and Protection

Question: I am always confused between Prevention, Detection, Protection. Which one is before the another? I'd say Prevention --> Detection --> Protection. Is that valid?
Comment: "before" implies a natural sequence - are you sure they belong in a sequence?
Comment: You need to add more context. The order could be different from one context to another.  I believe this is why you are sometimes confused :)
Comment: Yes it's somewhat valid, but instead of  "Protection" usually there's "Response".
Comment: In this context, prevention and protection seem to be synonymous.  If you prevent some type of attack you are protected against it.  Similarly, if you have protections against an attack, you have prevented that type of attack.  I guess you could argue that "protection" is slightly more general of a concept; e.g., detecting in-progress attack of some type that you previously hadn't fully prevented falls under the category of "protection", especially if your team can quickly respond to the newly detected attack and mitigate it.
Answer: Generally, it's a circle, not a line.
Prevention means it stops before happening. But to stop it, you need Protection. To protect from something, you usually need to have the means to Detect it. And in order to detect it, you must know what to look for, which knowledge may be considered Prevention.
Answer: I re-read the question a few times and I'll give my take on the essence of the question. I read this as as - "What comes first - preventing an attack by way of firewalls, security patches etc; detecting attacks; or responding to attacks/incidents". If so, I'd say these are parallel concepts that don't really have a sequence. You don't wait for a break-in to fix a bad lock on a door. In the world of security, attacks, patches, detection of attacks, internal security testing, patches and fixes etc happen anachronously. The infrastructure for all of these should always be active and in place.
Now, if we were to talk about a specific attack or security incident (say, a DOS attack), you'd have measures in place to ensure the attack doesn't bring down the server or its performance, following which you'd detect the DOS attack as its happening or in a very recent past, followed by remediation techniques that could be termed as "protection", but its more of a "response" (as Aria pointed out).


Do Force 'mind tricks' work on Droids?

Question: Just wondering following from this and this question, do we actually ever see (or have evidence of) Jedi successfully (or even attempting) to use their 'mind tricks' on Droids?
Answer: In the Star Wars novel The Truce at Bakura, Luke Skywalker is able to extract a deadly parasite he was poisoned with with from his lungs using the Force. In the Clone Wars cartoon series, several of the Jedi Masters are able to dismantle droids and use their nuts and bolts to rip through them.
A Jedi cannot manipulate an android's mind per se, but if you follow the canon of story where they are insanely powerful and able to manipulate things on a small scale using the Force, then it could be reasoned that a Jedi with the knowledge of building and programming droids (e.g. Anakin Skywalker), could reprogram a droid using the Force; effectively altering/controlling its mind.
Comment: What you reason towards is called Machine Empathy in certain settings.  While all mutations are treasonous, having the Machine Empathy mutation is highly treasonous.  Are you feeling okay, Djs-R-DOG?  Do you need some more Wakey-Wakey pills, or perhaps some time in an HPD&MC correctional spa?
Answer: Yes. In the (canon) junior novelisation for Return of the Jedi, we see Luke tricking the TT-8L gate guard droid with mind powers.

The way in turns out to be easy enough. An electronic eyeball barely
has time to pop out before Luke has said, "You will open the door."
Yes, this is a Jedi mind trick and it works easily. Inside, the
simpleminded guard who operates the door unthinkingly obeys.
Return of the Jedi: Beware the Power of the Dark Side!
Comment: I'm not convinced this says what you think it says. The electronic eyeball is clearly the guard droid you reference, and he is explicitly *outside*.  But the text mentions a (simpleminded) guard *inside* being the one who opens the door.  Why both would be involved is a bit curious, so maybe they're the same? Or is there a meatbag there just in case the droid malfunctions? Is the door itself not actually something the droid can manipulate? But evidently the meatbag can override the droid, and stop it from sounding any sort of alarm over this weird situation?
Comment: The text seems quite clear, really. It explicitly states that the _simpleminded guard_ opens the door, so there is no mind trick on a droid here. [The link](https://starwars.fandom.com/wiki/TT-8L/Y7_gatekeeper_droid) you gave also mentions that these droids "also functioned as holocams", which lends further credence to the idea that it was the organic guard who was mind-tricked and not the droid.
Comment: @terdon - the droid is the guard.
Comment: That's one possible interpretation, yes. To me, the wording suggests it isn't the guard though, especially knowing that the droid functions as a camera which is only useful if someone is looking at the image, and considering that the guard is referred to as _simpleminded_.
Comment: @terdon - I'm planning to ask this as a new question, but I'm 99% certain that there's no-one there except the droid built into the door and the Gamorrean guards guarding the entrance from the inside, neither of whom operate the door. - [*"Probably the most infamous and annoying TT-8L/Y7 in use was the one who kept out visitors out of Jabba's Palace.*"](https://www.starwars.com/databank/tt-8l-y7)
Comment: But the TT-8L is just a stalk and photoreceptor, and does not have any parts "inside" as far as I can tell - it cannot be the simpleminded guard inside. I guess the guard inside could be a different droid, although "simpleminded" seems like an odd descriptor for a droid.
Comment: @NuclearHoagie - I've seen no evidence that Jabba's gate had a second guard in a control room, being spoken to by the TT-8L, and lots of evidence that the TT-8L is the sentry that opens the door.
Comment: Just from the quoted texted it seems like this is a reverse line of sight telepathy.  Just as Darth Vader could choke someone he saw a TV monitor as though they were next to each other.  Luke mind tricked someone that SAW HIM on a TV monitor - the reverse of the Darth Vader scenario.
Answer: Droids can be Jedi as seen in the comic Skippy the Jedi Droid, therefore, that makes droids one with the force just as all living things. So I think a Jedi mind trick could work on a droid
Comment: That's rather interesting.  [The fandom wiki page](https://starwars.fandom.com/wiki/Skippy_the_Jedi_Droid) suggests this may not be canon (but also suggests that a legend of a force wielding droid is canon; just whether it was based on a real such droid is another matter).  Still, +1.
Answer: Legends: Yes, by another name
In Legends, a Force ability was known by the name of "mechu-deru" that allowed the user to not only influence droids, but to control or reprogram them entirely. From a now-deleted Hyperspace article on starwars.com:

It is believed that through their bizarre alchemies, the Sith somehow stumbled upon the ability to manipulate mechanicals of complex nature through the Force: ships, computers, and, indeed, even droids.
(source: Droids, Technology and the Force: A Clash of Phenomena, via Wookieepedia)

There seems to be a range of ways that mechu-deru could interface with droids and mechanical objects, from simply allowing the user to understand mechanical systems better (as described in The Jedi Path) to turning living beings into cyborgs called "technobeasts" (known as mechu-deru vitae). However, the ability definitely included control over droids:

Because droids are not organic beings, they were a subject few Jedi bothered to understand. Jedi powers that had a technical influence were usually crude, such as the Force ability mechu macture, or, "destroy droid." The Sith went farther than the Jedi ever did, developing the ability mechu-deru to allow for Force control over mechanical systems. In true Sith fashion, the power stressed absolute control, turning droids into puppets.
(source: The New Essential Guide to Droids (2006), page 195)
Answer: Droids dont have a conscious mind. I think its common knowledge that robots have computers, not brains. It is shown throught the series that ind tricks only work on the weak MINDED. This is shown when Luke attempts a mind trick on Jabba The Hut. You could see an example prooving this too when Ben Kenobi tricked the Stormtrooper using the old favorite quote: "These are not the droids you are looking for."
In summary: Mind tricks only work on weak minded, droids do not have inds therefore a mind trick would be useless against a droid.
Comment: Do you have a reference for that? I don't think droid brain technology has come up in canon. Certainly in other franchises e.g. Asimov and Star Trek androids have "positronic brains".
Comment: Here is a link answering your question. I have combed the wikis but I cant find references to what im saying. Here is the link:http://www.reddit.com/r/AskScienceFiction/comments/31xei7/star_wars_do_jedi_mind_tricks_work_on_droids/

Do Force 'mind tricks' work on Droids?


what exactly makes the car stealthy?

Question: I just recently got the papavero stealth edition car in watch dogs and it says when you click on it that its "A unique superior with STEALTH ABILITIES." My question is I guess what is it that makes it so superior and stealthy? The paint job, the tinted windows, what?
Comment: I might be wrong about this, which is why I'm not posting it as an answer, but from what I can tell the only 'stealthy' thing about it is the fact that it's painted black. Realistically, people would focus their attention on a swank black sports car like that, so unless there's some sort of not my problem field around it, it doesn't have anything. That said, for some reason, the cops do seem less likely to notice it?
Comment: @Snowskeeper I dont think that Watch Dogs simulates human vision. Rather the game knows in which radius you have to be to draw attention. Maybe this circle of suspicion is smaller in the "stealth car"
Comment: Watch Dogs wiki says, that it's useful in Online Hacking because you cannot be seen throu the tinted window
Comment: @JonasDralle Yep; that was what I was thinking. But I'm trying to assume that its actual 'superior stealth' qualities would somehow be tied to the features of the car, and those seemed to be what Tony was asking about.
Answer: There's now a Wiki article detailing what makes it stealthy.
Player vs Player
Pros:

A unique trait featured on the Stealth Edition that is not seen on any
  other vehicle is its extremely dark tinted windows. This feature can
  be very useful in Online Hacking and Online Tailing game-modes to
  avoid being easily seen when driving or parked.

Cons:

However, due to the
  fact it is unobtainable without a Uplay account, and is not available
  outside of the Car On Demand app, players aware of these facts may be
  able to easily recognize the signature differences between it and the
  base model, unless it is at very dark places or at night.

Player vs Computer
Pros:

This edition, as the name indicates, is supposedly effective in
  evading and eluding police, Club hitmen, Fixers and Viceroys. ... This can
  be noted because its standard counterpart, the Papavero, seems to take
  more time to lose the police. This may be because the windows are not
  tinted, allowing the police to easily see Aiden.

Cons:

It can be noted, however, CTOS scans take longer to complete when
  driving the car.

Source: http://watchdogs.wikia.com/wiki/Papavero_Stealth_Edition

what exactly makes the car stealthy?


Is there violation of energy conservation when a particle transforms to its anti-particle, for example $B^0\to\bar{B}^0$, or $K^0\to\bar{K}^0$

Question: additive information : $B^0$ and $\bar{B}^0$ don't have the same mass,
$K^0$ and $\bar{K}^0$ don't have the same mass.
is there energy violation?
if yes, is the key explanation of this coming from the relationship $\Delta E*\Delta t \sim \hbar$ :that is it authorized to have energy conservation if this is during a small duration?
Comment: They *do* have the same mass (or expectation value of the mass, since they are not quite energy eigenstates).  This is guaranteed by CPT.
Comment: all right. Thank you very much for your kind explanations. So the problem is solved : my question is wrong.
Comment: Are you sure ? For example : https://en.wikipedia.org/wiki/B_meson   This shows that there is *Delta m_d* between B0 and B0bar, so there is a difference of mass, so they don't have the same mass. But I'm not sure. Maybe Delta m_d is actually the mass difference between B_L and B_H ?!? Do you mean that B0 and B0 have *exactly* the same mass ?
Comment: The mass difference are between the weak eigenstates.  Ignoring the small CP violation, the mass eigenstates are symmetric and antisymmetric linear combinations of particle and antiparticle states, like K_S and K_L.
Comment: @Buzz That seems like an answer, not a comment.
Comment: @MathieuKrisztian You might like to read [this review of B-mixing](http://pdg.lbl.gov/2018/reviews/rpp2018-rev-b-bar-mixing.pdf).
Answer: Actually, the flavor eigenstates (such as $K^{0}$ and $\bar{K}^{0}$, which are eigenstates of strangeness and isospin) do have the same mass.  This is actually guaranteed by CPT invariance.  (More precisely, they have the equal expectation values for their the masses, since they are not quite energy eigenstates.)
The actual mass eigenstates are the weak eigenstates.  Ignoring the small CP violation, these mass eigenstates are symmetric and antisymmetric linear combinations of particle and antiparticle states, $K_{S}$ and $K_{L}$, which are
approximately $\frac{1}{\sqrt{2}}\left(\left|K^{0}\right\rangle\pm\left|\bar{K}^{0}\right\rangle\right)$.


Light patch in the night sky

Question: I am so sorry for being ambiguous. I'm not an astronomer and have have never actually even bothered to look at the sky before. I don't have a telescope nor camera.
Yet, I'm really really curious about what it is I saw in the sky tonight.
Towards, the east I first noticed a "constellation" the looked much like what is described to be the big dipper (It is possible that it could have been Andromeda and Pegasus). It was squarish and had somewhat of a ladle towards it's north eastern corner. The most distinguishable feature of the structure was that it had 3 stars in a straight line. It was the straightest line in the entire night sky.
About a hand's length to the west was another "constellation", my guts said it's name was Orion. Again, I have never seen, let alone distinguished, a constellation properly in my life. It was like a triangle with it's nose pointing towards the east. The sides that converged to the nose seemed to extend a bit backwards like antennas.
And to the west (a few inches north to the Orion was this strange glow.
At first I thought it was my eyes playing tricks on me as sometimes whenever you stare into light bulb or some other light source, a faint glow in that area of your vision often persists. And as I looked directly at it, it slowly faded away into darkness and all that was distinguishable was an extremely tiny star or two. But whenever I looked to something near it (like a tree or constellation) , the patch reappeared. Then, I noticed that there was cluster of tiny little stars. I couldn't make out much. What caused that light patch? It seemed to glow in and out like it was breathing. I am sure that my eyes weren't playing tricks on me because even as I turned around and tilted my head and jumped up and down in the process, the patch remained in the same spot in the sky.
The location which I observed this is from Ernakulam, Kerala, India. The nearest current sky map I could find is the following from Chennai (which is really far away):
I can't make head or tail of it. Please help and no I'm not crazy. I know it sounds like one of those crazy UFO stories but I assure you it's not.
Is there anything like what I've said observed in the night sky before?
Comment: Please note that using "left" and "right" is ambiguous when describing features of the night's sky, you might be oriented towards any direction. Could you please [edit] your question to instead use compass points, like "North", "South", and so on? Approximate angle to zenith or horizon, on top of your geolocation, date and time should give us enough information to answer your question. I have to agree though that it's likely M45 (Pleiades) that you saw. Next time, try also using [averted vision technique](http://astronomy.stackexchange.com/q/480/13), you'll see them much brighter. ;)
Comment: @TidalWave I think he used the averted vision technique and not knowing it's effect is what caused him surprise and confusion, notice this excerpt: _"And as I looked directly at it, it slowly faded away into darkness and all that was distinguishable was an extremely tiny star or two. But whenever I looked to something near it, the patch reappeared."_
Comment: Ouch, it's "Tildal" (as in ~) not "Tidal", so I didn't get the notification. Anyway, @EduardoSerra I agree that this question might be more about discovery of one's own body than anything special on the night's sky, but I wanted to point to that thread because there's two answers explaining it from that perspective. That the question is asking about Pleiades likely isn't a coincidence either. I did hear similar questions quite often, and it nearly always boils down to observers not realizing their own biological limitations. I.e. eyes playing tricks with the mind.
Comment: @TildalWave Of course, I agree with you and I think your link was a good addition to the answer.
Comment: @Tidal: You'll have to give me time. I have no compass (magnet, needle or puddle of water) as well. So, I'll have to wait until morning to see from which direction the sun rises to accurately tell it in terms of directions. Thank you for your support and I admire that none of you were harsh to me.
Comment: @Tildal: Actually, I'd like to bring something to your attention. This isn't a duplicate as I asked what that light patch is. I got my answer that it was Pleiades. I did not specifically ask why it disappeared. Although it is a good related question, my question is not a duplicate of it.
Answer: Given the description, that light patch was probably Pleiades.

It is a star cluster in the constellation of Taurus which is inspired from a popular Greek mythology of Seven Sisters. You can read more about it here.
EDIT: One of the great softwares, free and open source, for amateur level observational astronomy, though professionals use it as frequently is Stellarium. It's easy to use and should clear all your doubts.
Comment: It's not troublesome. Everybody has a start. :)
But it is my duty to ensure that it does not continue. :P
Comment: After looking at that map several times I think that what I thought to be the big dipper was probably andromeda. Am I right?
Comment: Andromeda and Pegasus. You described them as they were one. You interpreted them as one. Indeed, they are joint(as seen in map) but still two different constellations.
Comment: Is Pleiades near to Procyon and Jupiter?
Comment: Pleiades is East of Orion, and Procyon and Jupiter, west of Orion. See Edit!
Comment: @Chheku: :D I understand, it can be quite bothersome when someone runs up to you and asks trivial things. I'm downloading the software now.

Light patch in the night sky


Android Recyclerview vs ListView with Viewholder

Question: I recently came across the android RecyclerView which was released with Android 5.0 and it seems that RecyclerView is just an encapsulated traditional ListView with the ViewHolder pattern incorporated into it, which promotes the reuse of the view, rather than creating it every single time.
What are the other benefits of using RecyclerView ?
If both have the same effect in terms of performance, why would one prefer RecyclerView` ?
Edit
I found that people have asked similar question and the answers are not conclusive, adding them here for record keeping.
Recyclerview vs Listview
Should we use RecyclerView to replace ListView?
Why doesn't RecyclerView have onItemClickListener()? and How RecyclerView is different from Listview?
Comment: Because the `RecyclerView` is much faster and more versatile with a much better API. Things like animating the addition or removal of items are already implemented in the `RecyclerView` without you having to do anything. There is no question about it, throw your `ListView` in the trash can, the `RecyclerView` is here to steal the show.
Comment: You can associate a layout manager with a RecyclerView, so they're not limited to vertically scrolling lists. This is quite powerful additional functionality.
Comment: @Alan - What do you mean by "not limited to vertically scrolling lists" ? Are you saying that the Recycle View can act as an "placeholder" for Gridviews and ListViews too ?
Comment: @XaverKapeller - It would be great if you could list the differences between the two and answer the question rather than on a comment, so that it might help me and the others in the future who may be wondering about the same thing ?
Comment: @Alan - Could you provide a bit detail about what you meant and answer the question rather than on a comment. Thanks for taking the time
Answer: The other plus of using RecycleView is animation, it can be done in two lines of code
RecyclerView.ItemAnimator itemAnimator = new DefaultItemAnimator();
        recyclerView.setItemAnimator(itemAnimator);

But the widget is still raw, e.g you can't create header and footer.
Comment: And you never will be able to create header and footer in that sense. They're just other view types in your adapter. List view wraps your adapter in [`HeaderViewListAdapter`](http://developer.android.com/reference/android/widget/HeaderViewListAdapter.html) and adds header support in the background. With `RecyclerView` you're the one in control.
Comment: RecyclerView uses a DefaultItemAnimator by default. Then why did you use this code?
Answer: Okay so little bit of digging and I found these gems from Bill Philips article on RecycleView

RecyclerView can do more than ListView, but the RecyclerView class
  itself has fewer responsibilities than ListView. Out of the box,
  RecyclerView does not:

Position items on the screen
Animate views
Handle any touch events apart from scrolling

All of this stuff was baked in to ListView, but RecyclerView uses
  collaborator classes to do these jobs instead.
The ViewHolders you create are beefier, too. They subclass
  RecyclerView.ViewHolder, which has a bunch of methods RecyclerView
  uses. ViewHolders know which position they are currently bound to, as
  well as which item ids (if you have those). In the process, ViewHolder
  has been knighted. It used to be ListView's job to hold on to the
  whole item view, and ViewHolder only held on to little pieces of it.
Now, ViewHolder holds on to all of it in the ViewHolder.itemView
  field, which is assigned in ViewHolder's constructor for you.
Answer: More from Bill Phillip's article (go read it!) but i thought it was important to point out the following.

In ListView, there was some ambiguity about how to handle click events: Should the individual views handle those events, or should the ListView handle them through OnItemClickListener? In RecyclerView, though, the ViewHolder is in a clear position to act as a row-level controller object that handles those kinds of details.
We saw earlier that LayoutManager handled positioning views, and ItemAnimator handled animating them. ViewHolder is the last piece: it's responsible for handling any events that occur on a specific item that RecyclerView displays.
Answer: I used a ListView with Glide image loader, having memory growth. Then I replaced the ListView with a RecyclerView. It is not only more difficult in coding, but also leads to a more memory usage than a ListView. At least, in my project.
In another activity I used a complex list with EditText's. In some of them an input method may vary, also a TextWatcher can be applied. If I used a ViewHolder, how could I replace a TextWatcher during scrolling? So, I used a ListView without a ViewHolder, and it works.
Comment: *I used a ListView without a ViewHolder, and it works.* terrible idea ... *how could I replace a TextWatcher during scrolling?* there is no need to replace it ... just TextWacher should put data into different container after reusing ... and it can be done really easy
Comment: @Selvin, thanks for your opinion. Now I cannot edit that project. There were several `TextWatcher`s on a screen. Probably you are right, but I cannot check it out.
Answer: Reuses cells while scrolling up/down - this is possible with implementing View Holder in the listView adapter, but it was an optional thing, while in the RecycleView it's the default way of writing adapter.
Decouples list from its container - so you can put list items easily at run time in the different containers (linearLayout, gridLayout) with setting LayoutManager.
Example:
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
//or
mRecyclerView.setLayoutManager(new GridLayoutManager(this, 2));
mRecyclerView.setLayoutManager(new GridLayoutManager(this, 3));

Animates common list actions.
Animations are decoupled and delegated to ItemAnimator.

There is more about RecyclerView, but I think these points are the main ones.
LayoutManager
i) LinearLayoutManager - which supports both vertical and horizontal lists,
ii) StaggeredLayoutManager - which supports Pinterest like staggered lists,
iii) GridLayoutManager - which supports displaying grids as seen in Gallery apps.
And the best thing is that we can do all these dynamically as we want.
Answer: RecyclerView was created as a ListView improvement, so yes, you can create an attached list with  ListView control, but using RecyclerView is easier as it:

Reuses cells while scrolling up/down : this is possible with implementing View Holder in the ListView adapter, but it was an optional thing, while in the RecycleView it's the default way of writing adapter.
Decouples list from its container : so you can put list items easily at run time in the different containers (linearLayout, gridLayout) with setting LayoutManager.

mRecyclerView = (RecyclerView) findViewById(R.id.my_recycler_view);
      mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
      mRecyclerView.setLayoutManager(new GridLayoutManager(this, 2));

Animates common list actions : Animations are decoupled and delegated to ItemAnimator.
There is more about RecyclerView, but I think these points are the main ones.

So, to conclude, RecyclerView is a more flexible control for handling "list data" that follows patterns of delegation of concerns and leaves for itself only one task - recycling items.
Answer: If you use RecycleView, first you need more efford to setup. You need to give more time to setup simple Item onclick, border, touch event and other simple thing. But end product will be perfect.
So decision is yours. I suggest, if you design simple app like phonebook loading, where simple click of item is enough, you can implement listview. But if you design like social media home page with unlimited scrolling. Several different decoration between item, much control of individual item than use recycle view.


Moving from Machines to Dumbells

Question: When switching from Machines to Free Weights (Dumbbells) what are the things you need to take into consideration?
Answer: Something to consider:
Machines restrict your range of motion.  You are going to have less restriction on range of motion with dumbbells.  Generally this means that machines encourage good form.  With dumbbells you will have to focus on form because there is no machine to do it for you.
Answer: Dumbells are "heavier" than machines, why ?
because dumbells work on the balance and not only the weight like machines.
Comment: Generally is there a normal percentage of how much more difficult it is or does it depend on the person. For example, I can do 80kg Chest Press on a Machine (Male, 17, 79kg), so what should I start off with dumbbells at (or should I just goto like 20kg in each arm and then hope to go up next time)?
Comment: @e__ I don't really know, i'm using both ! You can maybe use a little more than 20kg. Try it ! 20kg is too light ? no problemo take heavier ! :D
Comment: It depends on the person. Dumbbells use more muscles because you have to stabilize the weight through the lifting motion. This means that the difficulty will depend on how strong your stabilizing muscles are, as well as which ones you are using. I'd suggest starting at 50% weight.

Moving from Machines to Dumbells


Dialer, Contacts and Messenger apps closing automatically in Oneplus X

Question: Since a week, the Dialer, Contacts and Messenger apps have been crashing frequently whenever I try to open them. But after few hours after crashing somehow they start working normally. I have tried clearing the data and cache, tried resetting the phone, installing third-party apps for making phone calls and messages. But even those apps are crashing, if they are related to making phone calls and messages. I tried wiping the data and making a hard reset, but still the problem persists. So please help me solving this issue. Thanks in advance.
Answer: I had one plus 1 back in 2015 and it was really good but with age it started showing similar issues. I took it to the service center and they said the problem is with OS and they are going to format and reinstall.
Luckily i got the upgraded OS but it didn't really help me, after 1 month i started facing the same problem then i visited the service center again and finally they end up replacing my handset to a new one.


scrollingCache?

Question: Can anybody explain the meaning of scrolling cache in Android. I stumbled upon this word, but was unable to find the explanation, either on android official website or on the web.
All I could find was how can I turn it on/off.
Thanks.
Answer: Scrolling cache is basically a drawing cache.
In android, you can ask a View to store its drawing in a cache called drawing cache (basically a bitmap). By default, a drawing cache is disabled because it takes up memory but you can ask the View to explicitly to create one either via setDrawingCacheEnabled or through hardware layers (setLayerType).
So why is it useful? Because using a drawing cache make your animation smooth compared to redrawing the view at every frame.
This type of animation can also be hardware accelerated because the rendering system can take this bitmap and upload it to the GPU as a texture (if using hardware layers) and do fast matrix manipulations on it (like change alpha, translate, rotation). Compare that to doing animation were you are redrawing (onDraw gets called) on every frame.
In the case of a listview, when you scroll by flinging, you are in essence animating the views of your list (either moving them up or down). The listview uses the drawing cache of its visible children (and some potentially visible children near the edges) to animate them very quickly.
Is there a disadvantage to using drawing cache? Yes it consumes memory which is why by default it is turned off for in a View. In the case of ListView, the cache automatically created for you as soon as you touch the ListView and move a little (to differentiate a tap from scroll). In other words, as soon as ListView thinks you are about to scroll/fling it will create a scroll cache for you to animate the scroll/fling motion.
Comment: ScrollingCache is enabled by default for ListView.
Comment: And what if I set softlayer on the ListView and call `setScrollingCachedEnabled(false)` ?  Does it results in using soft rendering pipeline without any bitmap caches?
Answer: scrollingCache is explained in full detail in the lecture of "the world of listView".
It's basically caches the scrolling itself so that it will move a bitmap, but according to my experience, it actually makes things much slower and take memory for nothing special.
scrollingCache is enabled by default, at least for listView . That's why if performance is important for you, you should consider disabling it.
Answer: I think you are talking about the following:
Imagine a list of 50 items where only 10 items are visible. Android will cache the next and previous (estimate) 5 items in a list item.
When you start scrolling through the list it will reuse the invisible item views, using the ArrayAdapter's function getView()
For example if you are scrolling to the top it will take a view on the bottom and place it on top with new data.
So scrolling cache are the next and previous items above/under the visible items.
Comment: This is official explanation http://developer.android.com/reference/android/widget/AbsListView.html#attr_android:scrollingCache
Comment: This is false. The cache you are talking about is the recycler and not the scrolling cache which is a drawing cache. See my answer below.
Answer: official explanation: http://developer.android.com/reference/android/widget/AbsListView.html#attr_android:scrollingCache
Romain Guy's blog about the cache color hint optimization: http://www.curious-creature.org/2008/12/22/why-is-my-list-black-an-android-optimization/

scrollingCache?


Zero Electric field inside conductor and Electrostatics definition

Question: When we define Electrostatics we say that charges are at rest or they are stationary, but when we put a conductor in electric field (assuming Electrostatics) and say that all charge resides on it's surface so that the conductor has net electric field zero in it's bulk we are saying that net force on any small charge is zero. So, how are we claiming that the charges are in rest by sending whole charge on surface (I mean, zero force and rest are two different things) ?
Answer: I'm not quite sure what you're getting at but

The individual electrons are indeed moving around due to thermal excitation. But statistically there should be an equal number moving left as moving right, so the net movement of charge is 0.
If the charge is mainly located near the surface of the metal, and not (in net) moving, that's a case of charge not moving, so we can analyze it as an electrostatic situation.


OpenStack Horizon behind reverse proxy (nginx preferred)

Question: Current situation:
I have a Triple-O OpenStack installation (Liberty) where even the "public" network is in a private environment (10.24.7.0/24 network). The only way to get access to that network is via a gateway host. I'd like to make Horizon accessible from the internet using a reverse proxy. Due to security concerns all outside communication should be encrypted via HTTPS. The reverse proxy should be used as SSL termination host and all inside traffic should be unencrypted.
The OpenStack deployment wasn't configured to use SSL/TLS and doesn't know that the "public" network isn't really public.
I'm currently trying to use Nginx as reverse proxy but usage of other reverse proxy software is also possible if they provide a solution to my problem.
The gateway host is running RHEL 7.2, Nginx is installed from official Nginx repo in version 1.11.1 (mainline).
gateway.example.com is the FQDN used in the examples,
22.214.171.124 is the external IP address of the gateway host used in the examples
10.24.7.9 is the "public" endpoint of the Triple-O installation
Work so far:

http://gateway.example.com loads the index.html where the certificate of the CA used for signing the server certificate can be downloaded.
Due to the fact that the OpenStack installation doesn't know that it is behind a SSL termination point I have to rewrite links in the content. This is done with two sub_filter directives, one generic (sub_filter 'http://$host' 'https://$host';) and one that replaces the OpenStack endpoint IP (sub_filter 'http://10.24.7.9' 'https://$host';)
The console feature of Horizon allows a user to connect to an instance's serial console via NoVNC embedded in Horizon. NoVNC uses websockets to establish a bi-directional TCP connection between the browser and the phyical host where the instance runs upon. To support this I had to configure Nginx to allow HTTP connection upgrades and to listen to port 6080.
iptables allows traffic on ports 80, 443 and 6080.

Problems:

On the Horizon page showing details to an instance instead of showing the body of a tab (overview, log, console, action log), the tab row is repeated and only the content of the overview tab is shown.
Connections to the console of an instance fail with error 1006. (The required URL to get the console show in its own browser tab was retrieved with nova get-vnc-console <ID> novnc and replacing the endpoint IP with the FQDN.) I suspect that this error is caused due to the fact that the connection that was upgraded from HTTP1.1 to websocket standard contains information regarding the "public" interface which cannot be accessed directly from the browser OR that the connection is refused by the NoVNC software due to a mismatch between the configured server address/hostname ("public") and the address in the request (proxy name/IP). Both of these aare speculation.

Nginx config file
ssl_certificate            /etc/nginx/certs/gateway.example.com.crt;
ssl_certificate_key        /etc/nginx/certs/gateway.example.com.key;
ssl_dhparam                /etc/nginx/certs/dh.pem;
ssl_protocols              TLSv1.2 TLSv1.1;
ssl_ciphers                AES256+EECDH:AES128+EECDH:!aNULL:!eNULL:!ECDSA:!SHA:!DSS;
ssl_prefer_server_ciphers  on;
ssl_session_cache          shared:SSL:10m;
ssl_session_timeout        10m;

server { # http
  server_name                 gateway.example.com localhost 220.127.116.11;
  listen                      *:80;
  root                        /usr/share/nginx/html;

  location / {
    index                     index.html;
  }

  location ~ ^/dashboard {
    return                    302     `https://$host$request_uri`;
  }

  location ~ ^/console {
    return                    302     `https://$host:6080$request_uri`;
  }

  location ~ ^/websockify {
    return                    302     `https://$host:6080$request_uri`;
  }
}

server { # https
  server_name                gateway.example.com localhost 126.96.36.199;
  listen                     *:443;
  ssl                        on;

  location / {
    sub_filter               '`http://10.24.7.9`'    '`https://$host`';
    sub_filter               '`http://$host`'        '`https://$host`';
    sub_filter_last_modified on;
    sub_filter_once          off;
    sub_filter_types         *;
    proxy_pass               `http://10.24.7.9/$uri`;
    proxy_request_buffering  off;
    proxy_http_version       1.1;
    proxy_set_header         Upgrade                           $http_upgrade;
    proxy_set_header         Connection                        "upgrade";
    proxy_set_header         Host                              $host;
    proxy_set_header         Accept-Encoding                   "";
    proxy_set_header         X-Real-IP                         $remote_addr;
    proxy_set_header         X-Forwarded-Host                  $host;
    proxy_set_header         X-Forwarded-Server                $host;
    proxy_set_header         X-Forwarded-Proto                 $scheme;
    proxy_set_header         X-Forwarded-For                   $proxy_add_x_forwarded_for;
    proxy_connect_timeout    90;
    proxy_send_timeout       90;
    proxy_read_timeout       90;
  }
}

server { # https on port 6080 for novnc
  server_name                gateway.example.com localhost 220.127.116.11;
  listen                     *:6080;
  ssl                        on;

  location / {
    proxy_pass               `http://10.24.7.9:6080/$uri`;
    proxy_request_buffering  off;
    proxy_http_version       1.1;
    proxy_set_header         Upgrade            $http_upgrade;
    proxy_set_header         Connection         "upgrade";
    proxy_set_header         Host               $host;
    proxy_set_header         X-Real-IP          $remote_addr;
    proxy_set_header         X-Forwarded-Host   $host;
    proxy_set_header         X-Forwarded-Server $host;
    proxy_set_header         X-Forwarded-Proto  $scheme;
    proxy_set_header         X-Forwarded-For    $proxy_add_x_forwarded_for;
 #    proxy_connect_timeout    90;
 #    proxy_send_timeout       90;
 #    proxy_read_timeout       90;
  }
}

Does anyone have a working configuration for this kind of setup? I'd like to stick with Nginx but can make the change to Apache or any other software that can provide a solution.
Edit: clarified CA usage, added suspicions regarding NoVNC connection failure
Answer: I was able to solve the second of the issues (error 1006) by changing some of the configuration options. As the other problem still persists I cannot confirm that the NoVNC console works from within the Horizon UI but when I call the NoVNC URL directly I get a connection and can interact with the instance.
This is the working solution till now:
ssl_certificate /etc/nginx/certs/gateway.example.com.crt;
ssl_certificate_key /etc/nginx/certs/gateway.example.com.key;
ssl_dhparam                /etc/nginx/certs/dh.pem;
ssl_protocols              TLSv1.2 TLSv1.1;
ssl_ciphers                AES256+EECDH:AES128+EECDH:!aNULL:!eNULL:!ECDSA:!SHA:!DSS;
ssl_prefer_server_ciphers  on;
ssl_session_cache          shared:SSL:10m;
ssl_session_timeout        10m;

server { # http
  server_name                 gateway.example.com localhost 184.108.40.206;
  listen                      *:80;
  root                        /usr/share/nginx/html;

  location / {
    index                     index.html;
  }

  location ~ ^/dashboard {
    return                    302     `https://$host$request_uri`;
  }

  location ~ ^/console {
    return                    302     `https://$host:6080$request_uri`;
  }

  location ~ ^/websockify {
    return                    302     `https://$host:6080$request_uri`;
  }
}

server { # https
  server_name                gateway.example.com localhost 22.214.171.124;
  listen                     *:443;
  ssl                        on;

  location / {
    sub_filter               '`http://10.24.7.9`'    '`https://$host`';
    sub_filter               '`http://$host`'        '`https://$host`';
    sub_filter_last_modified on;
    sub_filter_once          off;
    sub_filter_types         *;
    proxy_pass               `http://10.24.7.9/$uri`;
    proxy_request_buffering  off;
    proxy_http_version       1.1;
    proxy_set_header         Upgrade                           $http_upgrade;
    proxy_set_header         Connection                        "upgrade";
    proxy_set_header         Host                              $host;
    proxy_set_header         Origin                            `http://$host`;
    proxy_set_header         Accept-Encoding                   "";
    proxy_set_header         X-Real-IP                         $remote_addr;
    proxy_set_header         X-Forwarded-Host                  $host;
    proxy_set_header         X-Forwarded-Server                $host;
    proxy_set_header         X-Forwarded-Proto                 $scheme;
    proxy_set_header         X-Forwarded-For                   $proxy_add_x_forwarded_for;
    proxy_connect_timeout    90;
    proxy_send_timeout       90;
    proxy_read_timeout       90;
  }
}

server { # https on port 6080 for novnc
  server_name                gateway.example.com localhost 220.127.116.11;
  listen                     *:6080;
  ssl                        on;

  location / {
    proxy_pass               `http://10.24.7.9:6080/$uri`;
    proxy_request_buffering  off;
    proxy_http_version       1.1;
    proxy_set_header         Upgrade            $http_upgrade;
    proxy_set_header         Connection         "upgrade";
    proxy_set_header         Host               $host;
    proxy_set_header         Origin             `http://$host`;
    proxy_set_header         X-Real-IP          $remote_addr;
    proxy_set_header         X-Forwarded-Host   $host;
    proxy_set_header         X-Forwarded-Server $host;
    proxy_set_header         X-Forwarded-Proto  $scheme;
    proxy_set_header         X-Forwarded-For    $proxy_add_x_forwarded_for;
 #    proxy_connect_timeout    90;
 #    proxy_send_timeout       90;
 #    proxy_read_timeout       90;
  }
}

tl;dr
Changes:
In both server blocks for ports 443 and 6080 I added proxy_set_header Origin http://$host;. Don't know exactly what this is doing but it solved my problem.
This still leaves me with the first issue.
Answer: I was able to solve the first issue as well. The reason for this odd behavior was caused because the reverse proxy dropped the query part of the request (everything behind the ?). This again was caused by  misconfigured proxy_pass lines.
The solution to this was to remove /$uri from both proxy_pass lines in the configuration file (details see http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass ).
This is a working solution:
ssl_certificate /etc/nginx/certs/gateway.example.com.crt;
ssl_certificate_key /etc/nginx/certs/gateway.example.com.key;
ssl_dhparam /etc/nginx/certs/dh.pem;
ssl_protocols TLSv1.2 TLSv1.1;
ssl_ciphers AES256+EECDH:AES128+EECDH:!aNULL:!eNULL:!ECDSA:!SHA:!DSS;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;

server { # http
  server_name gateway.example.com localhost 22.214.171.124;
  listen *:80;
  root /usr/share/nginx/html;

  location / {
    index index.html;
  }

  location ~ ^/dashboard {
    return 302 `https://$host$request_uri`;
  }

  location ~ ^/console {
    return 302 `https://$host:6080$request_uri`;
  }

  location ~ ^/websockify {
    return 302 `https://$host:6080$request_uri`;
  }
}

server { # https
  server_name gateway.example.com localhost 220.127.116.11;
  listen *:443;
  ssl on;

  location / {
    sub_filter '`http://10.24.7.9`' '`https://$host`';
    sub_filter '`http://$host`' '`https://$host`';
    sub_filter_last_modified on;
    sub_filter_once off;
    sub_filter_types *;
    proxy_pass `http://10.24.7.9`;
    proxy_request_buffering off;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;
    proxy_set_header Origin `http://$host`;
    proxy_set_header Accept-Encoding "";
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_connect_timeout 90;
    proxy_send_timeout 90;
    proxy_read_timeout 90;
  }
}

server { # https on port 6080 for novnc
  server_name gateway.example.com localhost 220.127.116.11;
  listen *:6080;
  ssl on;

  location / {
  proxy_pass `http://10.24.7.9:6080`;
  proxy_request_buffering off;
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "upgrade";
  proxy_set_header Host $host;
  proxy_set_header Origin `http://$host`;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-Host $host;
  proxy_set_header X-Forwarded-Server $host;
  proxy_set_header X-Forwarded-Proto $scheme;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  # proxy_connect_timeout 90;
  # proxy_send_timeout 90;
  # proxy_read_timeout 90;
  }
}

Answer: I stumbled upon this while I was struggling with this for a while too. And this really helped me out. However nginx doesn't like the ` quotes around the http://$host etc. When you remove those it works. This is a working configuration for me for example:
ssl_certificate /etc/ssl/cert.pem;
ssl_certificate_key /etc/ssl/cert.key;
ssl_ciphers HIGH:!RC4:!MD5:!aNULL:!eNULL:!EXP:!LOW:!MEDIUM;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_session_tickets off;

server { # http
  server_name openstack.example.com;
  listen *:80;

  location / {
    return 302 https://$host$request_uri;
  }

  location ~ ^/console {
    return 302 https://$host:6080$request_uri;
  }

  location ~ ^/websockify {
    return 302 https://$host:6080$request_uri;
  }
}

server { # https
  server_name openstack.example.com;
  listen *:443;
  ssl on;

  location / {
    sub_filter 'http://192.168.0.200:6080' 'https://$host:6080';
    sub_filter 'http://$host:6080' 'https://$host:6080';
    sub_filter_last_modified on;
    sub_filter_once off;
    sub_filter_types *;
    proxy_pass http://192.168.0.200;
    proxy_request_buffering off;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;
    proxy_set_header Origin http://$host;
    proxy_set_header Accept-Encoding "";
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_connect_timeout 90;
    proxy_send_timeout 90;
    proxy_read_timeout 90;
  }
}

server { # https on port 6080 for novnc
  server_name openstack.example.com;
  listen *:6080;
  ssl on;

  location / {
    proxy_pass http://192.168.0.200:6080;
    proxy_request_buffering off;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;
    proxy_set_header Origin http://$host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_connect_timeout 90;
    proxy_send_timeout 90;
    proxy_read_timeout 90;
  }
}

I am posting this because maybe someone is searching for an updated answer.


Using SPServices is it possible to process one column at a time?

Question: My SharePoint list has many Date columns, (Date1, Date2, Date3...). I would like to work on one column at a time. Is it possible, Using SPServices, to loop through each column containing (Date) one after the other?
Answer: You'd have to make a few calls to piece it all together.
You can get all your date fields by using GetList
<code>$().SPServices({
  operation: "GetList",
  listName: "YOURLIST",
  completefunc: function(xData, Status) {

    $(xData.responseXML).find("Fields > Field").each(function() {
      // attr Type would be DateTime
      // attr StaticName would be what you'd want to use to build up code
      var $node = $(this);
      console.log( "Type: " + $node.attr("Type") + " StaticName: " + $node.attr("StaticName") );
    });
  }
});
</code>
So you could:
<code>1. Get list of all date field names and store in array or whatever.
2. Use that array to build up your viewFields string for the call
3. Select the items you need in the basic `GetListItems`
4. Use that array to loop through the date fields to do your logic.
</code>


SQL SERVER Project

Question: My Application Database Without Project and without Source safe, i planned to make my DB to be as project and add it to TFS, but I have no idea how to script the stored procedures, Triggers, Views, Functions, and what is the best practice to Make Update Script for All My stored procedures, Triggers, Views, and Functions to My customers DB.
Comment: What do you see when you right-click the database in SSMS?
Answer: The best procedure (IMHO) is to manually maintain a strict version of your schemas. Then when you need to make changes you write a delta script to move from one version to the next. I suggest you write the DDL scripts by hand -- you can make them concise and comment them.
Answer: You can use a tool like Visual Studio Team System for database architects, take a look at Running static code analysis on SQL Server database with Visual Studio Team System for database architects  it will show you how to import the data, disregard the static code analysis that comes later it does not apply to your question
Comment: That article is quite rubbish (I won't -1 though), and what does this have to do with the OP's question ? If static code analysis is the holy grail then you should at least explain why this is relavant to the OP's (cryptic) question.
Comment: in the article it clearly states how to import the objects, he asked "how to script the stored procedures, Triggers, Views, Functions" the static code analysis doesn't apply to his question but the first couple of steps do
Answer: I've found a good way to get SQL scripts into SCM from an existing database is to use SMSS's "export all to script" option or whatever it's called, can't remember now.
Then every other change you add the change script into your SCM with a different version number in the file name.
Every release (or set cycle depending on your development/release methodology) you apply all change scripts, then re-script the entire database, tag it, and start again.
Answer: The best way to do it - save the database in TFS as set of database creation script, i.e. MyTable table should be added to TFS as MyTable.sql file (CREATE TABLE...) etc. We are using SQL Examiner to do this - see the following article: How to keep your database under version control
We are working with SVN and I never tested SQL Examiner with TFS, but I know that the tool supports TFS.

SQL SERVER Project


irreducible Polynomial in a Cipher

Question: If we change the irreducible polynomial of the AES to someother irreducible or primitive polynomial, what effect will it have in security?
Answer: Yes, we can change the irreducible polynomial of AES to another irreducible polynomial. In doing so we have to implement a change of basis or change the polynomial for the S-Box, this may effect the security. Moreover research had been done on how to enhance the security of AES by changing the irreducible polynomial. See this paper for detailed discussion.
Hope this helps.
Answer: The polynomial in the AES is $x^8+x^4+x^3+x+1$ that is irreducible but not primitive. In fact, you can use an irreducible and primitive polynomial but you have to save 256 cases in computation. Another main reason for using $x^8+x^4+x^3+x+1$ in AES is mix-column state. In mix-column state we need an MDS matrix. The best optimal MDS matrix is circular MDS matrix that is constructed with the third element of finite field ($1 \,,\, \alpha \,,\, \alpha +1$). If you want to use an  irreducible and primitive polynomial, you have to check that is there an optimal MDS matrix like  MDS matrix of AES. I think, AES is designed such that with minimum RAM can be applied and has a proved security. In other words, in min-max problem of cryptography (security and speed) AES is an optima algorithm.

irreducible Polynomial in a Cipher


Fullscreen app location in Mission Control

Question: Is is possible to make the fullscreen applications be put right next to the desktop you are currently on, rather than to the right of all existing desktops in Mission Control?
Answer: Yes, go into System Preferences>Mission Control. Check the box next to "Automatically rearrange Spaces based on most recent use"
Comment: Does that actually do what I want? I thought that just arranged the spaces randomly based on what it thinks you use
Comment: No, it rearranges based on most recent use. You can always disable it if it isn't what you want.
Comment: This is not quite what I'm looking for. I only want to affect the location of new spaces.
Comment: This isn't possible in that configuration then


Strategy for maintaining git branches that with different versions of an API?

Question: Is there an effective way of using git to manage two branches that are based on the same code logic but support different API's? Here is a concrete example: Suppose I have a repo with one Python 2 file called abc.py. In commit A on branch py2, the file contents are:
print 'A'

Now I branch off of A with a new py3 branch and make commit A3 with this content:
print('A')

Back on the py2 branch, someone makes a new commit B with content
print 'A'
print 'B'

On py3, I merge py2 to get the B update and get this merge conflict:
<<<<<<>>>>>> 9d898

So the conflict over print 'A' is re-raised. I resolve this to
print('A')
print('B')

Now in py2 there is commit C with
print 'A'
print 'B'
print 'C'

and merging this into py3 gives the conflict
<<<<<<>>>>>> 2c5a5

So again all of the changes are re-raised as a merge conflict.
It seems like with this approach of frequently merging from py2 to py3 each merge will be more complicated and painful than the previous one. Is there a way to use git to maintain two branches like this where the previous merge history can be better incorporated? If not, I guess I am better off doing as few big "catch up" merges as possible, rather than doing frequent small merges which is usually the best approach.
Background: I am trying to port a project from Python 2 to Python 3. If I could do this instantaneously, I would do so and drop Python 2 support, but I can't do it instantly so I have to allow development on the Python 2 branch while the Python 3 port is done in another branch. I know that many large projects transitioned by going through a phase of supporting 2 and 3 simultaneously with one code base. Since I don't need to support Python 2 once Python 3 works, I thought the porting process would be simpler if I just did a one-way port, but the process of porting updates from Python 2 seems more difficult than I thought at first.
Disclaimer: I know my example is trivial and could be worked around by using the printing function from __future__ in Python 2, but there is not such an easy workaround for everything. Also, I think this question is more broadly applicable to other cases than just Python 2/3.
Answer: As disappointing as it may be to hear, I think that branches are probably not the right tool for the job. These branches are often called "long running branches" and generally never pan out to be as useful in practice as they initially seem to in theory.
I would suggest that a better tool is a text pre-processor like gpp, m4, or (if it were a c/c++ project) cpp.


How much percent of participants does tezos need to achieve consensus?

Question: I am currently looking at the nakamoto coefficient for tezos. The nakamoto index is the number of participants needed to get the absolute majority in a system, in bitcoin for example this would be 51%, i.e. the number of participants needed to get 51% of the stakes in the system would be the nakamoto index. For certain blockchains such as algorand one needs 2/3 of the participants in order for the system to achieve consensus, therefore the nakamoto index would be the number of participants needed to have more than 1/3 of the total stakes. So how many participants are needed for the system to act maliciously in tezos? (one third/one half or another number)
Answer: For the current consensus protocol, Emmy*, the attacker needs at least half of the total stake, since it's a Nakamoto-style algorithm (like Bitcoin and Ouroboros).
For the consensus algorithm of the next protocol proposal, Tenderbake, the attacker needs at least a third of the stake, since it's a "classic-style" algorithm (like PBFT, Tendermint, Casper). (The attacker might need slightly less, say 31%, because validators are a randomly sampled subset of  all possible participants, and the attacker may be lucky sometimes.)
Comment: That makes sense, thanks a lot.


What is the difference between consciousness and matter?

Question: I want to know the difference between consciousness, awareness, energy and matter. Also how could we define if any thing is consciousness or not?
Comment: Consciousness is something because of which you are able to be aware of your own existence in physical state.
Comment: Consciousness has self awareness, or "I". Matter doesn't.
Comment: Related: [What is the difference between living beings and dead matter according to scriptures?](https://hinduism.stackexchange.com/q/14520/277)
Answer: Consciousness is awareness or witness.  It witnesses or is aware of the matter. But matter i.e. objects are not aware of the subject. (Consciousness). Anything which can be known or experienced are the objects (matter).

Form is the seen, the eye is the seer; that eye is the seen, and mind
is its seer; thoughts in the mind are seen by the Witness, which alone
is the Seer, but can never be the seen.
This (Witness) does not rise, nor does It set; It does not increase,
nor does It decrease; It shines by itself and then others does It
illumine, without any external aid. (Dṛg-Dṛśya-Viveka verses 1,5)


Warning message in SPD 2010 after migration from 2007 to 2010

Question: I encountered the below warning message first time and after learning from few web articles I understand that this pop-up message appears when the workflow was created in SPD 2007 and the SharePoint site has migrated from 2007 to 2010. How true is this and can any one elaborate more on this for my better understanding. And what if I click on OK button?
Answer: It means what it says. Your workflow, created in 2007, currently uses ASPX forms as a user interface. Should you ever change the workflow (now that you are running the site in SP 2010), any future version of the workflow will be using an InfoPath-based form instead of the ASPX form.
The dialog is for information only. Nothing will happen when you click OK.
Things will continue to work as they should.
But when you edit the existing workflow, save and publish it, its form will no longer be your custom ASPX form, but a form that can be customized with InfoPath. InfoPath can be used without any knowledge of ASPX or HTML. It is a forms designer with a WYSIWYG interface (well, almost).
Comment: If the custom ASPX form changes to InfoPath, will it have all the fields and validation that were created in ASPX form?
Comment: Probably not. Automatically created forms will contain only the basics. What are you running? Foundation or Enterprise? See this for Foundation: http://msdn.microsoft.com/en-us/library/ms457061%28v=office.14%29.aspx
Comment: I am running SharePoint Enterprise 2010


Centralized Logs (error, deadlocks, slow queries) For SQL Servers

Question: I want to establish a centralized log for many SQL Servers, similar to the products  Graylog or elk stack.
What is the best and performant way to send these kind of logs to a log collector?
I searched for a native way for logstash, filebeat, winbeat, nxlog, ... to send the logs to these kind of log collectors, But I can't find a reliable native way.
I know Extended Events is a right tool for gathering logs. I want to know how can I send these logs to a data collector.
Is there a raw log file from extended events? Or is there any way to send logs automatically through the network with some kind of standard protocol like syslog(rsyslog) in Linux? Or any other standard way?
Answer: You're asking a few different questions:

Where can I find errors? Deadlocks? Slow queries? Each of these is its own question, each with separate answers. SQL Server doesn't store those three separate things in the same place, and honestly, you're only starting your journey into SQL Server's logs.
Which log collector should I use? Because each of these is its own kind of data, you may want to gather it with different tools.
How should I store the data? Again, the way you store error log data might be completely different from how you store query plans. They'll probably have different granularity levels, for example.

Try breaking your project down into smaller, more answerable individual questions rather than "how do I write a monitoring tool?" That question is just way too broad.
Comment: I edit my question, to narrow down my question. Also I wish you got my main point and it were good there is some resource with question that you raised. :)


Selecting correct ArcGisFeatureLayer to query onSingleTap event?

Question: My problem: I'm working on a Android (ArcGis) Attribute Editor following the sample code from their tutorials. The problem occurs when I have more than 1 ArcGisDynamicLayer and, more important, more than 1 ArcGisFeatureLayer.
My question: What is the (correct) approach to IDENTIFY the right Feature Layer to query when I tap on a "field" displayed on the map?
I read a similar question (Arcgis SDK for Android - Query multiple feature layers), but I didn't understand how to use IdentifyTask using only a single tap.
Answer: You specify the layers you want to identify in the IdentifyParameters constructor.  You can use the IdentifyTask on single tap by implementing the MapView.setOnSingleTapListener().


External Profiler for Unity 3D apps

Question: Hello is there a way to profile a Process with an external profiler? I use the unity profiler but it dosent show me allocations in other threads then the main thread.
Answer: I'm pretty sure that use Unity Profiler is the best way to profile Unity authored apps/games. Unity Profiler shows allocations only on the main thread, because is there where your game code resides.
In some cases we can create our own threads to do some calculations, I imagine is this your case, so I recommend to you use ANTS Performance Profiler and ANTS Memory Profiler, I used both of them to profile ordinary .NET apps and they are really amazing profiles and, yes, they show allocations to all your app's threads.
Comment: It looks like ANTS does not work with Unity because it is not a .net app (at least the editor)

External Profiler for Unity 3D apps


Warhammer 40k 8th: When using two allied factions what stratagems and warlord traits do you use from the codices

Question: Im playing Admech/imperial knights (seperate detachments) and I'm wondering, if my warlord is a knight, am I able to use admech strategems?/is the  trait in effect?
Answer: You can find all the information you need regarding the stratagems in your codex - right on the page with the stratagems. I'll quote from the Codex "Astra Militarum", p. 134 (of the german version):

Wenn du eine Armee in Schlachtordnung hast, die beliebige Astra-Militarum-Kontingente enthält (außer verstärkende Unterstützungskontingente), hast du Zugang zu den unten beschriebenen Gefechtsoptionen; du kannst also Befehlspunkte ausgeben, um sie zu aktivieren [...]

Very Loosely translated:

If you have an army that is battleforged and contains any Astra Militarum detachments (except whatever the english name for the detachment that allows you to just take any single unit you want for the price of one CP is), you gain access to the stratagems below. Meaning you can use Command Points to activate them

This text also appears in other codexes (I checked my codex Chaos Space Marines) and in the Psychic Awakening books (I checked Glaube und Zorn, which is the german version of Faith and Fury)
This means that as long as you have at least one full detachment from a specific army/keyword, you can use the stratagems. Note that most (if not all) stratagems are pretty much limited to be used only on the faction they come from (or even more specific units) - Your choice of Warlord is completely irrelevant for this, you have access to both AdMech and Knight Stratagems no matter which Warlord you choose.
Comment: Specific to AdMech/Knights - if the Knight is in House Questor Mechanicus, then three of the stratagems from the AdMech codex will also apply to the Knight (Benevolence of the Omnissiah, Knight of the Cog, and Tech-adept). Otherwise, as you stated, the stratagems' wordings exclude using them to target Knights.


What would the wavefunction represent in an observer-less universe?

Question: Suppose the universe has no observers, and the universe's dynamics is governed by the Schrodinger equation. What does the wavefunction represent now? Is it that parts of the universe keep "measuring" other parts of the universe and the wavefunction represents the statistical description of what measurements get recorded as the universe evolves?
Comment: The "observer" in quantum physics, AFAIK, IS any other particle that interacts. Isn't this a physics question, btw?
Comment: @kutschkem I asked this on the physics site too. I also want to know philosophers' ideas. An "measurement" in QM is some interaction between a macroscopic and a microscopic system. An interaction between microscopic particles is unitary, while measurements are non-unitary. This is why the measurement problem is popular. If you just remove all macroscopic systems, then all evolutions become unitary. But the problem is that the wavefunction now becomes meaningless, because probabilities are meaningless without measurements.
Comment: Ok, understood, I think. So the thought experiment here is a universe consisting only of an interstellar medium withoutany clumps that would count as macroscopic?
Answer: The wavefunction represents what is happening in reality. It is not a statistical summary since the square amplitudes only act according to the calculus of probabilities in some circumstances:
https://arxiv.org/abs/math/9911150
A measurement is just an interaction between physical systems that creates a record of the value of some physical quantity. It has nothing to do with conscious observers, which aren't required to explain anything in quantum physics:
https://arxiv.org/abs/1111.2187
Answer: The wavefunction represents what a measurement, were it to take place, would find as the statistics. Since we talk about it and compute it normally in a context before the measurement, it should make sense, in the same way, to talk about it in a universe where the measurement is infinitelly far in the future (or, in other words, never happening).


Interpret the formulation of a pricing model in crowdshipping

Question: I am trying to run the pricing model from the paper "Designing pricing and compensation schemes by integrating matching and routing models for crowd-shipping systems" on python with Gurobi, but the constraints given in this model do not preserve the network flow as expected. Maybe there should be more constraints to secure the networkflow from the origin nodes to the pick up nodes. I would like to get some feedback about the model and my 'translation' to python, as I don't get why it does not work as expected.
First the scenario: We have m drivers h in H, H=[1,..,m], each having an origin node tau[h] and a destination node tau_[h]. We have also n requests i in A, A=[1,..,n] (pickup nodes), which have to be delivered in the delivery nodes A_=[n+1,...,2n]. Resulting from this we have a Graph G(V,E) with V=A+A_+tau+tau_ nodes and E=V*V lines. A driver should drive from his origin passing a pickup and the appropriate delivery to his destination.(or directly from his origin to his destination).
This is the model from the paper:

The package size is not relevant and is neglected in the paper. That's why K is also not considered in the programm.
And here is my code:
<code>import gurobipy as gp
from gurobipy import GRB, quicksum
def pricing(n, m, A, A_, H, WTP, ETP, R, d2, V, V1, E2, d, t, s, l, a, b, M):

    global mod
    mod = gp.Model("Pricing")

    # Decision variables
    x = mod.addVars(E, H, vtype=GRB.BINARY, name="x")
    S = mod.addVars(V, H, vtype=GRB.CONTINUOUS,lb=0, name="S")
    L = mod.addVars(V, H, vtype=GRB.CONTINUOUS,lb=0, name="L")
    z = mod.addVars(A, vtype=GRB.BINARY, name="z")
    p = mod.addVars(E, H, vtype=GRB.CONTINUOUS, lb=0, name="p")
    c = mod.addVars(E, H, vtype=GRB.CONTINUOUS, lb=0, name="c")
    mod.setObjective(quicksum(p[i,j,h]*d2[i]-c[i, j, h]*d[i, j] for i in A for j in A_
    for h in H if j!=i ), gp.GRB.MAXIMIZE) # (40)
    mod.addConstrs((p[i, j, h] <= WTP[i]/d2[i] + (1-x[i, j, h])*M for i in A for j in A_
    for h in H if i!=j), name='Price_not_greater_than_WTP (02)/(28)')
    mod.addConstrs((c[i, j, h] >= ETP[h]*x[i, j, h] for j in A_ for h in H for i in A if
    i!=j), name='Compensation_not_less_than_ETP (03)/(29)')
    mod.addConstrs((p[i, j, h] >= c[i, j, h] for i in A for j in A_ for h in H),
    name="constraint4")
    mod.addConstrs((quicksum(x[i, j, h] for j in A_ for h in H) + z[i] == 1 for i in A),
    name="constraint5")
    mod.addConstrs((quicksum(x[i, j, h] for j in V if i!=j ) - quicksum(x[j, n + i, h]
    for j in V if j!=n+i) == 0 for i in A for h in H), name="constraint6")
    mod.addConstrs((quicksum(x[tau[h], j, h] for j in pickup_destination[h] ) == 1 for h
    in H), name="constraint7")
    mod.addConstrs((quicksum(x[i, tau_[h], h] for i in delivery_origin[h] ) == 1 for h
    in H), name="constraint8")
    mod.addConstrs((quicksum(x[i, j, h] for i in V if i!=j) - quicksum(x[j, i, h] for i
    in V if i!=j) == 0 for j in A_ for h in H), name="constraint9")
    mod.addConstrs((S[i, h] + s[i] + t[i, j] <= S[j, h] + (1-x[i, j, h])*M for (i, j) in
    E for h in H), name='courier_follows_matched_paths (10)/(34)')
    mod.addConstrs(( S[i, h] == [a[i], b[i]] for i in V for h in H),name="constraint11")
    mod.addConstrs((S[i, h] <= S[n + i, h] for i in V[0:-n] for h in H),
    name="constraint12")
    mod.addConstrs((L[i, h] + l[j] <= L[j, h]+ (1-x[i , j, h])*M for (i,j) in E for h in
    H), name='capacity_for_next_loading (13)/(35)')
    mod.addConstrs((L[i, h] <= R[h] for i in V for h in H ), name="constraint14")
    mod.addConstrs((L[tau[h], h] == 0 for h in H), name="constraint15.1")
    mod.addConstrs((L[tau_[h], h] == 0 for h in H), name="constraint15.2")
    mod.addConstrs((p[i, j, h] <= M*x[i, j, h] for i, j in E for h in H if i!=j),
    name="constraint23")
    mod.addConstrs((c[i, j, h] <= M*x[i, j, h] for i, j in E for h in H),
    name="constraint24")
    mod.addConstrs((p[i, j, h]*x[i, j, h]==p[i, j, h] for i, j in E for h in H if i!=j),
    name='constraint25')
    mod.addConstrs((c[i, j, h]*x[i, j, h]==c[i, j, h] for i, j in E for h in H
    ),name='constraint26')
    mod.optimize()

    active_arcs=[(i, j, h) for i, j in E for h in H if x[i, j, h].x>0.99]
    active_prices=[(i, j, h) for i, j in E for h in H if p[i, j, h].x>0.99]
    active_costs=[(i, j, h) for i, j in E for h in H if c[i, j, h].x>0.99]
    active_load=[(i, h) for i in V for h in H  if L[i, h].x>0.99]
    active_z=[i for i in A if z[i].x>0.99]
    active_Start=[(i, h) for i in V for h in H if S[i, h].x>0.99]

    if mod.status == GRB.OPTIMAL:

        optimal_x = mod.getAttr("x", x)
        optimal_S = mod.getAttr("x", S)
        optimal_L = mod.getAttr("x", L)
        optimal_z = mod.getAttr("x", z)
        optimal_p = mod.getAttr("x", p)
        optimal_c = mod.getAttr("x", c)

        return active_arcs, active_prices, active_costs, active_load,
        active_Start, active_z, optimal_L, optimal_S, optimal_c, optimal_p, optimal_x,
        optimal_z
    else:
        return None
n = 2  # Number of packages
m = 2  # Number of couriers
# Sets/nodes
A = list(range(m+1, n+m + 1))  # Set of package pickup nodes
A_ = list(range(n+m + 1, 2 * n +m+ 1))  # Set of package delivery nodes
H = list(range(1, m + 1))  # Set of couriers
tau=[h for h in H]
tau.insert(0,0)
tau_=[2*n + m +h for h in H]
tau_.insert(0,0)
V= tau[1:] + A + A_ + tau_[1:]
destination={(h): tau_[h] for h in H}
pickup_destination= {h: A+[destination[h]] for h in H}
origin={(h): tau[h] for h in H}
delivery_origin={h: A_+[origin[h]] for h in H}
Vh={(h): [origin[h]]+A+A_+[destination[h]] for h in H }
# Edges
E=[(i, j) for i in V for j in V if i!=j ]
M = 10000  # Large positive number
# Other parameters
WTP = {i: 10 for i in A}  # Maximum price that a Sender is willing to pay
ETP = {h: 2 for h in H}  # Minimum compensation that courier h expects
R = {(h): 5 for h in H }  # Capacity of courier h for package size k
d = {(i, j): 1 for i, j in E}  # Travel distance for link (i, j)
for key,value in d.items():
    if key[0]==key[1]:
        value= 0
    d[key]=value
d1= {i:1 for i in V} #Travel distance for price relevant arcs
d2= d1.copy()
for i in d2:
    if i not in A:
        d2[i]=0
t = {(i, j): 1 for i, j in E}  # Travel time for link (i, j)
s = {i: 1 for i in V}  # Service time at node i
for i in s:
    if i in tau:
        s[i]=0
    if i in tau_:
        s[i]=0
l = {i: 1 for i in V}  # Amount of packages that need to be loaded at node i
for key, value in l.items():
    global newvalue
    newvalue=value
    if key in A_:
        newvalue=value*(-1)
    if key in tau :
        newvalue=0
    if key in tau_:
        newvalue=0
    l[key]=newvalue #positive load in pickup and negative load at dropoff
a = {i:0 for i in V}  # Time window lower bound
b = {i: 10 for i in V}  # Time window upper bound

result = pricing(n, m, A, A_, H, WTP, ETP, R, d2, V, V1, E2, d, t, s, l, a, b, M)
</code>
When I run it like this, the plotted result looks like this:
So there is no constraint (in my programm) forcing the driver actually to begin at his origin. It would be very helpful to get some feedback where the mistake could be.
Answer: For source/dest node you may add constraints
$ \sum_j x_{\tau_h,j}^{h}- \sum_i x_{i,\tau_h}^h = 1$
$ \sum_j x_{\tau'_h,j}^{h}- \sum_i x_{i,\tau'_h}^h = -1 \ \ \forall h$
Comment: I try to find a solution without creating new constraints as the model given in the paper should work like that accoarding to the authors - I think there is something wrong with constraint 12 which defines the Starting-times Variables S[i,h] for a driver in a node.  S[i,h]<= S[i+n, h] for all i in V - but only the nodes i and n+i are compared and some possible combinations are left out.
Comment: @Last_Mile I don't think so since this constraint merely says courier will visit other nodes before reaching it's delivery node. The 2 constraints are wrote is pretty standard to endure flow at source & destination. You can replace constraints 7 & 8 with the above two, exclude source/dest nodes from flow constr 9 and try.


Which syllable is primarily stressed in the word "television"?

Question: I was taught to stress the first syllable of "television", but some dictionaries stress the syllable before -sion. My other question is "Does stressing VI before -sion exist in AmE?
Answer: Merriam-Webster says that putting the primary stress (or accent) on the second-to-last syllable of television is an "especially British" pronunciation.
I'm an American English speaker, and I don't remember ever hearing that pronunciation.
In American English, the pronunciation with primary stress on the first syllable may be analyzed as having tertiary stress on the second-to-last syllable: ˈteleˌvision.
Comment: Yes, and in American English, "1tele3vision" has the same 1 3 stress pattern as the verb "1tele3vise".
Comment: I'd say the version with the stress on the second last syllable is fairly uncommon in BrE.


How to get Drupal 7 installed in a sub-folder / sub-directory properly?

Question: Currently i'm trying to installing a drupal 7 installation in a subfolder of another drupal public_html folder, but it doesnt seem to work. I am getting a redirect loop error in chrome. I already modified the .htaccess in the parent drupal installation to ignore the sub-folder and i also set the $base_url in the sub-directory drupal installation.
Answer: When I do this, provided I have a clean install, I do not modify anything. Take the domain http://diw.ifi.uio.no/, where Drupal is installed in both /www/, and /www/gruppe01/, etc. (I just create the number of subdomains I need for various experiments). My DocumentRoot is set to be /www/. I just direct my browser to http://diw.ifi.uio.no/ for the main site, and  http://diw.ifi.uio.no/gruppe01/ for the first subfolder site, etc. and it works - just like that.
Have you tried starting with a clean install and just install Drupal in the subfolder using the standard install procedure without changing .htaccess? (While not always necessary, I recommend that you have $base_url set correctly in the site's  settings.php.)
In my experience, Drupal works fine out of the box when installed in a subdirectory of a vhost. The fact that there is another Drupal in the DocumentRoot does not make this any different, as long as each Drupal site has its own .htaccess, it will not try to read the .htaccess in any superior directory.
Examples:

http://diw.ifi.uio.no/
http://diw.ifi.uio.no/gruppe01/
Comment: nope i just reverted all my .htaccess and removed the base_url and still nothing.. chrome shows that its in a redirect loop error.
Comment: but that defeats the purpose... im just wondering what is causing the conflict as it has to be something to do with the root .htaccess affecting the sub directory one.
Comment: actually your right the root's htaccess file should have no affect on the subdirectory. i finally solved the issue as it was to do with modifying the subdirectory's .htaccess file to not rewrite the url to have the www prefix. apparently that was on which caused it to redirect in loop somehow.
Comment: This works perfectly.
Comment: what if some url is not existed for example http://diw.ifi.uio.no/gruppe03/non-exiting-directory , which .htaccess will be applied? root's or http://diw.ifi.uio.no/gruppe03's, of course without setting $base_url just like you mentioned.
Answer: If possible, it's better to setup the new site in it's own virtualhost, e.g a subdomain site1.example.com, site2.example.com etc..
If you want to install in a subfolder under a single vhost, you will find other odd configuration may be required (e.g embedded image paths etc.. )
If you want to go down the install in subfolder route, you've done some of the special conf and may just require RewriteBase in .htaccess to be set to the subfolder path for that site.
Comment: i just wanted to do a quick clone of the site to test out a drupal core update. yes i know i should have it done on a dev/stage environment, but i don't have that setup for this site.
Comment: so it seems that i have to do a subdomain setup.
Comment: If it's a subdomain setup, then access by site1.example.com rather than example.com/site1. You can redirect the latter to former, if not done already.
Answer: Okay after fiddling around some more. I finally solved the issue. First off the .htaccess in the subdirectory override's the root's .htaccess. so that means you dont have to worry about the root's .htaccess file
Therefore, anything that needs to be adjusted is within the subdirectory and you shouldn't need to touch anything in the root directory where you have your other drupal installed.
What i did was:

Comment out line 81 and line 82 of the subdirectory drupal installation .htaccess file.
Un-comment the line 94 RewriteBase to where you have your subdirectory drupal installed
Add in the $drupal_base variable in your sites/default/settings.php file to fix any file path issues you might have.

If this worked for you let me know! +1! :)
Comment: As I've already said, in a *clean* Drupal 7 install, it works straight out of the box *without* any of the antics you seem to resort to.
Comment: but it wasnt working so those are the changes I had to make to get it to work. it wasn't a fresh install as its a clone copy of an existing site so there could have been changes made while it was in development.


Has Q ever interacted with the Changelings?

Question: Given Q's personality, the Changelings would seem a prime example of a species he would want to interact with, test and mess with. They have a god complex, like to manipulate and control other species and bring war on the galaxy. Has Q ever been shown interacting with any member of the Changeling species in any of the Star Trek materials?
Comment: The Calamarain certainly know about the Q. Possibly the Borg also do.
Comment: Q seems to be the same species as Samantha and her relatives on Bewitched. They have exactly the same powers. Samantha's mother, Endora, and her Uncle Arthur used their powers to play practical jokes, just like Q does.
Comment: I'm not sure if anyone outside the Federation has been shown to even know about the Q.
Comment: Why would Q want to interact with another species with a god complex?
Comment: I doubt that the Changelings would have that sort of superiority complex in the  presence of Q. They may still make condescending remarks about "solids" if Q brings up the subject, but Q is not a solid and thus likely wouldn't care. It seems unlikely to me that the Changelings would remain smug if Q tortured them.
Answer: Eh.
I can't find anything about Q interacting with the Founders, or any Changeling besides Odo. Odo, however...
Both Q and Odo appear in the Deep Space 9 episode "Q-Less". In this episode, Q arrives at Deep Space 9, along with Vash.
However, while Odo and Q both appear in this episode, they don't really interact. Q is interacting more with Sisko and O'Brien, while Odo is focusing more on Quark. As Odo is the security officer on DS9, though, he'll almost certainly know that Q was on board and will have been briefed on what he is.
As this is the only time we see Q appear in Deep Space 9, there aren't really many other opportunities for such a meeting to happen in canon sources.
If you include non-canon sources such as licensed novels, then The Q Gambit by Mike Johnson might be another place where Q and Odo meet; it's a 6-part comic story where the USS Enterprise is transported into the future by Q to meet the crew of Deep Space 9 (including Odo).
Comment: The question seems more interested in interactions with the Founders than with Odo.
Comment: @OrangeDog - I found nothing about that. Odo is the only changeling that we see ever getting near Q.


How to increase visual length of form text field in Word?

Question: When a form text field is inserted in a Word document, the grey shaded length is about 5 characters long.  How can this length be increased?
Answer: Within the "properties" window (after right-clicking on the field), there is a default text option. If you insert spaces there, the size of the field shown will grow to compensate. The more you need to grow the field visibly, the more spaces should be added to the default text field.
Answer: The grey shading is just to indicate there is a form field there. By default the field will hold unlimited text, unless you change the field properties to only be a certain length. Still, the shading will only show a few spaces until you type, then the shading grows as you continue type.
As far as I know, there is no way to extend the shading when there is no text in the field. If the field is in a table, you could shade the entire cell.
Answer: If you have at least one Asian language pack installed you can "stretch" the form field by using Distributed text alignment. From there you can choose the width and if you set this to a higher value it will expand the form field as well.
Answer: I converted the area for a response to a question from text to table.  Then, added a box around the selected area. Visually, it now appears as a larger text box, even though the fillable area is only 5-10 characters in length.