Overcoming addiction by yourself is difficult; I'd suggest talking with a counselor if you're serious about quitting. Otherwise, find something else to do when you feel the urge to use.
Beating an opiate addiction is extremely tough. Look into Buprenorphine. It's a drug used to detox your body and stop cravings caused by the addiction. It's honestly a miracle drug.
Beating a narcotic addiction on your own is difficult but possible. Make sure to stay hydrated by drinking lots of water, getting plenty of rest, and staying occupied.