Created
January 4, 2013 22:56
-
-
Save inky/4458257 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 urllib | |
| from collections import defaultdict | |
| FAVICON_URL = "http://daringfireball.net/graphics/favicon.ico?v=005" | |
| print('Reading %s' % FAVICON_URL) | |
| icon_bytes = urllib.urlopen(FAVICON_URL).read() | |
| freq = defaultdict(int) | |
| for byte in icon_bytes: | |
| freq[ord(byte)] += 1 | |
| freq = tuple(reversed(sorted( (count, byte) for (byte, count) in freq.items() ))) | |
| print('') | |
| print('Bytes Frequency') | |
| print('-----------------') | |
| print('Total %d' % len(icon_bytes)) | |
| for (count, byte) in freq[:10]: | |
| print('%02X %d' % (byte, count)) |
This file contains hidden or 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
| Reading http://daringfireball.net/graphics/favicon.ico?v=005 | |
| Byte Frequency | |
| ----------------------- | |
| Total 6518 | |
| 00 2169 | |
| FF 896 | |
| 5A 621 | |
| 52 621 | |
| 4A 617 | |
| F1 426 | |
| 01 77 | |
| 06 40 | |
| 2A 32 | |
| 2D 29 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment