Combine the cucumber slices, onion slices, and salt in a large bowl.
Cover with ice water and let stand for 2 hours.
Drain thoroughly and rinse lightly.
In a saucepan, combine both vinegars, sugar, mustard seeds, celery seeds, red pepper flakes, turmeric, peppercorns, and garlic if using.
Bring the mixture to a gentle boil, stirring until the sugar completely dissolves.
Add the drained cucumbers and onions to the hot brine.
Simmer for about 5 minutes until the cucumbers are slightly translucent but still crisp.
Carefully pack the pickles into clean jars and pour the hot brine over them.
Allow the jars to cool completely before sealing.
Refrigerate for at least 24 hours before serving for the best flavor.