Java Iterate Bits in Byte Array

You’d have to write your own implementation of Iterable<Boolean> which took an array of bytes, and then created Iterator<Boolean> values which remembered the current index into the byte array and the current index within the current byte. Then a utility method like this would come in handy: private static Boolean isBitSet(byte b, int bit) { … Read more

Using for loop inside of a JSP

You concrete problem is caused because you’re mixing discouraged and old school scriptlets <% %> with its successor EL ${}. They do not share the same variable scope. The allFestivals is not available in scriptlet scope and the i is not available in EL scope. You should install JSTL (<– click the link for instructions) … Read more

Retry a Bash command with timeout

You can simplify things a bit by putting command right in the test and doing increments a bit differently. Otherwise the script looks fine: NEXT_WAIT_TIME=0 until [ $NEXT_WAIT_TIME -eq 5 ] || command; do sleep $(( NEXT_WAIT_TIME++ )) done [ $NEXT_WAIT_TIME -lt 5 ]