Most of the answers here are fairly general, but there are a number of practical things you can do when developing code to make mistakes less likely. Precisely what they are will differ between languages but for example a common source of bugs are hanging if statements - many languages for not insist you bracket code if it's a single line - e.g.
if fred==bill dosomethingtofred() else dosomethingtobill();
This will often give rise to bugs - particularly if the code is edited later. I've also not bracketed the test here as again that's permissible in some languages and is a potential error generator. Myself I will always, without exception, structure an if statement in full layed out over the full linage e.g.
if (fred==bill) {
dosomethingtobill();
}
else {
dosomethingtofred();
}
(note personally I prefer line end {. Some people frown on it and in a cooperative environment it is probably better to use the new line style, however I work as a consultant primarily writing code that will be maintained by myself and I rigorously adhere to indentation standards, so the additional compactness of the code pays off)
Similar techniques can be applied in most languages over a wide range of code constructs. I'd suggest you examine carefully where you are making the stupid mistakes then consider what code structures would prevent you from doing so then and use them every time going forward. Myself I have a fairly wide range of these constructs built up over several years (for another example all my sql is layed out the same way). As well as reducing stupid errors this also has the additional advantage that I can come back to code after several years and pick up the functionality very quickly.