UPDATE: this exploit was patched out of the console versions of the game in the 1.3 patch. As you play, record every single winning and losing outcome of the game as much as. Play the low stakes CalicoJack table casually.
Get to the casino and buy some Qi coins (at least around 1,000 Qi). If you're trying to use the same codes and are having problems with repeating an animal name, try changing the order of the codes or adding a number/letter on the end and that should allow it to go through. Here's my method: Make sure that your day is a very lucky day as it means there's a high frequency of winning more than two or three times in a row. It's best to buy a chicken for this, and use the code(s) when naming it to get specific item(s) you really need. You can also utilise this Stardew Valley cheat when it comes to purchasing and naming an animal, but you only get the item(s) once.
If you want to speed up this process further, go and chat to Gus the bartender at the saloon as he regularly mentions your name. For example, naming yourself will mean that whenever the game references your name you'll receive a Legend fish, Treasure Chest, and Stardrop in your inventory which can be sold for 5,000g, 5,000g, and 7,777g respectively, although the Stardrop is often consumed automatically rather than remaining in your inventory to sell. When it comes to Stardew Valley cheats, this is the big one! Every item in the game has a unique numerical code, and by using up to three of these codes each in as your character name, you'll spawn those items in your inventory every time your name is mentioned in the game.