Can I hint the optimizer by giving the range of an integer?

Yes, it is possible. For example, for gcc you can use __builtin_unreachable to tell the compiler about impossible conditions, like so: if (value < 0 || value > 36) __builtin_unreachable(); We can wrap the condition above in a macro: #define assume(cond) do { if (!(cond)) __builtin_unreachable(); } while (0) And use it like so: assume(x … Read more

Javascript: Generate a random number within a range using crypto.getRandomValues

IMHO, the easiest way to generate a random number in a [min..max] range with window.crypto.getRandomValues() is described here. An ECMAScript 2015-syntax code, in case the link is TL;TR: function getRandomIntInclusive(min, max) { const randomBuffer = new Uint32Array(1); window.crypto.getRandomValues(randomBuffer); let randomNumber = randomBuffer[0] / (0xffffffff + 1); min = Math.ceil(min); max = Math.floor(max); return Math.floor(randomNumber * … Read more

PHP range() from A to ZZ?

Take advantage of PHP’s ability to increment characters “perl-style” $letters = array(); $letter=”A”; while ($letter !== ‘AAA’) { $letters[] = $letter++; } But you could also use simple integer values, and take advantage of PHPExcel’s built-in PHPExcel_Cell::stringFromColumnIndex() method EDIT From PHP 5.5, you can also use Generators to avoid actually building the array in memory … Read more