else clause on loops

An interesting control flow for Python, for n in range(2, 10): for x in range(2, n): if n % x == 0: print n, ‘equals’, x, ‘*’, n/x break else: # loop fell through without finding a factor print n, ‘is a prime number’

Origin null is not allowed by Access-Control-Allow-Origin

If you are testing a simple ajax and found an error from Google Chrome’s element inspector, XMLHttpRequest cannot load file:///. Origin null is not allowed by Access-Control-Allow-Origin. High chances you are running the files directly from your computer (file://). Throw them in your localhost web server and it will work automagically. My own dumb discovery […]