First-principles calculations of charge carrier mobility and conductivity in bulk semiconductors and two-dimensional materials