I have been doing a lot of code porting lately, and I can understand the issues of just copying and pasting code in that you don't understand.
I look for code that has no dependencies first, where all of the code is self-contained.
This is one of the issues I find working with an API or Library created by someone else, you don't really know their mindset.
I have been thinking creating a website where nothing but algorithms are posted (and explained), which can work independent of the syntax of the particular language you are using.
Even if you find code that works, is it the code that is most efficient for what you are doing? I think there is a website with various algorithms for game development. I will post when I find it.
First, understand what it is you want to do, and then find code that is adaptable to that.
Edit: The key word is Chrestomathie
http://www.gamedev.net/topic/656764-anyone-know-of-any-game-programming-chrestomathies/