Click to See Complete Forum and Search --> : World's Longest HTML List?


Mr Initial Man
10-19-2008, 02:32 AM
Well, I had myself some fun: I wrote a script that generated a page that had a list on it. The list elements looked like this:

<li>#hexade <div style="background:hexade;"> </div></li>

The reason was simple: "#hexade" stood for a hexadecimal number. The div's background was therefore the color resulting from that hexadecimal number.

Here's where my list goes into the realm of the absurd: It contained every possible color for a webpage.

Every. Single. One.

Yes, my list goes from #000000 to #ffffff, leaving me with a page that's around 960 MB (no, that's not a typo), and 16,777,216 list items.

So, I ask you: Is that the world's longest HTML list and the world's largest webpage?

Jick
10-19-2008, 06:41 AM
That's ludicrous! Are you mad!? What's wrong with you!? :p

Sunny G
10-19-2008, 10:08 AM
I've always wanted to do this! Dude, you're awesome.
Now you just need to format it in a table it's not such a long list.
You know, each table cell will have its own background color.

Again, this is awesome. I'd love to see it.

scragar
10-19-2008, 10:23 AM
:p

Intresting...

<?php

for($i = 0; $i < 256; $i++){
$strI = ($i < 16)?'0'.dechex($i):dechex($i);
echo "<p>#{$strI}0000 - #{$strI}FFFF</p>
<table><tbody>";
for($j = 0; $j < 256; $j++){
$strJ = ($j < 16)?'0'.dechex($j):dechex($j);
echo "\n\t<tr><!-- #{$strI}{$strJ}?? -->";
for($k = 0; $k < 256; $k++){
$strK = ($k < 16)?'0'.dechex($k):dechex($k);
echo "\n\t\t<td style='color: #{$strI}{$strJ}{$strK}'>#{$strI}{$strJ}{$strK}</td>";
};
echo "\n\t</tr>";
};
echo "</tbody></table>\n";
};
if someone doesn't mind the huge ram requirement you could run that...

Mr Initial Man
10-19-2008, 12:18 PM
You want tables? I'll give you a table. It is SO on now!

You left out one thing I did, scragar: my script writes to an HTML file.

The current list can be found at http://mrinitialman.furtopia.org/Experiments/Colors/all_colors.zip Yes, it's in a zip file; my host admin insisted for obvious reasons.

NogDog
10-19-2008, 01:57 PM
This is better as a thought experiment than as something you'll ever want to run on a live host. :eek:

absurd.php:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
body {
font: 8pt 'courier new', courier, monospace;
}
ul {
margin: 0;
padding: 0;
list-style: none;
}
li {
float: left;
padding: 0 0 0 0.5em;
}
</style>
</head>
<body>
<ul>
<?php
for ($color = 0; $color <= 0xFFFFFF; $color++)
{
printf("<li>%06x <img src='image.php?color=%06x' width='40' height='10'></li>\n",
$color, $color);
}
?>
</ul>
</body>
</html>

image.php:

<?php
if(!isset($_GET['color']))
{
exit;
}
$red = min(hexdec(substr($_GET['color'], 0, 2)), 255);
$green = min(hexdec(substr($_GET['color'], 2, 2)), 255);
$blue = min(hexdec(substr($_GET['color'], 4, 2)), 255);
$img = imagecreate(1,1);
$color = imagecolorallocate($img, $red, $green, $blue);
imagesetpixel($img, 0, 0, $color);
header('Content-Type: image/png');
imagepng($img);
exit;
?>

:p

scragar
10-19-2008, 02:07 PM
This is better as a thought experiment than as something you'll ever want to run on a live host. :eek:

absurd.php:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
body {
font: 8pt 'courier new', courier, monospace;
}
ul {
margin: 0;
padding: 0;
list-style: none;
}
li {
float: left;
padding: 0 0 0 0.5em;
}
</style>
</head>
<body>
<ul>
<?php
for ($color = 0; $color <= 0xFFFFFF; $color++)
{
printf("<li>%06x <img src='image.php?color=%06x' width='40' height='10'></li>\n",
$color, $color);
}
?>
</ul>
</body>
</html>

image.php:

<?php
if(!isset($_GET['color']))
{
exit;
}
$red = min(hexdec(substr($_GET['color'], 0, 2)), 255);
$green = min(hexdec(substr($_GET['color'], 2, 2)), 255);
$blue = min(hexdec(substr($_GET['color'], 4, 2)), 255);
$img = imagecreate(1,1);
$color = imagecolorallocate($img, $red, $green, $blue);
imagesetpixel($img, 0, 0, $color);
header('Content-Type: image/png');
imagepng($img);
exit;
?>

:p

OK, that's gonna be many times slower than my code, although it's a nice idea serving every image seperatly I'm not sure it's a good idea since the images will be so much larger than plain text.

Ness_du_Frat
10-19-2008, 05:02 PM
Just one word : LOL ^^
You were really bored, weren't you ? I don't want to crash my computer right now, but I might give your script a look tomorrow and run it, just for the craziness of it :)

Mr Initial Man
10-19-2008, 06:47 PM
The ZIP file contains the actual HTML file--which my host would be grateful if it didn't become TOO popular.

NogDog
10-19-2008, 10:35 PM
OK, that's gonna be many times slower than my code, although it's a nice idea serving every image seperatly I'm not sure it's a good idea since the images will be so much larger than plain text.

It was intentionally designed to be a stupid idea. ;)

Mr Initial Man
10-20-2008, 12:19 PM
Well, I generated a table of color info: Here's the thead element:

<thead>
<tr>
<th id="Color">Color</th>
<th id="RGB">RGB Notation</th>
<th id="Hex">Hexadecimal</th>
<th id="ShortHex">Short Hex</th>
<th id="ColName">Color Name</th>
</tr>
</thead>


The whole page is a table; instead of <h1>, I used <caption>. :D

So now I have 5 columns, 16,777,216 rows, a total of 83,886,080 cells in the table body (+ 1 row and 5 cells in the table head, 1 row containing 1 cell in the table foot, for a total of 16,777,218 rows and 83,886,086 cells), and a problem: I think the file (which is over 3GB) is too large to zip.

Mr Initial Man
10-20-2008, 11:29 PM
UPDATE:

The error I'm getting is: "File not found or no read permission." The file is 3.79 GB--that's 4,072,034,810 bytes.

Does this error mean that the file is too big to ZIP?

scragar
10-20-2008, 11:38 PM
why not try a different compression system? tarballs are really good for plain text(and I'm sure you can get it set up on windows, no reason why not), the tar algorithm was originally designed for archiving source files.

You could also try rar, I've seen that used on some large files before now.



EDIT: I've made a .zip of a 4GB file(OK, so it's a 4GB file of nothing, but it's still 4GB -- archive size: 3.7MB :p), so file size can't be the problem(I was going to attach it as proof, but it's too large for the forums, and honestly I can't imagine anyone caring :p if you really do want it ask), could there be other problems?

Mr Initial Man
10-21-2008, 01:05 AM
A friend of mine said that ZIP programs max out at 2 GB.

How do I do a tarball or rar with Windows XP?

scragar
10-21-2008, 06:55 AM
http://7-zip.org/ <-- 7zip supports a whole number of archive formats, so that would be your best choice(since it's free), but that only does unpacking of rar, if you do want to make a rar you will have to download the 30 day trail of winrar from rarlabs.com (no linky for them)

Mr Initial Man
10-21-2008, 11:52 AM
Thanks! It works beautifully. :)

Now, I should make a table comparing every possible color to every possible color...

<?php
$n = "\n";
$fil = 'colorcombos.html';
$top = ('?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>All Possible HTML Colors</title>
<style type="text/css">
body{
font-family:verdana, sans-serif;
font-size:12pt;
}
table, td, th{
border:1px solid black;
border-collapse:collapse;
}
td, th{
text-align:center;
width:150px;
height:40px;
}
tfoot td{
text-align:left;
padding:10px;
}
caption{
padding:20px;
font-size:300%;
}
</style>
</head>
<body>
<table>
<caption>All Possible Colors</caption>
<thead>
<tr>
');


$mid = (' </tr>
</thead>
<tbody>
');
$bot=(' </tbody>
</table>
</body>
</html>
');
$th = '';
$td = '';

file_put_contents($fil, $top);

function Z($n){
if($n < 0x10){
return '00000';
} elseif($n < 0x100){
return '0000';
} elseif($n < 0x1000){
return '000';
} elseif($n < 0x10000){
return '00';
} elseif($n < 0x100000){
return '0';
} else {
return '';
}
}

for($i = 0; $i <= 0xffffff; $i++;){
$ch = Z($i) . dechex ($i);
$th .= ' <th id="c' . $ch . '">' . $ch . '</th>' . $n;
if($i % 0xffff = 0){
file_put_contents($fil, $th, FILE_APPEND);
$th = '';
}
}

file_put_contents($fil, $th); //Make sure the entire head was written.
file_put_contents($fil, $mid);

for($i1 = 0; $i1 <= 0xffffff; $i1++;){
$bgh = Z($i1) . dechex($i1);
$td .= ' <tr>' .$n;
for($i2 = 0; $i2 <= 0xffffff; $i2++;){
$col = Z($i2) . dechex($i2);
$td .= ' <td headers="c' . $col . '" style="background:' . $bgh . ';color:' . $col . '">Test</td>' . $n;
if($i2 % 0xffff = 0){
file_put_contents($fil, $td, FILE_APPEND);
$td = '';
}
}
$td .= ' </tr>' .$n;
file_put_contents($fil, $td, FILE_APPEND);
$td = '';
}
file_put_contents($fil, $td, FILE_APPEND); //Make sure everything is written to the final file.
file_put_contents($fil, $bot, FILE_APPEND);

?>

There. That should do it. Anyone got a computer that will handle this? :D

Mr Initial Man
11-08-2008, 03:04 PM
I did some calculations. Terabytes would be inadequate to describe the size of the resulting page. :eek: Oh, what hath my mind conceived? :D

Mr Initial Man
11-15-2008, 11:33 AM
Found the total file size for such a page:

21,673,571,210,232,777 bytes

That is:

19 PiB, 255 TiB, 1022 GiB, 144 MiB, 969B


Anyone got a 20+ Pebibyte hard drive lying around?

Shorts
11-15-2008, 12:16 PM
When I get home I want to port this to Perl! Give people some options :D

scragar
11-15-2008, 01:24 PM
When I get home I want to port this to Perl! Give people some options :D

If my home computer currently had a bigger resolution than 800(I know, I just installed knopix, again, I've gotta install my graphics driver) I'd do the edits myself, isn't too much of an edit needed though, perls pretty much the same with a few minor changes.

Shorts
11-15-2008, 03:05 PM
That is true, reason it was ridiculously easy to pick up php for me. Although I do miss my unless and lines like this from perl:


$i_rule = 'I totally do';
print 'I rule' if $i_rule;

scragar
11-15-2008, 03:11 PM
That is true, reason it was ridiculously easy to pick up php for me. Although I do miss my unless and lines like this from perl:


$i_rule = 'I totally do';
print 'I rule' if $i_rule;


see, now I hate the "do something if condition" syntax, but I love using that same syntax with unless, which I don't really mind.

I do love perls little $_ aswell, saves a lot of writing, just a shame it's a little unpredictable when you start messing with scopes.