I almost don't mind releasing my code public domain (and in fact I often do that) but lately I was thinking about if there is a license I could use which forbids the usage of my code for weapons, and now with all the NSA stuff perhaps even spying or more general "harming humanity" or something?
If you do choose to license your code under such a license, it would not be considered open source (according to the OSI) or free software (according to the FSF). Here's the relevant part of the Open Source Definition:
> The license must not restrict anyone from making use of the program in a specific field of endeavor. For example, it may not restrict the program from being used in a business, or from being used for genetic research.
You can insert a morality clause into your code. However, a broad one ("do no evil" essentially) will make your code unusable unless you define, in exact detail and in legalese, your own moral code. You could prohibit individual activities, but then you run the risk of having your code used for undesirable activities that you previously could not have foreseen.
If the code is never put into a public project I don't see how this would have any effect. I'm not required to abide by every license on everything I slap together on my laptop, it's when I distribute it or allow others (outside my organization) to use it that matters.
It depends on what kind of license it is: if it's an end-user license, then yes, you do (in theory) have to abide by it.
You're right that if it's just a copyright on the source code, then it's probably a restriction on redistribution, which means you couldn't _use_ that code for evil and then share it with others. But using it for evil for yourself: totally fine.
For an end-user license, sure. But even so the license restrictions only apply to the _recipients_. So if I'm the NSA and use GPL code, and only distribute it to NSA colleagues, I only have to provide my NSA colleagues with the license and code. (IANAL, but seems pretty clear to me on this)