How to construct a random error-correcting code (its generator matrix) according to the code parameters?
Look at Reed–Solomon codes. They are MDS codes, and AFAIK, MDS codes are most efficient codes that operates on independent blocks of bits.

If you need to support only erasures, there is simple to describe algorithm - consider input words as values of some polynomial at points 0..n-1, and compute (using a Galois Field) values of the same polynomial at points n..n+m-1 - it will be possible to restore polynomial coefficients from any n survived values.

If you can read Russian, I wrote more about erasure-only codes at ReedSolomonFFT-ru.md.