Birchas Hatorah and Sefardic women

Question: In an earlier question I mentioned that women make Birchas Hatorah. Is the same true for Sefardic women and why?
Comment: Why would there be a difference between Ashkenazim and Sefardim in this regard?
Answer: Bais Yosef Orach Chaim 47:14 - Women are Mechuyav in Birchas HaTorah
Yechave Da'as Chelek 3 Siman 72 page 230 says that we Pasken like this Bais Yosef.
Comment: There does not seem to be any Machlokes here.
Comment: I would appreciate a halacha lmasseh not the explanation like a Reb Ovadiah Yosef, Ben Ish Chai, or the Kaf Hachaim
Comment: the why was good too
Comment: There's a klal in hilchot berachot by Sephardim that when there's a machloket poskim about whether a beracha should be said, we paskin safek berachot l'hakel, even against the mechaber. Therefore quoting Maran Beit Yosef can't be the last word on this subject. (So see my other answer for something more contemporary.)
Comment: In general it is not always the Klal that all Sefardim Poskin like the Beis Yosef
Answer: Halacha Berurah 47:27

Women also say birkat hatorah every day because they're chayav to learn the laws that apply to them, for example hilchot Shabbat, tefillah, berachot, hilchot niddah and challah, and other halachot of issur and heter. In any event, they're not required to say birkat hatorah -- it's simply that if they want to, then they're permitted to.
Comment: @Gershon why not? Is it because I forgot to point out that Halacha Berurah is written by R' Ovadia Yosef's son, R' David Yosef?
Answer: Women are obligated to say Birchas Hatorah.
Even though the position of the Shulchan Aruch is that women may not make berachos when performing mitzvahs they are not obligated in [like time bound mitzvahs], the Shulchan Aruch stills requires women to make the bracha.
Many (Beis Halevi, among others) explain why [Sephardic] women can make Birchas Hatorah because they are obligated to learn the laws relating to mitzvahs they are obligated in.
The Brisker Rav (Hil. Berachos) quotes his father, R' Chaim Solovetchik, that Birchas Hatorah is not a Birchas HaMitzvos, but actually a Beracha on the 'cheftza of Torah' (more similar in classification to Birchas Hashvach).
Comment: "they are obligated to learn the laws relating to mitzvahs they are obligated in" which when you think about it is probably around 90% of laws, as a very rough estimate
Comment: @Heshy: True. The chiddush is that although they have no Mitzvah of Talmud Torah in it's own rights, the fact that they are obligated to learn the laws practically relevant to them (i.e., they are not obligated to learn as an end of its own, but as a means to keep their other obligations) is enough to obligate a Birchas HaTorah.
Comment: I 100% agree in lomdus.  It just bothers me when schools use "girls don't have to learn" as an excuse for low quality education.  Sure, if the boys are learning Sukkah it's probably better for the girls to learn something else, but most topics apply to everyone.  You never know when an obscure halacha in Bava Metziah is going to be relevant on short notice when you don't have your phone on you.  Not to mention Zeraim, Kodshim, and Tahoros (no I don't mean Berachos and Niddah) - Mashiach could come at any moment and we'll all have to know those halachos.

Birchas Hatorah and Sefardic women


Where is the username and password stored?

Question: Just for my curiosity, where is the username and associated password stored in Ubuntu? And how it is verified at the login time?
Answer: Passwords can be found (in hashed form) in /etc/shadow and the users in /etc/passwd.
The login program is used to establish a new session with the system.
       It is normally invoked automatically by responding to the login: prompt
       on the user´s terminal.  login may be special to the shell and may not
       be invoked as a sub-process. Typically, login is treated by the shell
       as exec login which causes the user to exit from the current shell.
       Attempting to execute login from any shell but the login shell will
       produce an error message.
<code>   The user is then prompted for a password, where appropriate. Echoing is
   disabled to prevent revealing the password. Only a small number of
   password failures are permitted before login exits and the
   communications link is severed.

   If password aging has been enabled for your account, you may be
   prompted for a new password before proceeding. You will be forced to
   provide your old password and the new password before continuing.
   Please refer to passwd(1) for more information.
</code>
More info at: http://manpages.ubuntu.com/manpages/hardy/man1/login.1.html
http://manpages.ubuntu.com/manpages/hardy/man5/passwd.5.html
Comment: Stored in hashed form ,what is it means
Comment: @tachyons It's a one-way conversion; a method of digesting a message and returning a near-unique string so you never have to store the original password (huge security risk). When you want to challenge a password you just subject it to the same hashing algorithm and if the hashes match, the passwords are 99.9999999% likely to be the same. http://en.wikipedia.org/wiki/Cryptographic_hash_function
Comment: Thanks I googled it and got many usefull links,it is really interesting :)


Dynamic navigation using a global

Question: Hi guys does anyone know how I might go about creating a dynamic navigation using a global with the navigation items as fields, is this even possible?
Answer: Global is not really the best option for dynamic navigation, because by definition it is designed to contain just one of something — and while it supports multiple fields, it only supports one instance of each field. Technically you could use a field within the global that supports multiple items (i.e. table fieldtype or matrix fieldtype), but none of the fieldTypes support hierarchical structures natively, so I don't see the advantage. Or you could simply paste static HTML into a text field, but I wouldn't really classify that as dynamic. Overall, not a particularly good option.
You should probably be looking into using a 'structure' (or to a lesser extent 'categoryGroup'), where each entry would represent a page or nav item, organized hierarchically. In this way you can reuse the same field within each entry (i.e. 'title') and loop through the entries to dynamically generate the nav, with the added benefit of being able to reorganize the nav easily using drag-and-drop.
For more information, see:

Documentation on using the nav tag.
Documentation on giving each Entry Type it's own template.
Answers from previous questions, such as here and here.
Check out some of the dedicated nav building plugins, such as a&m navigation or craft nav.
Comment: The disadvantage is that you are creating fields to represent each page/url. What happens when you need 'menuLink7'? Or you decide to change the order? Or want to disable a section temporarily? There is also no way to loop through your nav items (without looping through the fieldLayout, etc.) What you are doing is essentially creating static nav, that just happens to be stored in a database — which is fine but not really taking advantages of the capabilities of craft.
Comment: Thanks for the advice I'm new to craft, I am only looking for a simple nav with no drop downs and I have actually figured out a way of doing it by creating 6 fields, menuLink1, menuLink2 etc, that have a field type of entries and using {{ globalHandle.menuLink1.first().url }} it works fine. What are the disadvantages of this?

Dynamic navigation using a global


Non-locality and quanta

Question: Quantum mechanics is non-local in that long distance correlations are present, though there is no signalling possible. But QFT is Lorentz invariant and contains quantum mechanics as a special case. I assume this is not a paradox as paradoxes do not exist but I do not understand the details. Can anyone supply a reference or satisfactory explanation?
Answer: Correlations of results of measurement procedures of entangled system in QM (and thus also in QFT) are fixed at "the moment" of the observation and not previously as instead it happens for long-range correlated systems of statistical mechanics. In this sense, because the two measured parts of the system can stay arbitrarily far form each other (so that no physical signal can propagate from one part to the other with speed $<c$ during the measurement procedures),  non-locality is manifest in quantum theories. Even in QFT in spite of the fact that fields obey covariant and local equations. It is because non locality is due to entangled quantum states and not to field equations.
This is just what the experimental failure of Bell's inequalities proves: (1) these correlations show up and (2) they were not fixed before performing measurement on the system (as it would be if there were local hidden variables, more fundamental than the quantum description of the system).
It is worth stressing that these correlation do not imply any transfer of energy or momentum or other physical quantities from one part of the system to the other, and there is no violation of causality with them (also because the time order of the pair of distant observations may depend on the used reference frame, since the involved pair of events are spacelike separated).
Moreover, since the outcome of measurements is stochastic one cannot transfer information through these correlations.
The situation is similar to this one where the entangled system is replaced by a pair of magical quantum dice. I have a die and you have another one. It happens that, no matter the distance between us, once you get a number from your die, I get the same number from mine.
In principle we could communicate through these correlations, in practice we cannot, because as the outcome is stochastic I cannot impose to my die to produce the outcome I want.
There is another possibility to communicate through our magic quantum dice: I could communicate you something simply by throwing my die. You should see your die to reproduce my numbers and you would know, this way, that I am throwing my die.
Conversely, with correlations of QM even this possibility is forbidden: It is possible to prove that the outcome of your measurement procedures on your part of the system have the same statistics, independently from the fact that I perform measurement on my part of system or not, though each pair of outcomes (on both sides of the system) appear to be correlated.  So you cannot know whether or not I am "observing" my part of system.
Comment: thanks everyone for the answers ... it is a little more clear. I also got Mermins physics today description and that helps. But the dice are a real simple way to think about that paper!
Comment: While I never downvote, I must say that some of your assertions are false. Quantum mechanics respect causality/locality, and correlations exist before (joint) measurement. The expression "non-local correlations" is a nonsense. Causlaity/Locality has to do with the fact that an information or energy is not transfered instantaneously (or quicker than the speed of light) from one space-time point to an other space-time point. Correlations are what they are.
Comment: Excellent answer, cross referenced [here](https://www.quora.com/What-is-the-interpretation-of-the-instantaneous-superluminal-influence-behind-entanglement-which-could-be-the-underlying-phenomenon/comment/6338999)
Answer: Quantum Mechanics is non-local because you are working with particles and interactions all occur instantaneously. This doesn't allow locality. Quantum Field Theory is a framework that instead of working with particles, works with fields. A field has values at each point in space and allows local interactions. However, it doesn't enforce locality. It is only local because we choose equations of motion for our fields that are relativistic. If you wish you can write a non-relativistic Schroedinger equation in QFT and do non-relativistic calculations which will no longer obey locality.
Answer: Pseudo- apparent "Long-distances" correlations exist in statistical classical physics too.
In fact, if you consider a  system, which at some time, for some reason, in which two subsystems (of this system) are being locally correlated, and supposing, that, in the future, these two sub-systems are spatially separated , the correlations between these sub-systems continue to exist (these correlations are completely independent of the distance between the sub-systems), while no information or energy can be sent instantaneously from one sub-system to the other.
So, correlations have nothing to do with non-locality, in statistical classical physics, in Quantum mechanics, or in Quantum Field Theory. And Quantum mechanics and QFT respect causality/locality

Non-locality and quanta


In Android, how do I find caller of a method efficiently

Question: I am building a testing/analysis tool that requires instrumentation of Android framework classes. In that tool, the classes need to be instrumented to find out the caller of a method (i.e., method signature) that is currently being executed, and based on the caller some processing is done. My question is, which method I should use to determine the caller?
I know that one approach is to use java.lang.Throwable and the method getStackTrace. However, it is not efficient. Are there any other (public or hidden) API's (similar to sun.reflect.Reflection.getCallerClass of standard JDK) for Android platform that can be used?
Answer: There's Thread.getStackTrace().


How do I go about creating new flora and fauna in my novel?

Question: In my novel most species of animals and plant life have gone extinct, and they have to be created again. Some of these reborn animals and plants are old and others are supposed to be brand new species. I know what the purpose of the new flora and fauna will be, but how would I go about designing them? I know ill have to do my own research, but any advice on how to get started?
Comment: Are they being created by scientists or evolution?
Comment: Welcome to Worldbuilding SE, Luke. People posting questions on this site are encouraged to have done their research beforehand (not after) so that their question can be refined to a single specific point of inquiry. That said, can we at least assume this is on a post-apocalyptic earth? Are we talking nuclear apocalypse, climate change, zombie virus... Ultimately we need to know more about the world your flora and fauna inhabit to provide an extrapolated answer and I would also respectfully point out that evolution doesn't 'design' species so much as reward efficiency.
Answer: The way I would do this is I would start by asking myself, "What kind of environment do these new species inhabit?"  For example, I started writing a book last year set on a barren desert planet, and so I needed an ecosystem that could potentially exist there.
The next step is to think of several features that would benefit the inhabitants of your environment.  In my example, I created wolf-like creatures with thick matted fur to protect from sandstorms.  Then you can extrapolate from there.
Often it is easier to take an existing creature (like the wolves) and adapt them to the environment, rather than creating a completely original creature.  This can also help your audience visualize the creature because they already know what it looks like.
I can give more specific advice, but this answer is getting long :)
Comment: It's a good idea to research, as in your example, desert ecosystems, the organisms that live there and the adaptations they have will also help. Real-world creatures and their adaptations are a good starting place.
Answer: Tl/Dr:

Energy In - Energy Out = Storage is the most important rule
Nature doesn't care about divisions between species or individuals.  Design things that make sense without it
Avoid teleological worlds: If your fauna has a "purpose," hide it a much as possible.
Use tools from your life to build worlds.  It's more efficient that way.

I find it very important to look at energy balances.  Energy In - Energy Out = Storage.  It's a fundamental rule of physics, and utterly essential for living creatures.  More interestingly, storage is limited.  We can't just keep storing more and more energy.  You can store a lot of energy in fat, for instance, but at some point you become heavy enough that mobility becomes an issue.  Living creatures are constantly trying to spend the energy they get.
This is also very important to avoid telelogical planets, where the "purpose" of each new species is so evident that you can't believe they are real.  The only sure fire rule for species is that if you can do the same job in a different way, and use less energy, they'll find a way to do it.  Thus your job as a worldbuilder is to bury every "purpose" you came up with into this goal of being more efficient with energy.  It's the only truly believable "purpose."
Another key trick is to remember that nature doesn't have a concept of species, or of an individual.  We draw those lines as humans, as we try to make sense of the world.  Try to make it so that your species is not so much a "species" that is "doing things," as much as it is a gestalt of the individuals within that species.  It may make sense to have a worker bee sacrifice itself for the good of the hive, if we're thinking about the hive.  But that decision to sacrifice itself has to be made by the bee itself.  It needs to have been structured to make that self-sacrificial decision. (spoiler: We're still not entirely sure how this works)
Another classic example of this gestalt way of thinking is tree branches.  The current prevailing model of how trees grow is that each branch grows on its own, oblivious to what any other branch is doing.  The only exception is that one branch may use hormones to signal that it is a primary branch, which gets to grow straight up (Forming a trunk).  And the branch spawning process is typically rather random.  So while we may see one tree, it operates more as a set of 10-20 branches that all happen to have the same roots.
Beyond that, you really have to look at your own style.  Myself, I enjoy Chinese philosophy, which is heavily centered on balance and harmony with nature -- exactly what you need to build a world!  Accordingly, I tend to use the tools I already have available to me.  I'll use yin and yang to model the ebb and flow of energy.  I'll use the 5 elements to model the interplay between different species.  Then I'll use their interplay to create all the excitement I need.  When I need a sense of purpose, I'll use the daoist cosmology to provide a wuji and taiji.  For inspiration, I can model it using the I Ching.
Some of those terms may not mean anything to you.  They don't need to.  They are the tools I use.  Why do I use them?  I use them because they're efficient for me.  I already chose to learn how to use these tools in my life, so using them in my worldbuilding is almost free.
Remember the opening rule?  The only truly hard and fast rule?  Creatures will always find a way to do the same thing with less energy?  Chinese philosophy happens to be a low energy solution for me.  You have to find what makes sense to you.  Maybe you are an expert at musical theory.  You can craft a world based on the way chord progressions are constructed.  Are you a painter?  Think in terms of media: a watercolor world feels different than an acrylic world.
As long as you make sure Energy In - Energy Out = Storage, the rest is entirely what is most convenient for you.  Beyond that, the art is in hiding your own brush strokes.  The less obvious it is that you crafted flora/fauna with a purpose, the more believable and beautiful the world is.
(Oh, and I use StackExchange to help build my worlds.  I'm just saying... use what feels natural to you, and takes as little energy as reasonable.)


Best way to generate fitness landscape when using higher dimensional data

Question: I'm using a GA to find the best set of parameters to maximize a fitness function. I want to draw a fitness landscape to visualize the effectiveness of the algorithm. The fitness function, calculated using a DNN, has 8 input variables. The landscape I want to plot is 3 dimensional (x,y,fitness). What data should I assign to the x and y axes? Or should I avoid such a plot entirely? Which other types of plots would be better?
Comment: Can you clarify what you mean by "The landscape I want to plot is 3 dimensional"? Why is it 3d? How can we know what you should assign to x and y, if we don't actually know what these axes are supposed to represent in your context? Are your individuals 2d points? If yes, then having a 3d fitness landscape may make sense.
Comment: @nbro the individuals have 8 dimensions. Thats why I wasn't sure how to plot them on 2 axis. Thank you,
Answer: I understood your question as being "I have a fitness function based on 8 parameters" how can I display that graphically.
Visualising a multi-dimensional landscape is a hard problem.
If you convert it to some kind of 3d plot you are inevitably losing information.
It would help to consider what you are actually trying to achieve by doing so.
Do you have a practical use for the plot or is it just a bright shiny.
If you want to show something specific such as how one algorithm is better than another, you may be better off trying to visualise something else entirely.
Commonly you can look at the average fitness over time instead.
A better algorithm is typically one that increases fitness more quickly and/or with fewer resources.
So you could plot fitness by time by population with different coloured lines for each algorithm variation say.
That said if you really want to visualise the fitness landscape:
There a some useful information on or linked to the wikipedia page on Fitness_landscapes
You could also try:
Dimensionality Reduction
You could try [dimensionality reduction](Dimensionality reduction) to reduce the number of parameters down to something you can plot.
Identify dimensions with the most interesting properties
Look at which dimensions have the most intersting changes over time
Plot individual dimensions
Create multiple plots for different interesting pairs fo dimensions
Innovate ways to plot other dimensions
Why stick with 3D? Consider using:

colour
size
texture

Make your model interactive
Look here and elsewhere for inspiration
Why not provide a way of controlling which dimensions are displayed and how.
Comment: Can you explain why plotting a 3d fitness landscape (the OP's problem) is a hard problem? Because it shouldn't. If the individuals have more than 2 dimensions, then yes I agree that you may need some dimensionality reduction. So, I think you should address the OP's problem directly too in this answer. In any case, they don't explain what x and y are. It's unclear if their individuals are 2d points or not (probably yes).
Comment: I understood the individuals as having 8 dimensions.
Comment: thank you this makes sense. I kind of knew it wouldn't really make sense to try as 8 is not the same as 2. Ill go with the option to use multiple plots. It is mostly to generate something shiny, a figure which makes the whole objective of the algorithm easy to understand.


According to Trinitarianism, should prayers always be directed at one Person at a time, or can we pray to the whole Trinity simultaneously?

Question: According to Trinitarianism, is it valid to pray to God "in general" (the whole Godhead) without specifying the Person (Father, Son or Holy Spirit), or should we always be explicit about which Person we are specifically directing the prayer to?
Comment: I think "According to Trinitarianism" is way too vague for this question.
Answer: Jesus taught his disciples how to pray:

Pray then like this: "Our Father in heaven, hallowed be your name... (Matthew 6:9)

In other words, we pray to God the Father (Abba, Father).
"Hallowed be your name" tells us to worship God, and to praise Him for who He is.
Since there has only ever been the One Being of God, in whom subsist the three personages of Father, Son and Holy Spirit, when we pray to God we are praying to all three.
Our prayers are specifically directed to God the Father.  We pray in the name of Jesus, and it is the power of the Holy Spirit that intercedes for us when we struggle to know how to express ourselves:

In the same way, the Spirit helps us in our weakness.  We do not know what we ought to pray for, but the Spirit himself intercedes for us with groans that words cannot express.  And he who searches our hearts knows the mind of the Spirit, because the Spirit intercedes for the saints in accordance with God's will. (Romans 28:26-27)

When I pray to the Father, I remember to always thank Him for the greatest gift possible, that of His Son, and also to thank Him for the Holy Spirit which He sent to help us. However, I address my prayer specifically to our Father God in heaven.
Comment: Lets not forget though Isaiah 9:6 "6For unto us a child is born,
unto us a son is given,
and the government will be upon His shoulders.

And He will be called
Wonderful Counselor, Mighty God,
Everlasting Father, Prince of Peace." (Note the title given to Jesus...Everlasting Father)


Instructions for LEGO bag dated 2007 bought at a Thrift store

Question: I need the instructions for a LEGO parts bag I purchased at a Thrift store
Comment: It is from Palace Cinema. Pink circles are from the candy machine, doors for the limo and squares for the ground (you're missing the rare ones with cameras on it).
Answer: Based on the parts, it looks suspiciously like an internal part bag for 10232 Palace Cinema - which means there's no specific instructions to make something with just those parts - the whole set of instructions can be found online.
To clarify - a set like Palace Cinema will have a number of "Numbered" bags that correspond to part of the building instructions, and those bags sometimes contain smaller sealed bags of small parts - it looks like this is what you have there.
This is based on the two black doors - these seem to be fairly rare these days and the other parts (especially the 11 new dark red 2x2 tiles) fit nicely with the contents of that set.
Note that the year printed on the bag is the date the bag design was introduced - according to BrickSet the pink circles  were first produced in 2008 - and of the 80 sets that it has appeared in, only one of them contains the black doors as well.
Comment: A set that large has multiple bags of bricks inside. You've probably just got one.
Comment: @Laura If you look at [this pdf](http://cache.lego.com/bigdownloads/buildinginstructions/6145733.pdf) on page 24 you can see the pink circles and the various tiles from your bag. Page 6 shows the black doors being used for the car.
Comment: Thanks for all the help. My son can had the pieces to the rest of his Lego and create something with them. I only spent $0.50 for the bag. It's all good
Comment: @Laura Just FYI: the bags sometimes have information printed on them that applies to the bag itself, as a part used in the packaging. Some proof that the 2007 date applies to the bag: the [bracket](http://rebrickable.com/parts/99781) piece in that photo wasn't available until 2012.
Comment: Thanks for the suggestion, but only some of the part are similar to the Palace Theatre. There were no Pink circle parts. This was a sealed bag, until I opened it to take the pic
Comment: I really don't think this is the 10232 Palace Cinema, this was released in 2013. The bag all these parts came in is dated 2007. And the Palace Cinema does not have the pink circles. Any other suggestion would be great, but keep in mind the year 2007. thanks


Does mass affect rate of reaction?

Question: Suppose I am reacting HCl with CuCO3.
Experiment 1: I use 2g powdered CuCO3
Experiment 2: I use 4g powdered CuCO3
All other variables are kept constant.
Will this have any affect on rate of reaction? Will the 4g react faster because of more particles available for collision?
Comment: Higher mass means high surface contact area and therefore higher rate, especially if HCl is in sufficient excess.
Comment: More powder doesn't mean higher rate but a more saturated solution does.
Answer: $1$)
Let's admit first that the reaction rate is proportional to the amount of reactants, in the usual way. Whatever the order $1$ or $2$ of the reaction, the rate constant ${k_{1} }$ or ${k_2}$ will not change if the amount of reactant is increased. But the rate of reaction ${r = - dn/dt}$ does increase when the amount of reactant ${n}$ increases, whatever the order.
For $1$st order, the rate is : ${r = - dn/dt = k_1 n}$. So the rate ${r}$ increases by increasing the amount of reactant ${n}$.
For $2$nd order, the rate of rection is : ${r = - dn/dt = k_2 n^2}$. Here too, the rate of reaction increases when the amount of reactant $n$ increases.
$2)$ As the reactant is a solid, the reaction rate may not be proportional to the amount of reactant (in mole). Let's suppose that it is proportional to the surface of the grains. Even so, the surface increases by increasing the amount of powder. As a consequence, the reaction rate does also increase.

Does mass affect rate of reaction?


Change order content blocks home page

Question: Good afternoon, I was wondering to what extent you can change (the order for example) the existing contentblocks on the pages. Thank you in advance!
Answer: By default, Matrix blocks will display in the order you have entered them in your entry form.
If you need to change the display order, you can drag/drop your blocks straight from your entry form using the small handle on the right of the blocks and the order will be reflected on your page.
Comment: Thank you for your reply! I am pretty new to this, so can you make a screenshot of an example of an entry form? Thank you in advance!
Answer: As you can see from the screenshot below and as Oli already mentioned, you can simply drag the content blocks on a page and hit the save button. That said, this is possible with contentblocks that are in a matrixfield. If you have regular fields for your page, you will need to arrange them in the section setup. Only matrix block elements can be arranged differently for every page.

Change order content blocks home page


Can you put your readers right in the middle of things without assuming they know anything?

Question: Can you put your readers right in the middle of things without assuming they know anything? Let's take a very strange world with very unique world building like Made by Abyss or The Elder's Scrolls: Morrowind, can you take your readers right in the middle of things and name things that are known by the denizens of your world, but not your readers as though they knew everything and just expect them to read your book a second, third or even read a companion book, or should you reveal things step by step? Is this shock approach of just putting your readers in the middle of things ever done by a successful author?
Answer: Putting your reader right in the middle of the world, without preface or explanation, is a hallmark of mastery of world-building.
This is because it forces the author to inhabit their character's life in order to share their motivations as they interact with the fantastical world.
Read the first chapter of 'The Golden Compass' -- follow the look inside -- and examine how Phillip Pullman shows you Lyra's world.  There is not any explanation of what Pantalaimon is beyond being a daemon -- which gets no definition. Major elements of the world are just dropped on the table without explanation -- Dust, Scholars, a severed child -- and the story is engrossing.  I think this is because the author only provides just enough information about world elements as they come up.  That we learn much about the world from how the characters in the story react to them.  Later we get more detailed explanations, but as the story advances we consistent get just enough information to put the new element in sufficient context that we can accept it and keep moving through the story.
Similarly, Anthony Burgess's 'A Clockwork Orange,' throws the reader right into the middle of the story with the main character's first person narration in an argot of English, Russian and French that is almost impenetrable but conveys a lot of emotion and intent.
Another example is the first thirty pages of 'A Diamond Age' by Neal Stephenson that introduces a technological world very different from our own without the least bit of explanation and is totally engaging. His characters use phrases like 'The Feed' and skullgun and cripplers without any explanation, but because the context is understandable and the details aren't important when these elements are introduced, everything works to make a great story.
Answer: Yes, absolutely.
One example of a successful book that does this really strongly is Ninefox Gambit by Yoon Ha Lee. Lee drops you straight into an battle scene that very heavily uses in-universe "exotic technologies" which are very magical, different from anything genre-conventional and hard to wrap your head around, but that are normal for the POV characters. Rereading the first chapter, there is a tiny bit of infodump about things like the fact that adherence to a specific timekeeping system makes the technology work, but you're still thrown pretty much into the deep end. (And IIRC the fact that the specific timekeeping system involves ritualized torture is both the fundamental core of that universe and dealt out to you in dribs and drabs.)
(An interesting example of a nonfiction book that does something like this is Birth of a Theorem by mathematician Cédric Villani, which is an autobiographical account of his research leading up to his winning a Fields Medal (most prestigious prize in mathematics, think along the lines of Nobel Prize). The mathematics of it is both a huge part of the book and going to be completely incomprehensible to the vast, vast majority of readers, but I still found it an engaging book with a plotline I could follow.)
Honestly, I think doing this can make your book significantly more of a draw. I've talked about this before, but your #1 goal in the first chapter is to keep your readers hooked. They need to want to know what's on the next page, they need to be invested in some questions they want the book to answer. Those questions can be character-related, they can be plot-related, but they can also be worldbuilding-related. "Wait, what's this insert-fantasy-language-here thing and why is the POV character so desperate to steal it?" can serve as a minor hook. On the flip side, infodumping can actively work against you: by answering questions before the reader is curious about the answer, creating sections which don't advance plot or character and slow momentum, or actively weakening character development because infodumps often break POV.
The trick, of course, is to straddle the line between this and just outright losing the readers. The basic rule of thumb you need here is find a way to communicate exactly what the reader needs to know to understand the scene they're in and to make it compelling without breaking flow. Taking Morrowind for an example: if your character is travelling on foot, you can mention that they're trying to keep under cover and keeping a wary eye towards the sky for cliff racers. That gives the reader enough to know that there's some air-borne threat the character is trying to avoid, which adds suspense to the scene as a whole. You can seed some character detail here (how scared the character is, how they react to that fear, etc.) or setting detail (trying to hide under the caps of the mushroom trees, seeing Red Mountain on the horizon when they check the sky). You do not need to go in detail about what a cliff racer is exactly to do any of that, and doing so would most likely weaken the scene as a whole. On the flip side, if you just write your character walking along and then suddenly, a cliff racer attacks! you're in more of a pickle - the reader has absolutely zero context for the cliff racer built up, has no clue how large one is and what's going to happen and why there's something attacking in the first place, and you're going to have to give enough detail for them to understand that without breaking the flow of the action. A much harder task, especially if the character is familiar with cliff racers and can't echo the reader's suprise/shock/lack of understanding.
One important thing to note here is that readers' tolerances here vary. I've seen reviews of Ninefox Gambit that said the reader couldn't get into the book because they were hit with too much unexplained stuff at the start, but it's a hugely successful book and I loved it to pieces. I'm fairly far on the other side of the spectrum - I read fanfic in fandoms I don't know for fun and have abandoned published novels in the first chapter because it became clear that the author wanted to spoon-feed me every bit of information; the detective work of figuring out bits about the world and character from context is one of my favourite reading experiences and if you deprive me of that you'll probably lose me. So you probably want to keep a target audience in mind and keep the level of deep end vs infodump fairly constant throughout.
Answer: Most certainly, if you do it right.
David Drake's With the Lightnings drops you right into the lives of two characters with no build up or warning.  They are where they are, doing whatever it is that's going on that day.
With the Lightnings is the first of a series that ran to thirteen books.  I've read them all.  The introduction in the first chapter of With the Lightnings was, to me, very effective.  It showed me two very different characters in an interesting setting with interesting backgrounds - and made me want to learn more about them.
Drake has both characters doing something.
Daniel Leary is making his way through a foreign city, with a specific (though not specifically named goal) in mind.
Adele Mundy is attempting to organize a bunch of uncooperative workers in a newly founded library.
While both characters are going about their tasks, random thoughts of the past flit through their minds.  The current activity and the thoughts of the past meld together, leaving a dynamic flow instead of a static info dump.
I find the mixture natural and believable.  Characters in Drake's stories tend to think of things while carrying out routine tasks, just as normal people do.  When the situation gets tense, they focus on now and doing what has to be done, with the occassional flitting thought that they don't really have time for, but that comes anyway.
The characters' thoughts deliver some background, but not all at once. You get little sketches of the people and the background delivered in a constant stream with the action of the curent time providing the flow.
I greatly enjoy Drake's style.  I have all of the RCN (Daniel Leary and Adele Mundy) books, and I've read them all many times.  I also have most of the books from Drake's Hammer's Slammers series - also very good stories.

You can download a free eBook copy of With the Lightnings directly from the publisher at the link above.
Answer: Yes, this is done all the time. Often the trick to this is easier than you might guess: You take some task that is already familiar to readers. A meal, getting up and getting ready for work, eating or drinking something for breakfast, going to work, entertaining themselves, shopping for groceries, whatever.
And add your modern or magical or alien immersion to that.
The familiarity of a general task orients the reader and lets them guess what the magic is doing. Star Trek never explains a "sonic shower", but the purpose is obvious from the familiar context. Or a "Transporter", or "Warp Drive", or "Dilithium Crystal", etc.
When you name things known by the denizens of the world, do that in a context that gives the reader some clue. We are good at inferring a meaning from the context in which a word is used, if not once then in a few contexts in which people use it.


Individual Email Results not appearing for shared data extensions

Question: We have been using different BU and so shared data extensions that comes from the Mother BU.
We would like to use only shared data extensions (because we want to send from Email Studio and Journey Builder at the same place) but at the same time Individual Email Results in Salesforce.
I have been explaining that I have to use Salesforce Data extensions.
Is there any trick to use Shared Data extensions only that will fulfill Individual email results ?
I saw that Individual Email Results not appearing for Salesforce Send Emails but it does not help.
Thanks for your precious help
Comment: It should work if you use Shared DEs in Journey Builder and do a single send journey. Make sure to tick (on the email send activity) the checkbox where it says to send tracking results to Sales Cloud. Give it a try :-)
Comment: Would the Shared Salesforce Data Extensions folder not do the job?
Comment: Thank you, it is clicked by default in the email activity in Journey Builder. I have the option "send tracking results to Sales Cloud" for journey but not for email studio send with Shared DE. This is what I need. Thank you
Answer: I believe you should simply be able to use the "Shared Salesforce DataExtenison" folder
Comment: Yes thank youfor your help I am aware for Shared SF DE folder but it means we use to many different folders which is not user-friendly. I was hoping a unique folder and so a way to do so.


Cannot post successfully if not using cassini for jQuery posts in ASP.NET MVC

Question: When I set my project to start app using Visual Studio Development server (Cassini:Port)
my jQuery posts properly to the following URL
"SomeController/SomeMethod".
When I use localhost to run with the following URLS, it does not work
"http://localhost/Store/SomeController/SomeMethod" or
"SomeController/SomeMethod".
Any one facing this kind of issue?
Answer: Try using Url.Action to map the URLs so that they are correct no matter what the virtual root.
<code>$.post( '<%= Url.Action( "SomeMethod", "SomeController" ) %>'
        data,
        function() { ...callback.. },
        'json' );
</code>
If this still doesn't work, then we'll probably need to see your routing set up.  It would also be helpful to know whether ActionLinks work but jQuery AJAX doesn't.  If that's the case and the URLs are the same, then you may not have the correct urls for your Javascript files.  In that case, you'd want to use Url.Content to map those URLs so they are always correct.
<code><script type="text/javascript"
       src='<%= Url.Content( "~/Scripts/jquery-1.3.2.js' ) %>'>
</script>
</code>
Answer: You can create on iis yourapp.com and in [WindoewsRoot]\System32\drivers\etc\host add line
127.0.0.1 yourapp.com
and now you can test your application on this url http://yourapp.com/testpage/


Which squared mass difference associates with which kind of neutrinos, solar or atmospheric or accelerator or the reactor one?

Question: Why do we call the $\Delta_{21}$ as solar neutrino mass squared difference? Why do we say that the data from a solar neutrino experiment gives the information about $\Delta_{21}$ but does not give the information of $\Delta_{31}$ or $\Delta_{32}$ ? And on which basis we label these mass squared differences as solar, atmospheric, reactor etc. ?  The same question is for mixing angle $\theta_{12}$, why we call this solar neutrino mixing angle?
Answer: To start with, all named neutrinos are the same.
If you look at the particle data table , you will see

that the neutrinos of the three flavors ν1,ν2,ν3 correspond the same flavour leptons e , μ,  τ, in that order, by definition of the generations of flavour.
"atmospheric" "solar" "reactor" "accelerator" are convenience labels of how these elementary particles are produced, in this case the neutrinos or antineutrinos. Different production mechanisms are at work which have to be taken into account to model the incoming  to the detectors neutrino beam.
A look at the masses shows over how much energy the neutrino beam should be in order to be able to generate an onshell tau, or mu neutrino  when interacting with the detector.
This is a flux from the sun:

There is not enough energy for the beam to oscillate into detectable taus and muons.

There are two types of experiment which might be envisaged:
(1)  Appearance experiments,  where one searches for the appearance of states with a new flavour in a beam.   Such experiments are by necessity particularly sensitive to mixing parameters.
(2)  Disappearance experiments, where one looks for the disappearance of neutrinos of the initial  flavour  from  a  beam.   Such  experiments  might  involve,  in  particular,  electron neutrinos, in case there is not sufficient energy available to create neutrinos of another kind.
  Such is the situation with reactor-produced neutrinos and solar neutrinos, whose energy
  is far below the rest masses of the charged μ - and τ -leptons.  These kinds of experiment
  are particularly sensitive to small energies and therefore also to small mass values.

It is the interaction and creation of a  e , μ,  τ that signals detection and is measured, or the disappearance in numbers of the electron neutrinos from the flux.
The neutrinos from the sun do not have enough energy to generate mus and taus when interacting with the detectors, only the reduction of the flux of electron neutrinos can be measured. There was a neutrino flux problem in solar models which was solved by the hypothesis of neutrino oscillations.  The original model was the two neutrino model and thus the naming, using a theoretical model for the initial flux.
This is a good review of the subject.
Here is an analysis of solar and reactor data,  i.e fitting missing electron neutrino flux that uses the three neutrion oscillation, i.e. gives limits for all mass differences.

A global analysis of the solar, atmospheric and reactor neutrino data is presented in terms of three-neutrino oscillations. We include the most recent solar neutrino rates of Homestake, SAGE, GALLEX and GNO, as well as the recent 1117 day Super-Kamiokande data sample, including the recoil electron energy spectrum both for day and night periods and we treat in a unified way the full parameter space for oscillations, correctly accounting for the transition from the matter enhanced (MSW) to the vacuum oscillations regime. Likewise, we include in our description conversions with θ12>π/4. For the atmospheric data we perform our analysis of the contained events and the upward-going ν-induced muon fluxes, including the previous data samples of Frejus, IMB, Nusex, and Kamioka experiments as well as the full 71 kton-yr (1144 days) Super-Kamiokande data set, the recent 5.1 kton-yr contained events of Soudan2 and the results on upgoing muons from the MACRO detector. We first present the allowed regions of solar and atmospheric oscillation parameters θ12, Δm221 and θ23, Δm232, respectively, as a function of θ13 and determine the constraints from atmospheric and solar data on the mixing angle θ13, common to solar and atmospheric analyses. We also obtain the allowed ranges of parameters from the full five-dimensional combined analysis of the solar, atmospheric and reactor data.

So the other mass squared differences have also been given an upper bound with solar data.  It is the detection method that associates the identification to the source, and calling the Δ21 the solar neutrino is just the historical fact that a limit was first given using a two neutrino oscillation model.


Making JavaFX compile to Java 1.6 level source code

Question: How do I make JavaFX with netbeans compile my code to 1.6 level compliance.
At the moment it seems to be hard coded to 1.5 levels - stopping me from using useful tools in java.awt.Desktop (and the like)
Answer: Remember - because JavaFX must run on the Apple Java run-time which currently is Java 1.5 - JavaFX can't compile to Java 1.6.
Thus it likely will change in the future so that it can compile to Java 1.6.
Answer: Here's a good explanation by Stephen Chin: http://steveonjava.com/2009/01/02/hacking-javafx-10-to-use-java-16-features/
Also, Steve's blog on JavaFX is great if you're getting into the new language.


Normal map not working correctly

Question: I followed along with a tutorial which shows you step by step how to create a normal map. Parts of the normal maps shows on the default cube mesh when I render, but it shows the outlines of the default cube. Help will be much appreciated! Thanks
Comment: An illustration would help here ... but bear in mind unlike a displacement map, a normal map will not _actually_ displace the surface of an object, it will only alter the shading, as if the object's surface normals were tilted in the various directions encoded in the map.
Comment: try a lower strength value (like 1 or lower) as 10 is usually too high.
Answer: your normal map looks quite good no obvious artifacts or anything wrong with it, same goes for your Image Texture node and the rest in the node editor.
imho I would suggest you to do a quick retopo in order to keep (roughly) the basic shape of your sculpted cube (hi-poly). Normal maps are not able to follow curvatures and they cant fake the edges so it is not that strange you get this result. You need a minimum of actual geometry to use them sufficiently !
Answer: bevelling the edges should fix this, you may also need to set the auto smooth angle quite high in the objects data parameters.
Answer: Your scene has two objects - Cube and Cube.001.
It looks like Cube is on layer1, which is not visible in the viewport but is still rendered, while Cube.001 is on layer2 which is the only layer you are looking at in the viewport.
Read more about scene layers here. In the 3D view header, you can see a little dot in each layer that has an object, the visible layers (only layer2) are highlighted.

If you don't want the Cube object you can delete it from your scene. If you want to keep the other object, you can hide it when rendering by turning off the camera in the outliner.

You can also adjust your render layers so that only certain scene layers are visible in the render.

Normal map not working correctly


Does $\int_a^bf(x) = 0$ imply $f(x) = 0$ for a Riemann Integral function?

Question: Let $a < b$ and $f:[a, b] \rightarrow \mathbb R$ be a Riemann integral function. Suppose that $f(x) \geq 0$ for all $x \in [a, b]$. I want to show whether $\int_a^bf(x) = 0$ implies $f(x) = 0$ or not, but I'm not sure where to start. I don't know much about Riemann integral functions in general. I only know that $$\underline{\int_a^b} f=  \overline{\int_a^b} f.$$ Also, I know the fact that if $f$ is continuous, then $f(x) = 0$ for all $x\in [a, b]$. Can anyone provide any hints for me, because I'm really confused about this whole thing.
Comment: What about a function which is $0$ everywhere, except $1$ in $a$?
Comment: $f$ can be strictly positive at countably many points with the integral still being zero.
Comment: Indeed, $f$ can be non zero at an uncountable number of points and the integral is still zero.
Answer: Suppose that $f : [a,b] \to [0,\infty)$ is Riemann integrable and that
$$ \int_{a}^{b} f(x)\,\mathrm{d}x = 0. $$
As noted in the question, if $f$ is continuous on $[a,b]$, then $f(x) = 0$ for all $x \in [a,b]$.  This particular result has been demonstrated repeatedly on Math StackExchange, see, for example, this post and the posts linked to that post (on the sidebar to the right once you click the link).
If the hypothesis of continuity is dropped, the result no longer holds.  For example, fix some point $c \in [a,b]$ and consider a function $f$ defined by
$$ f(x)
= \begin{cases}
1 & \text{if $x = c$, and} \\
0 & \text{otherwise.}
\end{cases}
$$
This function is not identically zero, but
$$ \int_{a}^{b} f(x)\,\mathrm{d}x = 0. $$
Indeed, if $C = \{c_n\}_{n\in \mathbb{N}}$ is some countable collection of points in the interval $[a,b]$ and $\{a_n\}_{n\in\mathbb{N}}$ is a collection of positive numbers, then the function
$$ f(x)
= \begin{cases}
a_n & \text{if $x = c_n \in C$, and} \\
0 & \text{otherwise}
\end{cases}
$$
is a nonzero function which integrates to zero.  In other words, a nonnegative Riemann integrable function may be strictly positive on a countable collection of points and still integrate to zero.
Hence knowing that a nonnegative function integrates to zero on some interval is not sufficient to conclude that the function is identically zero on that interval.  One either needs to adjust the hypotheses to include continuity, or one needs to introduce a notion of being zero "almost everywhere".
Comment: Yes. *If* a function is Riemann integrable then Riemann and Lebesgue integral have the same value, so that $\int_{a}^{b} f(x)\,dx = 0$ for a non-negative Riemann integrable function implies $f(x) = 0$ a.e. It is also equivalent to $f(x) = 0$ at all continuity points of $f$: https://math.stackexchange.com/q/2367718/42969.
Comment: @MartinR Thank you for the link.  I spent a few minutes searching for such post, but clearly do not possess the search-fu that you do.


Crown Matrimonial

Question: So I was thinking, about the next king of England, Prince Charles. When he becomes king and if he decides to name Camilla the queen consort in due time, could he decide and does he have the power and authority to grant her the crown matrimonial, thus naming her his equal and they would co-reign? If he were to die before her, could she refuse Prince William the throne until she wants to grant him it? Also, is the crown matrimonial something that even still exists.
Comment: As it's written this is a question of [law](https://law.stackexchange.com/) rather than one of history, therefore, it seems off-topic here
Comment: As with *suo uxoris* in general, this is something historically demanded by the husbands of  queen regnants, not vice versa. Even if it was still a thing, it wouldn't apply to Camilla.
Comment: Technically Camilla could become Queen regnant without a coup or changing the laws.  She had some descent from British nobles, therefore she almost certainly has some descent from British royalty.  Therefore if enough descendants of British royalty die, Camilla will become the rightful Queen regnant.  Of course if uncounted (by me, at least) thousands of British and foreign royals and nobles die, making Camilla the rightful Queen, and Camilla doesn't die along with them, everyone will suspect her of arranging the deaths to become queen.
Answer: No, impossible. There is a big difference between a queen regnant and a queen consort. Camilla can, as Maxima Zorreguita did, become queen consort. You do that by marrying a crown prince or king (Edward VIII tried that). As consort of course she'll wield huge influence on the king. All wives do.
It is impossible for Charles to appoint his wife co ruler. Parliament will never accept that. They already have some beef about her becoming queen consort, as I understand. (They probably worry about the above influence.) Let alone co-ruler or take up the throne herself, supposing Charles would die first. The rules simply don't allow for it. No matter what happens, Camilla can never ever become Camilla I of England. Not unless she commits a coupe.
Here's a nice short clip how it works: https://www.youtube.com/watch?v=BUY6HGqYweQ
The United Kingdom together with most other European monarchies are parliamentarian monarchies. What you describe comes close to an absolute monarchy. In a parliamentarian monarchy the king carries the title and little else. That 'little else' can be quite a lot, I admit. But the king needs approval for it in parliament.
Here's an example:
In Belgium king Baudouin refused to countersign an abortion bill, already passed by parliament. Without his signature that bill was not valid. That could have been a real constitutional crisis. Parliament had approved. The government would have to resign. New elections. The next government would face exactly the same problem. Thus, new elections. Ad infinitum.
The solution was that the king was declared temporarily incapable of governing for 24 hours. In his absence the government became regent, and countersigned the bill. Everybody happy.
King Baudouin was very devout Roman Catholic and as such refused to countersign that bill, as the law required. His conscience  wouldn't allow it. That means a different solution had to be found. This is the heaviest weapon a constitutional monarch can yield. They normally don't use it, unless it is very important, very often for themselves.
Example: Queen Juliana of the Netherlands refused to accept 'A' and 'B' princes. (That royal family breeds faster than bunnies do, they have a lot of princes/princesses not in line for the throne. The government wanted to reduce royal costs by creating 'A' princes; in line for the throne with more benefits and 'B' princes; the remainder, with less benefits.) She would rather abdicate than countersign. The government gave in. All princess and princesses receive lots of state benefits today.
They run a serious risk that the government refuses a compromise or to give in. In that case, they have to abdicate. That includes the possibility of a republic. In case no heir is available, or the heir supports the monarch.
To get back to your question; suppose Charles would insist on it? Well, he wouldn't be the first one to be mad. George III was. Parliament would not accept it. Very likely he would be declared insane, a regent appointed, end of story.
--
I stressed the countersign, because kings and queens do no longer sign laws first. The government does. Only then they countersign that law, and after their signature the bill becomes law.
Comment: Good answer, but I'd like to point that under parliamentary sovereignty, Camilla (or anybody else) doesn't need a coup to became regnant queen; they just need an act of parliament. However, it's so unlikely (with or without a coup) that your answer that she can't be regnant queen is right for any practical purpose.
Comment: Agree with what you've written, but I would suggest that you explicitly mention that after the Glorious Revolution, Parliament is supreme.
Comment: The bit about Dutch Royalty is incorrect. There are 2 groups of princes; those in the "Royal Family" and a subset of those are also in the "Royal House". All are _theoretically_ in line for succession.
Comment: @MSalters : incorrect. Some members and their descendants are not in line for the throne. As we have a shitload of royal brads, not even theoretically.
Comment: @Jos: I disagree with your last comment there, but I am glad that you agree with me that there are two classes. Whether you call them "A" versus  "B" princes, or " Royal House" / "Royal Family", either way it contradicts your idea that Queen Juliana could prevent such a split. Not that your statement about benefits is even close to correct - even princes in the direct line of succession do not qualify. Currently only the King, his wife and his mother get any benefits - so not a single prince.

Crown Matrimonial


Can KWallet manage my ssh passwords?

Question: I need a way to store some SSH passwords. Note that these are login passwords which I need to pass to ssh; key authentication is unfortunately not an option. I'd like to be able to have KWallet fill them in for me somehow, because I think Gnome-keyring can do this. Does anyone know if KDE has this functionality in KWallet? And if so, how I can set it up to make use of it?
Answer: I don't have KDE handy but I poked at gnome-keyring a little bit and it looks like it accomplishes this by providing the ssh client with an alternate askpass program.
Check the value of $KWALLET_ASKPASS from your terminal in KDE. If it is set to something try this: export SSH_ASKPASS=$KWALLET_ASKPASS.
If not look around through your distro's packages and see if there is an askpass replacement program associated with kwallet. If so, set SSH_ASKPASS to that program.
Comment: Does that work even for a password (as opposed to a key passphrase)? OpenSSH is very finicky about reading passwords only from a terminal.
Answer: There is a KDE feature request from 2004 to use kwallet as an ssh agent. You might want to comment or vote on that bug.
Answer: Seems to be possible now using ksshaskpass (https://archlinux.org/packages/?name=ksshaskpass) using something similar to what Caleb suggested.
guide here https://wiki.archlinux.org/title/KDE_Wallet#Using_the_KDE_Wallet_to_store_ssh_key_passphrases
Comment: Unfortunately this refers to SSH Key passphrases, not basic login passwords.
Comment: I see, i'm sorry i misunderstood.
Maybe a script could be created, to poll the credentials from kwallet and pipe to the process needing it.

Can KWallet manage my ssh passwords?


Stub external service requests for functional tests with symfony di container

Question: question summary
Is it possible to inject stubs/mocks to the symfony di container in my test cases to simulate different external api responses?

test that my application sends an email if the api returns an error (i want to inject a stub for my http client class that returns a HTTP 500)
test that my application returns the correct result using 2 different APIs as source (i want to inject both HTTP Clients as stub with a specific result body)

details
i want to write functional tests for an silex application that uses the symfony di container. The application uses multiple API's as backend to fullfill the client reuquests.
The code injects an abstracted http client to the api client where i'm able to inject a http api client stub.
class AwesomeApiClient
   __construct(MyHttpClient $httpClient);

class MyApiHttpClient

This does work pretty good with unit testing.
Now i want to write functional tests.
I extended the silex WebTestCase and implemented the application initialization.
The MyApiHttpClient is injected with the symfony di container.
Now i want to do something like this:
# symfony di container does not allow this
$this->getDiContainer()->set('my_http_client', $myHttpClientStubInstance);

i want to configure my stub in every test so i'm able to test different (e.g. error, success) responses for the same request.
things i've tried:
using setter injection at runtime
$his->getDiContainer()->get('MyApiClient')->setHttpClient($myMock);
The DiContainer returns a new instance for everytime i call the get method. That does make absolutely sense. So this does not work.
overriding the http client in the di container
$this->getDiContainer->set('MyHttpClient', $myHttpClientStub);
Does not work because symfony does not allow to change definitions at runtime. Also it seems to take a definition, not an instance.
PHP-VCR
Does work with a few changes in my production code because it messes up the HTTP Headers in my curl header callbacks. Does not work for other services (rabbitmq...)
Answer: According to this, it should be possible to set mock in the DI container.
$client = self::createClient();

$serviceA = $this->getMockBuilder('ServiceA')
    ->disableOriginalConstructor()
    ->getMock();

$client->getContainer()->set('my_bundle.service.a', $serviceA);


My mom was once cheating . Is it compulsory for me to show love and care her

Question: Assalamu alaikum ,I am 20yrs old now.i am from india ,My father is still working in Riyadh and he visits us 2years once and also he privide us whatever my family needs. when i was 11 i found out my mom cheating with neighbor who was 24yrs old at that time . I found out when they talking double meaning & flirting in front of me . Also found messages (text) that man sent to my mother [ i wont live without you , talk to me , pick my phone ] . And even she went to his marriage 2yrs later and present him Table fan . Now she has no connection with him . I have not told this to anyone till now. I think she regret what she had done and even she prays and read quran now
The question is ...  Now she is suffering ill and i have no sympathy or empathy for her. Is it compulsory for me to show love and care towards her .
Answer: She was unfaithful to your father, but ultimately didn't follow through with it and now she has repented. Even if they engage in shirk it is taught to show kindness to parents. Cheating on her husband is a comparatively minor transgression.

But if they (both) strive with you to make you join in worship with Me
others that of which you have no knowledge, then obey them not; but
behave with them in the world kindly, and follow the path of him who
turns to Me in repentance and in obedience. Then to Me will be your
return, and I shall tell you what you used to do.
https://quran.com/31/15

Narrated Asma 'bint Abi Bakr: During the period of the peace treaty of
Quraish with Allah's Messenger (ﷺ), my mother, accompanied by her
father, came to visit me, and she was a pagan. I consulted Allah's
Messenger (ﷺ), "O Allah's Messenger (ﷺ)! My mother has come to me and
she desires to receive a reward from me, shall I keep good relation
with her?" He said, "Yes, keep good relation with her."
Sahih al-Bukhari 3183 https://sunnah.com/bukhari:3183


Time dependent Workflow - converting lead

Question: I have a time dependent workflow on a lead date field, i.e. if a lead is inactive for 30 days, then change the status field to inactive and reassign to an "unassigned leads" queue. The problem is, that if I have this time based workflow on my lead, I cannot convert this lead! Is there a workaround for this problem?
Answer: There is indeed workaround this problem. There is a similar question already here. But basically you will need somehow to delete the pending action from the time-based workflow queue before to convert your lead. For example, you can update a field that will reevaluate the criteria and cancel the time based workflow.


Client viewing before deployment

Question: I'm currently building a site on my local computer. I will transfer the finished product onto my client's new host/domain. Before he chooses this, what's the best way for him to view my current progress?
Comment: Welcome to WPSE! Questions should really be specific to WordPress. Your question as stated isn't really a WP question, but is more of a general development/hosting question. It might be better posted to https://stackoverflow.com
Answer: there is a lot of plugins where you can make all modifications on your theme, plugins and only logged users will see those changes, so you could show your client while for not logged in users will see "Maintenance" or "Soon" mode.
Also you can make a authentication log in system on your host "If that permit" to see your changes.
Answer: If you are using doing it on your device, the best way to share progress is by sharing the full page screenshot or by sharing screen using any software you want.
And it would be better to do the designing on production site, since you can stop others from seeing it using plugins.

Client viewing before deployment


Force user to allow facebook permissions using Graph API

Question: I developed Facebook application and I have some problems on "Allow access step",In initial stage user must authorize app and permissions.Currently if users skip extended permissions also landing to application home page , But I need to force user to accept all permissions, I got success when using FQL method , Now its not working , I cant find out the solution. Here is my code
<code>$TotalPermissions = UserAndFriendsPermissions();
return true;
$tp = substr_replace($TotalPermissions ,"",-1);
$this->loadClassFile("Facebook", MAIN_PLUGIN_PATH."Common/facebook/facebook.php");
$facebook = new Facebook(array('appId'  => $FBConnect["fb_app_id"],'secret' => $FBConnect["fb_secret_key"],));
$params = array('method' => 'fql.query','query' => "SELECT ".$tp." FROM permissions WHERE uid=me()");

$result = $facebook->api($params);
$totalp = count(explode(",",$tp));
$ap=0;
foreach ($result[0] as $key => $val)
{
if($val==1)
 {
   $ap++;
                        }
                    }
                    if($ap==$totalp)
                    {
                    return true;
                    }
                    else
                    {
                    ?>

                    <?php
                    Redirect("https://apps.facebook.com/APP_NAMESPACE");
                    }
</code>
Answer: You cannot force users to accept all your extended permissions. What you can do is to check for permissions given and handle those cases accordingly i.e. redirecting users who have not given permission to a landing page which explains why you need those permissions.


Android widget update frequency 0, what it actually means?

Question: I have found the following parts of code in a widget:
<code><appwidget-provider>
    android:updatePeriodMillis="0"
<appwidget-provider/>
</code>
Now, my question is now that: what it does mean with updatePeriodMillis set to 0.

I know that it is set for the how often the widget will receive remoteview or others. so, what is the significance to set it to 0.
Comment: it is time in millis for updating the widget
Answer: When you Set updatePeriodMillis to 0, You are actually disabling the update period on that particular widget. Means, that property is no more applicable to that widget.
Answer:
According to android documentation:

The updatePeriodMillis attribute defines how often the App Widget framework should request an update from the AppWidgetProvider by calling the onUpdate() callback method. The actual update is not guaranteed to occur exactly on time with this value and we suggest updating as infrequently as possible—perhaps no more than once an hour to conserve the battery. You might also allow the user to adjust the frequency in a configuration—some people might want a stock ticker to update every 15 minutes, or maybe only four times a day.
Note: If the device is asleep when it is time for an update (as defined by updatePeriodMillis), then the device will wake up in order to perform the update. If you don't update more than once per hour, this probably won't cause significant problems for the battery life. If, however, you need to update more frequently and/or you do not need to update while the device is asleep, then you can instead perform updates based on an alarm that will not wake the device. To do so, set an alarm with an Intent that your AppWidgetProvider receives, using the AlarmManager. Set the alarm type to either ELAPSED_REALTIME or RTC, which will only deliver the alarm when the device is awake. Then set updatePeriodMillis to zero ("0").
Comment: While this is exactly what the documentation says,  it doesn't answer the question.  That's why I looked for an answer in the first place. -1
Answer: According to Android developers
How often, in milliseconds, that this AppWidget wants to be updated. The AppWidget manager may place a limit on how often a AppWidget is updated.
This field corresponds to the android:updatePeriodMillis attribute in the AppWidget meta-data file.
Note: Updates requested with updatePeriodMillis will not be delivered more than once every 30 minutes.


Multithreading: What is the point of more threads than cores?

Question: I thought the point of a multi-core computer is that it could run multiple threads simultaneously. In that case, if you have a quad-core machine, what's the point of having more than 4 threads running at a time? Wouldn't they just be stealing time (CPU Resources) from each other?
Comment: When was the last time you had Firefox, MS Word, Winamp, Eclipse and a download manager (more than four programs/processes) running simultaneously on your quad core machine? Also, a single application might sometimes spawn more than four threads - how about that?
Comment: @Amarghosh I guess that was the question, why single application may want to spawn more threads than cores if it doesn't seem to bring any performance benefit. And your example with more than four programs is not quite relevant here. As you correctly noted, those are processes. OS multitasking feature (process multiplexing) has very little to do with threads within one process.
Comment: Stealing is not necessarily bad. You may have a thread with a higher priority for important tasks that need to steal time.
Answer: The answer revolves around the purpose of threads, which is parallelism: to run several separate lines of execution at once.  In an 'ideal' system, you would have one thread executing per core: no interruption.  In reality this isn't the case.  Even if you have four cores and four working threads, your process and it threads will constantly be being switched out for other processes and threads.  If you are running any modern OS, every process has at least one thread, and many have more.  All these processes are running at once.  You probably have several hundred threads all running on your machine right now.  You won't ever get a situation where a thread runs without having time 'stolen' from it.  (Well, you might if it's running real-time, if you're using a realtime OS or, even on Windows, use a real-time thread priority.  But it's rare.)
With that as background, the answer: Yes, more than four threads on a true four-core machine may give you a situation where they 'steal time from each other', but only if each individual thread needs 100% CPU.  If a thread is not working 100% (as a UI thread might not be, or a thread doing a small amount of work or waiting on something else) then another thread being scheduled is actually a good situation.
It's actually more complicated than that:

What if you have five bits of work that all need to be done at once?  It makes more sense to run them all at once, than to run four of them and then run the fifth later.
It's rare for a thread to genuinely need 100% CPU.  The moment it uses disk or network I/O, for example, it may be potentially spend time waiting doing nothing useful.  This is a very common situation.
If you have work that needs to be run, one common mechanism is to use a threadpool.  It might seem to make sense to have the same number of threads as cores, yet the .Net threadpool has up to 250 threads available per processor.  I'm not certain why they do this, but my guess is to do with the size of the tasks that are given to run on the threads.

So: stealing time isn't a bad thing (and isn't really theft, either: it's how the system is supposed to work.)  Write your multithreaded programs based on the kind of work the threads will do, which may not be CPU-bound.  Figure out the number of threads you need based on profiling and measurement.  You may find it more useful to think in terms of tasks or jobs, rather than threads: write objects of work and give them to a pool to be run.  Finally, unless your program is truly performance-critical, don't worry too much :)
Comment: +1 for "but only if each individual thread needs 100% CPU". That was the assumption I didn't realize I was making.
Comment: Great answer overall. One thing I'm missing is the mention of the terms "Interrupt signal" and "context switch". Both are fundamental to understanding the above, in my honest opinion.
Answer: Just because a thread exists doesn't always mean it's actively running. Many applications of threads involve some of the threads going to sleep until it's time for them to do something - for instance, user input triggering threads to wake up, do some processing, and go back to sleep.
Essentially, threads are individual tasks that can operate independently of one another, with no need to be aware of the progress of another task. It's quite possible to have more of these than you have ability to run simultaneously; they're still useful for convenience even if they sometimes have to wait in line behind one another.
Comment: Well said.   The 'one thread per CPU' argument only applies to CPU-bound code.   Asynchronous programming is another reason to use threads.
Answer: The point is that, despite not getting any real speedup when thread count exceeds core count, you can use threads to disentangle pieces of logic that should not have to be interdependent.
In even a moderately complex application, using a single thread try to do everything quickly makes hash of the 'flow' of your code. The single thread spends most of its time polling this, checking on that, conditionally calling routines as needed, and it becomes hard to see anything but a morass of minutiae.
Contrast this with the case where you can dedicate threads to tasks so that, looking at any individual thread, you can see what that thread is doing. For instance, one thread might block waiting on input from a socket, parse the stream into messages, filter messages, and when a valid message comes along, pass it off to some other worker thread. The worker thread can work on inputs from a number of other sources. The code for each of these will exhibit a clean, purposeful flow, without having to make explicit checks that there isn't something else to do.
Partitioning the work this way allows your application to rely on the operating system to schedule what to do next with the cpu, so you don't have to make explicit conditional checks everywhere in your application about what might block and what's ready to process.
Comment: This is an interesting thought... I'd always heard that multithreading an app is a net addition of complexity, but what you're saying makes sense.
Comment: Should point out, though, that using threads can only simplify things up to a certain point. All too often the attempt is made to make two threads do the work that should rightly be done by one, at which the complexity comes back in spades. The symptoms of this are excessive needs for communication and synchronization in order to coordinate some desired outcome.
Comment: Multithreading an app adds complexity if its concerns are not adequately separated.  If it's designed with minimal overlap of concerns (and thus shared state) it is a net save in complexity issues.
Comment: There are ways to structure single-threaded applications so that control-flow is clearer at the level you write programs. OTOH, if you can structure your threads so that they only pass messages to each other (instead of having shared resources) then it's pretty simple to work out what's going on and make everything work.
Comment: I think it's misleading to say we do not get "any real speedup" if # of threads > # of cores. It's simply not true. As other answers stated due to smart context switching on idle times of threads while waiting for I/O or whatever else, a significant performance improvement can be achieved by using more threads than cores.
Answer: If a thread is waiting for a resource (such as loading a value from RAM into a register, disk I/O, network access, launch a new process, query a database, or wait for user input), the processor can work on a different thread, and return to the first thread once the resource is available. This reduces the time the CPU spends idle, as the CPU can perform millions of operations instead of sitting idle.
Consider a thread that needs to read data off a hard drive.
In 2014, a typical processor core operates at 2.5 GHz and may be able to execute 4 instructions per cycle. With a cycle time of 0.4 ns, the processor can execute 10 instructions per nanosecond. With typical mechanical hard drive seek times are around 10 milliseconds, the processor is capable of executing 100 million instructions in the time it takes to read a value from the hard drive. There may be significant performance improvements with hard drives with a small cache (4 MB buffer) and hybrid drives with a few GB of storage, as data latency for sequential reads or reads from the hybrid section may be several orders of magnitude faster.
A processor core can switch between threads (cost for pausing and resuming a thread is around 100 clock cycles) while the first thread waits for a high latency input (anything more expensive than registers (1 clock) and RAM (5 nanoseconds)) These include disk I/O, network access (latency of 250ms), reading data off a CD or a slow bus, or a database call. Having more threads than cores means useful work can be done while high-latency tasks are resolved.
The CPU has a thread scheduler that assigns priority to each thread, and allows a thread to sleep, then resume after a predetermined time. It is the thread scheduler's job to reduce thrashing, which would occur if each thread executed just 100 instructions before being put to sleep again. The overhead of switching threads would reduce the total useful throughput of the processor core.
For this reason, you may want to break up your problem in to a reasonable number of threads. If you were writing code to perform matrix multiplication, creating one thread per cell in the output matrix might be excessive, whereas one thread per row or per n rows in the output matrix might reduce the overhead cost of creating, pausing, and resuming threads.
This is also why branch prediction is important. If you have an if statement that requires loading a value from RAM but the body of the if and else statements use values already loaded into registers, the processor may execute one or both branches before the condition has been evaluated. Once the condition returns, the processor will apply the result of the corresponding branch and discard the other. Performing potentially useless work here is probably better than switching to a different thread, which could lead to thrashing.
As we have moved away from high clock-speed single-core processors to multi-core processors, chip design has focused on cramming more cores per die, improving on-chip resource sharing between cores, better branch prediction algorithms, better thread switching overhead, and better thread scheduling.
Comment: the same can be done with a single thread and a queue though :\ is there really any benefit to having 80 threads on 2-4 cores, over just having 2-4 cores that just eat up tasks off a queue as soon as they arrive and they have nothing to do?
Answer: Most of the answers above talk about performance and simultaneous operation.  I'm going to approach this from a different angle.
Let's take the case of, say, a simplistic terminal emulation program.  You have to do the following things:

watch for incoming characters from the remote system and display them
watch for stuff coming from the keyboard and send them to the remote system

(Real terminal emulators do more, including potentially echoing the stuff you type onto the display as well, but we'll pass over that for now.)
Now the loop for reading from the remote is simple, as per the following pseudocode:
while get-character-from-remote:
    print-to-screen character

The loop for monitoring the keyboard and sending is also simple:
while get-character-from-keyboard:
    send-to-remote character

The problem, though, is that you have to do this simultaneously.  The code now has to look more like this if you don't have threading:
loop:
    check-for-remote-character
    if remote-character-is-ready:
        print-to-screen character
    check-for-keyboard-entry
    if keyboard-is-ready:
        send-to-remote character

The logic, even in this deliberately simplified example that doesn't take into account real-world complexity of communications, is quite obfuscated.  With threading, however, even on a single core, the two pseudocode loops can exist independently without interlacing their logic.  Since both threads will be mostly I/O-bound, they don't put a heavy load on the CPU, even though they are, strictly speaking, more wasteful of CPU resources than the integrated loop would be.
Now of course real-world usage is more complicated than the above.  But the complexity of the integrated loop goes up exponentially as you add more concerns to the application.  The logic gets ever more fragmented and you have to start using techniques like state machines, coroutines, et al to get things manageable.  Manageable, but not readable.  Threading keeps the code more readable.
So why would you not use threading?
Well, if your tasks are CPU-bound instead of I/O-bound, threading actually slows your system down.  Performance will suffer.  A lot, in many cases.  ("Thrashing" is a common problem if you drop too many CPU-bound threads.  You wind up spending more time changing the active threads than you do running the contents of the threads themselves.)  Also, one of the reasons the logic above is so simple is that I've very deliberately chosen a simplistic (and unrealistic) example.  If you wanted to echo what was typed to the screen then you've got a new world of hurt as you introduce locking of shared resources.  With only one shared resource this isn't so much a problem, but it does start to become a bigger and bigger problem as you have more resources to share.
So in the end, threading is about many things.  For example, it's about making I/O-bound processes more responsive (even if less efficient overall) as some have already said.  It's also about making logic easier to follow (but only if you minimize shared state).  It's about a lot of stuff, and you have to decide if its advantages outweigh its disadvantages on a case by case basis.
Answer: I strongly disagree with @kyoryu's assertion that the ideal number is one thread per CPU.
Think about it this way: why do we have multi-processing operating systems? For most of computer history, nearly all computers had one CPU. Yet from the 1960s on, all "real" computers had multi-processing (aka multi-tasking) operating systems.
You run multiple programs so that one can run while others are blocked for things like IO.
lets set aside arguments about whether Windows versions before NT were multi-tasking. Since then, every real OS had multi-tasking. Some don't expose it to users, but its there anyway, doing things like listening to the cellphone radio, talking to the GPS chip, accepting mouse input, etc.
Threads are just tasks that are a bit more efficient. There is no fundamental difference between a task, process, and thread.
A CPU is a terrible thing to waste, so have lots of things ready to use it when you can.
I will agree that with most procedural languages, C, C++, Java etc, writing proper thread safe code is a lot of work. With 6 core CPUs on the market today, and 16 core CPUs not far away, I expect that folks will move away from these old languages, as multi-threading is more and more of a critical requirement.
Disagreement with @kyoryu is just IMHO, the rest is fact.
Comment: If you've got lots of **processor-bound** threads, then the ideal number is one per CPU (or perhaps one less, to leave one to manage all the I/O and the OS and all that stuff). If you've got *IO-bound* threads, you can stack quite a lot on a single CPU. Different apps have different mixes of processor-bound and IO-bound tasks; that's totally natural, but why you have to be careful with universal declarations.
Comment: Of course, the most important difference between threads and processes is that on Windows there is no fork(), so process creation is really expensive, leading to over use of threads.
Comment: Except for protein folding, SETI, etc. there are no practical user tasks that are compute bound for very long. There is always a need to get info from the user, talk to the disk, talk to the DBMS, etc.

Yeah, the expense of fork() is one of the many things that Cutler cursed NT with that others at DEC knew.
Answer: Although you can certainly use threads for speeding up calculations depending on your hardware, one of their main uses is to do more than one thing at a time for user-friendliness reasons.
For example, if you have to do some processing in the background and also remain responsive to UI input, you can use threads. Without threads, the user interface would hang every time you tried to do any heavy processing.
Also see this related question: Practical uses for threads
Comment: UI handling is a classic example of an IO-bound task. It's not good to have a single CPU core doing both processing and IO tasks.
Answer: Imagine a Web server that has to serve an arbitrary number of requests. You have to serve the requests in parallel because otherwise each new request has to wait until all the other requests have been completed (including sending the response over the Internet). In this case, most web servers have way less cores than the number of requests they usually serve.
It also makes it easier for the developer of the server: You only have to write a thread program that serves a request, you don't have to think about storing multiple requests, the order you serve them, and so on.
Comment: You are writing software for an operation system that supports threading but has no capacity for multiplexing io? I think the web server is probably a bad example since in this case multiplexing io is almost always gonna be more efficient than spawning more threads than cores.
Answer: Many threads will be asleep, waiting for user input, I/O, and other events.
Comment: For sure. just use Task Manager on Windows or TOP on real OS, and see how many tasks/processes are alseep. Its always 90% or more.
Answer: Threads can help with responsiveness in UI applications.  Additionally, you can use threads to get more work out of your cores.  For instance, on a single core, you can have one thread doing IO and another doing some computation.  If it were single threaded, the core could essentially be idle waiting for the IO to complete.  That's a pretty high level example, but threads can definitely be used to pound your cpu a bit harder.
Comment: More specifically, one thread can be *waiting* on I/O while another does computation.  If I/O took (significant) CPU cycles, there'd be no benefit to running it in a separate thread.  The benefit is that your computation thread can run while your I/O thread is twiddling its thumbs waiting for a big aluminum cylinder to spin into place, or for packets to arrive over the wire from Iceland, or whatever.
Answer: A processor, or CPU, is the physical chip that is plugged into the system. A processor can have multiple cores (a core is the part of the chip that is capable of executing instructions). A core can appear to the operating system as multiple virtual processors if it is capable of simultaneously executing multiple threads (a thread is a single sequence of instructions).
A process is another name for an application. Generally, processes are independent of each other. If one process dies, it does not cause another process to also die. It is possible for processes to communicate, or share resources such as memory or I/O.
Each process has a separate address space and stack. A process can contain multiple threads, each able to execute instructions simultaneously. All the threads in a process share the same address space, but each thread will have its own stack.
Hopefully with these definitions and further research using these fundamentals will help your understanding.
Comment: I don't see how this addresses his question at all.  My interpretation of his question is about thread usage of cores and optimal use of the available resources, or about behaviour of threads as you increase their number, or something along those lines anyway.
Comment: @David perhaps it wasn't a direct answer to my question, but I still feel I learned by reading it.
Answer: The way some API are designed, you have no choice but to run them in a separate thread (anything with blocking operations). An example would be Python's HTTP libraries (AFAIK).
Usually this isn't much of a problem though (if it is a problem, the OS or API should ship with an alternative asynchronous operating mode, ie: select(2)), because it probably means the thread is going to be sleeping during waiting for I/O completion. On the other hand, if something is doing a heavy computation, you have to put it in a separate thread than say, the GUI thread (unless you enjoy manual multiplexing).
Answer: The ideal usage of threads is, indeed, one per core.
However, unless you exclusively use asynchronous/non-blocking IO, there's a good chance that you will have threads blocked on IO at some point, which will not use your CPU.
Also, typical programming languages make it somewhat difficult to use 1 thread per CPU.  Languages designed around concurrency (such as Erlang) can make it easier to not use extra threads.
Comment: Using threads for periodic tasks is a very common and welcome workflow, and it would be much less than ideal if they stole a core.
Comment: @Nick Bastin: Yes, but it's more efficient to stick those tasks into a task queue and execute them from that queue (or a similar strategy).  For optimal efficiency, 1 thread per core beats all, as it prevents overhead from unnecessary context switching and extra stacks being allocated.  No matter what, the periodic task *must* steal a core while 'active,' as the cpu can only actually perform one task per core (plus stuff like hyperthreading if available).
Comment: @Nick Bastin:  Unfortunately, as I said in the main answer, most modern languages don't lend themselves well to easily implementing a system which does this effectively is not trivial - you end up doing some amount of fighting typical usage of the language.
Comment: My point isn't that one thread per core isn't optimal, it's that one thread per core is a pipe dream (unless you're embedded) and designing to try to hit it is a waste of time, so you might as well do what makes it easy for you (and isn't any less efficient on a modern scheduler anyhow), rather than trying to optimize the number of threads you're using.  Should we spin up threads for no good reason?  Of course not, but whether you're unnecessarily wasting computer resources is a concern regardless of threading.
Comment: @Nick Bastin:  So, to summarize, one thread per core is ideal, but actually achieving that isn't very likely.  I probably should have been stronger than 'somewhat difficult' when talking about how likely it is to actually achieve such a thing.
Answer: In response to your first conjecture:  multi-core machines can simultaneously run multiple processes, not just the multiple threads of a single process.
In response to your first question:  the point of multiple threads is usually to simultaneously perform multiple tasks within one application.  The classic examples on the net are an email program sending and receiving mail, and a web server receiving and sending page requests.  (Note that it's essentially impossible to reduce a system like Windows to running only one thread or even only one process.  Run the Windows Task Manager and you'll typically see a long list of active processes, many of which will be running multiple threads.)
In response to your second question:  most processes/threads are not CPU-bound (ie, not running continuously and uninterrupted), but instead stop and wait frequently for I/O to finish.  During that wait, other processes/threads can run without "stealing" from the waiting code (even on a single core machine).
Answer: I know this is a super old question with plenty of good answers, but I am here to point out something that is important in current environment:
If you want to design an application for multi-threading, you should not be designing for a specific hardware setting. CPU technology has been advancing quite rapidly for years, and core counts are increasing steadily. If you deliberately design your application such that it uses only 4 threads, then you are potentially restricting yourself in a octa-core system (for example). Now, even 20-core systems are commercially available, so such a design is definitely doing more harm than good.
Answer: A thread is an abstraction that enables You to write code as simple as a sequence of operation, blissfully unaware of that the code is executed interlaced with other code, or parked waiting for IO,  or (maybe somewhat more aware of) waiting for other thread's events or messages.
Comment: I might have edited this by adding more examples since the downvotes - but a thread (or process, in this context almost no difference) were not invented in order to scale up the performance, but rather to simplify asynchronous code and avoid writing complicated state machines that had to handle all super-states possible in the program. In fact there was typically one CPU even in large servers.  I'm, just curious why my answer is considered anti-helpful?
Answer: The point is that the vast majority of programmers do not understand how to design a state machine. Being able to put everything in its own thread frees the programmer from having to think about how to efficiently represent the state of different in-progress computations so that they can be interrupted and later resumed.
As an example, consider video compression, a very cpu-intensive task. If you're using a gui tool, you probably want the interface to remain responsive (show progress, respond to cancel requests, window resizing, etc.). So you design your encoder software to process a large unit (one or more frames) at a time and run it in its own thread, separate from the UI.
Of course once you realize it would have been nice to be able to save the in-progress encoding state so you can close the program to reboot or play a resource-hungry game, you realize you should have learned how to design state machines from the beginning. Either that, or you decide to engineer a whole new problem of process-hibernation your OS so you can suspend and resume individual apps to disk...
Comment: Not (quite!) worth a -1, but seriously, that is about the most stupidly snide thing I've heard anybody say on this subject.  I, for example, have no problems in implementing a state machine.  None at all.  I just don't like to use them when other tools are there that leave behind **clearer** and **easier to maintain** code.  State machines have their places, and in those places they can't be matched.  Interlacing CPU-intensive operations with GUI updates is not one of those places.  At the very least coroutines are a better choice there, with threading being even better.
Comment: To everyone mod'ing my answer down, this is NOT an argument against using threads! If you can code a state machine that's great, and sure it often makes sense to run state machines in separate threads even if you don't have to. My comment was that often the choice to use threads is made primarily out of the desire to avoid designing state machines, which many programmers consider "too hard", rather than for any other benefit.