Was modifying some legacy code I inherited and came across this beautiful piece…
Something tells me, RECURSION, could have helped this mess.
Click here to see the whole thing…
Taste:
# This sorts out the responses. It currently goes to seventeen levels.
for (my $a = 0; $a < $message_counter; $a++) {
my $no = ($all_these{$response_to[$a]} ? 0 : 1);
if ($response_to[$a] == 0 || $no) {
$page .= qq(\r<BR>) . ‘ ’ x 2 . qq($line[$a]);
for (my $b = 0; $b < $message_counter; $b++) {
if ($response_to[$b] == $message_id[$a]) {
$page .= “\r<BR>” . ‘ ’ x 4 . qq($line[$b]);
for (my $c = 0; $c < $message_counter; $c++) {
if ($response_to[$c] == $message_id[$b]) {
$page .= “\r<BR>” . ‘ ’ x 6 . qq($line[$c]);
for (my $d = 0; $d < $message_counter; $d++) {
if ($response_to[$d] == $message_id[$c]) {
$page .= “\r<BR>” . ‘ ’ x 8 . qq($line[$d]);
for (my $e = 0; $e < $message_counter; $e++) {
if ($response_to[$e] == $message_id[$d]) {
$page .= “\r<BR>” . ‘ ’ x 10 . qq($line[$e]);
for (my $f = 0; $f < $message_counter; $f++) {
if ($response_to[$f] == $message_id[$e]) {
$page .= “\r<BR>” . ‘ ’ x 12 . qq($line[$f]);
for (my $g = 0; $g < $message_counter; $g++) {
if ($response_to[$g] == $message_id[$f]) {
$page .= “\r<BR>” . ‘ ’ x 14 . qq($line[$g]);
for (my $h = 0; $h < $message_counter; $h++) {
if ($response_to[$h] == $message_id[$g]) {
$page .= “\r<BR>” . ‘ ’ x 16 . qq($line[$h]);
for (my $i = 0; $i < $message_counter; $i++) {
if ($response_to[$i] == $message_id[$h]) {
$page .= “\r<BR>” . ‘ ’ x 18 . qq($line[$i]);
for (my $j = 0; $j < $message_counter; $j++) {
if ($response_to[$j] == $message_id[$i]) {
$page .= “\r<BR>” . ‘ ’ x 20 . qq($line[$j]);
for (my $k = 0; $k < $message_counter; $k++) {
if ($response_to[$k] == $message_id[$j]) {
$page .= “\r<BR>” . ‘ ’ x 22 . qq($line[$k]);
for (my $l = 0; $l < $message_counter; $l++) {
if ($response_to[$l] == $message_id[$k]) {
$page .= “\r<BR>” . ‘ ’ x 24 . qq($line[$l]);
for (my $m = 0; $m < $message_counter; $m++) {
if ($response_to[$m] == $message_id[$l]) {
$page .= “\r<BR>” . ‘ ’ x 26 . qq($line[$m]);
for (my $n = 0; $n < $message_counter; $n++) {
if ($response_to[$n] == $message_id[$m]) {
$page .= “\r<BR>” . ‘ ’ x 28 . qq($line[$n]);
for (my $o = 0; $o < $message_counter; $o++) {
if ($response_to[$o] == $message_id[$n]) {
$page .= “\r<BR>” . ‘ ’ x 30 . qq($line[$o]);
for (my $p = 0; $p < $message_counter; $p++) {
if ($response_to[$p] == $message_id[$o]) {
$page .= “\r<BR>” . ‘ ’ x 32 . qq($line[$p]);
for (my $q = 0; $q < $message_counter; $q++) {
if ($response_to[$q] == $message_id[$p]) {
$page .= “\r<BR>” . ‘ ’ x 34 . qq($line[$q]);
for (my $r = 0; $r < $message_counter; $r++) {
if ($response_to[$r] == $message_id[$q]) {
$page .= “\r<BR>” . ‘ ’ x 36 . qq($line[$r]);
for (my $s = 0; $s < $message_counter; $s++) {
if ($response_to[$s] == $message_id[$r]) {
$page .= “\r<BR>” . ‘ ’ x 38 . qq($line[$s]);
for (my $t = 0; $t < $message_counter; $t++) {
if ($response_to[$t] == $message_id[$s]) {
$page .= “\r<BR>” . ‘ ’ x 40 . qq($line[$t]);
for (my $u = 0; $u < $message_counter; $u++) {
if ($response_to[$u] == $message_id[$t]) {
$page .= “\r<BR>” . ‘ ’ x 42 . qq($line[$u]);
for (my $v = 0; $v < $message_counter; $v++) {
if ($response_to[$v] == $message_id[$u]) {
$page .= “\r<BR>” . ‘ ’ x 44 . qq($line[$v]);
for (my $w = 0; $w < $message_counter; $w++) {
if ($response_to[$w] == $message_id[$v]) {
$page .= “\r<BR>” . ‘ ’ x 46 . qq($line[$w]);
for (my $x = 0; $x < $message_counter; $x++) {
if ($response_to[$x] == $message_id[$w]) {
$page .= “\r<BR>” . ‘ ’ x 48 . qq($line[$x]);
for (my $y = 0; $y < $message_counter; $y++) {
if ($response_to[$y] == $message_id[$x]) {
$page .= “\r<BR>” . ‘ ’ x 50 . qq($line[$y]);
for (my $z = 0; $z < $message_counter; $z++) {
if ($response_to[$z] == $message_id[$y]) {
$page .= “\r<BR>” . ‘ ’ x 52 . qq($line[$z]);
for (my $aa = 0; $aa < $message_counter; $aa++) {
if ($response_to[$aa] == $message_id[$z]) {
$page .= “\r<BR>” . ‘ ’ x 54 . qq($line[$aa]);
for (my $bb = 0; $bb < $message_counter; $bb++) {
if ($response_to[$bb] == $message_id[$aa]) {
$page .= “\r<BR>” . ‘ ’ x 56 . qq($line[$bb]);
for (my $cc = 0; $cc < $message_counter; $cc++) {
if ($response_to[$cc] == $message_id[$bb]) {
$page .= “\r<BR>” . ‘ ’ x 58 . qq($line[$cc]);
for (my $dd = 0; $dd < $message_counter; $dd++) {
if ($response_to[$dd] == $message_id[$cc]) {
$page .= “\r<BR>” . ‘ ’ x 60 . qq($line[$dd]);
for (my $ee = 0; $ee < $message_counter; $ee++) {
if ($response_to[$ee] == $message_id[$dd]) {
$page .= “\r<BR>” . ‘ ’ x 62 . qq($line[$ee]);
for (my $ff = 0; $ff < $message_counter; $ff++) {
if ($response_to[$ff] == $message_id[$ee]) {
$page .= “\r<BR>” . ‘ ’ x 64 . qq($line[$ff]);
for (my $gg = 0; $gg < $message_counter; $gg++) {
if ($response_to[$gg] == $message_id[$ff]) {
$page .= “\r<BR>” . ‘ ’ x 66 . qq($line[$gg]);
for (my $hh = 0; $hh < $message_counter; $hh++) {
if ($response_to[$hh] == $message_id[$gg]) {
$page .= “\r<BR>” . ‘ ’ x 68 . qq($line[$hh]);
for (my $ii = 0; $ii < $message_counter; $ii++) {
if ($response_to[$ii] == $message_id[$hh]) {
$page .= “\r<BR>” . ‘ ’ x 70 . qq($line[$ii]);
for (my $jj = 0; $jj < $message_counter; $jj++) {
if ($response_to[$jj] == $message_id[$ii]) {
$page .= “\r<BR>” . ‘ ’ x 72 . qq($line[$jj]);
for (my $kk = 0; $kk < $message_counter; $kk++) {
if ($response_to[$kk] == $message_id[$jj]) {
$page .= “\r<BR>” . ‘ ’ x 74 . qq($line[$kk]);
for (my $ll = 0; $ll < $message_counter; $ll++) {
if ($response_to[$ll] == $message_id[$kk]) {
$page .= “\r<BR>” . ‘ ’ x 76 . qq($line[$ll]);
for (my $mm = 0; $mm < $message_counter; $mm++) {
if ($response_to[$mm] == $message_id[$ll]) {
$page .= “\r<BR>” . ‘ ’ x 78 . qq($line[$mm]);
for (my $nn = 0; $nn < $message_counter; $nn++) {
if ($response_to[$nn] == $message_id[$mm]) {
$page .= “\r<BR>” . ‘ ’ x 80 . qq($line[$nn]);
for (my $oo = 0; $oo < $message_counter; $oo++) {
if ($response_to[$oo] == $message_id[$nn]) {
$page .= “\r<BR>” . ‘ ’ x 82 . qq(<A HREF=”sub_discuss.cgi?section_id=$section_id&subject_id=$subject_id&vp=1&message_id=$message_id[$oo]&vp=1#$message_id[$oo]“><I>more…</I></A>);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
# This sorts out the responses. It currently goes to seventeen levels.
for (my $a = 0; $a < $message_counter; $a++) {
my $no = ($all_these{$response_to[$a]} ? 0 : 1);
if ($response_to[$a] == 0 || $no) {
$page .= qq(\r<BR>) . ' ' x 2 . qq($line[$a]);
for (my $b = 0; $b < $message_counter; $b++) {
if ($response_to[$b] == $message_id[$a]) {
$page .= "\r<BR>" . ' ' x 4 . qq($line[$b]);
for (my $c = 0; $c < $message_counter; $c++) {
if ($response_to[$c] == $message_id[$b]) {
$page .= "\r<BR>" . ' ' x 6 . qq($line[$c]);
for (my $d = 0; $d < $message_counter; $d++) {
if ($response_to[$d] == $message_id[$c]) {
$page .= "\r<BR>" . ' ' x 8 . qq($line[$d]);
for (my $e = 0; $e < $message_counter; $e++) {
if ($response_to[$e] == $message_id[$d]) {
$page .= "\r<BR>" . ' ' x 10 . qq($line[$e]);
for (my $f = 0; $f < $message_counter; $f++) {
if ($response_to[$f] == $message_id[$e]) {
$page .= "\r<BR>" . ' ' x 12 . qq($line[$f]);
for (my $g = 0; $g < $message_counter; $g++) {
The DOM is like an Ogre — it has layers… lots and lots of layers…
This way of thinking was key to the solution I found to a very interesting problem a friend of mine presented.
Problem: Integrating a Flash game that uses the up and down arrows into a new site with drop down menus. The menus need to sit on top of the flash game, so wmode=transparent must be used. As we know, Z-index does not work when a flash piece is running in the default “window” mode. Because the page is longer than the viewable area, it needed to scroll and in IE7, when hitting the up and down arrows in the game, the whole page would scroll. Essentially when the flash piece runs in wmode=transparent|opaque, IE7 captures the keystrokes along with the flash piece.
What do we want: We want the user to be able to use the up and down arrows without the page scrolling and the key presses registering in the game like it does in all other browsers.
Solution: overflow:auto
I wrapped the flash content div in a wrapper div the exact height of the flash movie and set its overflow property to auto. What this does is put the scrolling/key capturing focus on that div instead of the document when you click on the flash piece and play the game. Because the wrapper div is the exact height, there is nothing to scroll and all works well, flash registers the key presses and the screen does not move.
Sample:
<div id="gameWrapper" style="height:400px; overflow:auto">
<div id="flashContent">Flash will load here via SWFObject call. The flash movie is 400px in height and has the param.wmode set to "transparent|opaque"</div>
<div>
I was shocked I could not find this solution as easily online as I’d hoped. I did find a few examples of this after I figured it out, but the posts were very difficult to read made a simple solution look terribly difficult.
I’m building a web based S3 explorer/media manager for a work project as well as my DizCollect project. It is being written in .NET/C# ASP.NET MVC and I had a special need — creating empty folders for users to upload files to. Since I don’t store the files locally, I couldn’t just upload new files and have the folders build out.
I use the wonderful C# S3 library ThreeSharp.
The one thing it does not do out of the box is allow you to just create an empty folder. My behavior will be that a user clicks on a “new folder” button and is presented a text box. They enter the name of the new folder and it is created in the current location they are browsing in my S3 explorer. To get ThreeSharp to do this, you must add a content_type of “binary/octet-stream” and specify the folder with a trailing ‘/’. The ‘/’ is very important and is the difference between a folder or a file being created.
I hope this helps someone. It took me several hours to figure this out and I could not find a good example online anywhere.
Here is my extension to the ThreeSharpWrapper class to create an empty folder
/// <summary>
/// Adds a folder (empty) to a bucket
/// </summary>
public void AddEmptyFolder(String bucketName, String keyName) {
using (ObjectAddRequest objectAddRequest = new ObjectAddRequest(bucketName, keyName))
{
objectAddRequest.QueryList.Add("content_type", "binary/octet-stream");
using (ObjectAddResponse objectAddResponse = this.service.ObjectAdd(objectAddRequest)) { }
}
}
then to call the function you would use:
wrapper.AddEmptyFolder("myBucket", "test/"); //@params: (str)bucketName, (str)folderName