Of course my Marshall has feedback cancelling...

Today I was fooling around with my school's Peavey, and I managed to get some feedback out of it by putting the cord hafway into the guitar.

I was curious of why this would happen? I mean to say like 7/8s of the way into the guitar, and that's what caused the feedback. Like Nirvana's old gigs, the amp is almost always squealing and screeching unless Kurt muted the guitar.
I have never heard of feedback being caused by a cable being improperly connected. If anything, feedback should be less easy to happen- either the signal mutes completely because the tip of the cable is not making contact with the jack clip, or the bad connection sends less of the actual guitar signal to the amp.

Feedback is caused typically by the output of the amp being fed back into itself through the guitar pickups. That itself is usually incited by a lot of gain (distortion) and volume, all the while having the guitar very close to and/or facing the amp's speakers. At some levels of gain, amps will self oscillate which sounds a lot like feedback but is not controllable and really not musical.

Feedback is very useful for increasing sustain and provoking hyped harmonics. It can make your guitar feel more "alive" and rowdy. But if you cannot control it, you have a very annoying problem. There are a few devices that simulate or emulate feedback. One is the Ebow, which basically vibrates the guitar string. Another is the Digitech Freqout which emulates feedback in pedal form with a lot of tweakability.
Amp feedback is caused by the speakers moving the air, which moves the strings of your guitar. If you're in the right place with the right amount of air-moving (volume) going on at the right frequency, you have feedback sustain (as it becomes a sort of loop). "Gain" isn't necessary (you can do this with a completely clean amp).

An eBow doesn't produce feedback-like sounds. It produces sustain because it sort of endlessly "bows" a single string something like a cello bow.

One of the few devices that produces feedback-like sounds is the sustainer. Two brands are at the forefront; the Fernandes Sustainer and the Sustainiac, but you'll also find the old Kramer-Floyd Rose sustainer on a few guitars, including the PC-1 Jackson Phil Collen sig guitar. These produce a feedback loop similar to the amp-volume thing, but instead of using amp volume to excite the string(s), it uses an electromagnet that looks like a pickup in the neck position. It takes a signal from the bridge pickup, feeds it to the sustainer driver in the neck position through a PC board, and that gives you the same basic sound as amp-driven feedback, but with no need for an amp to even be connected to the guitar. The better sustainers allow you to change the harmonic frequency of the feedback (usually to an octave above or to some combination of the original frequency and the octave), and they also allow you to adjust things like the sensitivity and amount of feedback generated. Great for recording, great for your hearing.