Skip to content

Instantly share code, notes, and snippets.

@ratchit
ratchit / gist:4965687
Last active December 13, 2015 19:49
Bitmask convenience functions in JavaScript.
// Return the value of one offset bit in mask
function bit_query( mask, bit ) {
return ( ( mask & ( 1 << bit ) ) >> bit );
}
// Return input mask with offset bit switched ON
function bit_on( mask, bit ) {
return ( mask | ( 1 << bit ) );
}
@ratchit
ratchit / gist:3942066
Created October 23, 2012 22:23
Flask MethodView decorators for individual request methods
from flask.views import MethodView
class MethodView(MethodView):
_decorators = {}
def dispatch_request(self, *args, **kwargs):
"""Derived MethodView dispatch to allow for decorators to be
applied to specific individual request methods - in addition