UK, 1711—means that anyone can be right occasionally, if only by chance—often used specifically to suggest that one holding a fixed belief regardless of changing circumstances will occasionally, if rarely, be correct
USA, 1811—based on the three principal components that make up a flintlock gun: ‘lock’ denotes the firing mechanism, ‘stock’ the handle or wooden shoulder-piece to which it is attached, and ‘barrel’ the tube down which the bullet is fired
Many centuries before becoming a nickname for New York City and the name of a fictional city associated with the Batman stories, Gotham was used in Britain as the name of a (probably fictional) village proverbial for the folly of its inhabitants.