Today's phrase is actually derived from a nick-name given to an actual person. Here from the folks at Listverse is the whole story.
A “smart aleck” (or “smart alec”) is a person who, to the irritation of everyone around, acts like they know everything. The phrase was inspired by a 19th-century man named Alec Hoag. Hoag and his wife, Melinda, were robbers in New York City. They developed a con that involved Melinda posing as a prostitute and luring innocent customers into a dark alley. While making out with the unsuspecting victims, she’d slyly steal valuables from their pockets and hand them to Hoag, who was hiding nearby. The duo, knowing that some of their victims would report to the authorities, struck a deal with several police officers to split the valuables with them.
Hoag stopped giving the police officers their share after he ran into some financial troubles. To avoid suspicion, he came up with the “panel game.” In this new scheme, Melinda would instead lead the victims to their apartment, where she would have them take off their clothes and give a subtle signal. Alec would emerge and secretly take the valuables from the clothes before leaving through an exit. Then, to the horror of the victim, Hoag would knock on the door. Melinda would tell the victim that it was her husband, who’d returned from a trip earlier than expected. The victim would quickly pick up their clothes and escape through the window.
The police soon discovered the couple’s new scheme and subsequently arrested and jailed them. The nickname “Smart Alec” was given to him by police officers mocking him for trying to outsmart them, and it soon became widely used in the decades that followed.
I've known more than one person that the nick-name could apply to. In each case, the name was well earned!
Coffee out on the patio this morning. Supposed to be drying out today!