I really like the Flat Spring Generator by Chrisspen, and I used it for a battery holder I was working on, but thought it had some shortcomings.
-The original function took a length and curve diameter. This meant the user had to do some math if he wanted the curves to line up optimally with the spatial endpoints. My version takes a "bends" parameter instead. If you specify an even number of bends, the two spring endpoints will be on the same side of the space. An odd number will put them on opposite sides. The endpoints will always align with the midpoint of a curve(each endpoint is considered 1/2 of a bend).
-The original function always produced 180 degree bends. This is fine for a basic spring, but can result in inefficient use of space, and narrow bends resulting in kinks when the spring is later deformed. My version accepts a "spacing" paremeter which it uses to try and optimize the space used for a longer spring with wider, more graceful curves which should deform better. This should result in more durable springs for the same amount of space as the original.
Update Aug 21, 2019: fixed artifacts appearing if spring curve angles were wide.