eDonkey2000 Hash in Python
As part of a filesystem watcher program I maintain as part of a larger site, I need to obtain the ed2k hash of some files. Believe me when I tell you I have searched high and low for an Edonkey2000 hash algorithm in python. I've seen massive libraries that scared the bejesus out of me, but nothing clean, concise, and without external dependencies. Enjoy the below. It's worth noting it's just as fast as the C version.
import hashlib def hash_file(self, file_path): """ Returns the ed2k hash of a given file. """ md4 = hashlib.new('md4').copy def gen(f): while True: x = f.read(9728000) if x: yield x else: return def md4_hash(data): m = md4() m.update(data) return m with open(file_path, 'rb') as f: a = gen(f) hashes = [md4_hash(data).digest() for data in a] if len(hashes) == 1: return hashes[0].encode("hex") else: return md4_hash(reduce(lambda a,d: a + d, hashes, "")).hexdigest()
Linux Hates my Palm Pre
For the life of me, I can not get my desktop Linux to recognize (and thus charge or give filesystem access to) my Palm Pre. Apparently no one else on the Internet has this problem.
I've tried enabling low level usb debugging in the kernel, and I can see when I plug the device in:
usb 7-5.1.3: no configuration chosen from 1 choice
When Your Gentoo Desktop is Just a White Screen
Yeah, so this has happened to me twice, each time I forget how to fix it until too late.
As root:
eselect opengl list / eselect opengl set <nvidia/etc>