This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This snippet is a piece of trivia that illustrates some behaviour of closures in JS. | |
// Remember: With great power comes great responsibility! | |
// For details, see my blog post: | |
// http://kos.gd/2013/01/closures-the-cute-pets-that-bite/ | |
// Setup | |
if (typeof(print) === 'undefined') print = console.log.bind(console); | |
// For starters: | |
// Here's a function that calculates a sum of every N-th element of a given array. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
This module shows... | |
a) how GLSL error locations are presented depending on how the shader source is passed | |
(one string vs array of strings), | |
b) whether a single token can spread across several source strings. | |
''' | |
import ctypes | |
from OpenGL import GL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Some setup... | |
import sys | |
def throws(msg, f): | |
try: | |
f() | |
except Exception, e: | |
return msg in str(e) | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import operator | |
commands = {} | |
@operator.attrgetter('__get__') | |
def command(name, func): | |
commands[name] = func | |
return func | |
NewerOlder