Cimetidine inhibits bothe CYP2D6 and CYP3A4, so it's not going to be much good for codeine or any drug with a 3-O-methyl group as that methyl group is removed by CYP2D6. For drugs with said O-methyl group, you just want something that inhibits CYP3A4, like grapefruit juice, as it's responsible for the removal of the N-methyl group (which results in codeine to norcodeine, morphine to normorphine etc) and removal of said N-methyl group results in compounds that have much less opiate activity.
If instead the drug has a 3-hydroxy group (like morphine etc), then cimetidine is useful as CYP2D6 plays no role in the metabolism of these drugs.
So basically:
For codeine; dihydrocodeine; hydrocodone etc you want grapefruit juice, but not cimetidine
For morphine; dihydromorphine; hydromorphone etc you can use either grapefruit juice or cimetidine