Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View whirm's full-sized avatar

Elric Milon whirm

View GitHub Profile
@whirm
whirm / autopep8.el
Created July 31, 2013 13:36
Clean up python code from Emacs.
;;; autopep8.el -- clean up python code
;
; based on js-beautify.el - http://sethmason.com/2011/04/28/jsbeautify-in-emacs.html
; Rescued from https://raw.github.com/tomscytale/autopep8/8792df48806eb3c9fb9d901529e4e967520e09c2/autopep8.el
;
; put this in your emacs init:
; (add-to-list 'load-path "~/dir/containing/autopep8/")
; (require 'autopep8)
;
; to use:
from M2Crypto import EVP
from binascii import hexlify, unhexlify
def long_to_bytes(val, nrbytes=0):
hex_val = '%x' % abs(val)
if nrbytes:
padding = '0' * ((abs(nrbytes) * 2) - len(hex_val))
else:
padding = ''
result = unhexlify(padding + hex_val)[::-1]