US snacks maker John B. Sanfilippo & Son has posted a profit for the first half of its financial year as a series of moves to make the business profitable paid off.