Skip to content

Instantly share code, notes, and snippets.

@inky
Created January 4, 2013 22:56
Show Gist options
  • Select an option

  • Save inky/4458257 to your computer and use it in GitHub Desktop.

Select an option

Save inky/4458257 to your computer and use it in GitHub Desktop.
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))
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