beating (one's) chops and (one's) brains out

a coined expression from batting (one's) chops, talking idly but volubly and beating (one's) brains out, laboring strenuously with the mind, often with a sense of having failed.