Skip to content

Instantly share code, notes, and snippets.

View lukasz-madon's full-sized avatar

Lukasz lukasz-madon

View GitHub Profile
(function() {
window.S3Upload = (function() {
S3Upload.prototype.s3_object_name = 'default_name';
S3Upload.prototype.s3_sign_put_url = '/signS3put';
S3Upload.prototype.file_dom_selector = 'file_upload';
@lukasz-madon
lukasz-madon / gist:6685451
Created September 24, 2013 14:17
Reversing bits in python e.g 13 which is 1101 becomes 1011 which is 11
def reverse_bits(x):
out = 0
len = 0
num = x
while num > 0:
num /= 2
len += 1
for i in xrange(0, len):
bit = x >> i & 1
out |= bit << (len - 1 - i)
// This bit is important. It detects/adds XMLHttpRequest.sendAsBinary. Without this
// you cannot send image data as part of a multipart/form-data encoded request from
// Javascript. This implementation depends on Uint8Array, so if the browser doesn't
// support either XMLHttpRequest.sendAsBinary or Uint8Array, then you will need to
// find yet another way to implement this. (This is left as an exercise for the reader,
// but if you do it, please let me know and I'll integrate it.)
// from: http://stackoverflow.com/a/5303242/945521
if ( XMLHttpRequest.prototype.sendAsBinary === undefined ) {