Why are mirror images flipped horizontally but not vertically?

Question: Why is it that when you look in the mirror left and right directions appear flipped, but not the up and down?
Comment: On which plane are your (2) eyes oriented?
Comment: @user4577, "one-eyed" camera still sees left-right flip.
Comment: @user4577 - If that were the answer then by tilting my head 90 degrees I could expert the mirror to start inverting vertically rather than horizontally.  Only problem is, _that doesn't happen_.
Comment: And yet a lens turns the image upside down...
Comment: a mirror does NOT inverse left/right, but "inside/out". It's even one of the FAQs (I liked the Usenet time where it was the only good source of info, updated by all, and therefore the FAQs at that time were great : http://www.faqs.org/faqs/physics-faq/part3/ , question 20)
Comment: The issue with a normal mirror is an interesting puzzle, but I think the issue with a (round) double-convex *lens* makes the asymmetry even more obvious and striking. With the flat mirror you can kind of convince yourself that it is a bias of the left-right orientation of your human eyes, but with a round convex lens mirror there's (seemingly) nothing to explain the left-right swap, even though the lens itself is symmetrical...
Comment: It COULD flip you upside down, depending on the type of mirror (flat  vs concave vs convex)
Comment: If you analyze laws of reflection it is pretty obvious.
Comment: @OlivierDulac I read the FAQ you linked to because I was curious what inside/out could possibly mean. Should I see my skeleton when I look into a mirror? Anyway, the author, Scott I. Chase, says that mirrors reverse in/out, in particular the z-axis of the information traveling in and out.
Comment: Watch this video- [**"Mirrors by Physics Girl"**](https://m.youtube.com/watch?v=vBpxhfBlVLU).
Answer: Here's a video of physicist Richard Feynman discussing this question.
Imagine a blue dot and a red dot.  They are in front of you, and the blue dot is on the right.  Behind them is a mirror, and you can see their image in the mirror.  The image of the blue dot is still on the right in the mirror.
What's different is that in the mirror, there's also a reflection of you.  From that reflection's point of view, the blue dot is on the left.
What the mirror really does is flip the order of things in the direction perpendicular to its surface.  Going on a line from behind you to in front of you, the order in real space is

Your back
Your front
Dots
Mirror

The order in the image space is

Mirror
Dots
Your front
Your back

Although left and right are not reversed, the blue dot, which in reality is lined up with your right eye, is lined up with your left eye in the image.
The key is that you are roughly left/right symmetric.  The eye the blue dot is lined up with is still your right eye, even in the image.  Imagine instead that Two-Face was looking in the mirror. (This is a fictional character whose left and right side of his face look different.  His image on Wikipedia looks like this:)

If two-face looked in the mirror, he would instantly see that it was not himself looking back!  If he had an identical twin and looked right at the identical twin, the "normal" sides of their face would be opposite each other.  Two-face's good side is the right.  When he looked at his twin, the twin's good side would be to the original two-face's left.
Instead, the mirror Two-face's good side is also to the right.  Here is an illustration:

So two-face would not be confused by the dots.  If the blue dot is lined up with Two-Face's good side, it is still lined up with his good side in the mirror.  Here it is with the dots:

Two-face would recognize that left and right haven't been flipped so much as forward and backward, creating a different version of himself that cannot be rotated around to fit on top the original.
Comment: I just wanted to enhance this sentence of this answer because I believe it is the keypoint here: "What the mirror really does is flip the order of things in the direction perpendicular to its surface."
Comment: @Mark-eichenlaub: simply said: A mirror does NOT inverse left/right, but it reverse the "Inside/Out". It's even one of the FAQs (I liked the Usenet time where it was the only good source of info, updated by all, and therefore the FAQs at that time were great : http://faqs.org/faqs/physics-faq/part3 , question 20)
Comment: See 1:56 of [this video](http://www.youtube.com/watch?v=PxeU1sxXfPI) for a visualization of the axis reversal.
Comment: To add to this, I thought [this](https://www.youtube.com/watch?v=DYeZ8BWT31Y) video was the clearest explanation I've seen yet.
Comment: "Two-face would recognize that left and right haven't been flipped" But many people wouldn't. I think the correct answer is here: [Why do mirrors flip horizontally and not vertically?](https://penteract.net/blogs/blog04/Main/High-Tech/Science/Popular/why-do-mirrors-flip-horizontally.aspx) We "see" horizontal rotation because it's common.
Answer: Because they don't flip left with right (or up with down), they flip the 3D space you're standing in "inside out", so far from the mirror becomes far away inside the mirror and vice versa. A hand 1 meter from the mirror seems like it's 1 meter on the other side of the mirror but in the same spot with regards to left/right so nothing is flipped.
Wiggle your left hand - you'll see the hand which is to the left in the mirror wiggle. Wiggle your toes and the toes in the mirror image wiggle etc.
Comment: I was asked this question by a fellow Junior Fellow at Harvard who was convinced that it had to be the most important open question in early 21st century physics. ;-) By the way, there is one helpful twist. If you put a mirror on the ceiling above you, or the floor beneath you, it will reflect up and down, not left and right. Mirrors always reflect/exchange "in front of the mirror" and "behind the mirror". If we stand vertically, we just imagine that the person behind the mirror (the real image) is a real man and we rotate him by 180 degrees around the vertical axis.
Comment: Once we rotate the man in the mirror by 180 degrees around the vertical axis. he looks like a normal man ready to shake our hand. But the rotation by 180 degrees was artificially added. If $z$ is up-down and $x$ is left-right and $y$ is front/rear of the mirror, then the mirror which is in the $xz$ plane maps $y\to -y$ and keeps $x,z$. However, we can easily imagine rotations around vertical axes to make the mirror man look like the original man. Such a rotation changes the signs of $x,y$, so the sign flip of $y$ is replaced by a sign flip of $x$ - but the real transform only affects $y$!
Comment: I created/associated my account just to say that the first part of your explanation example (mirror on the ceiling) really clarifies well, you should post it as an answer!  The second part is a little more unclear, actually.
Comment: You don't answer the question.
Comment: This is a flip along the (defined) Z axis direction, which if you stand in front of a mirror is defined as the direction from your eyes to the mirror.
Answer: This common confusion stems from our familiarity with photographs. We forget that we rotate them to face ourselves.
Take a picture of yourself and hold it up in front of you. Probably you are holding it so that you can see your image. If so, you "flipped" the image of yourself when you rotated it 180 degrees around the vertical axis. When you look to the left side of the photo, you are looking over the right shoulder of your image. These directions are flipped!
Now look in a mirror. When you look to the left, you are looking over the left shoulder of your image. These directions are not flipped!
Now pick up the picture again and turn it so it's facing the same direction you are facing. You have removed the 180 degree rotation so that you and your image are "looking" in the same direction. The left side of your image is again to your left. If the picture is transparent enough that you can see your image, you'll see not the back of your head, but your eyes, giving you the impression that you're looking back at yourself. A mirror image! But again, left and right are not flipped.
When you say the mirror "flips" left and right, you are speaking from the frame of reference of one who is used to the 180 degree rotation that you apply to view an opaque photograph. But that's what we all do because we consider photographs, rotated 180 degrees to face ourselves, as being the "correct" left-right orientation.
What a mirror really flips is the depth dimension. That which is behind you appears to be in front of you.
Comment: Exactly. A mirror does **not** flip left and right. It is we who imagine another person in the mirror and change our frame of reference by "flipping" it. When I first read about mirrors flipping things (I was probably four or five), I found it confusing because I looked at the mirror and nothing was flipped. (It was only later that I learned to do the flipping with photographs and other people -- before that, I'd use to speak of the right hand of someone facing me as the left hand, because it was indeed to my left.)
Comment: The simple example: Write a few words on a transparent piece of plastic of some sort, then hold it up in front of yourself while looking in a mirror. You can read the text just fine in front of you, or in the mirror.
Comment: Great answer! I just imagine a photon emitting from my right eye, bouncing off the mirror, and then returning to my right eye. Nothing "flipped" there. The eye in the photograph that's directly across (or closest to) my right eye is actually my left eye, because I've flipped the photograph 180 degrees from the original direction of the camera, just as if the photons on the mirror were somehow "frozen", and someone rotated the mirror 180 degrees to face them.
Answer: Take a picture and look at it. Now turn the picture to face the mirror. Question one: who flipped the picture? Answer: you did. Now, face the picture back to you, and walk to the nearest refrigerator. Turn the picture to face the refrigerator. Wow! Refrigerators flip images too! Don't believe me? Take your flipped page and hold it up to a bright light. The image is flipped; no mirror required.
Now, most people will turn a page around the vertial axis when they want to face it away from themselves. However, you could flip the page around any axis you choose, as long as it's in the plane of the page. You could easily, for example, flip the page around the horizontal axis. If you still believe that mirrors flip images, you'll notice that you've now tricked the mirror into flipping the image top-to-bottom, not left-to-right. Flip the page around a diagonal axis, and you'll get a very different result.
Bottom line: mirrors don't flip images; people do.
Comment: Perfect explanation!!!  It took me a long time to figure this out, b/c Feynman's inside/out translation explanation is so confusing.  There is sorta/kinda a sense in which you could say that translation occurs, but ultimately it's irrelevant.  It's not related to "flipping" at all.
Answer: It's easier with images... The mirror doesn't flip left and right as you can see in the upper image. The so-called flip occurs when somebody in the real world rotates ${180}^{\circ}$ about the vertical axis to see you face to face, as can be seen in the lower image.
$\hspace{100px}$
Answer: Here's how I explain it (this is pretty similar to most of the other answers).
Assume the mirror is hanging vertically on a wall, and you're standing upright and facing it, looking at your own reflection.  (Just to make the assumptions explicit.)  And let's assume that you're facing north, and wearing a watch on your left wrist.
The mirror doesn't flip left and right; it flips forward and back.  Your front is farther north than your back, but your reflection's front is farther south than its back.  Your feet and the reflection's feet both face down.  The wrist with the watch is on the west side, both for you and your reflection.
So why do we think that the mirror flips left and right?  I think it's because we mentally map the (mathematically simple but physically awkward) transformation to something that makes physical sense.  The "simple" front-to-back reversal is mentally mapped to (a) a 180-degree rotation (something that people do all the time), and (b) a left-to-right reversal (which people don't do, but since we're pretty much bilaterally symmetric, it doesn't seem as strange).  So the person you see in the mirror looks like a normal person who happens to wear his watch on his "right" wrist and part his hair on the other side.
If we weren't bilaterally symmetric, we might see it differently.
For an example of what an actual front-to-back flip would look like, see this scene from Terminator 2; sorry about the background music, it's the only online video I've found of that scene.
Comment: "If we weren't bilaterally symmetric, we might see it differently."  If you hold something asymmetric in front of a mirror, like let's say some text, it still appears flipped horizontally.  So that doesn't really explain it.
Comment: @industry7: It appears flipped horizontally *to us*. If we weren't bilaterally symmetric, we might think of it differently. To us, a left-to-right reversal seems natural, even though it's not physically plausible, because the result of the reversal still looks natural. To an intelligent being without that kind of symmetry, a left-to-right reversal might not seem any more natural than a front-to-back reversal.
Comment: I'm not sure if I really made my point.  Just forget about the fact that humans are symmetrical for a second, and think about something that is inherently asymetrical.  For example, hold some text in front of a mirror.  It will be flipped horizontally, but not vertically.  And this is not a matter of perception, an objective electronic device would register the text is indeed backwards.
Comment: @industry7: Sure -- but you're also looking at the other side of it. The transformation can be seen in (at least) two ways: (1) A reflection on a vertical plane combined with a rotation about a vertical axis, or (2) a single reflection about the plane of the mirror. You could also see it as (3) a reflection on a horizontal plane combined with a rotation about a horizontal axis. We tend to choose (1) because it's more physically plausible.
Answer: First, lets separate the concepts; there is nothing that is "flipped" in the mirror image regarding one orientation more than others. the full group of transformations $O\left(3\right)$ includes transformations where $\det{\left(R\right)} = -1$. You can consider the following transformations examples of this:

they have one random direction flipped in sign, or
for the special case where $D= 2n+1$, you can flip all direction signs.

Moreover, all these rotations are equivalent to each other, that is, any of them is equivalent to any other by a normal rotation $\det{\left(R\right)} = 1$.
Explained in other way, the mirror image is also equivalent to your image with up and down flipped. You only think in the equivalent with the right-left flipped version because its easier to build in your mind. That might be related with the fact that our bodies are almost right-left symmetrical, but very poorly up-down symmetrical.
Answer: Imagine a mirror placed on the floor. Your face, looking at it, will be pointed downwards; but the face "in the mirror" is "looking" up.
The other answers here are great — I just wanted to make sure we discard the assumption that the mirror is placed on a wall!
Comment: a lake is much better, natural example, in this case.
Answer: Think about where a point above, below, left, and right of your point of view are in the reflection.  Your head is still on top, your feet still on the bottom in the mirror.  Likewise, your left hand is still to the left and your right hand to the right.  It seems flipped because, to look behind you, you are used to turning around (which swaps left/right), rather than flipping (which swaps top/bottom).  If we flipped upside down instead of turning around to see behind us, you would experience the opposite effect.
Answer: I can't resist: Here are two real experiments I came up with to explore the assertion that mirrors invert left-to-right but not up-to-down. Fans of the scientific method (and of Douglas Adams) know that the first step in any good experiment is to figure out exactly what the question (or hypothesis) really is. So, if you like having "obvious" assumptions shaken up a bit, please read on!

On an index card, write your name or some text in large block letters. Next, use one hand to hold it just in front of you as if it were a name badge at a meeting. With your other hand, hold a mirror in front of you so that you can read your "name badge." The text will look inverted left-to-right, as expected, while up-and-down looks normal, also as expected. Next, move the mirror upwards until it is straight above you, while tilting the bottom of the card out just enough so you can read it in the mirror. Result: You will still see the card text reversed left-to-right, as before. But think for a second: You are also seeing yourself standing on your head. That's top-to-bottom inversion, so you are getting both types of inversion at once! So, is the lack of vertical inversion really inherent in the mirror question, or have you just been holding the mirror in the wrong place all these years? And if so, why does the choice of where to place the mirror give one inversion in one case, and two in the other?
In the second experiment, hold the same card at arms length in front of you. Have it facing towards you this time so you an easily read it. Next, use your other arm to position a small mirror to the left or right of your line of sight of the card, and adjust the mirror until you can see the card in it. You will see the card text reversed left-to-right, just as with a face-on mirror. Now start moving the mirror in a circular arc until it is above the line of sight instead of to the left or right, keeping the reflected image of the card visible as you do so. When the mirror reaches the top, what do you see? Probably not what you expected: The text now has normal left-to-right order, but each letter is flipped upside down! In other words, the missing "vertical inversion" that everyone worries about in mirror experiments is right there in front of you. If you don't believe me, try it; there's no ambiguity in the effect. And if you want something more to ponder, try to figure out exactly when and how the vertical-is-normal, left-to-right-is-flipped image of the text transforms into the vertical-is-flipped, left-to-right-is-normal image during the rotation of the mirror. You can watch every step of the process as it occurs!

So, with these two experiments, it's worth asking: Is it really true that mirrors always reverse left-to-right? The earlier answer that references Feynman's video discusses this same point nicely, so be sure to look at that if you have not already. I'll likely comment more myself at a later time. But for now, I just wanted to provide a couple of easy, fast experiments you can try yourself, ones that may make you ponder just what the question really is. (The answer of course is 42 -- that much we already know!)
Answer: Left and right is relative to you only but not to the rest of your environment (including the mirror), but up and down is static for the whole environment including you and the mirror.
Answer: All you have to do is imagine the line $y=x+1$ on the Cartesian plane. If you reflect the line across a mirror in the vertical direction (across the $y$-axis), then the line becomes $y=-x+1$. Therefore, a vertical mirror flips the line's horizontal coordinates.
However, if you reflect the lines across a mirror is in the horizontal direction (across the $x$-axis), then the line becomes $y=-x-1$. A horizontal mirror flips the line's vertical coordinates.
The mirror just flips the axis perpendicular to its orientation!
Answer: Try this:

Make a paper cut-out of the letter F (or any easy-to-cut-out letter which is different from its horizontally and vertically flipped images). Shade or mark one side of the cut-out to distinguish it from the other. Get a second piece of paper and write the same letter on it several times.
Hold the cut-out in front of you while standing in front of a mirror.  The real cut-out and the image will both appear in the normal orientation, but (due to the shading/mark on one side) it will be obvious that the direct view and the mirror view show opposite sides of the same object.
Hold the paper in front of you so that you can read it normally.  You won't be able to read it in the mirror - only the backside will be visible.  Flip it so that you can read it in the mirror.  Which way did you turn it?  Chances are that you flipped the paper horizontally, and the letter now appears to be flipped horizontally.  You could also flip it vertically, and the letter would appear to be flipped vertically.

The flipping came from you.  All the mirror is doing is allowing you to see the opposite side of an object which is between you and the mirror.  For the cutout, the opposite side has the same shape, so you don't do any flipping and the image appears normal.  For the paper, the opposite side isn't interesting, and you have to turn the interesting side to face the mirror.
A more real-world situation is seeing a license plate in a mirror.  I you want to instead view the license plate directly, either you must turn to face it (if it's behind you) or it must turn to face you (if it's in front of you). Both of these turns would typically be about the vertical axis, because it's hard to rotate your head or car about the horizontal axis.
Answer: Because your eyes are set left and right and how you relate to the mirror.
When you turn a picture to reflect in a mirror, you usually turn it left or right.  If you turned it vertically, the up and down reflection will be opposite, but left and right will still be the same.
Comment: It also works with one eye. (although I agree with the second part of your answer)
Comment: The first sentence is not related, but the rest of the answer is 100% correct.
Answer: What if I say that the mirror doesn't flip left and right? You've heard it right the mirror doesn't do the flipping. As the above answers say the mirror shows what is right infront of it. It's you(we humans) who think it is flipping.
Let me get this in detail
Before we begin tell me ,
'What makes you think that the mirror flips your left and right?'
and
'what image do you think the mirror flips? in the first place'
The second question is a follow up question of the first one.
To answer these questions you need a camera not just an ordinary camera an imaginary,invisible camera
{ i.e i(camera) i,as in x+iy not in iPhone (pun intended)}

Now take a picture of yourself (No!! not a selfie!!)with that camera at a distance x and at height of your eye from ground. What do you see?
you will see a picture of 'beautiful you' in that picture with your left and right unswapped
Now place a mirror(a big one) facing you at a distance x/2 from you while you are standing still just the way you were. ( Now you know why I said, no selfie)
Now again with you still standing in the same position take a picture of the mirror with the cam exactly where your eye is (I know it's practically not possible but trust me  this 'i' can do anything) what do you see in this photo now? You will see the same 'you' as beautiful as you were in the first pic but with your left and right swapped

Now you see that the image is a flipped left and right.
(I guess you can answer the second question now)
Now, your question is why didn't the camera flip the up and down, right?
I'm getting there.
It's because of you. It's because you did something when you were taking the second pic. You must be thinking 'what did I do? I barely moved'
If you remember, After you have inserted the mirror, I've asked you take the second pic, how did you bring the cam from x to you and make it face the mirror?
You brought the cam to you with its lens still facing you and turned the camera around by 180 ° towards the mirror about the vertical axis (bringing camera to you and turning need not be in the same order) that's why the image is looking flipped left-right.
why did you turn it that way? why not about horizontal? Had you turned the camera 180 degrees about the horizontal axis we would have seen a vertically inverted photograph of you.
I hope you understand what turning about horizontal axis means.
When you turn the camera by 180° about horizontal the camera will face the mirror and the camera will be upside down
Remember:

turning about vertical

Turning about horizontal
You took it for granted that the camera has to be turned that way only because it doesn't make any sense taking pics with upside down camera,It's like looking at the world with legs up and head down.Yes, nobody looks at it that way but that that's what makes the difference.

To avoid confusion take another pic with camera facing the mirror and the camera is upside down. i.e turned 180° degrees about horizontal.

What do you see now? If you look at the pic in the camera It's again 'you', beautiful as ever but you are upside down i.e vertically inverted(you are also flipped left right but that another story, it's because we define left and right based on our top and bottom ), you'll notice it's not just you but also the whole world that is upside down.(Caution:Normal digital cameras and mobile cameras sometimes correct the orientation for you using gravity sensor and show upright image of you)
Still didn't get it? Thinking why the hell am I talking about this camera when we're taking about mirrors?
It's not a camera it's your point of view.
Getting back to the first question
What makes you think that the mirror flipped left and right?
Your took it for granted that your image is not vertically inverted. While taking the second pic I only asked you to make the camera face the mirror,I didn't tell you along which axis it should be rotated but you chose vertical axis only.
You assumed that you are not vertically inverted and asking why you are not vertically inverted.
But why are we all assuming that the image is flipped left right and why is it so hard to imagine that I'm vertically flipped even after being told? Well It's because when you flip your image horizontally your shape is almost the same except for your left is right. But when you flip vertically your shape is not retained. This is because our image is symmetric horizontally but not vertically.
Had we humans been vertically symmetric like in the image below (I know that some important organs are missing) it would have been easy for you to imagine that your are vertically flipped.
Comment: I found this answer the most simple!
Comment: Thanks for letting me know about it. It means a lot to me.
Comment: And one more thing. The biggest mind blow is when I realised that it's not just about vertical or horizontal we can turn but there are infinite number of ways in between them both. Infact we can choose any axis inclined to vertical ranging from 0° to180° and imagine that the image has been inverted along that axis. But fortunately only one of all the infinite axes make sense to our brain or else we'd be confused to death.
Comment: I was about to post the exact same answer before I found this. It is just gravity that defines how we rotate the object, not the mirror that rotates the image.
Answer: The mirror is not inverting the image in either direction but rather is acting like a rubber stamp doing a 1:1 transfer from surface to surface. If you wrote a word on a rubber stamp with fresh ink, then pressed the stamp to paper, the word on the paper would be backwards but not upside down. It's just a 1:1 transfer.
Answer: The simplest, but probably the only correct unswer is as follows:
"Left" and "Right" is determined WITH RESPECT TO "Up" and "Down".

Once you don't know what is "Up" (and/or "Down") you don't know what
is "Right" and "Left". For instance, when you see only wheels of a car, but not it's top and bottom, you cannot say which tire is left and which is right.
Alternatively, one can identify Up (U) and Down (D) if he/she knows
Right (R) and Left (L).

Hence, when you say that mirror "flips" R and L, you ASSUME that it does not "flip" U and D.
If you will assume that mirror does not "flip" R and L, you will come to conclusion that it flips U and D.
Comment: And why is it so easy to imagine that the mirror is flipping me left to right and it's so hard to apply the same to horizontal axis
Comment: I've figured out how to do that.I've added an answer.Look at it bro
Comment: I wrote this answer, which I think is still useful: The scene that we see "inside" the mirror is the "flipped" space outside the mirror.  It appears that left and right are reversed, but it is just as accurate to say that up and down are reversed; we perceive the former because that transformation makes sense to us (mainly because gravity is in agreement with our intuition), while the latter does not.  It would be equally accurate to say that the space is reversed through a diagonal plane at any arbitrary angle; it is reversed, that is all.
Comment: I was thinking the same.I think that mirror knows nothing about our posture,it is just us thinking that the image is flipped.But how can I explain it to someone who asks 'how can i think that mirror has not flipped the sides but turned upside down
Comment: And Dale's answer, above, is also useful.
Comment: Combining all of those answers:
The space "inside" the mirror is the reverse of the space "outside" the mirror, flipped across the plane of the mirror.  You can get the correct orientation back by flipping that perceived space across any plane, at any orientation.  We (unconsciously) choose a vertical plane because that is intuitive, and that is because up and down are not changed by that choice; switching left and right doesn't mess with our intuition.
Comment: ... but also see Alan H.'s answer, with its consideration of the orientation of the mirror.
Answer: A mirror flips the image front to back, not left to right. In the mirror your nose is in front of your face, but in reality it should be behind your face. Because your image is flipped front-to back it just so happens to appear from our common sense perspective that left and right are actually flipped. The L-R flip is an illusion symptomatic of the front to back flip.
This makes sense from the perspective of symmetry groups however the wiki article on molecular symmetry groups is much more complete.

Rotation-reflection axis: an axis around which a rotation by  $\tfrac{{360}^{\circ}}{n}$ , followed by a reflection in a plane perpendicular to it, leaves the molecule unchanged. Also called an $n$-fold improper rotation axis, it is abbreviated Sn. Examples are present in tetrahedral silicon tetrafluoride, with three S4 axes, and the staggered conformation of ethane with one S6 axis.

Essentially the front to back reflection is indistinguishable from a rotation.
Comment: True, but more explanation is needed (see Murod Abdukhakimov's explanation, which is made more clear with the addition of your explanation)
Answer: The accepted answer is fine, but there is something else I'd like to add to the discussion, a thought experiment that completely cleared up the question for me when I first thought of it.
As explained by others, mirrors just do what they do, they reflect light and that's it. So why is it that we have the impression that they flip us left-right, but not head-feet? This is because, in our heads, we compare the mirror image to what we would see if our "ghost" came out of our body, walked behind the mirror, and faced us. In this case, our head would face the ghost's head, our feet the ghost's feet, our left hand the ghost's right hand and our right hand the ghost's left hand. Whenever we meet another person face to face in real life, our body parts always face each other in this way.
Now imagine a world in which all of us were forced to lie on top of a skateboard, on our right side. Whenever you met a person face to face in this world, you would meet them with your head facing their feet, your feet facing their head, your left hand facing their left hand and your right hand facing their right hand. You would be used to this. Now comes the revelation: If, after living for a while in this world, you looked at yourself in the mirror, you would see yourself flipped head to feet, not left to right! This is because now you would be comparing the mirror image with your "ghost" coming out of your body, rolling on the skateboard while always lying on its right side, and ending up on the other side of the mirror with its head facing your feet and vice versa. The ghost's left hand would still face your left hand, and the same with the right hand.
So, the left and right flip is just a result of comparing our mirror image to the way we are used to seeing other people in front of us on Earth. One can conceive worlds whose inhabitants would perceive their mirror image as flipped top to bottom, or perhaps even other axes of symmetry if you made those worlds weird enough.
Answer: Mirrors flip in the dimension looking into/out of the mirror, not in the others.  What changes left/right is what we present to the mirror.  If you stand in front of another person, their right is on your left and vice versa, but their top is your top and their bottom is your bottom.  That's not the mirror, that's convention for left/right.
If you stand in front of a mirror and there's an object behind you on your right, if you look in the mirror it's also to the right of the reflection of you.
Check out especially the demonstration with the arrow in this video:
https://www.youtube.com/watch?v=vBpxhfBlVLU
(Embedded videos are apparently not yet available on this site).
Answer: The mirror reflects things from back to front and I think other answers explain that better than I could but I wanted to add an insight that a teacher once shared with me. It has stuck with me for years.
When we think the reflection is reversed left to right we are assuming the reflection got to the other side by moving around the side of the mirror while continually facing us. That is what most of us would probably do if we were a reflection, but there is another way. The reflection could go over the top. If it did that (while continually facing us) we would be looking at its feet. Up and down would be reversed, but left and right would not.
Answer: This my second answer to this question. I felt like writing a new one Instead of editing the old one because this a completely new approach and is way more simpler.
It all comes from how we define left and right and that mirror changes the direction in whic the object is facing when by inverting the Z-axis. We assume that the ponits on vertical axis, since it seperates the left and right, remain unchanged after mirroring, we can draw a similar axis between any two points and say that the mirror has flipped along that axis.
Mirror does nothing apart from inverting the Z-axis, as Feynman said. Each point on your body that is facing the mirror will remain with the same X and Y coordinates(or to say in simple language, image of each point is right in front of the actual point). Mirror doesn't differentiate any points as in such. The asymmetry arises from our definition of left and right, here's how we try to find out which part of an object is the right and which is left.
Step 1: I start by drawing a hypothetical line between what I assume are the top and bottom of the object.
Step 2: Then, I orient myself(hypothetically) along that axis and face in the same direction as that(I assume) the object is facing.
Step 3: Now, whichever half of the object contains the right half of the body, I call it the right side of the object, and whatever is 'left' (some clever pun by the author), I call it as the left side of the object.
When I see the reflection of the object in the mirror all the points (including top, bottom, left and right most points) are exactly in front of each other but the direction the object is facing has changed by 180°, Owing to the Z-axis inversion by mirror as Feynman said. This is where it all happened!!! Now that the image is 'facing' the opposite direction to the actual object, I'll have to position myself facing opposite direction to what I did earlier in step 2, This means in step 3, I'll find what earlier was to my right will be on the left and vice-versa and hence the right and left of the image appear to be swapped (Recall the PET classes when we as kids, used to confuse left and right beacuse our instructor in front is facing you and his 'left' is your 'right'). When we drew the axis we assumed that the points along the axis remained even in the image and everthing else is swapped along it. But in truth all points remained at the same place(Only Z inversion happened), Infact If I draw this line(which seperates right and left of a body), between any other two points and call the two halfs obtained as left and right, It'd appear that all the points on that axis remained at the same place and the inversion happened along the new axis.
If it is still confusing you, let's see how we can swap our top and bottom as opposed to left and right just by redefining 'left' and 'right'.
I draw a horizontal axis between the right most part of the object and left most and repeat step 2 with my head at the right most part of the object, this means what was the 'up'per half of the object earlier will now be the 'left' half and what was the 'bottom' half will be the 'right' half. On looking at the the mirror image and and repeating step 2 and 3 assuming that the ponits along the the new axis remained same, It would tell me that the new left and right (the former 'up' and 'down') have been swapped.
Answer: There are two posibilities You can show your real forehead from the position of the mirror image of your forehead: by rotating your body up-down or left-right by 180°. All you see then is the real you and the mirror image symetric horizontally or in the second case symetric vertically. When we compare a real person and the image we don't take in account that a person could rotate to show to somebody in two different ways:the easy one(left-right) and the more complicated one(up-down) ...
Answer: It is surprising how long and convoluted the answers to this question are. It has to do with the fact that the question is not trivial. Some of the answers complicate matters by bringing depth to the discussion, which, in my opinion, should be kept separate or not brought into discussion at all.
A mirror does not flip a planar image either horizontally or vertically.
The mirror produces a 'true image' of the planar image. Here, we define 'true image' as the image that you will perceive if you were able to somehow penetrate through the back of image, for example, in the case of a painting on a piece of paper. So the question now is, why does the image appear horizontally flipped to you when seeing in a mirror?
Let's say you have a painting on a piece of paper in your hand. You see the painting and your friend comes along and you want to show the painting to them. They stand in front of you, facing you. They are horizontally flipped with respect to you. (Mind you, they are not vertically flipped with respect to you, because none of your friends will come to talk to you on a hand-stand.) So to show the painting to your friend, you will have to flip the painting horizontally (and not vertically) so they see the same painting that you were seeing just a while ago. Now imagine you did the same in front of a mirror and not your friend. You basically present to the mirror a horizontally flipped painting. The mirror shows exactly what you present to it, and hence you see the painting as flipped.
A second example is your T-shirt. When you wear a T-shirt, you actually horizontally flip the T-shirt (and not vertically) when you wear it. You do that because anyone who comes to meet you face to face will be able to read what you were able to read when you bought the T-shirt. So basically you and your friends see the same thing since you present a horizontally flipped version of your T-shirt to your horizontally flipped friends. But when you see in the mirror, the mirror catches the horizontal flip and shows you a 'mirror image'.
Finally, when we look at ourselves in the mirror, we are actually looking at our 'true images'. However, our true images appear horizontally flipped to any friend who is standing face to face with us. In that sense, what we see of ourselves in the mirror, is a horizontally flipped version of what our friend will see of us when standing face to face!
Answer:
Indeed, a scene can be flipped "up-and down" using a mirror; if you place horizontally the mirror at bottom of the scene.
However, the image will not be the same with actual-object (if we go through only rotations and translation), if the object is "chiral" Chirality is a sort of 3-dimensional assymmetry .
https://en.wikipedia.org/wiki/Chirality

"I call any geometrical figure, or group of points, 'chiral', and say that it has chirality if its image in a plane mirror, ideally realized, cannot be brought to coincide with itself." ... Lord Kelvin.

(actual file URL: http://chem.libretexts.org/@api/deki/files/54210/=122a3121b7268f235234e7a9091fc4ea.jpg?revision=1).
(the term chiral came from Greek, χειρ (kheir) = hand).
Its a geometric property.
For a chiral shape, only 2 "Enantiomorph" found. It and its mirror-shape.
(however I don't know any geometric proof about why a chiral object have only 1 other enantiomorph (mirror image); where-ever we keep the mirror.)
Now, we get our flipped-image (left exchanged to right) of our body, because our body is chiral; and that chirality (a sort of asymmetry) exist in left-right direction of our body. If we had that-sort of asymmetry in our up-down direction, we would get our mirror-image different in up-down (after rotations and translations). (our up and down is also asymmetric, so when we stand on a shiny floor, we could found our-bottom (legs) is not same with the image's bottom (which is head); but if we try to superpose the 2 images, the difference come in left and right). That means mirror changes left-right direction... that is due to our body-construction; not the mirror. . If that hypothetical condition happened; we probably didn't called this geometric property as "chirality". Probably we would called it as "updowny" or such.
Our left and right side are asymmetric?
In-fact we often felt difficulty to discover the change in mirror, because apparently we are achiral (since our left side is "apparently" a mirror-image of our right, tied together, so it contains a plane of symmetry (plane-of reflection), whose existence is a condition for achirality );  the flipping becomes quite visible if we have certain birthmark in one side, that make us more asymmetric.
But our left side and right side is not completely mirror image of each-other. We can sense our left and right separately. We can move our left and right hand separately.
Answer: Put a mirror on the ceiling and look up.
Up/down is flipped, but left/right is not.
Answer: It's about coordinate systems and about a false claim in the question.
The mirror doesn't flip. You see your right hand to your right, up towards up (in the global sense).
When we look at a picture of ourselves, we still see the object's left most (in the global system) hand to our left. Again nothing is actually flipped (in the global system).
But in the deceptively posed question we are using the local system of the object (e.g. my actual right hand) hand as a comparison. Since the local systems of observer (same as global) and image (opposite to global) are opposite, the object appears flipped.
There is no problem with up/down, since observer and image have the same up/down direction, which also happens to coincide with the global.
Answer: The mirror inverts the z-axis (the connection line from you to the mirror), not the x- and y- axis ("left/right", "up/down"). You still see your left hand when looking on the left in the mirror, and your feet are still on the floor in the mirror.
Answer: The reason that images are always flipped in a horizontal axis in flat surfaces (standard mirrors, water's surface, etc) is because you have two eyes, one which is situated left of the other rather than to the right. If you had one eye, or eyes situated in a different configuration, the optical effects would be different.
Note also that the brain performs a double-transform correction to the image you observe since the way your eye works is very similar to a converging lens with the image beyond the focal point. That is, just like normal lenses, the image appears inverted (in both vertical and horizontal axes).
Comment: Chirality is property of the object, not the perspective (how we're looking). For example, our left and right hand are mirror-image of each-other, and non-superposable (so non-identical shapes) . If an object is chiral,  having a certain configuration (out of 2), (say our left hand), would remain like that, and an object having its opposite configuration (say our right hand), would remain like that. So I didn't find any relation with number-of  eye (2 or 1) and distinguishing opposite chiral figures. also if I close one eye the situation remains the same.


10 year ban on uk visa, can I apply for a different visa type?

Question: If a person has a 10 year ban on student visa entry and 10 years hasn't passed yet, is there any chance to reapply with another visa category? I was banned for 10 years in 2010.
Comment: As others have said below, no. You're 9/10 years through, any legal action or claims would be hugely expensive, and likely wouldn't reach a conclusion soon anyway. Your best bet is to wait it out for the final year, and then apply again and see if you are accepted. Spend this time making sure your next application is strong.
Comment: If you've built up a good travel history and credible ties to your country of residence since your ban, wait it out and reapply when the ban is over, making sure that you have good evidence showing you meet the visa criteria and that whatever caused your ban won't be repeated. If you reapply, you might want to get an Immigration lawyer with experience of applications to the UK to look over your submission. 10 year bans are only given after removal/deportation or for using deception in an application for entry clearance; adding a refusal to that history would not be a good thing.
Comment: What other visa category did you have in mind?
Answer: An entry ban means you are banned for 10 years, no matter what name, passport, or visa you attempt to use.
If you received a ban in 2010, then you only have a year or so to wait until the ban expires. Then you may apply for a visa, but there is no guarantee it will be approved.
Comment: Apparently some bans do not apply to family visa applications, so the first sentence isn't entirely true.
Answer: In addition to Gregs answer, the only way to circumvent a ban for the UK is to either:

challenge it on human rights grounds - this is massively expensive and nowhere near guaranteed to get you anywhere, even if you have a strong case.
Become an EU citizen and leverage the freedom of movement, as this supersedes any bans in place - note, this is only guaranteed to be viable for the next week or so, so move quickly...
Comment: @Traveller Past convictions are not, in themselves, grounds for denial of entry. However, if the person is judged to be a "genuine, present and sufficiently serious threat affecting one of the fundamental interests of society" (criminality, public health etc) they can be.
Comment: It has to be said that UK immigration takes a very, very dim view of people who attempt to challenge refusals on human rights grounds without an extremely good reason. A spurious challenge will damage your future chances of a visa.
Comment: Are you saying there are no grounds on which an EU citizen can be refused entry to the UK? Including having committed a serious crime, or being deemed 'not conducive to public good'?
Comment: -1 @Traveller, Moo A EU citizen can be deported and banned from another EU country, but the threshold is high. In the context of this answer, the statement is very unrealistic.
Answer: As far i know they will not issue you with visa for under the same category but after your ten ban. your are likely to get the visa if you provide all the information. please remember to state all refusals and on your application form. Be honest


OpenGL on Linux, Accumulation Buffer doesn't do anything

Question: I have an OpenGL graphics project, a particle system to be exact, and I'm using such effects like an accumulation buffer implemented motion blur, and also using the standard smooth to anti-alias (I know there are better ways).
My problem is that they only work at university, on their machines.
University use linux, same as me, but unfortunately I don't know what graphics cards they use.
I have a desktop with an AMD Radeon HD 6800, and a linux installation on an external HDD which I'm working on. This is the set up that does not anti-alias or show the motion blur!
So I tried updating my graphics driver, but I'm finding that tough to do on linux...
Last time I tried it destroyed my installation.
Answer: If you're running the Open drivers on a pre-3.6 kernel then MSAA & primitive smoothing simply isn't supported.


Telling the difference between anabolic steroid use vs dieting and exercise

Question: A lot of seemingly busy celebrities have rather well developed muscles, at least better than mine.  So my question is:  Is it possible to tell the difference simply by looking at pictures between people who eat healthy and exercise a lot vs people who take the shortcut of anabolic steroids?
Comment: Hi Andy, has anybody actually made that claim? Can you point out where?
Comment: Skliwz, I've never heard the claim being made that it's possible to tell them apart just by external appearance.  But I remember seeing some female Chinese Olympic swimmers with oddly large muscles of whom it was being said that maybe they do take such things.
Answer: Human growth hormone, while technically a peptide hormone and not a steroid hormone, might otherwise fit your criteria at least in spirit.  It's been involved in many high profile doping scandals; for example, Ben Johnson, Tim Montgomery, and of course Sylvester Stallone.
In long-term use, it may cause users to develop acromegalic features, the most superficially obvious of which would be a prominent "lantern jaw" and forehead "bossing". The growth of the jaw would also cause spreading of the teeth.
Although I can't find a credible source where Arnold admits to anything other than anabolic steroid use, I have been told by a professor that Arnold Schwarzenegger's face is the classic manifestation of this side-effect.
So for this specific example, yes, there may be some visible signs of using an exogenous substance versus "dieting and exercise".
Apologies for the shortage of citations, I'm apparently limited to 2 links as a new user.  This article verifies the use, the biology, and the allegations against the athletes listed in the first paragraph.
Answer: I don't think that is possible. What would you like to see? A specific artery pattern or something like that?
I think the possible speculations come from people that are jealous and try to rationalize the difference in muscle growth between the celebrity and them self by claiming steroid use. What they fail to take in to account is that those busy celebrities can have months of free time in between movies so they could quite literally work-out full time and they get to fill that time with the best trainers and nutritionists money can buy.
But then, you don't even have to, this is how Hugh Jackman trained for the second Wolverine movie: http://www.examiner.com/celebrity-fitness-and-health-in-national/hugh-jackman-eats-6-000-caloriesa-day-to-gain-weight-for-wolverine 1,5 hours a day with a really high intensity specialized workout program combined with a 6000 calorie diet...
Comment: Yeah, I was thinking something along the lines of relative proportion of muscles in the arms, neck and chest for example.
Comment: Ah, ok. I would imagine that the body would more or less grow in the same way when you train regularly as when you train with steroids. There could be a clue in growth striae from when your muscles grow to fast for the skin to keep up. But you could just as well get those with regular training, and I don't imagine you would ever get to see those on a celebrity, they'd be taken out with make-up or photoshop.


How to prevent being startled by co-workers while listening to music at your desk?

Question: Doesn't seem to be a good solution available.  I've heard of mirrors, but those have certain limitations. Wondering what methods people have found for avoiding surprises in the office.
Comment: This sounds counter-productive to me. You listen to music to block interruptions. It has nothing to do with what you use for that. It's natural to be startled when you're interrupted while you are fully engrossed. The alternative is to not concentrate on what you're doing or trying to do.
Comment: Not a dupe, but [related](http://lifehacks.stackexchange.com/questions/9831/listening-to-music-in-cubicle-without-headphones) since both deal -in a way- with being aware of your surroundings at work. Some answers might be useful for you OP
Comment: Cubicles or open floor plan?
Comment: Cubicles or offices.  Can't really do work anyway in an open floor office.
Comment: This question may have been better posted in The Workplace community ... but provided an answer below.  Hope it helps.
Comment: This question may have been better posed, "How to maintain concentration with interruptions?" It seems to me that the reason any problem exists is the desire to concentrate on work while being exposed to interruptions and distractions. Noises, voices that carry, laughter, strong odours (pleasant and unpleasant) can slow down thoughtful consideration which might be that individual's contribution.
Answer: You could try bone conduction headphones instead of usual ones. Those conduct the sound not by air but through the bones of your skull, thus leaving your ears free to hear your surroundings. I personally don't have any experience with them but the technology seems to already be quite mature based on the Amazon ratings.
Answer: I'm assuming you are using earbuds or earphones, so listening to music quietly without those might help you hear footsteps or lessen the alarm.
Turning your desk to face the entrance might let you see the incoming.
And the most complicated, make an "alarm system." Attach a little bell by the door or request for them to cough as they come or something like that. Or perhaps block the door with a plastic bag so it would rustle when they opened the door.
Comment: Yes, headphones.  Let's assume it's a noisy office environment (like mine, lots of loudmouths) so the headphones need to be quality with the music turned up loud to actually focus.  Then let's also assume the desk cannot be re-arranged due to cabinetry, walls, etc.
Comment: +1 on this answer, having your music a little more quiet can really help, both in hearing outside interruptions, but as well to not disturb other people. If I can take off my headphones and still hear my music, then other people can too, and at that point it's too loud.
Answer: I am a die-hard listen-to-music-at-work kind of person!  In fact, I find I am more distracted when I don't have music playing in background!  I have experienced working in open-floor cubicles, and office cubicles; private office (sole occupant), office with close neighbors and thin walls, as well as office-mate situations.  Here is what I have found to be the most useful and effective:
Wearing headphones/earbuds for pleasure (e.g., listening to music, videos, etc.)
Wear one ear on and one ear off.  You can still listen - and concentrate - to what is playing in your headphones/earbud, but hear anyone approaching or trying to get your attention.
You may have to give a little and lose some quality of sound (some sounds play in left but not right speaker, and vice versa) ... that may be the price you have to pay for being able to enjoy a little of home while at work.
Wearing headphones/earbuds for professional purposes (e.g., webinar, training video, Skype interview, etc.)
Hang a DO NOT DISTURB sign outside your office door/cubicle entrance indicating "Conference call/Skype Session/Webinar in progress".

Helpful to make a sign including images of all scenarios, have it laminated or put in a sheet protector, and hang it whenever you need to indicate you are not to be disturbed because of sensitive work taking place.
Co-workers will become accustomed to avoiding your office/workstation when they see "the sign" posted.
It is also a good idea to fore-warn your boss, co-workers (as appropriate), and any staff that report to you with at least a day's notice that you will be unavailable for a specific period of time, for your Skype interview/webinar session.  This way, when they come looking for you and come across "the sign" it is viewed more with an "Oh, yeah ... that's right" recollection, rather than a "What the ...?!" reaction.
If your office utilizes any type of shared calendar, it would be good to mark this as time you are unavailable.  So, again, if anyone goes around the office asking after you, anyone checking the shared calendar they can see you'd already marked this as time you'd planned as not available.

That should cover you.  Hope this is helpful!
Answer: Keep your environmental "white noise" volume as low as possible compatible with what you need to work. Lower volume will allow your sub-conscious to keep track of the office activity while you continue to work.
Place something near the office/cubicle entrance that can be used as a "door bell" to give you some prior warning that your attention is wanted. Such a thing could be a chair, wastebasket, or paper-tent "please knock" that could be easily moved and not be a hazard in the office place. A tiny wind-chime could do the trick. A bowl of candy just inside the entrance would make a sound that might not be jarring.
Comment: Interesting idea - barricade the cube entrance with physical obstacle.
Comment: @rommel Have you tried noisli.com?


Is it possible to test apex that relies on field history tracking?

Question: I have some code that relies on field history tracking by querying the History for a custom object. This works fine, but it appears that the history records aren't created during the test so none of my tests will pass.
Comment: There is an idea for this: https://success.salesforce.com/ideaView?id=08730000000h6RwAAI
Answer: I had a suspicion (remember reading somewhere) that Field History Tracking cannot be tested in a Unit Test Class.
A bit of Developer Board surfing threw up this post which confirmed that since none of the data is actually committed during a Unit Test, its not possible to Unit Test Field History Tracking.
http://boards.developerforce.com/t5/Visualforce-Development/Unit-Testing-and-History-Table/td-p/142422
The History tables are ReadOnly, coz I'm guessing they're a little bit like the Salesforce System Fields. To maintain the integrity of the audit trail, they're locked to writes. To be able to write our own history records, we'd need to roll our own History Mechanism, with an object and a trigger
To confirm this suspicion, I quickly wrote this test class : (after turning on Field History Tracking on the Type field)
@isTest
public class AccountTest {
@isTest
    private static void  testOne(){
     Account acc = new Account(Name = 'Hello', Type='Other');
     insert acc;
     Test.startTest();
acc.Type = 'Prospect';
update acc;
Test.stopTest();

AccountHistory[] ah =  [Select AccountId, Field, OldValue, NewValue from AccountHistory where AccountId = :acc.Id];
System.debug('ACC HIST IS ' + ah);
System.assertEQuals(1, ah.size());   //ASSERTION FAILS
    }

}

(As an aside, this also fails when executed from Execute Anonymous or when run on load from a VF Page. It would seem that you can't query for the History from the same execution context. Inserting the account first, and then separately updating the Type seems to yield History from execute anonymous / vf)
To make your tests with work sufficient coverage, you can make use of the Test.isRunningTest to return a mock AccountHistory response as below (although OldValue and NewValue will be null as they are not writeable)
public class AccountHistoryUtil {

@isTest
    private static void  testOne(){
    Account acc = new Account(Name = 'Hello World' + Datetime.now());
    insert acc;

    Test.startTest();

    AccountHistoryUtil accHistClass = new AccountHistoryUtil();

    accHistClass.processAccountUpdate(acc.Id);

    AccountHistory[] accHist = accHistClass.retrieveAccountHistory(acc.Id);
    Test.stopTest();
    System.assertEQuals(1, accHist.size());
    }

    public void processAccountUpdate(Id accountId){
       Account acc = new Account(Id = accountId, Type = 'Other');
       update acc;

    }

    public AccountHistory[] retrieveAccountHistory(Id accountId){
     List<AccountHistory> ah;
     if(Test.isRunningTest()){  //if TEST, create dummy AccountHistory
         ah = new List<AccountHistory>{}; //OldValue, NewValue not writeable
         ah.add(new AccountHistory(AccountId=accountId, Field='Type'));
     }
     else
         ah=  [Select AccountId, Field, OldValue, NewValue from AccountHistory where AccountId = :accountId];

     return ah;
    }
}

Comment: Interesting... Is the field history object writeable? Could we create our own field history records?
Comment: The History tables are ReadOnly, coz I'm guessing they're a little bit like the Salesforce System Fields. To maintain the integrity of the audit trail, they're locked to writes. To be able to write our own history records, we'd need to roll our own History Mechanism, with an object and a trigger.
Comment: More information on mocking history records can be found here https://www.jamessimone.net/blog/joys-of-apex/mocking-apex-history-records/#:~:text=History%20records%20don't%20get%20created%20during%20unit%20tests.
Answer: You can't populate the history tables from unit tests as this happens after a transaction is committed to the database, which doesn't happen in the test context, rather the entire transaction is rolled back at the end of the test.  The history table is only writeable by the system, not by your code, so you can't go that route either.
The one thing that you can do is instantiate the objects that would be stored in the history table if you were lucky enough to be able to write to it, although you can only write to a subset of fields (oldValue and newValue are not writeable for example - you can still access them but they will be null).  Thus the way that I've handled this in the past is to put the SOQL query that extracts the data from the history table into its own method, which simply executes the query and returns the list of matching history objects.  Then a different method is used to process that list.  My unit test can create the list of objects to be processed independently of the SOQL, although I can still execute that (and get an empty result) in order to get coverage.
Here's an example using accounts:
public with sharing class HiistoryExample {
    public List<AccountHistory> queryDatabase(id accountId)
    {
        return [select AccountId, OldValue, NewValue, IsDeleted, Id, Field, CreatedBy.Name
                from AccountHistory
                where AccountId=:accountId order by createddate desc];
    }

    public List<String> ProcessRows(List<AccountHistory> historyList)
    {
        List<String> results=new List<String>();
        for (AccountHistory hist : historyList)
        {
            String field=hist.field;
            Object oldValue=hist.oldValue;
            Object newValue=hist.newValue;

            results.add(field + '|' + oldValue + '|' + newValue);
        }

        return results;
    }

    public static testMethod void testExample()
    {
        Account acc=new Account(Name='Unit Test');
        insert acc;

        HiistoryExample example=new HiistoryExample();
        example.queryDatabase(acc.id);

        List<AccountHistory> histList=new List<AccountHistory>();
        AccountHistory hist=new AccountHistory(Field='Name');
        histList.add(hist);

        List<String> results=example.processRows(histList);
        System.assertEquals(1, results.size());
        System.assertEquals('Name|null|null', results[0]);
    }
}

and when I execute the test method from eclipse, I get 100% coverage.  If you need to test code that relies on real values for old/new, I tend to create a custom class, populate this with the new/old values and process that. Then my unit tests can create their own instances of the custom class for processing.
Comment: Seems we can now write to the history table for custom objects although cannot find documentation that states such.
Answer: Revive a nearly 5-year old question? Sure! Why not?
This recently came up again in a question that I was working on answering, when that question was closed as a duplicate of this one.
In addition to the methods already mentioned, it is possible to use Test.loadData() to create <obj name>__History records (this also works for history objects that don't have the __History suffix like OpportunityFieldHistory). At this time, the salesforce docs go back to API v30.0 (Spring '14), and I see Test.loadData() in the docs for that version. I haven't done a lot of searching/testing to see exactly when this became possible...but if you're reading this, then you should be able to use it.
This requires a csv (comma-separated variable) file to be uploaded as a static resource. As far as I can tell, the only field of history objects that is absolutely required is the ParentId field. The advantage of this approach is that you are able to specify values for OldValue and NewValue.
The following is an example using a custom object from my org, Circuit__c, with a custom field Card__c. The Id prefix for my object is a0R.
ParentId,Field,OldValue,NewValue
a0R000000000000,Card__c,123,456
a0R000000000000,Card__c,456,abc

Uploaded as a static resource named 'TestCircuitHistoryData', you would load it in a test like so
// Pretend that there's a test class definition out here somewhere...
@isTest
static void testLoadHistory(){
    // loadData takes 2 parameters, an SObject type, and the name of a static resource
    //   (as a string)
    List<Circuit__History> cs = Test.loadData(Circuit__History.SObjectType, 'TestCircuitHistoryData');

    // When debugged, you can see that OldValue and NewValue are indeed populated
    system.debug(cs);
    // Rows of the CSV file are created/inserted top-down
    // 08:39:45:923 USER_DEBUG [15]|DEBUG|(Circuit__History:{Id=0170v00000KAxZxAAL, IsDeleted=false, ParentId=a0R000000000000EAA, CreatedById=null, CreatedDate=null, Field=Card__c, OldValue=123, NewValue=456}, Circuit__History:{Id=0170v00000KAxZyAAL, IsDeleted=false, ParentId=a0R000000000000EAA, CreatedById=null, CreatedDate=null, Field=Card__c, OldValue=456, NewValue=abc})
}

There are two big caveats with this approach:

You'll probably need to use 'fake' Ids for the ParentId field. You could extract some actual history data from a production org, and put it in a csv file uploaded as a static resource...but that doesn't change the fact that the ParentId you have in your static resource will (practically speaking) never match the Id for records you'll create in a unit test.
The records that are loaded are inserted, and available through queries in a test method. However, the OldValue and NewValue fields will come back as null if you try to query them. Test.loadData() can only provide values to those fields in the 'in memory' instances that you get as a result of calling Test.loadData()

That means that if you have logic that depends on the values stored in OldValue and/or NewValue, and you want to test it, the method you're trying to test would need to have its history data injected into it (as opposed to directly querying for it in the method). Data can be injected via static variables, class constructors, method parameters, etc... The important point is that you want to separate the job of fetching the data from the job of operating on it.
// Testing this method using Test.loadData() is not possible because it depends on
//   OldValue/NewValue, and there is not a way to have those fields be anything other
//   than null (from a query) at time of writing
public void directlyQueryHistory(){
    List<Circuit__History> chList = [SELECT Id, ParentId, Field, OldValue, NewValue FROM Circuit__History WHERE ParentId IN :myCircuits];

    for(Circuit__History ch :chList){
        if(ch.Field == 'Special_Field__c' && ch.OldValue != 'trouble'){
            // Do interesting things here
        }
    }
}

// If we break the above method into two methods (both public, or at least @testVisible),
//   that will allow us to 'inject' test data, which will allow us to test logic that
//   depends on OldValue or NewValue.
// As is, there isn't much for us to test in this particular method (other than
//   making sure it gets called so it's marked as covered).
public void QueryHistory(){
    List<Circuit__History> chList = [SELECT Id, ParentId, Field, OldValue, NewValue FROM Circuit__History WHERE ParentId IN :myCircuits];
    operateOnHistory(chList);
}

// This method only cares about operating on data.
// It does not fetch (i.e. query) for anything on its own, everything it needs to
//   run needs to be set up for it by other code prior to running this method.
// Because the data is injected, we can use Test.loadData() in a unit test and have
//   OldValue available.
public void operateOnHistory(List<Circuit__History> history){
    for(Circuit__History ch :history){
        if(ch.Field == 'Special_Field__c' && ch.oldValue != 'trouble'){
            // Do interesting things here
        }
    }
}

An example test class (which makes some additional assumptions)
@isTest
private class HistoryTest{
    static List<Circuit__History> circuitHistory;

    static void setup(){
        // This cannot be done inside a @testSetup method because static variables
        //   set in such a method are erased before each unit test is run
        circuitHistory = Test.loadData(Circuit__History.SObjectType, 'TestCircuitHistoryData');
    }

    @isTest
    static void testLoadedHistory(){
         MyCircuitClass mcc = new MyCircuitClass();

         // Operating on the Circuit History probably results in changes to
         //   those circuits (or changes on objects related to those circuits).
         // Thus, it's probably a good idea to make sure those object records exist
         Map<Id, Circuit__c> circuitsMap = new Map<Id, Circuit__c>();
         for(Circuit__History ch: circuitHistory){
             circuitsMap.put(ch.ParentId, new Circuit__c(Id = ch.ParentId));
         }

         // We'll also likely need to inject these circuits to do anything useful.
         mcc.circuitsMap = circuitsMap;

         test.startTest();
         mcc.operateOnHistory(circuitHistory);
         test.stopTest();
    }
}

Comment: @battery.cord Well, I ran my example scenario again, and it does work for my custom object's history object as well as for `OpportunityFieldHistory`. I tried the same for `AccountHistory` and am getting `Validation Errors While Saving Record(s)` with no stack trace. So it would be more accurate to say that this technique works for some but not all History objects. In those cases, combining dependency injection with a wrapper class to abstract out a standard History object would be a way to work around this (good luck testing that wrapper class though).
Comment: I found that this is the most elegant way to accomplish loading data without creating unnecessary apex overhead.
Comment: It does not seem to be possible to create test history data using `Test.loadData`. Reference: https://salesforce.stackexchange.com/questions/198260/deserialize-history-record-with-read-only-fields
Comment: Just tested the same method using a custom object's history data, and was able to get the records to insert (with the `NewValue` and `OldValue` fields showing null when queried).
Answer: It now seems that you can insert EntityHistory objects during testing, although you cannot write the old and new values. I have not found documentation that says you can so maybe it came along by accident with the ability to set system fields etc, who knows.
Documentation on EntityHistory object does not state that it can be created:
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_entityhistory.htm
However this question here got me to try it myself and I could indeed insert a history object as outlined in the OP answer here:
Test Class Coverage for Custom Object History
Reproducible example
@isTest
private class historyTest{

    public static testmethod void doit(){
        Account a = new account(name='test');
        insert a;

        Opportunity o = New Opportunity(accountid = a.id,closedate=date.today(),name='test',stagename='test');
        insert o;

        [Custom Object] cObj = new [CustomObject](Name='test',Opportunity__c = o.id);
        insert cObj;

        [CustomObject]__history objectHistory = new [CustomObject__history(ParentId = s.Id, Field = 'Hours_Allocated__c');
        insert objectHistory;

        system.debug([Select ParentID From {CustomObject}__History]);

    }

}

Comment: Actually this doesn't seem to work.

when I run code

    @isTest class TestClass {
    static testMethod void testMetod() {
        Account a = new Account(Name = 'a');
        insert a;
        insert new AccountHistory(AccountId=a.Id, Field = 'Name');
    }
    }

I see internal error

[![enter image description here][1]][1]

  [1]: https://i.stack.imgur.com/qyttF.gif
Comment: According to the comment on the answer above, this seems to be specific to custom objects - but when I try to insert a custom history object record, I get an error saying that "insert is not allowed on CustomObject__History"
Comment: It worked as of the writing of the answer. Must have been a bug that they fixed and is a good example of why should not implement undocumented features. I have not tried it today as I trust in your tests
Answer: You can also do this:
1) Before you call your target class create a list of strings and populate with the values you would like, here have used create date, time of history row but can be anything. The list should have the values you want to test for.
// create list to substitute when target is running in test mode
List<List<String>> testOfferHistoryList = new List<List<String>>();
for (integer i=0; i<3; i++) {
     List<string> tempList = new List<string>();
     tempList.add(string.ValueOf(date.today()-i));
     tempList.add('15:00');
     tempList.add(offer.id);  // id of test data row created previously
     testOfferHistoryList.add(tempList);
}

2) Assign it to a variable in your target class:
VocCollection vocData = new VocCollection();  // instantiate target class
vocData.testOfferHistoryList.addall(testOfferHistoryList);
3) In your target class you, after you read the relevant history object you put the results into a list of strings just like the one above. So rather than use the list of yourObject_History objects in subsequent processing, you use the list of strings you have just created (should have exactly the same structure).
4) Lastly test if running in test mode and if so then substitute the test list of string for the real list of strings, ie
 if (Test.isRunningTest()) {
     offerHistoryList.addAll(testOfferHistoryList);
 }

5) Carry on processing as per normal using substituted list instead
Answer: Thanks for the if(Test.isRunningTest()){ idea.  Instead of restricting to the account.id, I opened it up and limited the results to 10.  This gave me enough code coverage to deploy.  I made the change in the Class, so that the test class when running will use the history list without the account.id restriction:
 List<AccountHistory> ahistorylist;
 if(Test.isRunningTest()){  //if TEST, don't limit by a.id
     ahistorylist = [select
      AccountId,
      OldValue,
      NewValue,
      IsDeleted,
      Id,
      Field,
      CreatedDate,
      CreatedById,
      CreatedBy.Name
      From AccountHistory
      order by CreatedDate desc
   Limit 10 ];
 } else {
 ahistorylist = [select
      AccountId,
      OldValue,
      NewValue,
      IsDeleted,
      Id,
      Field,
      CreatedDate,
      CreatedById,
      CreatedBy.Name
      From AccountHistory
      where AccountId= :a.id
      order by CreatedDate desc
   Limit 100 ];
 }
 // Loop through all field history records
 for (AccountHistory fh: ahistorylist ) {

    String toText = '';
    String fromText = '';
    String skipthis = 'no';


Challenge closed as duplicate that's clearly different

Question: I posted Draw the Olympic Games logo, which is clearly a code-golf question requiring users to post a solution that outputs ascii-art.
chubakueno posted Olympic Games Logo - Free Style Edition, which is a popularity-contest and has no restrictions on output format. This post has been closed as a duplicate of the above contest.
I cite Are two questions duplicates if they have different scoring rules? and Duplicate questions on Meta as precedent that these challenges can be considered different; while the posts from my question would be valid answers to the closed question, (currently) the opposite is not true. It's a different challenge with a different goal and much broader restrictions.
I don't have the reputation to cast a reopen vote and get the ball rolling on this, but I believe that the new challenge should be reopened.
Comment: It seems to me, that the _real_ challenge, was to prevent it from being removed. :-P
Answer: And now it's been reopened. Thanks!


What is an Ethereum contract?

Question: Ethereum is described as using and enabling the creation of "Smart Contracts", sometimes called just "contracts".  But what is an Ethereum contract?  Is it a legal document, or something else?
Answer: The terms "Contract", "Smart Contract", and sometimes "DApp" are all often used interchangeably to describe the same thing.
A "Contract" on Ethereum is a piece of code.  This code is stored on the blockchain as bytecode and is immutable once created.
A Contract has an address similar to the way that normal private key based accounts have a public address.  The difference is that contract addresses do not have an associated private key.  In all other ways, contract addresses are treated the same as private key backed addresses.
When a transaction is sent to a contract's address, it triggers the execution of the contract's bytecode.  A contract's code can do anything that a normal address can do, including sending funds to other addresses and calling code on other contracts. The only thing that a contract cannot do that a normal address can is initiating a transaction.  Transactions on Ethereum must always be initiated by private key based addresses.
Contracts have 2 ** 256 32-byte storage slots available to store data in.  This can be thought of as each contract having its own database available for keeping track of data that needs to be persisted through the lifecycle of a contract.
Most contracts are written in a high level language such as Solidity which compiles to bytecode that is deployable onto the Ethereum blockchain.
Comment: What exactly can a normal address do that a contract code can also do? How does the contract bridge between the real and digital world since all that it does is record transactions on the blockchain?
Comment: Contract addresses have bytecode associated with them and there is no one externally controlling the private keys behind the contract.

Contracts keep a CRAB log instead of a CRUD database (Create read append burn vs Create read update delete).

There is no native bridge, if you put nonsense on the blockchain you get nonsense out. Therefore we need oracles, trustworthy parties that translate physical state to blockchain state. Thankfully there are really cool projects like towncrier (decentralized intel SGX oracles).
Answer: It is certainly not a legal document.
Put simply it is just a piece of code embedded to a blockchain that has its own address that is being executed every time transactions to this address arrive. You can think of it as a contract that has strict logic defined by a code and there is nothing in existence that could stop this code to be executed if somebody pays for it.
I wrote kinda Ethereum 101. Hope that helps.
Answer: https://en.wikipedia.org/wiki/Smart_contract
http://szabo.best.vwh.net/smart_contracts_idea.html
An Ethereum Contract is programming code (as data stored in the blockchain) that you send money (ether) at, which it can decide (through smart contract logic and blockchain consensus) to delay, send on money, call other contracts, modify it's storage, signal outside observers, require two or more signatures, etc. Anything (nearly anything?) arbitrary programming can do, an Ethereum Contract can do (with enough developer hours and resources).
You can have your code be executed and verified on the Ethereum blockchain. (That is why it is sometimes referred to as "The World's Computer".) If you wanted to have property locked up in such a way that three people are needed over a one week period, or two people over a month period (but the third person can see what they're up to and perhaps negate their action), or any other problem that requires distributed trust (without a notary, lawyer, or judge to help enforce things), then Ethereum might be a great fit as a solution.
tl;dr: "Is it a legal document", No - but it might just replace the entire legal system.
Comment: "If you wanted to have property locked up in such a way that three people are needed over a one week period" How do you physically lock up the real-world property if everything operates in the digital blockchain only?
Answer: Here smart contracts explained to a non-programmer:
...Smart contract is like a web site. A blockchain address may belong to a program. A program then is called a smart contract. It is called a contract just because the code is open. However it is simpler to compare it to a web site (or web service). For example, a classified advertisements service could be a smart contract. Its code would be stored at a particular address in the blockchain — just like a web site url. A transaction to this address would not contain money but an advertisement text. And the smart contract would publish this advertisement, i.e. saves to blockchain...
Answer: Smart Contract is an agreement or contract (because they contain instructions or command "if this is found, then this will happen"), that works on the Ethereum blockchain. These instructions or commands in the form of code are distributed throughout the whole Ethereum network. This distributed code is executed in the ETH blockchain because that smart contract which is written (in Solidity which is a programming language for ETH blockchain) contain functions which are required by user to be executed in the ETH network. To execute these smart contracts on the Ethereum network, you have to pay fee called "gas" for the nodes or computers on the network. The code or smart contract is distributed to all nodes (computers all over the world) and executed on an EVM Ethereum Virtual Machine. There are more features of smart contracts...i can go in deep but i think it's enough for this question.

What is an Ethereum contract?


Facebook custom tab not visible for everyone?

Question: I've a fan page which has 2 custom tabs (lets call them "catalogo" and "rifa"), problem is that one of them only shows to certain people on a seemly random basis.
As far as the settings is concerned, both were created with identical settings on the same day. The both pull content from the same server (http://flor360.com) and secure and non-secure versions from Tab URL are correct and verified to be accessible.
What puzzles me it that just some users are able to see the "rifa" tab, but everyone is able to see the "catalogo" one.
It's reproducible 100% of the time if you sign out of FB and visit https://www.facebook.com/floristeria.flor360 you will only see the "catalogo" tab but if you log to FB and visit the same page again, if you're "lucky" you see both tabs, "catalogo" and "rifa".
I've been trying different settings all day but it just look like a FB bug to me, I've read the following related topics:
Some facebook tabs doesn't show for all users
developers.connect.facebook.com/bugs/250648431689434/?browse=search_4f4fde5e1c9a43429488828
developers.beta.facebook.com/bugs/257675740992709/?browse=search_4f7f3b8ff0a253393699815
[sorry they're not URL, StackOverflow though it was SPAM]
But it's not any of those suggestions (SSL is OK and changing "secure browsing" setting did nothing).
What puzzles me even more is that this mount visitor to the "rifa" tab ammounts to 1.022 people, and there has been a lot of interactions on it, but yet it seems that this tab is just not visible for some other people.
Comment: Ever managed to find out what was the problem? I'm having the same issue and for the life of me, I can't figure out why the tab isn't displayed.
Answer: remove the tab which is not visible and add it again through your admin login
_______&next=http:url">https://www.facebook.com/dialog/pagetab?app_id=_______&next=http:url where ur files are hosted"


Steroid hormones: how do they travel through the cytoplasm (not just the blood plasma) if they're hydrophobic?

Question: I get that steroid hormones need hydrophilic plasma protein carriers (eg albumin, TBG) to travel in the plasma because they're not soluble in the plasma. However, I don't see any sources talking about how these hormones can then traverse through the (presumably also hydrophilic) cytoplasm to get to their receptors either in the cytoplasm or nucleoplasm. Anyone have any clarifications on this?
Answer: Firstly not all steroid hormones travel inside the cell and regulate the gene expression.
Basically there are two pathways- direct and indirect.
Steroid hormones are lipid-soluble, which allows them to cross the extracellular membrane to the inside of the cell.

Classical models of steroid action suggest that steroid hormones bind to specific nuclear receptor proteins once inside the cell. Reference

Once inside the cell, a steroid hormone binds with receptor proteins in the cytoplasm. The steroid hormone and its receptor form a complex, called a steroid complex, which moves into the nucleus where it influences the expression of genes.
Reference

In the indirect pathway,

The traditional nuclear steroid receptors can also indirectly regulate gene transcription by serving as signal transduction proteins that interact with various signaling pathways in the cytoplasm of a cell. In particular, ER can activate kinases, enzymes that phosphorylate and thereby activate other proteins. This sets in motion a signaling cascade that eventually ends in the nucleus with the induction of gene transcription.
Reference
Answer: I am not an expert in this area, but found a summary of and illustration from a textbook — Karen Lounsbury, Pharmacology, 2009 — on a Science Direct summary page.
Apparently for the glucocorticoid hormones there is a cytoplasmic glucocorticoid receptor protein (GR in the diagram) they bind to, presumably keeping them soluble in the aqueous environment. This causes heat-shock proteins (HSP90 in the diagram) associated with the receptor to be released from it, which allows the complex to be translocated to the nucleus where it binds to a glucocorticoid response element (GRE in the diagram), triggering transcription of appropriate genes.

More detail is given in a paper by Bledsoe et al. (2002) in which the structure of the dimeric GR bound to a steroid analogue was determined. To quote from the introduction to that paper:

Like most nuclear receptors, GR is a modular protein that is organized into three major domains: an N-terminal activation function-1 domain (AF-1), a central DNA binding domain (DBD), and a C-terminal ligand binding domain (LBD).
…
Within the context of the full-length receptor, both the AF-1 function
and the DNA binding activity of GR are dependent on hormone binding.
In the absence of ligand, GR is retained in the cytoplasm by
association with chaperone proteins such as hsp90 and p23, which bind
to the LBD (ref). The chaperone activity of the hsp90
complex has been shown to be critical for hormone binding by GR
(refs). Hormone binding
initiates the release of chaperone proteins from GR, allowing
dimerization and translocation of the receptor into the nucleus. In
the nucleus, GR binds to DNA promoter elements…

A image of their structure is shown below:
Answer: I suspect the issue is mainly one of diffusion distance. Steroid hormones are not that insoluble as they are compact and have multiple oxygen functional groups. Checking predicted log octanol/water partition coefficients on PubChem gives 3-4ish for steroid hormones compared to 6+ for a typical fatty acid, despite the latter having an ionizable headgroup.
These hormones are present in the body at nanomolar concentrations or even lower, and at that concentration, almost anything is soluble. The problem with them being in the plasma at any concentration, though, is that as soon as a molecule would collide with the lipid membrane of a cell in the wall of the vessel, it would tend to stick, and therefore the vessels would act sort of like a chromatography column that drastically reduces the apparent diffusion coefficient and generates steep gradients. While this might actually be desirable for a local mediator like a prostaglandin that has a range of a few cell diameters, it is very undesirable for something like steroid hormones that travel to completely different organs from where they are produced. Therefore, a hydrophilic carrier is essential.
On the scale of the cytoplasm of a single cell, this is not likely to be an issue, especially since there are receptors inside that act as a "sponge" or "sink" to catch and trap molecules that diffuse in.


How to download the audio files on Wikipedia pages?

Question: Sometimes a Wikipedia page contains audio files that I would like to download and save, for example, the individual pronunciations in the IPA chart for consonants. However, I wasn't able to find any explicit audio file to download. Any help?
Answer: You can go to these pages:

Vowels
Consonants

And then right click on the speaker icon next to the sound you would like to download, and press "Open link in new tab". Then you you can right click the audio player shown in the new tab, and click "Save audio as..."
Answer: I think the ones you want are sourced from http://www.yorku.ca/earmstro/introducing_the_ipa/ and there are .mp3 files there that are downloadable.
Answer: If you inspect the audio play button using your browser's dev tools, you can see an img nearby in the structure, like so:

When the play button is clicked, the img is changed to an audio element, which is then played. If you click play then double click on the audio element's src before it goes away, you can get the audio file source, such as this one. Just replace file/// with https://upload.wikimedia.org/wikipedia/commons.
But an easier way in cases where it's possible is to view the original source, as pnuts suggests.
Comment: Thanks, tried inspecting elements but didn't expect the element to be replaced.
Answer: This how I did it, it's a bit complicated but it worked.
Take this IPA letter as an example -
You first have to click the source button under the audio player.
That in turn makes you go to this page
After that, you will click on the Menu option on the audio player.
Then you click on the download button and select the MP3 option. That will get you to this page.
You then click on the right icon to Download, change the ".ogg" to a ".mp3", save and it's done.
Answer: just follow visuals and you will get there...
https://i.stack.imgur.com/2vuhZ.png
https://i.stack.imgur.com/xVtYG.gif


When is the "Resourceful" trait active?

Question: I have a monster that has the Resourceful trait, but when is it active?  Is it active when it's in my pack or only when I'm using it during the final kill?
Answer: The Resourceful trait doesn't instill any innate bonuses: it just indicates the monster can learn certain passives that increase rewards (e.g., Item Scavenger and Item Collector).
Those passives, however, are active as long as the monster is in your paradigm pack: you don't need to use any of the paradigms the monster is in or have the monster active during the final blow.

When is the "Resourceful" trait active?


Is the prophet's (pbuh) life before the Qur'an was revealed to him considered as sunnah?

Question: I read couple of definitions of sunnah and they were all something like "whatever the Prophet (pbuh) said, did or approved to do." But none mentions these have to be after Islam have been revealed to him (pbuh). On the other hand, I don't recall anything called sunnah that happened before Islam. Is there an implied "after Islam revealed" in the definition of sunnah?
Answer: The quran simply says to follow the prophets example, it dosent say to exclude any certain point of time such as the time before he became a prophet

Say, [O Muhammad], "O mankind, indeed I am the Messenger of Allah to you all, [from Him] to whom belongs the dominion of the heavens and the earth. There is no deity except Him; He gives life and causes death." So believe in Allah and His Messenger, the unlettered prophet, who believes in Allah and His words, and follow him that you may be guided.7:158
"… He [Heraclius] said, 'Had you ever blamed him for telling lies before he claimed what he claimed?' I replied, 'No.' … He said, 'Does he break his promises?' I replied, 'No, but we are now at truce with him and we are afraid that he may betray us.' … . 'When I asked you whether he was ever blamed for telling lies, your reply was in the negative, so I took it for granted that a person who did not tell a lie about (others) the people could never tell a lie about Allah. I asked you whether he had ever broken his promise. You replied in the negative. And such are the apostles; they never break their promises…'" (Sahih al-Bukhari, Volume 4, Book 52, Number 191)

The hadith above exlains that even the enemies of the prophet knew that he never told a lie, before and after prophet hood, demonstrating that he was a role model before he bacame the prophet.
Furthermore, that during the isra wal mi'raj the Prophet (pbuh) was offered wine, water and milk as a drink by Jibreel (or gabriel)  The prophet (pbuh) chose to drink milk upon which Jibreel alaihi salaam commented: you are rightly guided and your Ummah will be as well.
I would also like to point out that the incident explained above occured before alcohol was made unlawful, so the prophet was a guide to his ummah before Allah commanded much of the the prohabition of certain things.
This shows that the prophet was rightly guided before he had the title of the prophet, and we are simply told to follow him to be guided, Allah did not differentiate before or after he became a prophet, as he was a good example at all times.
Answer: Consider this: the Prophet (salallahu alayhi wa sallam) was sent as a Prophet, to guide us to the straight path. That was the mission statement of his life after prophethood.
As Muslims, being told to follow his sunnah, obviously means that we should follow whatever Allah inspired him to, as part of his prophethood. Also, as a prophet, Allah protected his actions from anything wrong -- like in Surah Abasa, when he turned away from Abdullah ibn Umm Maktoom, Allah revealed a rebuke in the Qur'an.
Also, sunnah, linguistically, means something habitually done by someone. Islamically, it means a collection of actions, approvals, etc. that Allah inspired the Prophet to do.
Based on these points, it doesn't really make sense to follow his actions prior to his prophethood as part of his sunnah, because they are not linked to divine guidance.
Source: Seerah + usool-ul-fiqh classes
Comment: But wasn't he always destined to become a Prophet? Hasn't Allah only choose those who are the best of us to become prophets? I would have thought this meant that Muhammad peace be upon him would have been a good example, even before receiving the Quran
Comment: @Pureferret being destined is one thing, quite different and separate from having all of your life divinely guided as a source of legislation for all time.
Answer: There are certainly stories form before Muhammad (Peace and Blessings be upon him), became a Prophet of Allah that we can learn form and are often cited as such, though I do not have a grasp as to whether these have the same level of authenticity as when his actions were being actively recorded.
One such story is told by Muhammad himself:

The apostle of Allah later told how Allah had preserved him in his childhood and state of innocence, saying, 'I was among Quraysh boys and we were carrying stones for some play. We were all naked, and every boy had placed his ezar [loincloth] around his neck to carry stones in it, and I had done the same as . When I was thus moving about, some Being whom I did see struck me a fearful blow and exclaimed, "Bind on thy ezar "; accordinglyl I girded myself therewith, and thus carried the stones on my neck, I being the only one among my companions who wore his ezar.'
Answer: Qur'an says Prophet (SAW) was already lost then Allah guided him:
Ad-Duhaa:93/7:

وَوَجَدَكَ ضَالًّا فَهَدَىٰ
And did He not find you erring and guided you?