Last active
December 23, 2015 04:29
-
-
Save benosteen/6580196 to your computer and use it in GitHub Desktop.
This file contains 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
def bars(html_filename, list_of_stuff): | |
with open(html_filename, "w") as htmlfile: | |
htmlfile.write("<html><head><style>.bar { width: 100%; height: 0.3em; } </style></head><body>") | |
for instance_number in list_of_stuff: | |
htmlfile.write('<div class="bar" style="background-color: #{0};"> </div>\n'.format(instance_number)) | |
htmlfile.write("</body></html>") | |
def blocks(html_filename, list_of_stuff): | |
with open(html_filename, "w") as htmlfile: | |
htmlfile.write("<html><head><style>.block { width: 0.3em; height: 0.3em; float:left; } </style></head><body>") | |
for instance_number in list_of_stuff: | |
htmlfile.write('<div class="block" style="background-color: #{0};"> </div>\n'.format(instance_number)) | |
htmlfile.write("</body></html>") | |
from struct import pack | |
# Methods to generate random and ordered numbers for testing: | |
def random_stuff(amount): | |
from random import randint | |
# Create 'amount' of 6 digit hex numbers as a string, from 3 random (0 -> 255) numbers packed together: | |
return map(lambda x: pack("BBB", randint(0,255), randint(0,255), randint(0,255)).encode("hex"), range(amount)) | |
def ordered_stuff(amount): | |
delta = (256 ** 3 - 1) / amount | |
return map(lambda x: pack("BBB", delta*x / 256 ** 2, delta*x / 256 % 256, delta*x % 256 ).encode("hex"), range(amount)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment