What play is "to thine own self be true" from?
The quote you are referring comes from the famous parting advice of Polonius to his son Laertes in Shakespeare's Hamlet. Polonius gives the young man a great deal of practical worldly advice and concludes with these lines:
This above all: to thine ownself be true,
And it must follow, as the night the day,
Thou canst not then be false to any man.
The speech is to be found in Act 1, Scene 3 of the play. It begins with the following lines:
Yet here, Laertes! aboard, aboard, for shame!
The wind sits in the shoulder of your sail,
And you are stay'd for. There; my blessing with thee!
And these few precepts in thy memory
See thou character.
By "See thou character" he means something like "See that thou print" or "See that thou engrave."
Laertes is going to travel to France by sailing ship in order to attend the university in Paris. In this scene, Polonius is portrayed as a loving father of both Ophelia and Laertes. Polonius has been to a university himself, as he tells Hamlet in a later scene, and he is well aware of all the various kinds of trouble that a young man can get into when he goes away to college and is enjoying an exhilarating amount of freedom for the first time in his life.
Sometime later, in Act 2, Scene 1, Polonius will be shown sending a servant named Reynaldo to France to spy on Laertes, showing how apprehensive the father is about his young son. This helps to characterize Polonius as a man who is addicted to spying on people--a trait which will result in his own death.
Ralph Waldo Emerson's most famous essay "Self-Reliance" focuses on the theme of being true to one's own self.